From 1970abfeb9771157454510bafcda1a94184826e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Sat, 6 Sep 2025 21:49:31 +0200 Subject: [PATCH] daemon: Avoid comparison of integers of different signs. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes guix/guix#1173. * nix/libstore/gc.cc (LocalStore::removeUnusedLinks): Cast ‘st_size’ as unsigned. Reported-by: Congcong Kuo Change-Id: Ibe4674bcef186befe8a0e536278c87458b098c9d --- nix/libstore/gc.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nix/libstore/gc.cc b/nix/libstore/gc.cc index 08638b51153..77a2a7027db 100644 --- a/nix/libstore/gc.cc +++ b/nix/libstore/gc.cc @@ -608,7 +608,8 @@ void LocalStore::removeUnusedLinks(const GCState & state) /* Drop links for files smaller than 'deduplicationMinSize', even if they have more than one hard link. */ - if (st.st_nlink != 1 && st.st_size >= deduplicationMinSize) { + if (st.st_nlink != 1 + && ((unsigned long long) st.st_size) >= deduplicationMinSize) { actualSize += st.st_size; unsharedSize += (st.st_nlink - 1) * st.st_size; continue;