From 33b372d945ebe760bd858c497460d65e321a7b39 Mon Sep 17 00:00:00 2001 From: Olaf Bergmann Date: Tue, 19 Feb 2019 12:49:50 +0100 Subject: [PATCH] coap_gnutls.c: Removed dead code Coverity found that status is always 0 when validate_cn_call_back() is invoked (CID 1476517). This change removes the dead code by introducing a constant that can be inferred at compile-time. --- src/coap_gnutls.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/coap_gnutls.c b/src/coap_gnutls.c index b019e762..13913000 100644 --- a/src/coap_gnutls.c +++ b/src/coap_gnutls.c @@ -532,6 +532,9 @@ static int cert_verify_gnutls(gnutls_session_t g_session) gnutls_x509_crt_t cert; uint8_t der[2048]; size_t size; + /* status == 0 indicates that the certificate passed to + * setup_data.validate_cn_call_back has been validated. */ + const int cert_is_trusted = !status; cert_list = gnutls_certificate_get_peers(g_session, &cert_list_size); if (cert_list_size == 0) { @@ -554,7 +557,7 @@ static int cert_verify_gnutls(gnutls_session_t g_session) size, c_session, 0, - status ? 0 : 1, + cert_is_trusted, g_context->setup_data.cn_call_back_arg)) { alert = GNUTLS_A_ACCESS_DENIED; goto fail;