]> git.ipfire.org Git - thirdparty/git.git/commit
config: fix sign comparison warnings
authorPatrick Steinhardt <ps@pks.im>
Wed, 23 Jul 2025 14:08:42 +0000 (16:08 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 23 Jul 2025 15:15:22 +0000 (08:15 -0700)
commitb06408b817c70204542924db0c689f258f010f7e
treef68cd23bc682bacd330e35b15c9d55fd0e876586
parent08b775864edf96b97500fd70446c55528f5cf4a6
config: fix sign comparison warnings

There are a couple of -Wsign-compare warnings in "config.c":

  - `prepare_include_condition_pattern()` is returns a signed integer,
    where it either returns a negative error code or the index of the
    last dir separator in a path. That index will always be a
    non-negative number, but we cannot just change the return type to a
    `size_t` due to it being re-used as error code. This is fixed by
    splitting up concerns: the return value is only used as error code,
    and the prefix is now returned via an out-pointer. This fixes a sign
    comparison warning when comparing `text.len < prefix`,

  - We treat `struct config_store_data::seen` as signed integer in
    several places even though it's unsigned.

  - There are multiple trivial sign comparison warnings where we use a
    signed loop index to iterate through an unsigned number of items.

Fix all of these issues and drop the `DISABLE_SIGN_COMPARE_WARNINGS`
macro.

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