Re: [GSoC PATCH] pathspec: fix sign comparison warnings
- From
Arnav Bhate <bhatearnav@gmail.com>
- Date
- Mar 16, 2025, 10:14 UTC
- Message-ID
- <a720058a-f8cd-422c-a8c3-af7536bfc880@gmail.com>
- In-Reply-To
- <xmqqcyelq714.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
Show 14 quoted lines
> Karthik Nayak <karthik.188@gmail.com> writes: > >> Also a bigger question is, shouldn't the type of `pathspec.nr` and >> 'istate.cache_nr' be the actual change required? Shouldn't they be set >> to 'size_t'? > > Please do not blindly advocate the idea that size_t is always the > right type for any countables. It is not. > > Platform natural way to count things is either "unsigned int", if > you are only counting, or "int", if you need to be able to signal an > unusual state other than "here is now many we have in the set", like > how index related functions uses (-pos-1) to signal a location in > the same range with different meanings.
I did notice that negative states were sometimes used for such things, which why I said I didn't want to do the change to unsigned, it would be too complicated to change such things, and I do not think any alternative would be better.
-- Regards, Arnav Bhate (He/Him)