summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2017-08-18 12:57:07 +0200
committerNikos Mavrogiannopoulos <nmav@redhat.com>2017-08-18 14:41:26 +0200
commita791437e62f6c92bba4ee5ee79c38dfdf2b54fbe (patch)
tree4ae352872d6bb888bdb5e888eb03ade9a791ae36
parent91d88c300104c66ec14bc3d570c2569ff30158ae (diff)
downloadgnutls-a791437e62f6c92bba4ee5ee79c38dfdf2b54fbe.tar.gz
lib: use casts and be explicit on intentional enumeration use
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
-rw-r--r--lib/alert.c8
-rw-r--r--lib/algorithms.h2
-rw-r--r--lib/algorithms/ciphersuites.c10
3 files changed, 12 insertions, 8 deletions
diff --git a/lib/alert.c b/lib/alert.c
index 0e26297340..b692ed6f9c 100644
--- a/lib/alert.c
+++ b/lib/alert.c
@@ -155,7 +155,7 @@ gnutls_alert_send(gnutls_session_t session, gnutls_alert_level_t level,
data[0] = (uint8_t) level;
data[1] = (uint8_t) desc;
- name = gnutls_alert_get_name((int) data[1]);
+ name = gnutls_alert_get_name((gnutls_alert_description_t) data[1]);
if (name == NULL)
name = "(unknown)";
_gnutls_record_log("REC: Sending Alert[%d|%d] - %s\n", data[0],
@@ -345,7 +345,7 @@ int gnutls_error_to_alert(int err, int *level)
*/
int gnutls_alert_send_appropriate(gnutls_session_t session, int err)
{
- int alert;
+ gnutls_alert_description_t alert;
int level;
alert = gnutls_error_to_alert(err, &level);
@@ -353,7 +353,7 @@ int gnutls_alert_send_appropriate(gnutls_session_t session, int err)
return alert;
}
- return gnutls_alert_send(session, level, alert);
+ return gnutls_alert_send(session, (gnutls_alert_level_t)level, alert);
}
/**
@@ -371,5 +371,5 @@ int gnutls_alert_send_appropriate(gnutls_session_t session, int err)
**/
gnutls_alert_description_t gnutls_alert_get(gnutls_session_t session)
{
- return session->internals.last_alert;
+ return (gnutls_alert_description_t)session->internals.last_alert;
}
diff --git a/lib/algorithms.h b/lib/algorithms.h
index cd2082000d..67902290be 100644
--- a/lib/algorithms.h
+++ b/lib/algorithms.h
@@ -195,7 +195,7 @@ const cipher_entry_st *cipher_name_to_entry(const char *name);
inline static cipher_type_t _gnutls_cipher_type(const cipher_entry_st * e)
{
if (unlikely(e == NULL))
- return 0;
+ return CIPHER_AEAD; /* doesn't matter */
return e->type;
}
diff --git a/lib/algorithms/ciphersuites.c b/lib/algorithms/ciphersuites.c
index ae5dba1c09..5b93fc97bf 100644
--- a/lib/algorithms/ciphersuites.c
+++ b/lib/algorithms/ciphersuites.c
@@ -1158,7 +1158,7 @@ const gnutls_cipher_suite_entry_st *ciphersuite_to_entry(const uint8_t suite[2])
gnutls_kx_algorithm_t
_gnutls_cipher_suite_get_kx_algo(const uint8_t suite[2])
{
- int ret = 0;
+ gnutls_kx_algorithm_t ret = GNUTLS_KX_UNKNOWN;
CIPHER_SUITE_ALG_LOOP(ret = p->kx_algorithm, suite);
return ret;
@@ -1403,7 +1403,9 @@ _gnutls_figure_common_ciphersuite(gnutls_session_t session,
unsigned int i, j;
int ret;
const version_entry_st *version = get_version(session);
- unsigned int is_dtls = IS_DTLS(session), kx, cred_type;
+ unsigned int is_dtls = IS_DTLS(session);
+ gnutls_kx_algorithm_t kx;
+ gnutls_credentials_type_t cred_type;
unsigned int no_cert_found = 0;
const gnutls_group_entry_st *sgroup = NULL;
@@ -1527,7 +1529,9 @@ _gnutls_get_client_ciphersuites(gnutls_session_t session,
unsigned int j;
int ret;
- unsigned int is_dtls = IS_DTLS(session), kx, cred_type;
+ unsigned int is_dtls = IS_DTLS(session);
+ gnutls_kx_algorithm_t kx;
+ gnutls_credentials_type_t cred_type;
uint8_t cipher_suites[MAX_CIPHERSUITE_SIZE*2 + RESERVED_CIPHERSUITES];
unsigned cipher_suites_size = 0;
size_t init_length = cdata->length;