Merge pull request #5166 from kaspar030/syntax_check_debug_code

core: debug: rely on optimizer to kick out unused debug code
This commit is contained in:
Sebastian Meiling 2018-01-15 14:52:35 +01:00 committed by GitHub
commit eb89954f13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 91 additions and 121 deletions

View File

@ -67,7 +67,9 @@ extern "C" {
* @name Debugging defines
* @{
*/
#if ENABLE_DEBUG
#ifndef ENABLE_DEBUG
#define ENABLE_DEBUG (0)
#endif
/**
* @def DEBUG_FUNC
@ -92,10 +94,7 @@ extern "C" {
*
* @note Another name for ::DEBUG_PRINT
*/
#define DEBUG(...) DEBUG_PRINT(__VA_ARGS__)
#else
#define DEBUG(...)
#endif
#define DEBUG(...) if (ENABLE_DEBUG) DEBUG_PRINT(__VA_ARGS__)
/** @} */
/**

View File

@ -447,10 +447,11 @@ char *thread_stack_init(thread_task_func_t task_func, void *arg, void *stack_sta
*/
void thread_add_to_list(list_node_t *list, thread_t *thread);
#ifdef DEVELHELP
/**
* @brief Returns the name of a process
*
* @note when compiling without DEVELHELP, this *always* returns NULL!
*
* @param[in] pid the PID of the thread to get the name from
*
* @return the threads name
@ -458,6 +459,7 @@ void thread_add_to_list(list_node_t *list, thread_t *thread);
*/
const char *thread_getname(kernel_pid_t pid);
#ifdef DEVELHELP
/**
* @brief Measures the stack usage of a stack
*

View File

@ -44,13 +44,16 @@ int thread_getstatus(kernel_pid_t pid)
return t ? (int) t->status : STATUS_NOT_FOUND;
}
#ifdef DEVELHELP
const char *thread_getname(kernel_pid_t pid)
{
#ifdef DEVELHELP
volatile thread_t *t = thread_get(pid);
return t ? t->name : NULL;
}
#else
(void)pid;
return NULL;
#endif
}
void thread_sleep(void)
{

View File

@ -132,7 +132,8 @@ int timer_init(tim_t tim, unsigned long freq, timer_cb_t cb, void *arg)
}
if (freq != sys_clock_freq()) {
DEBUG("In 32-bit mode, the GPTimer frequency must equal the system clock frequency (%u).", sys_clock_freq());
DEBUG("In 32-bit mode, the GPTimer frequency must equal the system clock frequency (%u).\n",
(unsigned)sys_clock_freq());
return -1;
}
}

View File

@ -164,14 +164,14 @@ void uart_write(uart_t uart, const uint8_t *data, size_t len)
{
DEBUG("writing to serial port ");
#if ENABLE_DEBUG
for (size_t i = 0; i < len; i++) {
DEBUG("%02x ", (unsigned char) data[i]);
if (ENABLE_DEBUG) {
for (size_t i = 0; i < len; i++) {
DEBUG("%02x ", (unsigned char) data[i]);
}
for (size_t i = 0; i < len; i++) {
DEBUG("%c", (char) data[i]);
}
}
for (size_t i = 0; i < len; i++) {
DEBUG("%c", (char) data[i]);
}
#endif
DEBUG("\n");

View File

@ -70,8 +70,8 @@ int kw2xrf_spi_init(kw2xrf_t *dev)
#endif
if (res != SPI_OK) {
LOG_ERROR("[kw2xrf_spi] failed to init SPI_%i device (code %i)\n",
SPIDEV, res);
LOG_ERROR("[kw2xrf_spi] failed to init SPI_%u device (code %i)\n",
(unsigned)SPIDEV, res);
return 1;
}
/* verify SPI params */
@ -90,8 +90,8 @@ int kw2xrf_spi_init(kw2xrf_t *dev)
}
spi_release(SPIDEV);
DEBUG("[kw2xrf_spi] SPI_DEV(%i) initialized: mode: %i, clk: %i, cs_pin: %i\n",
SPIDEV, SPIMODE, SPICLK, CSPIN);
DEBUG("[kw2xrf_spi] SPI_DEV(%u) initialized: mode: %u, clk: %u, cs_pin: %u\n",
(unsigned)SPIDEV, (unsigned)SPIMODE, (unsigned)SPICLK, (unsigned)CSPIN);
return 0;
}

