2022-06-29 21:19:27

by Gix, Brian

[permalink] [raw]
Subject: [PATCH BlueZ v2 1/2] core: make bt_uuid_hash() portable across archs

bt_uuid_t is defined as a byte array, so it can cause alignment errors
on some architectures, when the two 64 bit halves are treated as u64s.
This patch ensures proper alignment across all architectures.

Fixes:
src/adapter.c: In function ‘bt_uuid_hash’:
src/adapter.c:3617:8: error: cast increases required alignment of target type [-Werror=cast-align]
val = (uint64_t *)&uuid_128.value.u128;
^
cc1: all warnings being treated as errors
---
src/adapter.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index afefa1d5d..c8b3d27a7 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -3607,16 +3607,14 @@ static void add_uuid_to_uuid_set(void *data, void *user_data)
static guint bt_uuid_hash(gconstpointer key)
{
const bt_uuid_t *uuid = key;
- bt_uuid_t uuid_128;
- uint64_t *val;
+ uint64_t uuid_128[2];

if (!uuid)
return 0;

- bt_uuid_to_uuid128(uuid, &uuid_128);
- val = (uint64_t *)&uuid_128.value.u128;
+ bt_uuid_to_uuid128(uuid, (bt_uuid_t *)uuid_128);

- return g_int64_hash(val) ^ g_int64_hash(val+1);
+ return g_int64_hash(uuid_128) ^ g_int64_hash(uuid_128+1);
}

static gboolean bt_uuid_equal(gconstpointer v1, gconstpointer v2)
--
2.36.1


2022-06-29 21:19:39

by Gix, Brian

[permalink] [raw]
Subject: [PATCH BlueZ v2 2/2] core: Fix signed vs unsigned compare

__time_t is not a portable data type, and can cause sign mismatch on
some compares.

Fixes:
CC src/bluetoothd-device.o
src/device.c: In function ‘device_is_name_resolve_allowed’:
src/device.c:4092:17: error: comparison of integer expressions of different signedness: ‘__time_t’ {aka ‘long int’} and ‘long unsigned int’ [-Werror=sign-compare]
if (now.tv_sec >= device->name_resolve_failed_time +
^~
cc1: all warnings being treated as errors
---
src/device.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/device.c b/src/device.c
index 7b451e458..b91e5dc58 100644
--- a/src/device.c
+++ b/src/device.c
@@ -4088,8 +4088,8 @@ bool device_is_name_resolve_allowed(struct btd_device *device)
/* now >= failed_time + name_request_retry_delay, meaning the
* period of not sending name request is over.
*/
- if (now.tv_sec >= device->name_resolve_failed_time +
- btd_opts.name_request_retry_delay)
+ if (now.tv_sec >= (time_t)(device->name_resolve_failed_time +
+ btd_opts.name_request_retry_delay))
return true;

return false;
--
2.36.1

2022-06-29 23:04:09

by bluez.test.bot

[permalink] [raw]
Subject: RE: [BlueZ,v2,1/2] core: make bt_uuid_hash() portable across archs

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=655172

---Test result---

Test Summary:
CheckPatch PASS 2.89 seconds
GitLint FAIL 1.99 seconds
Prep - Setup ELL PASS 41.69 seconds
Build - Prep PASS 0.64 seconds
Build - Configure PASS 8.18 seconds
Build - Make PASS 1200.17 seconds
Make Check PASS 11.59 seconds
Make Check w/Valgrind PASS 439.69 seconds
Make Distcheck PASS 228.53 seconds
Build w/ext ELL - Configure PASS 8.21 seconds
Build w/ext ELL - Make PASS 1172.36 seconds
Incremental Build with patchesPASS 2428.45 seconds

Details
##############################
Test: GitLint - FAIL
Desc: Run gitlint with rule in .gitlint
Output:
[BlueZ,v2,1/2] core: make bt_uuid_hash() portable across archs
9: B1 Line exceeds max length (98>80): "src/adapter.c:3617:8: error: cast increases required alignment of target type [-Werror=cast-align]"

[BlueZ,v2,2/2] core: Fix signed vs unsigned compare
9: B1 Line exceeds max length (162>80): "src/device.c:4092:17: error: comparison of integer expressions of different signedness: ‘__time_t’ {aka ‘long int’} and ‘long unsigned int’ [-Werror=sign-compare]"




---
Regards,
Linux Bluetooth

2022-06-30 20:40:52

by patchwork-bot+bluetooth

[permalink] [raw]
Subject: Re: [PATCH BlueZ v2 1/2] core: make bt_uuid_hash() portable across archs

Hello:

This series was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <[email protected]>:

On Wed, 29 Jun 2022 14:16:39 -0700 you wrote:
> bt_uuid_t is defined as a byte array, so it can cause alignment errors
> on some architectures, when the two 64 bit halves are treated as u64s.
> This patch ensures proper alignment across all architectures.
>
> Fixes:
> src/adapter.c: In function ‘bt_uuid_hash’:
> src/adapter.c:3617:8: error: cast increases required alignment of target type [-Werror=cast-align]
> val = (uint64_t *)&uuid_128.value.u128;
> ^
> cc1: all warnings being treated as errors
>
> [...]

Here is the summary with links:
- [BlueZ,v2,1/2] core: make bt_uuid_hash() portable across archs
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=8fc3368db840
- [BlueZ,v2,2/2] core: Fix signed vs unsigned compare
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=31690310c096

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html