Skip to content

Commit c09dd04

Browse files
cfriedtChristopher Friedt
authored andcommitted
kernel: atomics: update print specifiers for atomic_t
The print specifier for `atomic_t` should be updated to `%ld`, `%lu`, or `%lx` to account for the type change of `atomic_t` to `long`. Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
1 parent 653ca0e commit c09dd04

File tree

12 files changed

+29
-32
lines changed

12 files changed

+29
-32
lines changed

drivers/ieee802154/ieee802154_kw41z.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ static int kw41z_tx(const struct device *dev, enum ieee802154_tx_mode mode,
706706
handle_ack(kw41z, frag->data[2]);
707707
}
708708

709-
LOG_DBG("seq_retval: %d", kw41z->seq_retval);
709+
LOG_DBG("seq_retval: %ld", kw41z->seq_retval);
710710
return kw41z->seq_retval;
711711
}
712712

subsys/bluetooth/host/att.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ static inline bool att_chan_is_connected(struct bt_att_chan *chan)
436436
static int bt_att_chan_send(struct bt_att_chan *chan, struct net_buf *buf,
437437
bt_att_chan_sent_t cb)
438438
{
439-
BT_DBG("chan %p flags %u code 0x%02x", chan, atomic_get(chan->flags),
439+
BT_DBG("chan %p flags %lu code 0x%02x", chan, atomic_get(chan->flags),
440440
((struct bt_att_hdr *)buf->data)->code);
441441

442442
return chan_send(chan, buf, cb);
@@ -2612,7 +2612,7 @@ static struct bt_att_chan *att_get_fixed_chan(struct bt_conn *conn)
26122612

26132613
static void att_chan_attach(struct bt_att *att, struct bt_att_chan *chan)
26142614
{
2615-
BT_DBG("att %p chan %p flags %u", att, chan, atomic_get(chan->flags));
2615+
BT_DBG("att %p chan %p flags %lu", att, chan, atomic_get(chan->flags));
26162616

26172617
if (sys_slist_is_empty(&att->chans)) {
26182618
/* Init general queues when attaching the first channel */

subsys/bluetooth/host/conn.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,7 @@ struct bt_conn *bt_conn_ref(struct bt_conn *conn)
10771077
}
10781078
} while (!atomic_cas(&conn->ref, old, old + 1));
10791079

1080-
BT_DBG("handle %u ref %d -> %d", conn->handle, old, old + 1);
1080+
BT_DBG("handle %u ref %ld -> %ld", conn->handle, old, old + 1);
10811081

10821082
return conn;
10831083
}
@@ -1088,7 +1088,7 @@ void bt_conn_unref(struct bt_conn *conn)
10881088

10891089
old = atomic_dec(&conn->ref);
10901090

1091-
BT_DBG("handle %u ref %d -> %d", conn->handle, old,
1091+
BT_DBG("handle %u ref %ld -> %ld", conn->handle, old,
10921092
atomic_get(&conn->ref));
10931093

10941094
__ASSERT(old > 0, "Conn reference counter is 0");

subsys/bluetooth/host/l2cap.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1855,7 +1855,7 @@ static int l2cap_chan_le_send(struct bt_l2cap_le_chan *ch,
18551855
return -EAGAIN;
18561856
}
18571857

1858-
BT_DBG("ch %p cid 0x%04x len %u credits %u", ch, ch->tx.cid,
1858+
BT_DBG("ch %p cid 0x%04x len %u credits %lu", ch, ch->tx.cid,
18591859
seg->len, atomic_get(&ch->tx.credits));
18601860

18611861
len = seg->len - sdu_hdr_len;
@@ -1998,7 +1998,7 @@ static void le_credits(struct bt_l2cap *l2cap, uint8_t ident,
19981998

19991999
l2cap_chan_tx_give_credits(ch, credits);
20002000

2001-
BT_DBG("chan %p total credits %u", ch, atomic_get(&ch->tx.credits));
2001+
BT_DBG("chan %p total credits %lu", ch, atomic_get(&ch->tx.credits));
20022002

20032003
l2cap_chan_tx_resume(ch);
20042004
}
@@ -2172,7 +2172,7 @@ static void l2cap_chan_send_credits(struct bt_l2cap_le_chan *chan,
21722172

21732173
l2cap_send(chan->chan.conn, BT_L2CAP_CID_LE_SIG, buf);
21742174

2175-
BT_DBG("chan %p credits %u", chan, atomic_get(&chan->rx.credits));
2175+
BT_DBG("chan %p credits %lu", chan, atomic_get(&chan->rx.credits));
21762176
}
21772177

21782178
static void l2cap_chan_update_credits(struct bt_l2cap_le_chan *chan,

subsys/bluetooth/services/ots/ots_l2cap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ static int l2cap_recv(struct bt_l2cap_chan *chan, struct net_buf *buf)
122122

123123
static void l2cap_status(struct bt_l2cap_chan *chan, atomic_t *status)
124124
{
125-
LOG_DBG("Channel %p status %u", chan, *status);
125+
LOG_DBG("Channel %p status %lu", chan, atomic_get(status));
126126
}
127127

128128
static void l2cap_connected(struct bt_l2cap_chan *chan)

subsys/net/ip/net_pkt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ void net_pkt_unref(struct net_pkt *pkt)
538538

539539
#if NET_LOG_LEVEL >= LOG_LEVEL_DBG
540540
#if CONFIG_NET_PKT_LOG_LEVEL >= LOG_LEVEL_DBG
541-
NET_DBG("%s [%d] pkt %p ref %d frags %p (%s():%d)",
541+
NET_DBG("%s [%d] pkt %p ref %ld frags %p (%s():%d)",
542542
slab2str(pkt->slab), k_mem_slab_num_free_get(pkt->slab),
543543
pkt, ref - 1, pkt->frags, caller, line);
544544
#endif
@@ -619,7 +619,7 @@ struct net_pkt *net_pkt_ref(struct net_pkt *pkt)
619619
} while (!atomic_cas(&pkt->atomic_ref, ref, ref + 1));
620620

621621
#if CONFIG_NET_PKT_LOG_LEVEL >= LOG_LEVEL_DBG
622-
NET_DBG("%s [%d] pkt %p ref %d (%s():%d)",
622+
NET_DBG("%s [%d] pkt %p ref %ld (%s():%d)",
623623
slab2str(pkt->slab), k_mem_slab_num_free_get(pkt->slab),
624624
pkt, ref + 1, caller, line);
625625
#endif

subsys/net/ip/net_private.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,14 +248,14 @@ static inline void net_pkt_print_buffer_info(struct net_pkt *pkt, const char *st
248248
printk("%s", str);
249249
}
250250

251-
printk("%p[%d]", pkt, atomic_get(&pkt->atomic_ref));
251+
printk("%p[%ld]", pkt, atomic_get(&pkt->atomic_ref));
252252

253253
if (buf) {
254254
printk("->");
255255
}
256256

257257
while (buf) {
258-
printk("%p[%d/%u (%u/%u)]", buf, atomic_get(&pkt->atomic_ref),
258+
printk("%p[%ld/%u (%u/%u)]", buf, atomic_get(&pkt->atomic_ref),
259259
buf->len, net_buf_max_len(buf), buf->size);
260260

261261
buf = buf->frags;

subsys/net/ip/net_shell.c

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1496,7 +1496,7 @@ static void tcp_sent_list_cb(struct tcp *conn, void *user_data)
14961496
details->printed_details = true;
14971497
}
14981498

1499-
PR("%p %d %u\t %u\t %zd\t %d\t %d/%d/%d %s\n",
1499+
PR("%p %ld %u\t %u\t %zd\t %d\t %d/%d/%d %s\n",
15001500
conn, atomic_get(&conn->ref_count), conn->recv_win,
15011501
conn->send_win, conn->send_data_total, conn->unacked_len,
15021502
conn->in_retransmission, conn->in_connect, conn->in_close,
@@ -1524,12 +1524,12 @@ static void tcp_sent_list_cb(struct tcp *conn, void *user_data)
15241524
struct net_buf *frag = pkt->frags;
15251525

15261526
if (!details->printed_send_queue_header) {
1527-
PR("%p[%d/%zd]", pkt,
1527+
PR("%p[%ld/%zd]", pkt,
15281528
atomic_get(&pkt->atomic_ref),
15291529
net_pkt_get_len(pkt));
15301530
details->printed_send_queue_header = true;
15311531
} else {
1532-
PR(" %p[%d/%zd]",
1532+
PR(" %p[%ld/%zd]",
15331533
pkt, atomic_get(&pkt->atomic_ref),
15341534
net_pkt_get_len(pkt));
15351535
}
@@ -1630,7 +1630,7 @@ static void allocs_cb(struct net_pkt *pkt,
16301630

16311631
if (func_alloc) {
16321632
if (in_use) {
1633-
PR("%p/%d\t%5s\t%5s\t%s():%d\n",
1633+
PR("%p/%ld\t%5s\t%5s\t%s():%d\n",
16341634
pkt, atomic_get(&pkt->atomic_ref), str,
16351635
net_pkt_slab2str(pkt->slab),
16361636
func_alloc, line_alloc);
@@ -3632,8 +3632,7 @@ static void context_info(struct net_context *context, void *user_data)
36323632
}
36333633

36343634
#if defined(CONFIG_NET_BUF_POOL_USAGE)
3635-
PR("%p\t%d\t%d\tEDATA (%s)\n",
3636-
pool, pool->buf_count,
3635+
PR("%p\t%d\t%ld\tEDATA (%s)\n", pool, pool->buf_count,
36373636
atomic_get(&pool->avail_count), pool->name);
36383637
#else
36393638
PR("%p\t%d\tEDATA\n", pool, pool->buf_count);
@@ -3671,13 +3670,11 @@ static int cmd_net_mem(const struct shell *shell, size_t argc, char *argv[])
36713670
PR("%p\t%d\t%u\tTX\n",
36723671
tx, tx->num_blocks, k_mem_slab_num_free_get(tx));
36733672

3674-
PR("%p\t%d\t%d\tRX DATA (%s)\n",
3675-
rx_data, rx_data->buf_count,
3676-
atomic_get(&rx_data->avail_count), rx_data->name);
3673+
PR("%p\t%d\t%ld\tRX DATA (%s)\n ", rx_data, rx_data->buf_count,
3674+
atomic_get(&rx_data->avail_count), rx_data->name);
36773675

3678-
PR("%p\t%d\t%d\tTX DATA (%s)\n",
3679-
tx_data, tx_data->buf_count,
3680-
atomic_get(&tx_data->avail_count), tx_data->name);
3676+
PR("%p\t%d\t%ld\tTX DATA (%s)\n", tx_data, tx_data->buf_count,
3677+
atomic_get(&tx_data->avail_count), tx_data->name);
36813678
#else
36823679
PR("Address\t\tTotal\tName\n");
36833680

@@ -4242,14 +4239,14 @@ static void net_pkt_buffer_info(const struct shell *shell, struct net_pkt *pkt)
42424239
struct net_buf *buf = pkt->buffer;
42434240

42444241
PR("net_pkt %p buffer chain:\n", pkt);
4245-
PR("%p[%d]", pkt, atomic_get(&pkt->atomic_ref));
4242+
PR("%p[%ld]", pkt, atomic_get(&pkt->atomic_ref));
42464243

42474244
if (buf) {
42484245
PR("->");
42494246
}
42504247

42514248
while (buf) {
4252-
PR("%p[%d/%u (%u/%u)]", buf, atomic_get(&pkt->atomic_ref),
4249+
PR("%p[%ld/%u (%u/%u)]", buf, atomic_get(&pkt->atomic_ref),
42534250
buf->len, net_buf_max_len(buf), buf->size);
42544251

42554252
buf = buf->frags;

subsys/net/l2/ethernet/arp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static void arp_entry_cleanup(struct arp_entry *entry, bool pending)
3737
NET_DBG("%p", entry);
3838

3939
if (pending) {
40-
NET_DBG("Releasing pending pkt %p (ref %d)",
40+
NET_DBG("Releasing pending pkt %p (ref %ld)",
4141
entry->pending,
4242
atomic_get(&entry->pending->atomic_ref) - 1);
4343
net_pkt_unref(entry->pending);

subsys/shell/shell_cmds.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ static int cmd_shell_stats_show(const struct shell *shell, size_t argc,
314314
ARG_UNUSED(argc);
315315
ARG_UNUSED(argv);
316316

317-
shell_print(shell, "Lost logs: %u", shell->stats->log_lost_cnt);
317+
shell_print(shell, "Lost logs: %lu", shell->stats->log_lost_cnt);
318318

319319
return 0;
320320
}

0 commit comments

Comments
 (0)