Skip to content

Commit

Permalink
Logging: Fix COAP_MAX_LOGGING_LEVEL == 0 compile errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdeep1 committed Jul 19, 2023
1 parent b26ef52 commit 90c1a98
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/coap_gnutls.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ coap_get_tls_library_version(void) {

static void
coap_gnutls_audit_log_func(gnutls_session_t g_session, const char *text) {
#if COAP_MAX_LOGGING_LEVEL > 0
if (g_session) {
coap_session_t *c_session =
(coap_session_t *)gnutls_transport_get_ptr(g_session);
Expand All @@ -270,6 +271,10 @@ coap_gnutls_audit_log_func(gnutls_session_t g_session, const char *text) {
} else {
coap_log_warn("** (null): %s", text);
}
#else /* COAP_MAX_LOGGING_LEVEL == 0 */
(void)g_session;
(void)text;
#endif /* COAP_MAX_LOGGING_LEVEL == 0 */
}

static void
Expand Down Expand Up @@ -2098,6 +2103,7 @@ coap_dtls_new_server_session(coap_session_t *c_session) {
static void
log_last_alert(coap_session_t *c_session,
gnutls_session_t g_session) {
#if COAP_MAX_LOGGING_LEVEL > 0
int last_alert = gnutls_alert_get(g_session);

if (last_alert == GNUTLS_A_CLOSE_NOTIFY)
Expand All @@ -2108,6 +2114,10 @@ log_last_alert(coap_session_t *c_session,
coap_log_warn("***%s: Alert '%d': %s\n",
coap_session_str(c_session),
last_alert, gnutls_alert_get_name(last_alert));
#else /* COAP_MAX_LOGGING_LEVEL == 0 */
(void)c_session;
(void)g_session;
#endif /* COAP_MAX_LOGGING_LEVEL == 0 */
}

/*
Expand Down
4 changes: 4 additions & 0 deletions src/coap_mbedtls.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,12 +324,14 @@ get_san_or_cn_from_cert(mbedtls_x509_crt *crt) {
return NULL;
}

#if COAP_MAX_LOGGING_LEVEL > 0
static char *
get_error_string(int ret) {
static char buf[128] = {0};
mbedtls_strerror(ret, buf, sizeof(buf)-1);
return buf;
}
#endif /* COAP_MAX_LOGGING_LEVEL */

static int
self_signed_cert_verify_callback_mbedtls(void *data,
Expand Down Expand Up @@ -1245,6 +1247,7 @@ coap_dtls_free_mbedtls_env(coap_mbedtls_env_t *m_env) {
}
}

#if COAP_MAX_LOGGING_LEVEL > 0
static const char *
report_mbedtls_alert(unsigned char alert) {
switch (alert) {
Expand All @@ -1268,6 +1271,7 @@ report_mbedtls_alert(unsigned char alert) {
return "";
}
}
#endif /* COAP_MAX_LOGGING_LEVEL */

/*
* return -1 failure
Expand Down

0 comments on commit 90c1a98

Please sign in to comment.