View File

@ -689,16 +689,16 @@ static int xbee_recv(netdev_t *dev, void *buf, size_t len, void *info)
size = (size_t)(xbee->rx_limit - 1);
if (buf == NULL) {
if (len > 0) {
DEBUG("[xbee] recv: reading size and dropping: %i\n", size);
DEBUG("[xbee] recv: reading size and dropping: %u\n", (unsigned)size);
xbee->rx_count = 0;
}
else {
DEBUG("[xbee] recv: reading size without dropping: %i\n", size);
DEBUG("[xbee] recv: reading size without dropping: %u\n", (unsigned)size);
}
}
else {
size = (size > len) ? len : size;
DEBUG("[xbee] recv: consuming packet: reading %i byte\n", size);
DEBUG("[xbee] recv: consuming packet: reading %u byte\n", (unsigned)size);
memcpy(buf, xbee->rx_buf, size);
xbee->rx_count = 0;
}

View File

@ -222,7 +222,7 @@ static int _mkdir(vfs_mount_t *mountp, const char *name, mode_t mode)
mutex_lock(&fs->lock);
DEBUG("littlefs: mkdir: mountp=%p, name=%s, mode=%" PRIu32 "\n",
(void *)mountp, name, mode);
(void *)mountp, name, (uint32_t)mode);
int ret = lfs_mkdir(&fs->fs, name);
mutex_unlock(&fs->lock);

View File

