git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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.
Previous: rsbecker@nexbridge.comNext: Junio C Hamano
Message 5 of 8 in “[GSoC][RFC] Replace use of atoi() with strtol_i(), as a microproject”
  1. mohitmarathe@proton.meJan 8, 2024
  2. Christian CouderJan 9, 2024
  3. Mohit MaratheJan 10, 2024
  4. rsbecker@nexbridge.comJan 10, 2024
  5. Junio C HamanoJan 10, 2024
  6. Junio C HamanoJan 10, 2024
  7. Mohit MaratheJan 12, 2024
  8. Mohit MaratheJan 17, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.