From 044be470d2d67208c672eae2a67457f8a0dde935 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Sun, 7 May 2023 11:54:58 +0200 Subject: [PATCH] device: fix -Wsign-compare MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/device.c b/device.c index 35805c5..ac939bf 100644 --- a/device.c +++ b/device.c @@ -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);