Re: [GSoC][RFC] Replace use of atoi() with strtol_i(), as a microproject
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 10, 2024, 18:46 UTC
- Message-ID
- <xmqq5y01auw2.fsf@gitster.g>
- In-Reply-To
- <004601da43ee$2b6cd0c0$82467240$@nexbridge.com>
<rsbecker@nexbridge.com> writes:
> I am not sure this is a good idea. The error detection inside strtol_i() reports a -1 if the supplied text value is invalid. This does not differentiate between an invalid value and a valid "-1" supplied. Replacing all instances of atoi() with strtol_i() will likely cause breakages as the error semantics are different between the two.
atoi() and strtol_i() have totally different function signatures, so it won't be a straight replacement. The report of "-1" you mention is only about strtol_i() reporting "have we successfully read out a number [yes/no]?". The value we parsed goes to a separate location, so there is no risk of confusion as long as the caller knows what it is doing.
Thanks.