summaryrefslogtreecommitdiff
path: root/nix
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2025-09-06 21:49:31 +0200
committerLudovic Courtès <ludo@gnu.org>2025-09-06 22:23:40 +0200
commit1970abfeb9771157454510bafcda1a94184826e5 (patch)
tree4515dce2cb98e3851d89423598bc3ca4d44a3af7 /nix
parentb8f528e73341e0f70db04ade2654d0eff4157703 (diff)
daemon: Avoid comparison of integers of different signs.
Fixes guix/guix#1173. * nix/libstore/gc.cc (LocalStore::removeUnusedLinks): Cast ‘st_size’ as unsigned. Reported-by: Congcong Kuo <congcong.kuo@gmail.com> Change-Id: Ibe4674bcef186befe8a0e536278c87458b098c9d
Diffstat (limited to 'nix')
-rw-r--r--nix/libstore/gc.cc3
1 files changed, 2 insertions, 1 deletions
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;