Re: [PATCH BlueZ 2/2] core: Fix signed vs unsigned compare

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Brian,

On Wed, Jun 29, 2022 at 12:56 PM Brian Gix <brian.gix@xxxxxxxxx> 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




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux