Re: [GSOC][PATCH] apply: address -Wsign-comparison warnings
- From
- Zejun Zhao <jelly.zhao.42@gmail.com>
- Date
- Feb 21, 2025, 06:37 UTC
- Message-ID
- <20250221063705.15539-1-jelly.zhao.42@gmail.com>
- In-Reply-To
- <xmqqpljfxhvp.fsf@gitster.g>
On Tue, Feb 18 2025 09:49:46 -0800, Junio C Hamano wrote,
Show 6 quoted lines
> Doesn't it mean that a change that makes these line-number > variables to size_t is wrong? Of course the change is not made to > break the code but may be to please some code paths in other parts > of the system that wants these line-number variables that are > currently "int" to compare or assign without range-checking with > "size_t" quantity or variable,
Sorry but I don't think the change here is wrong. These line-number variables are used as unsigned integers (compared with unsigned, used to index arrays, ...). And what's more important, we even do range-checking on `line` before we assign it to those line-number's, which means we want to ensure the line-number's always store an unsigned integer. So why not declare these line-number's as unsigned if we initialize them as unsigned and at the same time use them as unsigned?
Regards.