diff mbox series

[BlueZ,v2,2/2] core: Fix signed vs unsigned compare

Message ID 20220629211640.65822-2-brian.gix@intel.com (mailing list archive)
State Accepted
Commit 31690310c096994c553c373ab5464cc39fbfe860
Headers show
Series [BlueZ,v2,1/2] core: make bt_uuid_hash() portable across archs | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/checkpatch success Checkpatch PASS
tedd_an/gitlint fail [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]"

Commit Message

Brian Gix June 29, 2022, 9:16 p.m. UTC
__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 mbox series

Patch

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;