Fix 32 bit Compiler Errors
v3 cover Fix 32 bit Compiler Errors
In a couple places the sizeof() macro has been assumed to return a (long unsigned) value, and so the string formater %lu has been used to print out warnings derived from this assumption. While correct on 64 bit systems, this is an incorrect assumption on 32 bit systems.
These two changes explicitly cast the sizeof return to long in the affected cases.
v2: Fix bluez.test.bot warnings
v3: Just use %zu format descriptor, which should be architecture agnostic.
Brian Gix (2):
advertising: Fix formater for size_t data type tools/mgmt-tester: Fix formatter for size_t value
src/advertising.c | 2 +- tools/mgmt-tester.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.25.4
PATCH v3 1/2 advertising: Fix formater for size_t data type
On some 32 bit systems sizeof does not return (unsigned long). The size_t formater %zu handles this across architectures.
Fixes the error:
In file included from src/advertising.c:30:src/advertising.c: In function ‘read_controller_cap_complete’:src/log.h:60:20: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 5 has type ‘unsigned int’ [-Werror=format=]
60 | btd_error(0xffff, "%s:%s() " fmt, __FILE__, __func__, ## arg)
| ^~~~~~~~~~
src/advertising.c:1757:3: note: in expansion of macro ‘error’
1757 | error("Controller capabilities malformed, size %lu != %u",
| ^~~~~
src/advertising.c:1757:52: note: format string is defined here
1757 | error("Controller capabilities malformed, size %lu != %u",
| ~~^
| |
| long unsigned int
| %u
---
src/advertising.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)src/advertising.c +1 -1
@@ -1754,7 +1754,7 @@ static void read_controller_cap_complete(uint8_t status, uint16_t length, }if (sizeof (rp->cap_len) + rp->cap_len != length) { -error ("Controller capabilities malformed, size %lu != %u" , +error ("Controller capabilities malformed, size %zu != %u" ,sizeof (rp->cap_len) + rp->cap_len, length);return ; }
Signature · 1 line
2.25.4
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=423259
---Test result---
##############################
Test: CheckPatch - FAIL
Output:
advertising: Fix formater for size_t data type
WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line) #17:
unsigned int’, but argument 5 has type ‘unsigned int’ [-Werror=format=]
- total: 0 errors, 1 warnings, 8 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.
"[PATCH] advertising: Fix formater for size_t data type" has style problems, please review.
NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPLIT_STRING SSCANF_TO_KSTRTO
NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
tools/mgmt-tester: Fix formatter for size_t value
WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line) #16:
‘long unsigned int’, but argument 2 has type ‘unsigned int’ [-Werror=format=]
- total: 0 errors, 1 warnings, 8 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.
"[PATCH] tools/mgmt-tester: Fix formatter for size_t value" has style problems, please review.
NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPLIT_STRING SSCANF_TO_KSTRTO
NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
##############################
Test: CheckGitLint - PASS
##############################
Test: CheckBuild - PASS
##############################
Test: MakeCheck - PASS
---
Regards,
Linux Bluetooth
PATCH v3 2/2 tools/mgmt-tester: Fix formatter for size_t value
In reply to Brian GixOn 32 bit systems, sizeof macro doesn't always return (unsigned long), and the %zu formatter specifically handles size_t.
Fix following error:
tools/mgmt-tester.c: In function ‘read_50_controller_cap_complete’:tools/mgmt-tester.c:9124:58: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 2 has type ‘unsigned int’ [-Werror=format=]
9124 | tester_warn("Controller capabilities malformed, size %lu != %u",
| ~~^
| |
| long unsigned int
| %u
9125 | sizeof(rp->cap_len) + rp->cap_len, length);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| |
| unsigned int
---
tools/mgmt-tester.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)tools/mgmt-tester.c +1 -1
@@ -9121,7 +9121,7 @@ static void read_50_controller_cap_complete(uint8_t status, uint16_t length, }if (sizeof (rp->cap_len) + rp->cap_len != length) { -tester_warn ("Controller capabilities malformed, size %lu != %u" , +tester_warn ("Controller capabilities malformed, size %zu != %u" ,sizeof (rp->cap_len) + rp->cap_len, length);tester_test_failed (); }
Signature · 1 line
2.25.4
Gix, Brian
AppliedApplied
Quoted 20 lines · Brian Gix
In a couple places the
sizeof()macro has been assumed to return a (long unsigned) value, and so the string formater %lu has been used to print out warnings derived from this assumption. While correct on 64 bit systems, this is an incorrect assumption on 32 bit systems.These two changes explicitly cast the sizeof return to long in the affected cases.
v2: Fix bluez.test.bot warnings
v3: Just use %zu format descriptor, which should be architecture agnostic.
Brian Gix (2):
advertising: Fix formater forsize_tdata typetools/mgmt-tester: Fix formatter forsize_tvaluesrc/advertising.c | 2 +- tools/mgmt-tester.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)