2021-05-21 09:48:51

by yekai (A)

[permalink] [raw]
Subject: [PATCH v2 00/12] net/Bluetooth: correct the use of print format

According to Documentation/core-api/printk-formats.rst,
Use the correct print format.
1. Printing an unsigned int value should use %u instead of %d.
2. Printing an unsigned long value should use %lu instead of %ld.
Otherwise printk() might end up displaying negative numbers.

changes v1 -> v2:
fix some style problems

Kai Ye (12):
net/Bluetooth/bnep - use the correct print format
net/Bluetooth/cmtp - use the correct print format
net/Bluetooth/hidp - use the correct print format
net/Bluetooth/rfcomm - use the correct print format
net/Bluetooth/6lowpan - use the correct print format
net/Bluetooth/a2mp - use the correct print format
net/Bluetooth/amp - use the correct print format
net/Bluetooth/hci - use the correct print format
net/Bluetooth/mgmt - use the correct print format
net/Bluetooth/msft - use the correct print format
net/Bluetooth/sco - use the correct print format
net/Bluetooth/smp - use the correct print format

net/bluetooth/6lowpan.c | 16 +++++------
net/bluetooth/a2mp.c | 24 ++++++++--------
net/bluetooth/amp.c | 6 ++--
net/bluetooth/bnep/core.c | 8 +++---
net/bluetooth/cmtp/capi.c | 22 +++++++--------
net/bluetooth/hci_conn.c | 8 +++---
net/bluetooth/hci_core.c | 48 ++++++++++++++++----------------
net/bluetooth/hci_event.c | 24 ++++++++--------
net/bluetooth/hci_request.c | 8 +++---
net/bluetooth/hci_sock.c | 6 ++--
net/bluetooth/hci_sysfs.c | 2 +-
net/bluetooth/hidp/core.c | 6 ++--
net/bluetooth/mgmt.c | 16 +++++------
net/bluetooth/mgmt_config.c | 4 +--
net/bluetooth/msft.c | 2 +-
net/bluetooth/rfcomm/core.c | 68 ++++++++++++++++++++++-----------------------
net/bluetooth/rfcomm/sock.c | 8 +++---
net/bluetooth/rfcomm/tty.c | 10 +++----
net/bluetooth/sco.c | 8 +++---
net/bluetooth/smp.c | 6 ++--
20 files changed, 150 insertions(+), 150 deletions(-)

--
2.8.1


2021-05-21 09:48:55

by yekai (A)

[permalink] [raw]
Subject: [PATCH v2 03/12] net/Bluetooth/hidp - use the correct print format

According to Documentation/core-api/printk-formats.rst,
Use the correct print format. Printing an unsigned int value should use %u
instead of %d. Otherwise printk() might end up displaying negative numbers.

Signed-off-by: Kai Ye <[email protected]>
---
net/bluetooth/hidp/core.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c
index 0db48c8..1dc8dee 100644
--- a/net/bluetooth/hidp/core.c
+++ b/net/bluetooth/hidp/core.c
@@ -508,7 +508,7 @@ static int hidp_process_data(struct hidp_session *session, struct sk_buff *skb,
unsigned char param)
{
int done_with_skb = 1;
- BT_DBG("session %p skb %p len %d param 0x%02x", session, skb, skb->len, param);
+ BT_DBG("session %p skb %p len %u param 0x%02x", session, skb, skb->len, param);

switch (param) {
case HIDP_DATA_RTYPE_INPUT:
@@ -553,7 +553,7 @@ static void hidp_recv_ctrl_frame(struct hidp_session *session,
unsigned char hdr, type, param;
int free_skb = 1;

- BT_DBG("session %p skb %p len %d", session, skb, skb->len);
+ BT_DBG("session %p skb %p len %u", session, skb, skb->len);

hdr = skb->data[0];
skb_pull(skb, 1);
@@ -589,7 +589,7 @@ static void hidp_recv_intr_frame(struct hidp_session *session,
{
unsigned char hdr;

- BT_DBG("session %p skb %p len %d", session, skb, skb->len);
+ BT_DBG("session %p skb %p len %u", session, skb, skb->len);

hdr = skb->data[0];
skb_pull(skb, 1);
--
2.8.1

2021-05-21 09:49:18

by yekai (A)

[permalink] [raw]
Subject: [PATCH v2 09/12] net/Bluetooth/mgmt - use the correct print format

According to Documentation/core-api/printk-formats.rst,
Use the correct print format. Printing an unsigned int value should use %u
instead of %d. Otherwise printk() might end up displaying negative numbers.

Signed-off-by: Kai Ye <[email protected]>
---
net/bluetooth/mgmt.c | 16 ++++++++--------
net/bluetooth/mgmt_config.c | 4 ++--
2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 51c7e64..efdec6c 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -4269,7 +4269,7 @@ int mgmt_add_adv_patterns_monitor_complete(struct hci_dev *hdev, u8 status)

done:
hci_dev_unlock(hdev);
- bt_dev_dbg(hdev, "add monitor %d complete, status %d",
+ bt_dev_dbg(hdev, "add monitor %d complete, status %u",
rp.monitor_handle, status);

return err;
@@ -4494,7 +4494,7 @@ int mgmt_remove_adv_monitor_complete(struct hci_dev *hdev, u8 status)

done:
hci_dev_unlock(hdev);
- bt_dev_dbg(hdev, "remove monitor %d complete, status %d",
+ bt_dev_dbg(hdev, "remove monitor %d complete, status %u",
rp.monitor_handle, status);

return err;
@@ -4824,7 +4824,7 @@ void mgmt_start_discovery_complete(struct hci_dev *hdev, u8 status)
{
struct mgmt_pending_cmd *cmd;

- bt_dev_dbg(hdev, "status %d", status);
+ bt_dev_dbg(hdev, "status %u", status);

hci_dev_lock(hdev);

@@ -5080,7 +5080,7 @@ void mgmt_stop_discovery_complete(struct hci_dev *hdev, u8 status)
{
struct mgmt_pending_cmd *cmd;

- bt_dev_dbg(hdev, "status %d", status);
+ bt_dev_dbg(hdev, "status %u", status);

hci_dev_lock(hdev);

@@ -5293,7 +5293,7 @@ static int set_device_id(struct sock *sk, struct hci_dev *hdev, void *data,
static void enable_advertising_instance(struct hci_dev *hdev, u8 status,
u16 opcode)
{
- bt_dev_dbg(hdev, "status %d", status);
+ bt_dev_dbg(hdev, "status %u", status);
}

static void set_advertising_complete(struct hci_dev *hdev, u8 status,
@@ -6337,7 +6337,7 @@ static void conn_info_refresh_complete(struct hci_dev *hdev, u8 hci_status,
handle = __le16_to_cpu(cp->handle);
conn = hci_conn_hash_lookup_handle(hdev, handle);
if (!conn) {
- bt_dev_err(hdev, "unknown handle (%d) in conn_info response",
+ bt_dev_err(hdev, "unknown handle (%u) in conn_info response",
handle);
goto unlock;
}
@@ -7641,7 +7641,7 @@ static void add_advertising_complete(struct hci_dev *hdev, u8 status,
struct adv_info *adv_instance, *n;
u8 instance;

- bt_dev_dbg(hdev, "status %d", status);
+ bt_dev_dbg(hdev, "status %u", status);

hci_dev_lock(hdev);

@@ -8172,7 +8172,7 @@ static void remove_advertising_complete(struct hci_dev *hdev, u8 status,
struct mgmt_cp_remove_advertising *cp;
struct mgmt_rp_remove_advertising rp;

- bt_dev_dbg(hdev, "status %d", status);
+ bt_dev_dbg(hdev, "status %u", status);

hci_dev_lock(hdev);

diff --git a/net/bluetooth/mgmt_config.c b/net/bluetooth/mgmt_config.c
index 1deb0ca..6ef701c 100644
--- a/net/bluetooth/mgmt_config.c
+++ b/net/bluetooth/mgmt_config.c
@@ -146,7 +146,7 @@ int set_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data,
const u16 type = le16_to_cpu(TO_TLV(buffer)->type);

if (buffer_left < exp_len) {
- bt_dev_warn(hdev, "invalid len left %d, exp >= %d",
+ bt_dev_warn(hdev, "invalid len left %u, exp >= %u",
buffer_left, exp_len);

return mgmt_cmd_status(sk, hdev->id,
@@ -198,7 +198,7 @@ int set_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data,
}

if (exp_type_len && len != exp_type_len) {
- bt_dev_warn(hdev, "invalid length %d, exp %zu for type %d",
+ bt_dev_warn(hdev, "invalid length %d, exp %zu for type %u",
len, exp_type_len, type);

return mgmt_cmd_status(sk, hdev->id,
--
2.8.1

2021-05-21 09:49:37

by yekai (A)

[permalink] [raw]
Subject: [PATCH v2 12/12] net/Bluetooth/smp - use the correct print format

According to Documentation/core-api/printk-formats.rst,
Use the correct print format. Printing an unsigned int value should use %u
instead of %d. Otherwise printk() might end up displaying negative numbers.

Signed-off-by: Kai Ye <[email protected]>
---
net/bluetooth/smp.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index 2def906..56c59f8 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -859,7 +859,7 @@ static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth,
memset(smp->tk, 0, sizeof(smp->tk));
clear_bit(SMP_FLAG_TK_VALID, &smp->flags);

- bt_dev_dbg(hcon->hdev, "auth:%d lcl:%d rem:%d", auth, local_io,
+ bt_dev_dbg(hcon->hdev, "auth:%u lcl:%u rem:%u", auth, local_io,
remote_io);

/* If neither side wants MITM, either "just" confirm an incoming
@@ -925,7 +925,7 @@ static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth,
get_random_bytes(&passkey, sizeof(passkey));
passkey %= 1000000;
put_unaligned_le32(passkey, smp->tk);
- bt_dev_dbg(hcon->hdev, "PassKey: %d", passkey);
+ bt_dev_dbg(hcon->hdev, "PassKey: %u", passkey);
set_bit(SMP_FLAG_TK_VALID, &smp->flags);
}

@@ -1654,7 +1654,7 @@ int smp_user_confirm_reply(struct hci_conn *hcon, u16 mgmt_op, __le32 passkey)
case MGMT_OP_USER_PASSKEY_REPLY:
value = le32_to_cpu(passkey);
memset(smp->tk, 0, sizeof(smp->tk));
- bt_dev_dbg(conn->hcon->hdev, "PassKey: %d", value);
+ bt_dev_dbg(conn->hcon->hdev, "PassKey: %u", value);
put_unaligned_le32(value, smp->tk);
fallthrough;
case MGMT_OP_USER_CONFIRM_REPLY:
--
2.8.1

2021-05-21 09:50:45

by yekai (A)

[permalink] [raw]
Subject: [PATCH v2 07/12] net/Bluetooth/amp - use the correct print format

According to Documentation/core-api/printk-formats.rst,
Use the correct print format. Printing an unsigned int value should use %u
instead of %d. Otherwise printk() might end up displaying negative numbers.

Signed-off-by: Kai Ye <[email protected]>
---
net/bluetooth/amp.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/bluetooth/amp.c b/net/bluetooth/amp.c
index be2d469..2134f92 100644
--- a/net/bluetooth/amp.c
+++ b/net/bluetooth/amp.c
@@ -78,7 +78,7 @@ struct amp_ctrl *amp_ctrl_lookup(struct amp_mgr *mgr, u8 id)
{
struct amp_ctrl *ctrl;

- BT_DBG("mgr %p id %d", mgr, id);
+ BT_DBG("mgr %p id %u", mgr, id);

mutex_lock(&mgr->amp_ctrls_lock);
list_for_each_entry(ctrl, &mgr->amp_ctrls, list) {
@@ -179,7 +179,7 @@ int phylink_gen_key(struct hci_conn *conn, u8 *data, u8 *len, u8 *type)

/* Legacy key */
if (conn->key_type < 3) {
- bt_dev_err(hdev, "legacy key type %d", conn->key_type);
+ bt_dev_err(hdev, "legacy key type %u", conn->key_type);
return -EACCES;
}

@@ -257,7 +257,7 @@ void amp_read_loc_assoc_frag(struct hci_dev *hdev, u8 phy_handle)
struct hci_request req;
int err;

- BT_DBG("%s handle %d", hdev->name, phy_handle);
+ BT_DBG("%s handle %u", hdev->name, phy_handle);

cp.phy_handle = phy_handle;
cp.max_len = cpu_to_le16(hdev->amp_assoc_size);
--
2.8.1

2021-05-21 09:50:51

by yekai (A)

[permalink] [raw]
Subject: [PATCH v2 08/12] net/Bluetooth/hci - use the correct print format

According to Documentation/core-api/printk-formats.rst,
Use the correct print format. Printing an unsigned int value should use %u
instead of %d. Otherwise printk() might end up displaying negative numbers.

Signed-off-by: Kai Ye <[email protected]>
---
net/bluetooth/hci_conn.c | 8 ++++----
net/bluetooth/hci_core.c | 48 ++++++++++++++++++++++-----------------------
net/bluetooth/hci_event.c | 24 +++++++++++------------
net/bluetooth/hci_request.c | 8 ++++----
net/bluetooth/hci_sock.c | 6 +++---
net/bluetooth/hci_sysfs.c | 2 +-
6 files changed, 48 insertions(+), 48 deletions(-)

diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 88ec089..5b6bbeb 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -300,7 +300,7 @@ static bool find_next_esco_param(struct hci_conn *conn,
if (lmp_esco_2m_capable(conn->link) ||
(esco_param[conn->attempt - 1].pkt_type & ESCO_2EV3))
break;
- BT_DBG("hcon %p skipped attempt %d, eSCO 2M not supported",
+ BT_DBG("hcon %p skipped attempt %u, eSCO 2M not supported",
conn, conn->attempt);
}

@@ -471,7 +471,7 @@ static void hci_conn_idle(struct work_struct *work)
idle_work.work);
struct hci_dev *hdev = conn->hdev;

- BT_DBG("hcon %p mode %d", conn, conn->mode);
+ BT_DBG("hcon %p mode %u", conn, conn->mode);

if (!lmp_sniff_capable(hdev) || !lmp_sniff_capable(conn))
return;
@@ -637,7 +637,7 @@ int hci_conn_del(struct hci_conn *conn)
{
struct hci_dev *hdev = conn->hdev;

- BT_DBG("%s hcon %p handle %d", hdev->name, conn, conn->handle);
+ BT_DBG("%s hcon %p handle %u", hdev->name, conn, conn->handle);

cancel_delayed_work_sync(&conn->disc_work);
cancel_delayed_work_sync(&conn->auto_accept_work);
@@ -1574,7 +1574,7 @@ void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active)
{
struct hci_dev *hdev = conn->hdev;

- BT_DBG("hcon %p mode %d", conn, conn->mode);
+ BT_DBG("hcon %p mode %u", conn, conn->mode);

if (conn->mode != HCI_CM_SNIFF)
goto timer;
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index b0d9c36..49e15b6 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -261,7 +261,7 @@ static int hci_init1_req(struct hci_request *req, unsigned long opt)
amp_init1(req);
break;
default:
- bt_dev_err(hdev, "Unknown device type %d", hdev->dev_type);
+ bt_dev_err(hdev, "Unknown device type %u", hdev->dev_type);
break;
}

@@ -1386,7 +1386,7 @@ int hci_inquiry(void __user *arg)
ir.num_rsp = inquiry_cache_dump(hdev, max_rsp, buf);
hci_dev_unlock(hdev);

- BT_DBG("num_rsp %d", ir.num_rsp);
+ BT_DBG("num_rsp %u", ir.num_rsp);

if (!copy_to_user(ptr, &ir, sizeof(ir))) {
ptr += sizeof(ir);
@@ -2897,7 +2897,7 @@ int hci_remove_adv_instance(struct hci_dev *hdev, u8 instance)
if (!adv_instance)
return -ENOENT;

- BT_DBG("%s removing %dMR", hdev->name, instance);
+ BT_DBG("%s removing %uMR", hdev->name, instance);

if (hdev->cur_adv_instance == instance) {
if (hdev->adv_instance_timeout) {
@@ -3010,7 +3010,7 @@ int hci_add_adv_instance(struct hci_dev *hdev, u8 instance, u32 flags,
INIT_DELAYED_WORK(&adv_instance->rpa_expired_cb,
adv_instance_rpa_expired);

- BT_DBG("%s for %dMR", hdev->name, instance);
+ BT_DBG("%s for %uMR", hdev->name, instance);

return 0;
}
@@ -3169,7 +3169,7 @@ static bool hci_remove_adv_monitor(struct hci_dev *hdev,

free_monitor:
if (*err == -ENOENT)
- bt_dev_warn(hdev, "Removing monitor with no matching handle %d",
+ bt_dev_warn(hdev, "Removing monitor with no matching handle %u",
monitor->handle);
hci_free_adv_monitor(hdev, monitor);

@@ -3194,7 +3194,7 @@ bool hci_remove_single_adv_monitor(struct hci_dev *hdev, u16 handle, int *err)
if (!*err && !pending)
hci_update_background_scan(hdev);

- bt_dev_dbg(hdev, "%s remove monitor handle %d, status %d, %spending",
+ bt_dev_dbg(hdev, "%s remove monitor handle %u, status %d, %spending",
hdev->name, handle, *err, pending ? "" : "not ");

return pending;
@@ -3877,7 +3877,7 @@ int hci_register_dev(struct hci_dev *hdev)
sprintf(hdev->name, "hci%d", id);
hdev->id = id;

- BT_DBG("%p name %s bus %d", hdev, hdev->name, hdev->bus);
+ BT_DBG("%p name %s bus %u", hdev, hdev->name, hdev->bus);

hdev->workqueue = alloc_ordered_workqueue("%s", WQ_HIGHPRI, hdev->name);
if (!hdev->workqueue) {
@@ -3968,7 +3968,7 @@ void hci_unregister_dev(struct hci_dev *hdev)
{
int id;

- BT_DBG("%p name %s bus %d", hdev, hdev->name, hdev->bus);
+ BT_DBG("%p name %s bus %u", hdev, hdev->name, hdev->bus);

hci_dev_set_flag(hdev, HCI_UNREGISTER);

@@ -4171,7 +4171,7 @@ static void hci_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
{
int err;

- BT_DBG("%s type %d len %d", hdev->name, hci_skb_pkt_type(skb),
+ BT_DBG("%s type %d len %u", hdev->name, hci_skb_pkt_type(skb),
skb->len);

/* Time stamp */
@@ -4206,7 +4206,7 @@ int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen,
{
struct sk_buff *skb;

- BT_DBG("%s opcode 0x%4.4x plen %d", hdev->name, opcode, plen);
+ BT_DBG("%s opcode 0x%4.4x plen %u", hdev->name, opcode, plen);

skb = hci_prepare_cmd(hdev, opcode, plen, param);
if (!skb) {
@@ -4283,7 +4283,7 @@ struct sk_buff *hci_cmd_sync(struct hci_dev *hdev, u16 opcode, u32 plen,
if (!test_bit(HCI_UP, &hdev->flags))
return ERR_PTR(-ENETDOWN);

- bt_dev_dbg(hdev, "opcode 0x%4.4x plen %d", opcode, plen);
+ bt_dev_dbg(hdev, "opcode 0x%4.4x plen %u", opcode, plen);

hci_req_sync_lock(hdev);
skb = __hci_cmd_sync(hdev, opcode, plen, param, timeout);
@@ -4326,19 +4326,19 @@ static void hci_queue_acl(struct hci_chan *chan, struct sk_buff_head *queue,
hci_add_acl_hdr(skb, chan->handle, flags);
break;
default:
- bt_dev_err(hdev, "unknown dev_type %d", hdev->dev_type);
+ bt_dev_err(hdev, "unknown dev_type %u", hdev->dev_type);
return;
}

list = skb_shinfo(skb)->frag_list;
if (!list) {
/* Non fragmented */
- BT_DBG("%s nonfrag skb %p len %d", hdev->name, skb, skb->len);
+ BT_DBG("%s nonfrag skb %p len %u", hdev->name, skb, skb->len);

skb_queue_tail(queue, skb);
} else {
/* Fragmented */
- BT_DBG("%s frag %p len %d", hdev->name, skb, skb->len);
+ BT_DBG("%s frag %p len %u", hdev->name, skb, skb->len);

skb_shinfo(skb)->frag_list = NULL;

@@ -4359,7 +4359,7 @@ static void hci_queue_acl(struct hci_chan *chan, struct sk_buff_head *queue,
hci_skb_pkt_type(skb) = HCI_ACLDATA_PKT;
hci_add_acl_hdr(skb, conn->handle, flags);

- BT_DBG("%s frag %p len %d", hdev->name, skb, skb->len);
+ BT_DBG("%s frag %p len %u", hdev->name, skb, skb->len);

__skb_queue_tail(queue, skb);
} while (list);
@@ -4385,7 +4385,7 @@ void hci_send_sco(struct hci_conn *conn, struct sk_buff *skb)
struct hci_dev *hdev = conn->hdev;
struct hci_sco_hdr hdr;

- BT_DBG("%s len %d", hdev->name, skb->len);
+ BT_DBG("%s len %u", hdev->name, skb->len);

hdr.handle = cpu_to_le16(conn->handle);
hdr.dlen = skb->len;
@@ -4451,7 +4451,7 @@ static struct hci_conn *hci_low_sent(struct hci_dev *hdev, __u8 type,
break;
default:
cnt = 0;
- bt_dev_err(hdev, "unknown link type %d", conn->type);
+ bt_dev_err(hdev, "unknown link type %u", conn->type);
}

q = cnt / num;
@@ -4604,7 +4604,7 @@ static void hci_prio_recalculate(struct hci_dev *hdev, __u8 type)

skb->priority = HCI_PRIO_MAX - 1;

- BT_DBG("chan %p skb %p promoted to %d", chan, skb,
+ BT_DBG("chan %p skb %p promoted to %u", chan, skb,
skb->priority);
}

@@ -4647,7 +4647,7 @@ static void hci_sched_sco(struct hci_dev *hdev)

while (hdev->sco_cnt && (conn = hci_low_sent(hdev, SCO_LINK, &quote))) {
while (quote-- && (skb = skb_dequeue(&conn->data_q))) {
- BT_DBG("skb %p len %d", skb, skb->len);
+ BT_DBG("skb %p len %u", skb, skb->len);
hci_send_frame(hdev, skb);

conn->sent++;
@@ -4671,7 +4671,7 @@ static void hci_sched_esco(struct hci_dev *hdev)
while (hdev->sco_cnt && (conn = hci_low_sent(hdev, ESCO_LINK,
&quote))) {
while (quote-- && (skb = skb_dequeue(&conn->data_q))) {
- BT_DBG("skb %p len %d", skb, skb->len);
+ BT_DBG("skb %p len %u", skb, skb->len);
hci_send_frame(hdev, skb);

conn->sent++;
@@ -4694,7 +4694,7 @@ static void hci_sched_acl_pkt(struct hci_dev *hdev)
(chan = hci_chan_sent(hdev, ACL_LINK, &quote))) {
u32 priority = (skb_peek(&chan->data_q))->priority;
while (quote-- && (skb = skb_peek(&chan->data_q))) {
- BT_DBG("chan %p skb %p len %d priority %u", chan, skb,
+ BT_DBG("chan %p skb %p len %u priority %u", chan, skb,
skb->len, skb->priority);

/* Stop if priority has changed */
@@ -4746,7 +4746,7 @@ static void hci_sched_acl_blk(struct hci_dev *hdev)
while (quote > 0 && (skb = skb_peek(&chan->data_q))) {
int blocks;

- BT_DBG("chan %p skb %p len %d priority %u", chan, skb,
+ BT_DBG("chan %p skb %p len %u priority %u", chan, skb,
skb->len, skb->priority);

/* Stop if priority has changed */
@@ -4819,7 +4819,7 @@ static void hci_sched_le(struct hci_dev *hdev)
while (cnt && (chan = hci_chan_sent(hdev, LE_LINK, &quote))) {
u32 priority = (skb_peek(&chan->data_q))->priority;
while (quote-- && (skb = skb_peek(&chan->data_q))) {
- BT_DBG("chan %p skb %p len %d priority %u", chan, skb,
+ BT_DBG("chan %p skb %p len %u priority %u", chan, skb,
skb->len, skb->priority);

/* Stop if priority has changed */
@@ -4855,7 +4855,7 @@ static void hci_tx_work(struct work_struct *work)
struct hci_dev *hdev = container_of(work, struct hci_dev, tx_work);
struct sk_buff *skb;

- BT_DBG("%s acl %d sco %d le %d", hdev->name, hdev->acl_cnt,
+ BT_DBG("%s acl %u sco %u le %u", hdev->name, hdev->acl_cnt,
hdev->sco_cnt, hdev->le_cnt);

if (!hci_dev_test_flag(hdev, HCI_USER_CHANNEL)) {
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 341c8ce..266b7fb 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -519,7 +519,7 @@ static void hci_cc_read_num_supported_iac(struct hci_dev *hdev,

hdev->num_iac = rp->num_iac;

- BT_DBG("%s num iac %d", hdev->name, hdev->num_iac);
+ BT_DBG("%s num iac %u", hdev->name, hdev->num_iac);
}

static void hci_cc_write_ssp_mode(struct hci_dev *hdev, struct sk_buff *skb)
@@ -765,7 +765,7 @@ static void hci_cc_read_buffer_size(struct hci_dev *hdev, struct sk_buff *skb)
hdev->acl_cnt = hdev->acl_pkts;
hdev->sco_cnt = hdev->sco_pkts;

- BT_DBG("%s acl mtu %d:%d sco mtu %d:%d", hdev->name, hdev->acl_mtu,
+ BT_DBG("%s acl mtu %u:%u sco mtu %u:%u", hdev->name, hdev->acl_mtu,
hdev->acl_pkts, hdev->sco_mtu, hdev->sco_pkts);
}

@@ -883,7 +883,7 @@ static void hci_cc_read_data_block_size(struct hci_dev *hdev,

hdev->block_cnt = hdev->num_blocks;

- BT_DBG("%s blk mtu %d cnt %d len %d", hdev->name, hdev->block_mtu,
+ BT_DBG("%s blk mtu %u cnt %u len %u", hdev->name, hdev->block_mtu,
hdev->block_cnt, hdev->block_len);
}

@@ -1046,7 +1046,7 @@ static void hci_cc_le_read_buffer_size(struct hci_dev *hdev,

hdev->le_cnt = hdev->le_pkts;

- BT_DBG("%s le mtu %d:%d", hdev->name, hdev->le_mtu, hdev->le_pkts);
+ BT_DBG("%s le mtu %u:%u", hdev->name, hdev->le_mtu, hdev->le_pkts);
}

static void hci_cc_le_read_local_features(struct hci_dev *hdev,
@@ -1435,7 +1435,7 @@ static void le_set_scan_enable_complete(struct hci_dev *hdev, u8 enable)
break;

default:
- bt_dev_err(hdev, "use of reserved LE_Scan_Enable param %d",
+ bt_dev_err(hdev, "use of reserved LE_Scan_Enable param %u",
enable);
break;
}
@@ -3801,7 +3801,7 @@ static void hci_num_comp_pkts_evt(struct hci_dev *hdev, struct sk_buff *skb)
int i;

if (hdev->flow_ctl_mode != HCI_FLOW_CTL_MODE_PACKET_BASED) {
- bt_dev_err(hdev, "wrong event for mode %d", hdev->flow_ctl_mode);
+ bt_dev_err(hdev, "wrong event for mode %u", hdev->flow_ctl_mode);
return;
}

@@ -3811,7 +3811,7 @@ static void hci_num_comp_pkts_evt(struct hci_dev *hdev, struct sk_buff *skb)
return;
}

- BT_DBG("%s num_hndl %d", hdev->name, ev->num_hndl);
+ BT_DBG("%s num_hndl %u", hdev->name, ev->num_hndl);

for (i = 0; i < ev->num_hndl; i++) {
struct hci_comp_pkts_info *info = &ev->handles[i];
@@ -3853,7 +3853,7 @@ static void hci_num_comp_pkts_evt(struct hci_dev *hdev, struct sk_buff *skb)
break;

default:
- bt_dev_err(hdev, "unknown type %d conn %p",
+ bt_dev_err(hdev, "unknown type %u conn %p",
conn->type, conn);
break;
}
@@ -3876,7 +3876,7 @@ static struct hci_conn *__hci_conn_lookup_handle(struct hci_dev *hdev,
return chan->conn;
break;
default:
- bt_dev_err(hdev, "unknown dev_type %d", hdev->dev_type);
+ bt_dev_err(hdev, "unknown dev_type %u", hdev->dev_type);
break;
}

@@ -3889,7 +3889,7 @@ static void hci_num_comp_blocks_evt(struct hci_dev *hdev, struct sk_buff *skb)
int i;

if (hdev->flow_ctl_mode != HCI_FLOW_CTL_MODE_BLOCK_BASED) {
- bt_dev_err(hdev, "wrong event for mode %d", hdev->flow_ctl_mode);
+ bt_dev_err(hdev, "wrong event for mode %u", hdev->flow_ctl_mode);
return;
}

@@ -3899,7 +3899,7 @@ static void hci_num_comp_blocks_evt(struct hci_dev *hdev, struct sk_buff *skb)
return;
}

- BT_DBG("%s num_blocks %d num_hndl %d", hdev->name, ev->num_blocks,
+ BT_DBG("%s num_blocks %d num_hndl %u", hdev->name, ev->num_blocks,
ev->num_hndl);

for (i = 0; i < ev->num_hndl; i++) {
@@ -3925,7 +3925,7 @@ static void hci_num_comp_blocks_evt(struct hci_dev *hdev, struct sk_buff *skb)
break;

default:
- bt_dev_err(hdev, "unknown type %d conn %p",
+ bt_dev_err(hdev, "unknown type %u conn %p",
conn->type, conn);
break;
}
diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c
index 8ace5d3..b9b39ed 100644
--- a/net/bluetooth/hci_request.c
+++ b/net/bluetooth/hci_request.c
@@ -301,7 +301,7 @@ struct sk_buff *hci_prepare_cmd(struct hci_dev *hdev, u16 opcode, u32 plen,
if (plen)
skb_put_data(skb, param, plen);

- bt_dev_dbg(hdev, "skb len %d", skb->len);
+ bt_dev_dbg(hdev, "skb len %u", skb->len);

hci_skb_pkt_type(skb) = HCI_COMMAND_PKT;
hci_skb_opcode(skb) = opcode;
@@ -316,7 +316,7 @@ void hci_req_add_ev(struct hci_request *req, u16 opcode, u32 plen,
struct hci_dev *hdev = req->hdev;
struct sk_buff *skb;

- bt_dev_dbg(hdev, "opcode 0x%4.4x plen %d", opcode, plen);
+ bt_dev_dbg(hdev, "opcode 0x%4.4x plen %u", opcode, plen);

/* If an error occurred during request building, there is no point in
* queueing the HCI command. We can simply return.
@@ -1103,7 +1103,7 @@ void hci_req_add_le_passive_scan(struct hci_request *req)
interval = hdev->le_scan_interval;
}

- bt_dev_dbg(hdev, "LE passive scan with whitelist = %d", filter_policy);
+ bt_dev_dbg(hdev, "LE passive scan with whitelist = %u", filter_policy);
hci_req_start_scan(req, LE_SCAN_PASSIVE, interval, window,
own_addr_type, filter_policy, addr_resolv);
}
@@ -3078,7 +3078,7 @@ static void le_scan_restart_work(struct work_struct *work)

hci_req_sync(hdev, le_scan_restart, 0, HCI_CMD_TIMEOUT, &status);
if (status) {
- bt_dev_err(hdev, "failed to restart LE scan: status %d",
+ bt_dev_err(hdev, "failed to restart LE scan: status %u",
status);
return;
}
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
index 251b912..6ef2be0 100644
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
@@ -193,7 +193,7 @@ void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb)
struct sock *sk;
struct sk_buff *skb_copy = NULL;

- BT_DBG("hdev %p len %d", hdev, skb->len);
+ BT_DBG("hdev %p len %u", hdev, skb->len);

read_lock(&hci_sk_list.lock);

@@ -258,7 +258,7 @@ static void __hci_send_to_channel(unsigned short channel, struct sk_buff *skb,
{
struct sock *sk;

- BT_DBG("channel %u len %d", channel, skb->len);
+ BT_DBG("channel %u len %u", channel, skb->len);

sk_for_each(sk, &hci_sk_list.head) {
struct sk_buff *nskb;
@@ -305,7 +305,7 @@ void hci_send_to_monitor(struct hci_dev *hdev, struct sk_buff *skb)
if (!atomic_read(&monitor_promisc))
return;

- BT_DBG("hdev %p len %d", hdev, skb->len);
+ BT_DBG("hdev %p len %u", hdev, skb->len);

switch (hci_skb_pkt_type(skb)) {
case HCI_COMMAND_PKT:
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index 9874844..be37a5e 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -48,7 +48,7 @@ void hci_conn_add_sysfs(struct hci_conn *conn)

BT_DBG("conn %p", conn);

- dev_set_name(&conn->dev, "%s:%d", hdev->name, conn->handle);
+ dev_set_name(&conn->dev, "%s:%u", hdev->name, conn->handle);

if (device_add(&conn->dev) < 0) {
bt_dev_err(hdev, "failed to register connection device");
--
2.8.1

2021-05-21 09:51:13

by yekai (A)

[permalink] [raw]
Subject: [PATCH v2 01/12] net/Bluetooth/bnep - use the correct print format

According to Documentation/core-api/printk-formats.rst,
Use the correct print format. Printing an unsigned int value should use %u
instead of %d. Otherwise printk() might end up displaying negative numbers.

Signed-off-by: Kai Ye <[email protected]>
---
net/bluetooth/bnep/core.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c
index 43c2841..72f47b3 100644
--- a/net/bluetooth/bnep/core.c
+++ b/net/bluetooth/bnep/core.c
@@ -126,8 +126,8 @@ static int bnep_ctrl_set_netfilter(struct bnep_session *s, __be16 *data, int len
f[i].start = get_unaligned_be16(data++);
f[i].end = get_unaligned_be16(data++);

- BT_DBG("proto filter start %d end %d",
- f[i].start, f[i].end);
+ BT_DBG("proto filter start %u end %u",
+ f[i].start, f[i].end);
}

if (i < BNEP_MAX_PROTO_FILTERS)
@@ -266,7 +266,7 @@ static int bnep_rx_extension(struct bnep_session *s, struct sk_buff *skb)
break;
}

- BT_DBG("type 0x%x len %d", h->type, h->len);
+ BT_DBG("type 0x%x len %u", h->type, h->len);

switch (h->type & BNEP_TYPE_MASK) {
case BNEP_EXT_CONTROL:
@@ -424,7 +424,7 @@ static int bnep_tx_frame(struct bnep_session *s, struct sk_buff *skb)
int len = 0, il = 0;
u8 type = 0;

- BT_DBG("skb %p dev %p type %d", skb, skb->dev, skb->pkt_type);
+ BT_DBG("skb %p dev %p type %u", skb, skb->dev, skb->pkt_type);

if (!skb->dev) {
/* Control frame sent by us */
--
2.8.1

2021-05-21 09:51:19

by yekai (A)

[permalink] [raw]
Subject: [PATCH v2 04/12] net/Bluetooth/rfcomm - use the correct print format

According to Documentation/core-api/printk-formats.rst,
Use the correct print format. Printing an unsigned int value should use %u
instead of %d. Otherwise printk() might end up displaying negative numbers.
And fix the correct local variables type that been used.

Signed-off-by: Kai Ye <[email protected]>
---
net/bluetooth/rfcomm/core.c | 68 ++++++++++++++++++++++-----------------------
net/bluetooth/rfcomm/sock.c | 8 +++---
net/bluetooth/rfcomm/tty.c | 10 +++----
3 files changed, 43 insertions(+), 43 deletions(-)

diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
index f2bacb4..eec8fdc 100644
--- a/net/bluetooth/rfcomm/core.c
+++ b/net/bluetooth/rfcomm/core.c
@@ -338,7 +338,7 @@ static void rfcomm_dlc_unlink(struct rfcomm_dlc *d)
{
struct rfcomm_session *s = d->session;

- BT_DBG("dlc %p refcnt %d session %p", d, refcount_read(&d->refcnt), s);
+ BT_DBG("dlc %p refcnt %u session %p", d, refcount_read(&d->refcnt), s);

list_del(&d->list);
d->session = NULL;
@@ -370,7 +370,7 @@ static int __rfcomm_dlc_open(struct rfcomm_dlc *d, bdaddr_t *src, bdaddr_t *dst,
int err = 0;
u8 dlci;

- BT_DBG("dlc %p state %ld %pMR -> %pMR channel %d",
+ BT_DBG("dlc %p state %lu %pMR -> %pMR channel %u",
d, d->state, src, dst, channel);

if (rfcomm_check_channel(channel))
@@ -450,8 +450,8 @@ static int __rfcomm_dlc_close(struct rfcomm_dlc *d, int err)
if (!s)
return 0;

- BT_DBG("dlc %p state %ld dlci %d err %d session %p",
- d, d->state, d->dlci, err, s);
+ BT_DBG("dlc %p state %lu dlci %u err %d session %p",
+ d, d->state, d->dlci, err, s);

switch (d->state) {
case BT_CONNECT:
@@ -502,7 +502,7 @@ int rfcomm_dlc_close(struct rfcomm_dlc *d, int err)
struct rfcomm_dlc *d_list;
struct rfcomm_session *s, *s_list;

- BT_DBG("dlc %p state %ld dlci %d err %d", d, d->state, d->dlci, err);
+ BT_DBG("dlc %p state %lu dlci %u err %d", d, d->state, d->dlci, err);

rfcomm_lock();

@@ -551,12 +551,12 @@ struct rfcomm_dlc *rfcomm_dlc_exists(bdaddr_t *src, bdaddr_t *dst, u8 channel)

int rfcomm_dlc_send(struct rfcomm_dlc *d, struct sk_buff *skb)
{
- int len = skb->len;
+ unsigned int len = skb->len;

if (d->state != BT_CONNECTED)
return -ENOTCONN;

- BT_DBG("dlc %p mtu %d len %d", d, d->mtu, len);
+ BT_DBG("dlc %p mtu %u len %u", d, d->mtu, len);

if (len > d->mtu)
return -EINVAL;
@@ -571,9 +571,9 @@ int rfcomm_dlc_send(struct rfcomm_dlc *d, struct sk_buff *skb)

void rfcomm_dlc_send_noerror(struct rfcomm_dlc *d, struct sk_buff *skb)
{
- int len = skb->len;
+ unsigned int len = skb->len;

- BT_DBG("dlc %p mtu %d len %d", d, d->mtu, len);
+ BT_DBG("dlc %p mtu %u len %u", d, d->mtu, len);

rfcomm_make_uih(skb, d->addr);
skb_queue_tail(&d->tx_queue, skb);
@@ -826,7 +826,7 @@ static int rfcomm_send_ua(struct rfcomm_session *s, u8 dlci)
{
struct rfcomm_cmd cmd;

- BT_DBG("%p dlci %d", s, dlci);
+ BT_DBG("%p dlci %u", s, dlci);

cmd.addr = __addr(!s->initiator, dlci);
cmd.ctrl = __ctrl(RFCOMM_UA, 1);
@@ -840,7 +840,7 @@ static int rfcomm_send_disc(struct rfcomm_session *s, u8 dlci)
{
struct rfcomm_cmd cmd;

- BT_DBG("%p dlci %d", s, dlci);
+ BT_DBG("%p dlci %u", s, dlci);

cmd.addr = __addr(s->initiator, dlci);
cmd.ctrl = __ctrl(RFCOMM_DISC, 1);
@@ -855,7 +855,7 @@ static int rfcomm_queue_disc(struct rfcomm_dlc *d)
struct rfcomm_cmd *cmd;
struct sk_buff *skb;

- BT_DBG("dlc %p dlci %d", d, d->dlci);
+ BT_DBG("dlc %p dlci %u", d, d->dlci);

skb = alloc_skb(sizeof(*cmd), GFP_KERNEL);
if (!skb)
@@ -876,7 +876,7 @@ static int rfcomm_send_dm(struct rfcomm_session *s, u8 dlci)
{
struct rfcomm_cmd cmd;

- BT_DBG("%p dlci %d", s, dlci);
+ BT_DBG("%p dlci %u", s, dlci);

cmd.addr = __addr(!s->initiator, dlci);
cmd.ctrl = __ctrl(RFCOMM_DM, 1);
@@ -892,7 +892,7 @@ static int rfcomm_send_nsc(struct rfcomm_session *s, int cr, u8 type)
struct rfcomm_mcc *mcc;
u8 buf[16], *ptr = buf;

- BT_DBG("%p cr %d type %d", s, cr, type);
+ BT_DBG("%p cr %d type %u", s, cr, type);

hdr = (void *) ptr; ptr += sizeof(*hdr);
hdr->addr = __addr(s->initiator, 0);
@@ -918,7 +918,7 @@ static int rfcomm_send_pn(struct rfcomm_session *s, int cr, struct rfcomm_dlc *d
struct rfcomm_pn *pn;
u8 buf[16], *ptr = buf;

- BT_DBG("%p cr %d dlci %d mtu %d", s, cr, d->dlci, d->mtu);
+ BT_DBG("%p cr %d dlci %u mtu %u", s, cr, d->dlci, d->mtu);

hdr = (void *) ptr; ptr += sizeof(*hdr);
hdr->addr = __addr(s->initiator, 0);
@@ -963,7 +963,7 @@ int rfcomm_send_rpn(struct rfcomm_session *s, int cr, u8 dlci,
struct rfcomm_rpn *rpn;
u8 buf[16], *ptr = buf;

- BT_DBG("%p cr %d dlci %d bit_r 0x%x data_b 0x%x stop_b 0x%x parity 0x%x"
+ BT_DBG("%p cr %d dlci %u bit_r 0x%x data_b 0x%x stop_b 0x%x parity 0x%x"
" flwc_s 0x%x xon_c 0x%x xoff_c 0x%x p_mask 0x%x",
s, cr, dlci, bit_rate, data_bits, stop_bits, parity,
flow_ctrl_settings, xon_char, xoff_char, param_mask);
@@ -998,7 +998,7 @@ static int rfcomm_send_rls(struct rfcomm_session *s, int cr, u8 dlci, u8 status)
struct rfcomm_rls *rls;
u8 buf[16], *ptr = buf;

- BT_DBG("%p cr %d status 0x%x", s, cr, status);
+ BT_DBG("%p cr %u status 0x%x", s, cr, status);

hdr = (void *) ptr; ptr += sizeof(*hdr);
hdr->addr = __addr(s->initiator, 0);
@@ -1025,7 +1025,7 @@ static int rfcomm_send_msc(struct rfcomm_session *s, int cr, u8 dlci, u8 v24_sig
struct rfcomm_msc *msc;
u8 buf[16], *ptr = buf;

- BT_DBG("%p cr %d v24 0x%x", s, cr, v24_sig);
+ BT_DBG("%p cr %u v24 0x%x", s, cr, v24_sig);

hdr = (void *) ptr; ptr += sizeof(*hdr);
hdr->addr = __addr(s->initiator, 0);
@@ -1126,7 +1126,7 @@ static int rfcomm_send_credits(struct rfcomm_session *s, u8 addr, u8 credits)
struct rfcomm_hdr *hdr;
u8 buf[16], *ptr = buf;

- BT_DBG("%p addr %d credits %d", s, addr, credits);
+ BT_DBG("%p addr %u credits %u", s, addr, credits);

hdr = (void *) ptr; ptr += sizeof(*hdr);
hdr->addr = addr;
@@ -1163,7 +1163,7 @@ static void rfcomm_make_uih(struct sk_buff *skb, u8 addr)
/* ---- RFCOMM frame reception ---- */
static struct rfcomm_session *rfcomm_recv_ua(struct rfcomm_session *s, u8 dlci)
{
- BT_DBG("session %p state %ld dlci %d", s, s->state, dlci);
+ BT_DBG("session %p state %ld dlci %u", s, s->state, dlci);

if (dlci) {
/* Data channel */
@@ -1217,7 +1217,7 @@ static struct rfcomm_session *rfcomm_recv_dm(struct rfcomm_session *s, u8 dlci)
{
int err = 0;

- BT_DBG("session %p state %ld dlci %d", s, s->state, dlci);
+ BT_DBG("session %p state %ld dlci %u", s, s->state, dlci);

if (dlci) {
/* Data DLC */
@@ -1247,7 +1247,7 @@ static struct rfcomm_session *rfcomm_recv_disc(struct rfcomm_session *s,
{
int err = 0;

- BT_DBG("session %p state %ld dlci %d", s, s->state, dlci);
+ BT_DBG("session %p state %ld dlci %u", s, s->state, dlci);

if (dlci) {
struct rfcomm_dlc *d = rfcomm_dlc_get(s, dlci);
@@ -1323,7 +1323,7 @@ static int rfcomm_recv_sabm(struct rfcomm_session *s, u8 dlci)
struct rfcomm_dlc *d;
u8 channel;

- BT_DBG("session %p state %ld dlci %d", s, s->state, dlci);
+ BT_DBG("session %p state %ld dlci %u", s, s->state, dlci);

if (!dlci) {
rfcomm_send_ua(s, 0);
@@ -1364,8 +1364,8 @@ static int rfcomm_apply_pn(struct rfcomm_dlc *d, int cr, struct rfcomm_pn *pn)
{
struct rfcomm_session *s = d->session;

- BT_DBG("dlc %p state %ld dlci %d mtu %d fc 0x%x credits %d",
- d, d->state, d->dlci, pn->mtu, pn->flow_ctrl, pn->credits);
+ BT_DBG("dlc %p state %lu dlci %u mtu %u fc 0x%x credits %u",
+ d, d->state, d->dlci, pn->mtu, pn->flow_ctrl, pn->credits);

if ((pn->flow_ctrl == 0xf0 && s->cfc != RFCOMM_CFC_DISABLED) ||
pn->flow_ctrl == 0xe0) {
@@ -1395,7 +1395,7 @@ static int rfcomm_recv_pn(struct rfcomm_session *s, int cr, struct sk_buff *skb)
struct rfcomm_dlc *d;
u8 dlci = pn->dlci;

- BT_DBG("session %p state %ld dlci %d", s, s->state, dlci);
+ BT_DBG("session %p state %lu dlci %u", s, s->state, dlci);

if (!dlci)
return 0;
@@ -1552,7 +1552,7 @@ static int rfcomm_recv_rls(struct rfcomm_session *s, int cr, struct sk_buff *skb
struct rfcomm_rls *rls = (void *) skb->data;
u8 dlci = __get_dlci(rls->dlci);

- BT_DBG("dlci %d cr %d status 0x%x", dlci, cr, rls->status);
+ BT_DBG("dlci %u cr %d status 0x%x", dlci, cr, rls->status);

if (!cr)
return 0;
@@ -1572,7 +1572,7 @@ static int rfcomm_recv_msc(struct rfcomm_session *s, int cr, struct sk_buff *skb
struct rfcomm_dlc *d;
u8 dlci = __get_dlci(msc->dlci);

- BT_DBG("dlci %d cr %d v24 0x%x", dlci, cr, msc->v24_sig);
+ BT_DBG("dlci %u cr %d v24 0x%x", dlci, cr, msc->v24_sig);

d = rfcomm_dlc_get(s, dlci);
if (!d)
@@ -1611,7 +1611,7 @@ static int rfcomm_recv_mcc(struct rfcomm_session *s, struct sk_buff *skb)
type = __get_mcc_type(mcc->type);
len = __get_mcc_len(mcc->len);

- BT_DBG("%p type 0x%x cr %d", s, type, cr);
+ BT_DBG("%p type 0x%x cr %u", s, type, cr);

skb_pull(skb, 2);

@@ -1666,7 +1666,7 @@ static int rfcomm_recv_data(struct rfcomm_session *s, u8 dlci, int pf, struct sk
{
struct rfcomm_dlc *d;

- BT_DBG("session %p state %ld dlci %d pf %d", s, s->state, dlci, pf);
+ BT_DBG("session %p state %lu dlci %u pf %d", s, s->state, dlci, pf);

d = rfcomm_dlc_get(s, dlci);
if (!d) {
@@ -1790,8 +1790,8 @@ static int rfcomm_process_tx(struct rfcomm_dlc *d)
struct sk_buff *skb;
int err;

- BT_DBG("dlc %p state %ld cfc %d rx_credits %d tx_credits %d",
- d, d->state, d->cfc, d->rx_credits, d->tx_credits);
+ BT_DBG("dlc %p state %lu cfc %u rx_credits %u tx_credits %u",
+ d, d->state, d->cfc, d->rx_credits, d->tx_credits);

/* Send pending MSC */
if (test_and_clear_bit(RFCOMM_MSC_PENDING, &d->flags))
@@ -1896,7 +1896,7 @@ static struct rfcomm_session *rfcomm_process_rx(struct rfcomm_session *s)
struct sock *sk = sock->sk;
struct sk_buff *skb;

- BT_DBG("session %p state %ld qlen %d", s, s->state, skb_queue_len(&sk->sk_receive_queue));
+ BT_DBG("session %p state %lu qlen %u", s, s->state, skb_queue_len(&sk->sk_receive_queue));

/* Get data directly from socket receive queue without copying it. */
while ((skb = skb_dequeue(&sk->sk_receive_queue))) {
@@ -2153,7 +2153,7 @@ static int rfcomm_dlc_debugfs_show(struct seq_file *f, void *x)
struct l2cap_chan *chan = l2cap_pi(s->sock->sk)->chan;
struct rfcomm_dlc *d;
list_for_each_entry(d, &s->dlcs, list) {
- seq_printf(f, "%pMR %pMR %ld %d %d %d %d\n",
+ seq_printf(f, "%pMR %pMR %lu %u %u %u %u\n",
&chan->src, &chan->dst,
d->state, d->dlci, d->mtu,
d->rx_credits, d->tx_credits);
diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
index ae6f807..4c4081e 100644
--- a/net/bluetooth/rfcomm/sock.c
+++ b/net/bluetooth/rfcomm/sock.c
@@ -194,7 +194,7 @@ static void rfcomm_sock_kill(struct sock *sk)
if (!sock_flag(sk, SOCK_ZAPPED) || sk->sk_socket)
return;

- BT_DBG("sk %p state %d refcnt %d", sk, sk->sk_state, refcount_read(&sk->sk_refcnt));
+ BT_DBG("sk %p state %d refcnt %u", sk, sk->sk_state, refcount_read(&sk->sk_refcnt));

/* Kill poor orphan */
bt_sock_unlink(&rfcomm_sk_list, sk);
@@ -965,7 +965,7 @@ int rfcomm_connect_ind(struct rfcomm_session *s, u8 channel, struct rfcomm_dlc *
bdaddr_t src, dst;
int result = 0;

- BT_DBG("session %p channel %d", s, channel);
+ BT_DBG("session %p channel %u", s, channel);

rfcomm_session_getaddr(s, &src, &dst);

@@ -978,7 +978,7 @@ int rfcomm_connect_ind(struct rfcomm_session *s, u8 channel, struct rfcomm_dlc *

/* Check for backlog size */
if (sk_acceptq_is_full(parent)) {
- BT_DBG("backlog full %d", parent->sk_ack_backlog);
+ BT_DBG("backlog full %u", parent->sk_ack_backlog);
goto done;
}

@@ -1016,7 +1016,7 @@ static int rfcomm_sock_debugfs_show(struct seq_file *f, void *p)
read_lock(&rfcomm_sk_list.lock);

sk_for_each(sk, &rfcomm_sk_list.head) {
- seq_printf(f, "%pMR %pMR %d %d\n",
+ seq_printf(f, "%pMR %pMR %d %u\n",
&rfcomm_pi(sk)->src, &rfcomm_pi(sk)->dst,
sk->sk_state, rfcomm_pi(sk)->channel);
}
diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
index a585849..eeae373 100644
--- a/net/bluetooth/rfcomm/tty.c
+++ b/net/bluetooth/rfcomm/tty.c
@@ -207,7 +207,7 @@ static ssize_t show_address(struct device *tty_dev, struct device_attribute *att
static ssize_t show_channel(struct device *tty_dev, struct device_attribute *attr, char *buf)
{
struct rfcomm_dev *dev = dev_get_drvdata(tty_dev);
- return sprintf(buf, "%d\n", dev->channel);
+ return sprintf(buf, "%u\n", dev->channel);
}

static DEVICE_ATTR(address, 0444, show_address, NULL);
@@ -319,7 +319,7 @@ static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc)
struct rfcomm_dev *dev;
struct device *tty;

- BT_DBG("id %d channel %d", req->dev_id, req->channel);
+ BT_DBG("id %d channel %u", req->dev_id, req->channel);

dev = __rfcomm_dev_add(req, dlc);
if (IS_ERR(dev)) {
@@ -579,7 +579,7 @@ static int rfcomm_get_dev_info(void __user *arg)

int rfcomm_dev_ioctl(struct sock *sk, unsigned int cmd, void __user *arg)
{
- BT_DBG("cmd %d arg %p", cmd, arg);
+ BT_DBG("cmd %u arg %p", cmd, arg);

switch (cmd) {
case RFCOMMCREATEDEV:
@@ -613,7 +613,7 @@ static void rfcomm_dev_data_ready(struct rfcomm_dlc *dlc, struct sk_buff *skb)
return;
}

- BT_DBG("dlc %p len %d", dlc, skb->len);
+ BT_DBG("dlc %p len %u", dlc, skb->len);

tty_insert_flip_string(&dev->port, skb->data, skb->len);
tty_flip_buffer_push(&dev->port);
@@ -749,7 +749,7 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)

BT_DBG("tty %p id %d", tty, tty->index);

- BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
+ BT_DBG("dev %p dst %pMR channel %u opened %d", dev, &dev->dst,
dev->channel, dev->port.count);

err = tty_port_open(&dev->port, tty, filp);
--
2.8.1

2021-05-21 18:12:55

by yekai (A)

[permalink] [raw]
Subject: [PATCH v2 11/12] net/Bluetooth/sco - use the correct print format

According to Documentation/core-api/printk-formats.rst,
Use the correct print format. Printing an unsigned int value should use %u
instead of %d. Otherwise printk() might end up displaying negative numbers.

Signed-off-by: Kai Ye <[email protected]>
---
net/bluetooth/sco.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index 3bd4156..d9a4e88 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -310,7 +310,7 @@ static void sco_recv_frame(struct sco_conn *conn, struct sk_buff *skb)
if (!sk)
goto drop;

- BT_DBG("sk %p len %d", sk, skb->len);
+ BT_DBG("sk %p len %u", sk, skb->len);

if (sk->sk_state != BT_CONNECTED)
goto drop;
@@ -905,7 +905,7 @@ static int sco_sock_getsockopt_old(struct socket *sock, int optname,

opts.mtu = sco_pi(sk)->conn->mtu;

- BT_DBG("mtu %d", opts.mtu);
+ BT_DBG("mtu %u", opts.mtu);

len = min_t(unsigned int, len, sizeof(opts));
if (copy_to_user(optval, (char *)&opts, len))
@@ -1167,7 +1167,7 @@ static void sco_connect_cfm(struct hci_conn *hcon, __u8 status)
if (hcon->type != SCO_LINK && hcon->type != ESCO_LINK)
return;

- BT_DBG("hcon %p bdaddr %pMR status %d", hcon, &hcon->dst, status);
+ BT_DBG("hcon %p bdaddr %pMR status %u", hcon, &hcon->dst, status);

if (!status) {
struct sco_conn *conn;
@@ -1196,7 +1196,7 @@ void sco_recv_scodata(struct hci_conn *hcon, struct sk_buff *skb)
if (!conn)
goto drop;

- BT_DBG("conn %p len %d", conn, skb->len);
+ BT_DBG("conn %p len %u", conn, skb->len);

if (skb->len) {
sco_recv_frame(conn, skb);
--
2.8.1

2021-06-02 20:21:19

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [PATCH v2 00/12] net/Bluetooth: correct the use of print format

Hi Kai,

> According to Documentation/core-api/printk-formats.rst,
> Use the correct print format.
> 1. Printing an unsigned int value should use %u instead of %d.
> 2. Printing an unsigned long value should use %lu instead of %ld.
> Otherwise printk() might end up displaying negative numbers.
>
> changes v1 -> v2:
> fix some style problems
>
> Kai Ye (12):
> net/Bluetooth/bnep - use the correct print format
> net/Bluetooth/cmtp - use the correct print format
> net/Bluetooth/hidp - use the correct print format
> net/Bluetooth/rfcomm - use the correct print format
> net/Bluetooth/6lowpan - use the correct print format
> net/Bluetooth/a2mp - use the correct print format
> net/Bluetooth/amp - use the correct print format
> net/Bluetooth/hci - use the correct print format
> net/Bluetooth/mgmt - use the correct print format
> net/Bluetooth/msft - use the correct print format
> net/Bluetooth/sco - use the correct print format
> net/Bluetooth/smp - use the correct print format

please fix the commit message to apply with expected style. Fixing up 12 patches manually is not something I am going to do.

Regards

Marcel