* [PATCH BlueZ 1/2] core: make bt_uuid_hash() portable across archs
@ 2022-06-29 19:44 Brian Gix
2022-06-29 19:44 ` [PATCH BlueZ 2/2] core: Fix signed vs unsigned compare Brian Gix
2022-06-29 22:15 ` [BlueZ,1/2] core: make bt_uuid_hash() portable across archs bluez.test.bot
0 siblings, 2 replies; 4+ messages in thread
From: Brian Gix @ 2022-06-29 19:44 UTC (permalink / raw)
To: linux-bluetooth; +Cc: luiz.von.dentz, brian.gix
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH BlueZ 2/2] core: Fix signed vs unsigned compare
2022-06-29 19:44 [PATCH BlueZ 1/2] core: make bt_uuid_hash() portable across archs Brian Gix
@ 2022-06-29 19:44 ` Brian Gix
2022-06-29 21:07 ` Luiz Augusto von Dentz
2022-06-29 22:15 ` [BlueZ,1/2] core: make bt_uuid_hash() portable across archs bluez.test.bot
1 sibling, 1 reply; 4+ messages in thread
From: Brian Gix @ 2022-06-29 19:44 UTC (permalink / raw)
To: linux-bluetooth; +Cc: luiz.von.dentz, brian.gix
__time_t is not a portable data type, and can cause sign mismatch on
come 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 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/device.c b/src/device.c
index 7b451e458..012d73583 100644
--- a/src/device.c
+++ b/src/device.c
@@ -4088,7 +4088,7 @@ 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 +
+ if ((unsigned)now.tv_sec >= device->name_resolve_failed_time +
btd_opts.name_request_retry_delay)
return true;
--
2.36.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH BlueZ 2/2] core: Fix signed vs unsigned compare
2022-06-29 19:44 ` [PATCH BlueZ 2/2] core: Fix signed vs unsigned compare Brian Gix
@ 2022-06-29 21:07 ` Luiz Augusto von Dentz
0 siblings, 0 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2022-06-29 21:07 UTC (permalink / raw)
To: Brian Gix; +Cc: linux-bluetooth@vger.kernel.org, luiz.von.dentz
Hi Brian,
On Wed, Jun 29, 2022 at 12:56 PM Brian Gix <brian.gix@intel.com> wrote:
>
> __time_t is not a portable data type, and can cause sign mismatch on
> come 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 | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/device.c b/src/device.c
> index 7b451e458..012d73583 100644
> --- a/src/device.c
> +++ b/src/device.c
> @@ -4088,7 +4088,7 @@ 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 +
> + if ((unsigned)now.tv_sec >= device->name_resolve_failed_time +
> btd_opts.name_request_retry_delay)
> return true;
>
> --
> 2.36.1
Can't we just use the same type for name_resolve_failed_time?
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [BlueZ,1/2] core: make bt_uuid_hash() portable across archs
2022-06-29 19:44 [PATCH BlueZ 1/2] core: make bt_uuid_hash() portable across archs Brian Gix
2022-06-29 19:44 ` [PATCH BlueZ 2/2] core: Fix signed vs unsigned compare Brian Gix
@ 2022-06-29 22:15 ` bluez.test.bot
1 sibling, 0 replies; 4+ messages in thread
From: bluez.test.bot @ 2022-06-29 22:15 UTC (permalink / raw)
To: linux-bluetooth, brian.gix
[-- Attachment #1: Type: text/plain, Size: 2511 bytes --]
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=655155
---Test result---
Test Summary:
CheckPatch FAIL 2.96 seconds
GitLint FAIL 1.97 seconds
Prep - Setup ELL PASS 43.80 seconds
Build - Prep PASS 0.68 seconds
Build - Configure PASS 8.68 seconds
Build - Make PASS 1384.18 seconds
Make Check PASS 11.80 seconds
Make Check w/Valgrind PASS 443.83 seconds
Make Distcheck PASS 232.81 seconds
Build w/ext ELL - Configure PASS 8.71 seconds
Build w/ext ELL - Make PASS 1414.25 seconds
Incremental Build with patchesPASS 2767.06 seconds
Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script with rule in .checkpatch.conf
Output:
[BlueZ,2/2] core: Fix signed vs unsigned compare
WARNING:UNSPECIFIED_INT: Prefer 'unsigned int' to bare use of 'unsigned'
#89: FILE: src/device.c:4091:
+ if ((unsigned)now.tv_sec >= device->name_resolve_failed_time +
/github/workspace/src/12900652.patch 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.
/github/workspace/src/12900652.patch has style problems, please review.
NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG 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: GitLint - FAIL
Desc: Run gitlint with rule in .gitlint
Output:
[BlueZ,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,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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-06-29 22:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-29 19:44 [PATCH BlueZ 1/2] core: make bt_uuid_hash() portable across archs Brian Gix
2022-06-29 19:44 ` [PATCH BlueZ 2/2] core: Fix signed vs unsigned compare Brian Gix
2022-06-29 21:07 ` Luiz Augusto von Dentz
2022-06-29 22:15 ` [BlueZ,1/2] core: make bt_uuid_hash() portable across archs bluez.test.bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).