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
This commit is contained in:
Ludovic Courtès 2025-09-06 21:49:31 +02:00
parent b8f528e733
commit 1970abfeb9
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -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;