Bluetooth: vhci: Avoid needless snprintf() calls
Subsystems (2)
PATCH 1/1 Bluetooth: vhci: Avoid needless snprintf() calls
Avoid double-copying of string literals. Use a "const char *" for each string instead of copying from .rodata into stack and then into the skb. We can go directly from .rodata to the skb.
This also works around a Clang bug (that has since been fixed[1]).
---
Cc: Marcel Holtmann <[email protected]>
Cc: Luiz Augusto von Dentz <[email protected]>
Cc: Josh Poimboeuf <[email protected]>
Cc: Nathan Chancellor <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: [email protected]
--- drivers/bluetooth/hci_vhci.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/bluetooth/hci_vhci.c +5 -5
@@ -289,18 +289,18 @@ static void vhci_coredump(struct hci_dev *hdev)static void vhci_coredump_hdr (struct hci_dev *hdev,struct sk_buff *skb) { -char buf[80 ]; +const char *buf; -snprintf (buf,sizeof (buf),"Controller Name: vhci_ctrl\n" ); + buf ="Controller Name: vhci_ctrl\n" ;skb_put_data (skb, buf,strlen (buf)); -snprintf (buf,sizeof (buf),"Firmware Version: vhci_fw\n" ); + buf ="Firmware Version: vhci_fw\n" ;skb_put_data (skb, buf,strlen (buf)); -snprintf (buf,sizeof (buf),"Driver: vhci_drv\n" ); + buf ="Driver: vhci_drv\n" ;skb_put_data (skb, buf,strlen (buf)); -snprintf (buf,sizeof (buf),"Vendor: vhci\n" ); + buf ="Vendor: vhci\n" ;skb_put_data (skb, buf,strlen (buf)); }
Signature · 1 line
2.34.1
Quoted 4 lines · Kees Cook
Avoid double-copying of string literals. Use a "const char *" for each string instead of copying from .rodata into stack and then into the skb. We can go directly from .rodata to the skb.
Quoted 8 lines
This also works around a Clang bug (that has since been fixed[1]).
Reported-by kernel test robot <[email protected]>Fixes ab4e4380d4e1 ("Bluetooth: Add vhci devcoredump support")Signed-off-by Kees Cook <[email protected]>
Quoted 42 lines
---
Cc: Marcel Holtmann <[email protected]>
Cc: Luiz Augusto von Dentz <[email protected]>
Cc: Josh Poimboeuf <[email protected]>
Cc: Nathan Chancellor <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: [email protected]--- drivers/bluetooth/hci_vhci.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)drivers/bluetooth/hci_vhci.c +5
-5@@ -289,18 +289,18 @@ static void vhci_coredump(struct hci_dev *hdev)static void vhci_coredump_hdr (struct hci_dev *hdev,struct sk_buff *skb) { -char buf[80 ]; +const char *buf; -snprintf (buf,sizeof (buf),"Controller Name: vhci_ctrl\n" ); + buf ="Controller Name: vhci_ctrl\n" ;skb_put_data (skb, buf,strlen (buf)); -snprintf (buf,sizeof (buf),"Firmware Version: vhci_fw\n" ); + buf ="Firmware Version: vhci_fw\n" ;skb_put_data (skb, buf,strlen (buf)); -snprintf (buf,sizeof (buf),"Driver: vhci_drv\n" ); + buf ="Driver: vhci_drv\n" ;skb_put_data (skb, buf,strlen (buf)); -snprintf (buf,sizeof (buf),"Vendor: vhci\n" ); + buf ="Vendor: vhci\n" ;skb_put_data (skb, buf,strlen (buf)); }Signature · 1 line
2.34.1
Quoted 4 lines · Kees Cook
Avoid double-copying of string literals. Use a "const char *" for each string instead of copying from .rodata into stack and then into the skb. We can go directly from .rodata to the skb.
Quoted 8 lines
This also works around a Clang bug (that has since been fixed[1]).
Reported-by kernel test robot <[email protected]>Fixes ab4e4380d4e1 ("Bluetooth: Add vhci devcoredump support")Signed-off-by Kees Cook <[email protected]>
Thanks!
Signature · 1 line
Josh
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=953638
---Test result---
Test Summary:
CheckPatch PENDING 0.27 seconds GitLint PENDING 0.23 seconds SubjectPrefix PASS 0.13 seconds BuildKernel PASS 24.58 seconds CheckAllWarning PASS 26.80 seconds CheckSparse PASS 30.60 seconds BuildKernel32 PASS 24.17 seconds TestRunnerSetup PASS 463.69 seconds TestRunner_l2cap-tester PASS 21.37 seconds TestRunner_iso-tester PASS 32.87 seconds TestRunner_bnep-tester PASS 4.71 seconds TestRunner_mgmt-tester FAIL 120.00 seconds TestRunner_rfcomm-tester PASS 7.85 seconds TestRunner_sco-tester PASS 12.70 seconds TestRunner_ioctl-tester PASS 8.43 seconds TestRunner_mesh-tester PASS 6.25 seconds TestRunner_smp-tester PASS 7.33 seconds TestRunner_userchan-tester PASS 5.06 seconds IncrementalBuild PENDING 0.84 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner Output:
Total: 490, Passed: 483 (98.6%), Failed: 3, Not Run: 4
Failed Test Cases
LL Privacy - Set Flags 2 (Enable RL) Failed 0.147 seconds LL Privacy - Set Flags 3 (2 Devices to RL) Failed 0.183 seconds LL Privacy - Start Discovery 2 (Disable RL) Failed 0.185 seconds
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series Output:
---
Regards,
Linux Bluetooth
Quoted 1 line · On Tue, Apr 15, 2025 at 10:04:09AM -0700, [email protected] wrote:
TestRunner_mgmt-tester FAIL 120.00 seconds
This test looks to be broken? Or the existing tree is broken? It fails with other unrelated patches too, e.g.:
https://patchwork.kernel.org/project/bluetooth/patch/[email protected]/
Signature · 1 line
Kees Cook
Luiz Augusto von Dentz
maintainerHi Kees,
Quoted 8 lines · Kees Cook
Quoted 1 line · On Tue, Apr 15, 2025 at 10:04:09AM -0700, [email protected] wrote:
TestRunner_mgmt-tester FAIL 120.00 seconds
This test looks to be broken? Or the existing tree is broken? It fails with other unrelated patches too, e.g.:
https://patchwork.kernel.org/project/bluetooth/patch/[email protected]/
Probably some false positive, running locally seems to pass so it is most likely something not quite right with github environment.
Quoted 3 lines
--
Kees Cook
Signature · 1 line
Luiz Augusto von Dentz
This patch was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:
Hello:
This patch was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:
Quoted 6 lines · On Tue, 15 Apr 2025 09:15:19 -0700 you wrote:
Avoid double-copying of string literals. Use a "const char *" for each string instead of copying from .rodata into stack and then into the skb. We can go directly from .rodata to the skb.
This also works around a Clang bug (that has since been fixed[1]).
Quoted 8 lines
Reported-by kernel test robot <[email protected]>Fixes ab4e4380d4e1 ("Bluetooth: Add vhci devcoredump support")Signed-off-by Kees Cook <[email protected]>[...]
Here is the summary with links:
- Bluetooth: vhci: Avoid needless snprintf() calls
https://git.kernel.org/bluetooth/bluetooth-next/c/3b32759328e9
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html