device: fix -Wsign-compare

Code should avoid comparing signed and unsigned integers, because of
implicit case.  Explicit casts are safe because 'lock' size is PATH_MAX.

  device.c: In function ‘device_lock’:
  device.c:64:15: warning: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Wsign-compare]
     64 |         if (n >= sizeof(lock))
        |               ^~

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
This commit is contained in:
Krzysztof Kozlowski
2023-05-07 11:54:58 +02:00
committed by Bjorn Andersson
parent c7e7a81a6c
commit 044be470d2

View File

@@ -61,7 +61,7 @@ static void device_lock(struct device *device)
int n;
n = snprintf(lock, sizeof(lock), "/tmp/cdba-%s.lock", device->board);
if (n >= sizeof(lock))
if (n >= (int)sizeof(lock))
errx(1, "failed to build lockfile path");
fd = open(lock, O_RDONLY | O_CREAT, 0666);