diff mbox series

[v2,1/2] Bluetooth: hci_core: Fix build warnings

Message ID 20230915232139.3661778-1-luiz.dentz@gmail.com
State Superseded
Headers show
Series [v2,1/2] Bluetooth: hci_core: Fix build warnings | expand

Commit Message

Luiz Augusto von Dentz Sept. 15, 2023, 11:21 p.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This fixes the following warnings:

net/bluetooth/hci_core.c: In function ‘hci_register_dev’:
net/bluetooth/hci_core.c:2620:54: warning: ‘%d’ directive output may
be truncated writing between 1 and 10 bytes into a region of size 5
[-Wformat-truncation=]
 2620 |         snprintf(hdev->name, sizeof(hdev->name), "hci%d", id);
      |                                                      ^~
net/bluetooth/hci_core.c:2620:50: note: directive argument in the range
[0, 2147483647]
 2620 |         snprintf(hdev->name, sizeof(hdev->name), "hci%d", id);
      |                                                  ^~~~~~~
net/bluetooth/hci_core.c:2620:9: note: ‘snprintf’ output between 5 and
14 bytes into a destination of size 8
 2620 |         snprintf(hdev->name, sizeof(hdev->name), "hci%d", id);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
 net/bluetooth/hci_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

bluez.test.bot@gmail.com Sept. 16, 2023, 12:01 a.m. UTC | #1
This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=784857

---Test result---

Test Summary:
CheckPatch                    PASS      1.72 seconds
GitLint                       PASS      0.68 seconds
SubjectPrefix                 PASS      0.25 seconds
BuildKernel                   PASS      33.24 seconds
CheckAllWarning               PASS      36.14 seconds
CheckSparse                   WARNING   41.19 seconds
CheckSmatch                   WARNING   115.05 seconds
BuildKernel32                 PASS      31.70 seconds
TestRunnerSetup               PASS      488.47 seconds
TestRunner_l2cap-tester       PASS      29.48 seconds
TestRunner_iso-tester         PASS      58.00 seconds
TestRunner_bnep-tester        PASS      9.85 seconds
TestRunner_mgmt-tester        PASS      211.98 seconds
TestRunner_rfcomm-tester      PASS      15.07 seconds
TestRunner_sco-tester         PASS      18.45 seconds
TestRunner_ioctl-tester       PASS      16.89 seconds
TestRunner_mesh-tester        PASS      12.43 seconds
TestRunner_smp-tester         PASS      13.60 seconds
TestRunner_userchan-tester    PASS      10.41 seconds
IncrementalBuild              PASS      37.71 seconds

Details
##############################
Test: CheckSparse - WARNING
Desc: Run sparse tool with linux kernel
Output:
net/bluetooth/hci_event.c: note: in included file (through include/net/bluetooth/hci_core.h):
##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:
net/bluetooth/hci_event.c: note: in included file (through include/net/bluetooth/hci_core.h):


---
Regards,
Linux Bluetooth
diff mbox series

Patch

diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index db4f28d68d71..5a7fb496297b 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2617,7 +2617,8 @@  int hci_register_dev(struct hci_dev *hdev)
 	if (id < 0)
 		return id;
 
-	snprintf(hdev->name, sizeof(hdev->name), "hci%d", id);
+	snprintf(hdev->name, sizeof(hdev->name), "hci%u",
+		 id ? id % HCI_MAX_ID : id);
 	hdev->id = id;
 
 	BT_DBG("%p name %s bus %d", hdev, hdev->name, hdev->bus);