]> git.ipfire.org Git - thirdparty/git.git/commit
commit-graph: fix sign comparison warnings
authorPatrick Steinhardt <ps@pks.im>
Thu, 7 Aug 2025 08:04:46 +0000 (10:04 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 7 Aug 2025 21:32:28 +0000 (14:32 -0700)
commit1c7ca23f9f43ce877911a4764e42389a06df6b56
treece96b0618a04cae2d6c4b78509bd1e64be28430f
parent285b2c94adaa0c342f6ac7cb9e0c0c0848469a67
commit-graph: fix sign comparison warnings

The "commit-graph.c" file has a bunch of sign comparison warnings:

  - There are a bunch of variables that are declared as signed integers
    even though they are used to count entities, like for example
    `num_commit_graphs_before` and `num_commit_graphs_after`.

  - There are several cases where we use signed loop variables to
    iterate through an unsigned entity count.

  - In `write_graph_chunk_base_1()` we count how many chunks we have
    written in total. But while the value represents a positive
    quantity, we still return a signed integer that we then later
    compare with unsigned values.

  - The Bloom settings hash version is being assigned `-1` even though
    it's an unsigned value. This is used to indicate an unspecified
    value and relies on 1's complement.

Fix all of these cases by either using the proper variable type or by
adding casts as required.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
commit-graph.c