diff --git a/pkg/nimble/autoconn/nimble_autoconn.c b/pkg/nimble/autoconn/nimble_autoconn.c index f9cee1841a..b75469b474 100644 --- a/pkg/nimble/autoconn/nimble_autoconn.c +++ b/pkg/nimble/autoconn/nimble_autoconn.c @@ -164,20 +164,16 @@ static void _on_scan_evt(uint8_t type, const ble_addr_t *addr, int8_t rssi, static void _evt_dbg(const char *msg, int handle, const uint8_t *addr) { -#if ENABLE_DEBUG - printf("[autoconn] %s (%i|", msg, handle); - if (addr) { - bluetil_addr_print(addr); + if (IS_ACTIVE(ENABLE_DEBUG)) { + printf("[autoconn] %s (%i|", msg, handle); + if (addr) { + bluetil_addr_print(addr); + } + else { + printf("n/a"); + } + puts(")"); } - else { - printf("n/a"); - } - puts(")"); -#else - (void)msg; - (void)handle; - (void)addr; -#endif } static void _on_netif_evt(int handle, nimble_netif_event_t event, diff --git a/pkg/openthread/contrib/platform_functions_wrapper.c b/pkg/openthread/contrib/platform_functions_wrapper.c index d1f2b435a2..4d4ef5e8a3 100644 --- a/pkg/openthread/contrib/platform_functions_wrapper.c +++ b/pkg/openthread/contrib/platform_functions_wrapper.c @@ -110,17 +110,13 @@ uint8_t ot_call_command(char* command, void *arg, void* answer) void output_bytes(const char* name, const uint8_t *aBytes, uint8_t aLength) { -#if ENABLE_DEBUG - DEBUG("%s: ", name); - for (int i = 0; i < aLength; i++) { - DEBUG("%02x", aBytes[i]); + if (IS_ACTIVE(ENABLE_DEBUG)) { + DEBUG("%s: ", name); + for (int i = 0; i < aLength; i++) { + DEBUG("%02x", aBytes[i]); + } + DEBUG("\n"); } - DEBUG("\n"); -#else - (void)name; - (void)aBytes; - (void)aLength; -#endif } OT_COMMAND ot_channel(otInstance* ot_instance, void* arg, void* answer) { diff --git a/pkg/openthread/contrib/platform_radio.c b/pkg/openthread/contrib/platform_radio.c index 4f8f4a51b5..a91a1419cc 100644 --- a/pkg/openthread/contrib/platform_radio.c +++ b/pkg/openthread/contrib/platform_radio.c @@ -159,7 +159,7 @@ void recv_pkt(otInstance *aInstance, netdev_t *dev) /* Get RSSI from a radio driver. RSSI should be in [dBm] */ Rssi = (int8_t)rx_info.rssi; - if (ENABLE_DEBUG) { + if (IS_ACTIVE(ENABLE_DEBUG)) { DEBUG("Received message: len %d\n", (int) sReceiveFrame.mLength); for (int i = 0; i < sReceiveFrame.mLength; ++i) { DEBUG("%x ", sReceiveFrame.mPsdu[i]); @@ -216,7 +216,7 @@ void otPlatRadioSetExtendedAddress(otInstance *aInstance, const otExtAddress *aE for (unsigned i = 0; i < IEEE802154_LONG_ADDRESS_LEN; i++) { reversed_addr[i] = (uint8_t) ((uint8_t *)aExtAddress)[IEEE802154_LONG_ADDRESS_LEN - 1 - i]; } - if (ENABLE_DEBUG) { + if (IS_ACTIVE(ENABLE_DEBUG)) { for (unsigned i = 0; i < IEEE802154_LONG_ADDRESS_LEN; ++i) { DEBUG("%x ", (uint8_t) ((uint8_t *)reversed_addr)[i]); } @@ -344,7 +344,7 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aPacket) }; /*Set channel and power based on transmit frame */ - if (ENABLE_DEBUG) { + if (IS_ACTIVE(ENABLE_DEBUG)) { DEBUG("otPlatRadioTransmit->channel: %i, length %d\n", (int) aPacket->mChannel, (int)aPacket->mLength); for (size_t i = 0; i < aPacket->mLength; ++i) { diff --git a/pkg/paho-mqtt/contrib/riot_iface.c b/pkg/paho-mqtt/contrib/riot_iface.c index 8c18e84abd..90f1cddcc6 100644 --- a/pkg/paho-mqtt/contrib/riot_iface.c +++ b/pkg/paho-mqtt/contrib/riot_iface.c @@ -88,8 +88,7 @@ static int mqtt_read(struct Network *n, unsigned char *buf, int len, } } while (rc < len && xtimer_now64().ticks64 < send_tick && rc >= 0); -#ifdef ENABLE_DEBUG - if (IS_USED(MODULE_LWIP) && rc > 0) { + if (IS_ACTIVE(ENABLE_DEBUG) && IS_USED(MODULE_LWIP) && rc > 0) { DEBUG("MQTT buf asked for %d, available to read %d\n", rc, tsrb_avail(&tsrb_lwip_tcp)); for (int i = 0; i < rc; i++) { @@ -97,7 +96,6 @@ static int mqtt_read(struct Network *n, unsigned char *buf, int len, } DEBUG("\n"); } -#endif return rc; } diff --git a/pkg/semtech-loramac/contrib/semtech_loramac.c b/pkg/semtech-loramac/contrib/semtech_loramac.c index c5d12c743e..4b42ee2ffc 100644 --- a/pkg/semtech-loramac/contrib/semtech_loramac.c +++ b/pkg/semtech-loramac/contrib/semtech_loramac.c @@ -712,7 +712,7 @@ void *_semtech_loramac_event_loop(void *arg) /* save the uplink counter */ _save_uplink_counter(mac); #endif - if (ENABLE_DEBUG) { + if (IS_ACTIVE(ENABLE_DEBUG)) { switch (confirm->McpsRequest) { case MCPS_UNCONFIRMED: { @@ -755,7 +755,7 @@ void *_semtech_loramac_event_loop(void *arg) break; } - if (ENABLE_DEBUG) { + if (IS_ACTIVE(ENABLE_DEBUG)) { switch (indication->McpsIndication) { case MCPS_UNCONFIRMED: DEBUG("[semtech-loramac] MCPS indication Unconfirmed\n"); diff --git a/pkg/tinydtls/contrib/sock_dtls.c b/pkg/tinydtls/contrib/sock_dtls.c index 1eb6bff70c..0d9fd8cc3d 100644 --- a/pkg/tinydtls/contrib/sock_dtls.c +++ b/pkg/tinydtls/contrib/sock_dtls.c @@ -117,19 +117,19 @@ static int _event(struct dtls_context_t *ctx, session_t *session, sock_dtls_t *sock = dtls_get_app_data(ctx); msg_t msg = { .type = code, .content.ptr = session }; -#ifdef ENABLE_DEBUG - switch (code) { - case DTLS_EVENT_CONNECT: - DEBUG("sock_dtls: event connect\n"); - break; - case DTLS_EVENT_CONNECTED: - DEBUG("sock_dtls: event connected\n"); - break; - case DTLS_EVENT_RENEGOTIATE: - DEBUG("sock_dtls: event renegotiate\n"); - break; + if (IS_ACTIVE(ENABLE_DEBUG)) { + switch (code) { + case DTLS_EVENT_CONNECT: + DEBUG("sock_dtls: event connect\n"); + break; + case DTLS_EVENT_CONNECTED: + DEBUG("sock_dtls: event connected\n"); + break; + case DTLS_EVENT_RENEGOTIATE: + DEBUG("sock_dtls: event renegotiate\n"); + break; + } } -#endif /* ENABLE_DEBUG */ if (!level && (code != DTLS_EVENT_CONNECT)) { mbox_put(&sock->mbox, &msg); }