diff mbox series

[BlueZ,1/2] advertising: Make data size explicit for formats

Message ID 20210127174050.1536152-2-brian.gix@intel.com (mailing list archive)
State New, archived
Headers show
Series Fix 32 bit Compiler Errors | expand

Commit Message

Brian Gix Jan. 27, 2021, 5:40 p.m. UTC
On some 32 bit systems sizeof does not return (unsigned long)

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(-)

Comments

bluez.test.bot@gmail.com Jan. 27, 2021, 6:02 p.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=423109

---Test result---

##############################
Test: CheckPatch - FAIL
Output:
advertising: Make data size explicit for formats
WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line)
#25: 
      |                                                    long unsigned int

- 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: Make data size explicit for formats" 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: Make data size explicit for formats
WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line)
#18: 
      |                                                          long unsigned int

- 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: Make data size explicit for formats" 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 - FAIL
Output:
advertising: Make data size explicit for formats
9: B1 Line exceeds max length (139>80): "src/log.h:60:20: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 5 has type ‘unsigned int’ [-Werror=format=]"

tools/mgmt-tester: Make data size explicit for formats
8: B1 Line exceeds max length (151>80): "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=]"
12: B1 Line exceeds max length (82>80): "      |                                                          long unsigned int"


##############################
Test: CheckBuild - PASS

##############################
Test: MakeCheck - PASS



---
Regards,
Linux Bluetooth
Denis Kenzior Jan. 27, 2021, 7:29 p.m. UTC | #2
Hi Brian,

>   		error("Controller capabilities malformed, size %lu != %u",

Note that it might make things prettier/easier to use %zu instead.  Refer to 
'man 3 printf'

> -				sizeof(rp->cap_len) + rp->cap_len, length);
> +			(long) sizeof(rp->cap_len) + rp->cap_len, length);
>   		return;
>   	}
>   
> 

Regards,
-Denis
diff mbox series

Patch

diff --git a/src/advertising.c b/src/advertising.c
index 4f5123fa1..36e737987 100644
--- a/src/advertising.c
+++ b/src/advertising.c
@@ -1755,7 +1755,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",
-				sizeof(rp->cap_len) + rp->cap_len, length);
+			(long) sizeof(rp->cap_len) + rp->cap_len, length);
 		return;
 	}