@ -72,10 +72,10 @@ int conn_can_raw_set_filter(conn_can_raw_t *conn, struct can_filter *filter, siz
assert(conn != NULL);
assert(filter != NULL || count == 0);
DEBUG("conn_can_raw_set_filter: conn=%p, filter=%p, count=%d\n",
(void *)conn, (void *)filter, count);
DEBUG("conn_can_raw_set_filter: conn->filter=%p, conn->count=%d\n",
(void *)conn->filter, conn->count);
DEBUG("conn_can_raw_set_filter: conn=%p, filter=%p, count=%u\n",
(void *)conn, (void *)filter, (unsigned)count);
DEBUG("conn_can_raw_set_filter: conn->filter=%p, conn->count=%u\n",
(void *)conn->filter, (unsigned)conn->count);
/* unset previous filters */
if (conn->count) {

View File

@ -509,7 +509,7 @@ static void _isotp_fill_dataframe(struct isotp *isotp, struct can_frame *frame,
frame->can_id = isotp->opt.tx_id;
frame->can_dlc = num_bytes + pci_len;
DEBUG("_isotp_fill_dataframe: num_bytes=%d, pci_len=%d\n", num_bytes, pci_len);
DEBUG("_isotp_fill_dataframe: num_bytes=%d, pci_len=%d\n", (unsigned)num_bytes, (unsigned)pci_len);
if (num_bytes < space) {
if (isotp->opt.flags & CAN_ISOTP_TX_PADDING) {

View File

@ -960,7 +960,7 @@ static size_t cbor_stream_decode_at(cbor_stream_t *stream, size_t offset, int in
offset += inner_read_bytes = cbor_stream_decode_at(stream, offset, indent + 2);
if (inner_read_bytes == 0) {
DEBUG("Failed to read array item at position %d\n", i);
DEBUG("Failed to read array item at position %u\n", (unsigned)i);
break;
}
@ -994,7 +994,7 @@ static size_t cbor_stream_decode_at(cbor_stream_t *stream, size_t offset, int in
offset += value_read_bytes = cbor_stream_decode_at(stream, offset, indent + 2); /* value */
if (key_read_bytes == 0 || value_read_bytes == 0) {
DEBUG("Failed to read key-value pair at position %d\n", i);
DEBUG("Failed to read key-value pair at position %u\n", (unsigned)i);
break;
}
@ -1073,7 +1073,7 @@ void cbor_stream_decode(cbor_stream_t *stream)
size_t read_bytes = cbor_stream_decode_at(stream, offset, 0);
if (read_bytes == 0) {
DEBUG("Failed to read from stream at offset %d, start byte 0x%02X\n", offset, stream->data[offset]);
DEBUG("Failed to read from stream at offset %u, start byte 0x%02X\n", (unsigned)offset, stream->data[offset]);
cbor_stream_print(stream);
return;
}

View File

@ -241,7 +241,7 @@ static ssize_t constfs_read(vfs_file_t *filp, void *dest, size_t nbytes)
nbytes = fp->size - filp->pos;
}
memcpy(dest, fp->data + filp->pos, nbytes);
DEBUG("constfs_read: read %d bytes\n", nbytes);
DEBUG("constfs_read: read %lu bytes\n", (long unsigned)nbytes);
filp->pos += nbytes;
return nbytes;
}

View File

@ -131,7 +131,7 @@ static void _listen(sock_udp_t *sock)
res = coap_parse(&pdu, buf, res);
if (res < 0) {
DEBUG("gcoap: parse failure: %d\n", res);
DEBUG("gcoap: parse failure: %d\n", (int)res);
/* If a response, can't clear memo, but it will timeout later. */
return;
}
@ -723,7 +723,7 @@ size_t gcoap_req_send2(const uint8_t *buf, size_t len,
}
else if (!res) {
memo->state = GCOAP_MEMO_UNUSED;
DEBUG("gcoap: sock send failed: %d\n", res);
DEBUG("gcoap: sock send failed: %d\n", (int)res);
}
return res;
} else {

View File

@ -229,7 +229,7 @@ bool gnrc_mac_queue_rx_packet(gnrc_mac_rx_t *rx, uint32_t priority, gnrc_pktsnip
return true;
}
DEBUG("[gnrc_mac] Can't push RX packet @ %p, no entries left\n", pkt);
DEBUG("[gnrc_mac] Can't push RX packet @ %p, no entries left\n", (void*)pkt);
return false;
}
#endif /* GNRC_MAC_RX_QUEUE_SIZE != 0 */
@ -268,7 +268,7 @@ void gnrc_mac_dispatch(gnrc_mac_rx_t *rx)
if (!gnrc_netapi_dispatch_receive(rx->dispatch_buffer[i]->type,
GNRC_NETREG_DEMUX_CTX_ALL,
rx->dispatch_buffer[i])) {
DEBUG("Unable to forward packet of type %i\n", buffer[i]->type);
DEBUG("Unable to forward packet of type %i\n", rx->dispatch_buffer[i]->type);
gnrc_pktbuf_release(rx->dispatch_buffer[i]);
}
rx->dispatch_buffer[i] = NULL;

View File

@ -26,8 +26,7 @@
#define ENABLE_DEBUG (0)
#include "debug.h"
#if ENABLE_DEBUG
char *lwmac_timeout_names[] = {
static const char *lwmac_timeout_names[] = {
[GNRC_LWMAC_TIMEOUT_DISABLED] = "DISABLED",
[GNRC_LWMAC_TIMEOUT_WR] = "WR",
[GNRC_LWMAC_TIMEOUT_NO_RESPONSE] = "NO_RESPONSE",
@ -35,7 +34,6 @@ char *lwmac_timeout_names[] = {
[GNRC_LWMAC_TIMEOUT_WAIT_DEST_WAKEUP] = "WAIT_FOR_DEST_WAKEUP",
[GNRC_LWMAC_TIMEOUT_WAKEUP_PERIOD] = "WAKEUP_PERIOD",
};
#endif
static inline void _lwmac_clear_timeout(gnrc_lwmac_timeout_t *timeout)
{

View File

@ -85,7 +85,7 @@ static inline int _snd_rcv_mbox(mbox_t *mbox, uint16_t type, gnrc_pktsnip_t *pkt
/* send message */
int ret = mbox_try_put(mbox, &msg);
if (ret < 1) {
DEBUG("gnrc_netapi: dropped message to %p (was full)\n", mbox);
DEBUG("gnrc_netapi: dropped message to %p (was full)\n", (void*)mbox);
}
return ret;
}

View File

@ -34,10 +34,6 @@
#define ENABLE_DEBUG (0)
#include "debug.h"
#if ENABLE_DEBUG
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
#endif
#define _NETIF_NETAPI_MSG_QUEUE_SIZE (8)
static gnrc_netif_t _netifs[GNRC_NETIF_NUMOF];
@ -454,6 +450,8 @@ void gnrc_netif_release(gnrc_netif_t *netif)
static inline bool _addr_anycast(const gnrc_netif_t *netif, unsigned idx);
static int _addr_idx(const gnrc_netif_t *netif, const ipv6_addr_t *addr);
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
/**
* @brief Matches an address by prefix to an address on the interface
*
@ -568,15 +566,11 @@ int gnrc_netif_ipv6_addr_add_internal(gnrc_netif_t *netif,
* for SLAAC */
ipv6_addr_set_solicited_nodes(&sol_nodes, addr);
res = gnrc_netif_ipv6_group_join_internal(netif, &sol_nodes);
#if ENABLE_DEBUG
if (res < 0) {
DEBUG("nib: Can't join solicited-nodes of %s on interface %u\n",
ipv6_addr_to_str(addr_str, addr, sizeof(addr_str)),
netif->pid);
}
#else
(void)res;
#endif
#endif /* GNRC_IPV6_NIB_CONF_ARSM */
if (_get_state(netif, idx) == GNRC_NETIF_IPV6_ADDRS_FLAGS_STATE_VALID) {
void *state = NULL;
@ -880,7 +874,6 @@ static unsigned _match(const gnrc_netif_t *netif, const ipv6_addr_t *addr,
best_match = match;
}
}
#if ENABLE_DEBUG
if (*idx >= 0) {
DEBUG("gnrc_netif: Found %s on interface %" PRIkernel_pid " matching ",
ipv6_addr_to_str(addr_str, &netif->ipv6.addrs[*idx],
@ -898,7 +891,6 @@ static unsigned _match(const gnrc_netif_t *netif, const ipv6_addr_t *addr,
ipv6_addr_to_str(addr_str, addr, sizeof(addr_str)),
(filter != NULL) ? "true" : "false");
}
#endif
return best_match;
}
@ -1249,12 +1241,10 @@ static void *_gnrc_netif_thread(void *args)
case GNRC_NETAPI_MSG_TYPE_SND:
DEBUG("gnrc_netif: GNRC_NETDEV_MSG_TYPE_SND received\n");
res = netif->ops->send(netif, msg.content.ptr);
#if ENABLE_DEBUG
if (res < 0) {
DEBUG("gnrc_netif: error sending packet %p (code: %u)\n",
msg.content.ptr, res);
}
#endif
break;
case GNRC_NETAPI_MSG_TYPE_SET:
opt = msg.content.ptr;
@ -1292,12 +1282,10 @@ static void *_gnrc_netif_thread(void *args)
"netif->ops->msg_handler()\n", msg.type);
netif->ops->msg_handler(netif, &msg);
}
#if ENABLE_DEBUG
else {
DEBUG("gnrc_netif: unknown message type 0x%04x"
"(no message handler defined)\n", msg.type);
}
#endif
break;
}
}

View File

@ -59,9 +59,7 @@ static fib_entry_t _fib_entries[GNRC_IPV6_FIB_TABLE_SIZE];
fib_table_t gnrc_ipv6_fib_table;
#endif
#if ENABLE_DEBUG
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
#endif
kernel_pid_t gnrc_ipv6_pid = KERNEL_PID_UNDEF;

View File

@ -21,7 +21,7 @@
#define ENABLE_DEBUG (0)
#include "debug.h"
#if ENABLE_DEBUG && defined(MODULE_IPV6_ADDR)
#if defined(MODULE_IPV6_ADDR)
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
#endif

View File

@ -24,9 +24,8 @@
#include "debug.h"
#if GNRC_IPV6_NIB_CONF_6LN
#if ENABLE_DEBUG
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
#endif
extern void _handle_search_rtr(gnrc_netif_t *netif);

View File

@ -23,9 +23,8 @@
#include "debug.h"
#if GNRC_IPV6_NIB_CONF_6LR
#if ENABLE_DEBUG
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
#endif
static uint8_t _update_nce_ar_state(const sixlowpan_nd_opt_ar_t *aro,
_nib_onl_entry_t *nce)
@ -38,12 +37,12 @@ static uint8_t _update_nce_ar_state(const sixlowpan_nd_opt_ar_t *aro,
_set_ar_state(nce,
GNRC_IPV6_NIB_NC_INFO_AR_STATE_REGISTERED);
DEBUG("nib: Successfully registered %s\n",
ipv6_addr_to_str(addr_str, &ipv6->src, sizeof(addr_str)));
ipv6_addr_to_str(addr_str, &nce->ipv6, sizeof(addr_str)));
return SIXLOWPAN_ND_STATUS_SUCCESS;
}
else {
DEBUG("nib: Could not register %s, neighbor cache was full\n",
ipv6_addr_to_str(addr_str, &ipv6->src, sizeof(addr_str)));
ipv6_addr_to_str(addr_str, &nce->ipv6, sizeof(addr_str)));
return SIXLOWPAN_ND_STATUS_NC_FULL;
}
}

View File

@ -28,9 +28,7 @@
#define ENABLE_DEBUG (0)
#include "debug.h"
#if ENABLE_DEBUG
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
#endif
/**
* @brief Determines supposed link-layer address from interface and option

View File

@ -42,9 +42,7 @@ static _nib_dr_entry_t _def_routers[GNRC_IPV6_NIB_DEFAULT_ROUTER_NUMOF];
static _nib_abr_entry_t _abrs[GNRC_IPV6_NIB_ABR_NUMOF];
#endif /* GNRC_IPV6_NIB_CONF_MULTIHOP_P6C */
#if ENABLE_DEBUG
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
#endif
mutex_t _nib_mutex = MUTEX_INIT;
evtimer_msg_t _nib_evtimer;

View File

@ -27,9 +27,7 @@
#include "debug.h"
#if GNRC_IPV6_NIB_CONF_ROUTER
#if ENABLE_DEBUG
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
#endif
static void _snd_ra(gnrc_netif_t *netif, const ipv6_addr_t *dst,
bool final, _nib_abr_entry_t *abr);

View File

@ -39,9 +39,7 @@
#include "xtimer.h"
#endif
#if ENABLE_DEBUG
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
#endif
#if GNRC_IPV6_NIB_CONF_QUEUE_PKT
static gnrc_pktqueue_t _queue_pool[GNRC_IPV6_NIB_NUMOF];
@ -418,8 +416,8 @@ static void _handle_rtr_sol(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6,
netif->pid);
DEBUG(" - IP Hop Limit: %u (should be 255)\n", ipv6->hl);
DEBUG(" - ICMP code: %u (should be 0)\n", rtr_sol->code);
DEBUG(" - ICMP length: %u (should > %u)\n", icmpv6_len,
sizeof(ndp_rtr_sol_t));
DEBUG(" - ICMP length: %u (should > %u)\n", (unsigned)icmpv6_len,
(unsigned)sizeof(ndp_rtr_sol_t));
return;
}
/* pre-check option length */
@ -529,7 +527,7 @@ static void _handle_rtr_adv(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6,
DEBUG(" - IP Hop Limit: %u (should be 255)\n", ipv6->hl);
DEBUG(" - ICMP code: %u (should be 0)\n", rtr_adv->code);
DEBUG(" - ICMP length: %u (should > %u)\n", (unsigned)icmpv6_len,
sizeof(ndp_rtr_adv_t));
(unsigned)sizeof(ndp_rtr_adv_t));
DEBUG(" - Source address: %s (should be link-local)\n",
ipv6_addr_to_str(addr_str, &ipv6->src, sizeof(addr_str)));
DEBUG(" - Router lifetime: %u (should be <= 9000 on non-6LN)\n",
@ -793,8 +791,8 @@ static void _handle_nbr_sol(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6,
DEBUG("nib: Received neighbor solicitation is invalid. Discarding silently\n");
DEBUG(" - IP Hop Limit: %u (should be 255)\n", ipv6->hl);
DEBUG(" - ICMP code: %u (should be 0)\n", nbr_sol->code);
DEBUG(" - ICMP length: %u (should > %u)\n", icmpv6_len,
sizeof(ndp_nbr_sol_t));
DEBUG(" - ICMP length: %u (should > %u)\n", (unsigned)icmpv6_len,
(unsigned)sizeof(ndp_nbr_sol_t));
DEBUG(" - Target address: %s (should not be multicast)\n",
ipv6_addr_to_str(addr_str, &nbr_sol->tgt, sizeof(addr_str)));
DEBUG(" - Source address: %s\n",
@ -905,8 +903,8 @@ static void _handle_nbr_adv(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6,
DEBUG("nib: Received neighbor advertisement is invalid. Discarding silently\n");
DEBUG(" - IP Hop Limit: %u (should be 255)\n", ipv6->hl);
DEBUG(" - ICMP code: %u (should be 0)\n", nbr_adv->code);
DEBUG(" - ICMP length: %u (should > %u)\n", icmpv6_len,
sizeof(ndp_nbr_adv_t));
DEBUG(" - ICMP length: %u (should > %u)\n", (unsigned)icmpv6_len,
(unsigned)sizeof(ndp_nbr_adv_t));
DEBUG(" - Target address: %s (should not be multicast)\n",
ipv6_addr_to_str(addr_str, &nbr_adv->tgt, sizeof(addr_str)));
DEBUG(" - Destination address: %s\n",

View File

@ -24,9 +24,7 @@
ipv6_addr_t gnrc_ipv6_whitelist[GNRC_IPV6_WHITELIST_SIZE];
BITFIELD(gnrc_ipv6_whitelist_set, GNRC_IPV6_WHITELIST_SIZE);
#if ENABLE_DEBUG
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
#endif
int gnrc_ipv6_whitelist_add(const ipv6_addr_t *addr)
{

View File

@ -26,9 +26,10 @@
#define ENABLE_DEBUG (0)
#include "debug.h"
#if ENABLE_DEBUG
/* For PRIu8 etc. */
#include <inttypes.h>
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
#endif
gnrc_pktsnip_t *gnrc_ndp_nbr_sol_build(const ipv6_addr_t *tgt,
gnrc_pktsnip_t *options)

View File

@ -29,9 +29,7 @@ static mutex_t _ctx_mutex = MUTEX_INIT;
static uint32_t _current_minute(void);
static void _update_lifetime(uint8_t id);
#if ENABLE_DEBUG
static char ipv6str[IPV6_ADDR_MAX_STR_LEN];
#endif
static inline bool _valid(uint8_t id)
{

View File

@ -225,7 +225,7 @@ void gnrc_sixlowpan_frag_send(gnrc_sixlowpan_msg_frag_t *fragment_msg)
size_t payload_len = gnrc_pkt_len(fragment_msg->pkt->next);
msg_t msg;
#if defined(DEVELHELP) && defined(ENABLE_DEBUG)
#if defined(DEVELHELP) && ENABLE_DEBUG
if (iface == NULL) {
DEBUG("6lo frag: iface == NULL, expect segmentation fault.\n");
/* remove original packet from packet buffer */

View File

@ -46,9 +46,7 @@ static rbuf_int_t rbuf_int[RBUF_INT_SIZE];
static rbuf_t rbuf[RBUF_SIZE];
#if ENABLE_DEBUG
static char l2addr_str[3 * RBUF_L2ADDR_MAX_LEN];
#endif
/* ------------------------------------
* internal function definitions

View File

@ -279,7 +279,7 @@ static void _send(gnrc_pktsnip_t *pkt)
}
else if (datagram_size <= SIXLOWPAN_FRAG_MAX_LEN) {
DEBUG("6lo: Send fragmented (%u > %" PRIu16 ")\n",
(unsigned int)datagram_size, iface->max_frag_size);
(unsigned int)datagram_size, iface->sixlo.max_frag_size);
msg_t msg;
fragment_msg.pid = hdr->if_pid;
@ -302,7 +302,7 @@ static void _send(gnrc_pktsnip_t *pkt)
#else
(void) datagram_size;
DEBUG("6lo: packet too big (%u > %" PRIu16 ")\n",
(unsigned int)datagram_size, iface->max_frag_size);
(unsigned int)datagram_size, iface->sixlo.max_frag_size);
gnrc_pktbuf_release(pkt2);
#endif
}

View File

@ -42,9 +42,7 @@
#define ENABLE_DEBUG (0)
#include "debug.h"
#if ENABLE_DEBUG
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
#endif
#define GNRC_RPL_GROUNDED_SHIFT (7)
#define GNRC_RPL_MOP_SHIFT (3)
@ -465,8 +463,8 @@ bool _parse_options(int msg_type, gnrc_rpl_instance_t *inst, gnrc_rpl_opt_t *opt
first_target = target;
}
DEBUG("RPL: adding FT entry %s/%d 0x%" PRIx32 "\n",
ipv6_addr_to_str(addr_str, &(target->target), sizeof(addr_str)),
DEBUG("RPL: adding FT entry %s/%d\n",
ipv6_addr_to_str(addr_str, &(target->target), (unsigned)sizeof(addr_str)),
target->prefix_length);
gnrc_ipv6_nib_ft_add(&(target->target), target->prefix_length, src,

View File

@ -32,9 +32,7 @@
#define ENABLE_DEBUG (0)
#include "debug.h"
#if ENABLE_DEBUG
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
#endif
static gnrc_rpl_parent_t *_gnrc_rpl_find_preferred_parent(gnrc_rpl_dodag_t *dodag);

View File

@ -20,9 +20,7 @@
#define ENABLE_DEBUG (0)
#include "debug.h"
#if ENABLE_DEBUG
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
#endif
#define GNRC_RPL_SRH_PADDING(X) ((X & 0xF0) >> 4)
#define GNRC_RPL_SRH_COMPRE(X) (X & 0x0F)

View File

@ -56,7 +56,7 @@ int pthread_barrier_wait(pthread_barrier_t *barrier)
mutex_lock(&barrier->mutex);
DEBUG("%s: hit a synchronization barrier. pid=%" PRIkernel_pid"\n",
sched_active_thread->name, sched_active_pid);
thread_getname(sched_active_pid), sched_active_pid);
int switch_prio = -1;
@ -64,7 +64,7 @@ int pthread_barrier_wait(pthread_barrier_t *barrier)
/* need to wait for further threads */
DEBUG("%s: waiting for %u threads. pid=%" PRIkernel_pid "\n",
sched_active_thread->name, barrier->count, sched_active_pid);
thread_getname(sched_active_pid), barrier->count, sched_active_pid);
pthread_barrier_waiting_node_t node;
node.pid = sched_active_pid;
@ -90,7 +90,7 @@ int pthread_barrier_wait(pthread_barrier_t *barrier)
/* all threads have arrived, wake everybody up */
DEBUG("%s: waking every other thread up. pid=%" PRIkernel_pid "\n",
sched_active_thread->name, sched_active_pid);
thread_getname(sched_active_pid), sched_active_pid);
int count = 1; /* Count number of woken up threads.
* The first thread is the current thread. */

View File

@ -28,12 +28,14 @@
* @}
*/
#include <stdint.h>
#include <string.h>
#include "pthread.h"
#include "sched.h"
#include "xtimer.h"
#include <stdint.h>
#include <string.h>
#include "thread.h"
#define ENABLE_DEBUG (0)
#include "debug.h"
@ -43,7 +45,7 @@ int pthread_rwlock_init(pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *at
(void) attr;
if (rwlock == NULL) {
DEBUG("Thread %" PRIkernel_pid " pthread_rwlock_%s(): rwlock=NULL supplied\n", thread_pid, "init");
DEBUG("Thread %" PRIkernel_pid " pthread_rwlock_%s(): rwlock=NULL supplied\n", thread_getpid(), "init");
return EINVAL;
}
@ -54,7 +56,7 @@ int pthread_rwlock_init(pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *at
int pthread_rwlock_destroy(pthread_rwlock_t *rwlock)
{
if (rwlock == NULL) {
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): rwlock=NULL supplied\n", thread_pid, "destroy");
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): rwlock=NULL supplied\n", thread_getpid(), "destroy");
return EINVAL;
}
@ -105,19 +107,19 @@ static int pthread_rwlock_lock(pthread_rwlock_t *rwlock,
{
if (rwlock == NULL) {
DEBUG("Thread %" PRIkernel_pid": pthread_rwlock_%s(): is_writer=%u, allow_spurious=%u %s\n",
thread_pid, "lock", is_writer, allow_spurious, "rwlock=NULL");
thread_getpid(), "lock", is_writer, allow_spurious, "rwlock=NULL");
return EINVAL;
}
mutex_lock(&rwlock->mutex);
if (!is_blocked(rwlock)) {
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): is_writer=%u, allow_spurious=%u %s\n",
thread_pid, "lock", is_writer, allow_spurious, "is open");
thread_getpid(), "lock", is_writer, allow_spurious, "is open");
rwlock->readers += incr_when_held;
}
else {
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): is_writer=%u, allow_spurious=%u %s\n",
thread_pid, "lock", is_writer, allow_spurious, "is locked");
thread_getpid(), "lock", is_writer, allow_spurious, "is locked");
/* queue for the lock */
__pthread_rwlock_waiter_node_t waiting_node = {
@ -140,12 +142,12 @@ static int pthread_rwlock_lock(pthread_rwlock_t *rwlock,
if (waiting_node.continue_) {
/* pthread_rwlock_unlock() already set rwlock->readers */
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): is_writer=%u, allow_spurious=%u %s\n",
thread_pid, "lock", is_writer, allow_spurious, "continued");
thread_getpid(), "lock", is_writer, allow_spurious, "continued");
break;
}
else if (allow_spurious) {
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): is_writer=%u, allow_spurious=%u %s\n",
thread_pid, "lock", is_writer, allow_spurious, "is timed out");
thread_getpid(), "lock", is_writer, allow_spurious, "is timed out");
priority_queue_remove(&rwlock->queue, &waiting_node.qnode);
mutex_unlock(&rwlock->mutex);
return ETIMEDOUT;
@ -162,7 +164,7 @@ static int pthread_rwlock_trylock(pthread_rwlock_t *rwlock,
int incr_when_held)
{
if (rwlock == NULL) {
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): rwlock=NULL supplied\n", thread_pid, "trylock");
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): rwlock=NULL supplied\n", thread_getpid(), "trylock");
return EINVAL;
}
else if (mutex_trylock(&rwlock->mutex) == 0) {
@ -237,30 +239,30 @@ int pthread_rwlock_timedwrlock(pthread_rwlock_t *rwlock, const struct timespec *
int pthread_rwlock_unlock(pthread_rwlock_t *rwlock)
{
if (rwlock == NULL) {
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): rwlock=NULL supplied\n", thread_pid, "unlock");
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): rwlock=NULL supplied\n", thread_getpid(), "unlock");
return EINVAL;
}
mutex_lock(&rwlock->mutex);
if (rwlock->readers == 0) {
/* the lock is open */
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): lock is open\n", thread_pid, "unlock");
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): lock is open\n", thread_getpid(), "unlock");
mutex_unlock(&rwlock->mutex);
return EPERM;
}
if (rwlock->readers > 0) {
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): release %s lock\n", thread_pid, "unlock", "read");
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): release %s lock\n", thread_getpid(), "unlock", "read");
--rwlock->readers;
}
else {
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): release %s lock\n", thread_pid, "unlock", "write");
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): release %s lock\n", thread_getpid(), "unlock", "write");
rwlock->readers = 0;
}
if (rwlock->readers != 0 || rwlock->queue.first == NULL) {
/* this thread was not the last reader, or no one is waiting to aquire the lock */
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): no one is waiting\n", thread_pid, "unlock");
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): no one is waiting\n", thread_getpid(), "unlock");
mutex_unlock(&rwlock->mutex);
return 0;
}
@ -274,12 +276,12 @@ int pthread_rwlock_unlock(pthread_rwlock_t *rwlock)
if (waiting_node->is_writer) {
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): continue %s %" PRIkernel_pid "\n",
thread_pid, "unlock", "writer", waiting_node->thread->pid);
thread_getpid(), "unlock", "writer", waiting_node->thread->pid);
--rwlock->readers;
}
else {
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): continue %s %" PRIkernel_pid "\n",
thread_pid, "unlock", "reader", waiting_node->thread->pid);
thread_getpid(), "unlock", "reader", waiting_node->thread->pid);
++rwlock->readers;
/* wake up further readers */
@ -288,12 +290,12 @@ int pthread_rwlock_unlock(pthread_rwlock_t *rwlock)
if (waiting_node->is_writer) {
/* Not to be unfair to writers, we don't try to wake up readers that came after the first writer. */
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): continuing readers blocked by writer %" PRIkernel_pid "\n",
thread_pid, "unlock", waiting_node->thread->pid);
thread_getpid(), "unlock", waiting_node->thread->pid);
break;
}
waiting_node->continue_ = true;
DEBUG("Thread %" PRIkernel_pid ": pthread_rwlock_%s(): continue %s %" PRIkernel_pid "\n",
thread_pid, "unlock", "reader", waiting_node->thread->pid);
thread_getpid(), "unlock", "reader", waiting_node->thread->pid);
/* wake up this reader */
qnode = priority_queue_remove_head(&rwlock->queue);

View File

@ -736,7 +736,7 @@ int vfs_normalize_path(char *buf, const char *path, size_t buflen)
}
while(path <= path_end) {
DEBUG("vfs_normalize_path: + %d \"%.*s\" <- \"%s\" (%p)\n", npathcomp, len, buf, path, path);
DEBUG("vfs_normalize_path: + %d \"%.*s\" <- \"%s\" (%p)\n", npathcomp, (int)len, buf, path, path);
if (path[0] == '\0') {
break;
}