]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
lib: use casts and be explicit on intentional enumeration use
authorNikos Mavrogiannopoulos <nmav@redhat.com>
Fri, 18 Aug 2017 10:57:07 +0000 (12:57 +0200)
committerNikos Mavrogiannopoulos <nmav@redhat.com>
Fri, 18 Aug 2017 12:41:26 +0000 (14:41 +0200)
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
lib/alert.c
lib/algorithms.h
lib/algorithms/ciphersuites.c

index 0e262973407c05756302d700751e859ea3cf9619..b692ed6f9cb52f33a68eb8577ba6178651422456 100644 (file)
@@ -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;
 }
index cd2082000df8d43726b796f6ddce46c58c1fccf4..67902290be243f8967dde2de238f6d9ee7bd1a2b 100644 (file)
@@ -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;
 }
 
index ae5dba1c09b8f314fda5f5ac85d1120eba32afc6..5b93fc97bfd1903c13f98788583c1837d575be8c 100644 (file)
@@ -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;