2021-01-28 00:46:17

by Gix, Brian

[permalink] [raw]
Subject: [PATCH BlueZ v3 0/2] 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(-)

--
2.25.4


2021-01-28 00:46:59

by Gix, Brian

[permalink] [raw]
Subject: [PATCH BlueZ v3 2/2] tools/mgmt-tester: Fix formatter for size_t value

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

diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c
index fe73a6d89..bb9fb0b9c 100644
--- a/tools/mgmt-tester.c
+++ b/tools/mgmt-tester.c
@@ -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();
}
--
2.25.4

2021-01-28 22:23:40

by Gix, Brian

[permalink] [raw]
Subject: Re: [PATCH BlueZ v3 0/2] Fix 32 bit Compiler Errors

Applied

On Wed, 2021-01-27 at 15:10 -0800, Brian Gix wrote:
> 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(-)
>