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

Re: [PATCH 4/7] Use strtoumax instead of strtoull.

From
Junio C Hamano <gitster@pobox.com>
Date
May 18, 2020, 18:29 UTC
Message-ID
<xmqqy2pp2j2l.fsf@gitster.c.googlers.com>
In-Reply-To
<20200518100356.29292-4-dtucker@dtucker.net>
Darren Tucker <dtucker@dtucker.net> writes:
> strtoumax is in the compat library so this works on platforms that don't
> have a native strtoull.

The above description (even though is a good one) alone would leave the reader wondering if this patch now has removed the last use of strtoull(), removing the need to have NO_STRTOULL in the Makefile and configure.ac, and also wonder why the patch does not touch Makefile etc. Something like

	We still use strtoull() as a part of the compatibility
	implementation of strtoumax(), so we cannot remove the
	support to detect/configure the use of the function in the
	Makefile and autoconf, though.

may deserve to be made into the second paragraph that follows the above description.

Shouldn't the type of some variables in the codepath also be changed to make sure we receive the return value from the function in a variable that is large enough?

Thanks.
Show 31 quoted lines
> Signed-off-by: Darren Tucker <dtucker@dtucker.net>
> ---
>  t/helper/test-progress.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/t/helper/test-progress.c b/t/helper/test-progress.c
> index 5d05cbe789..3e9eb2abe3 100644
> --- a/t/helper/test-progress.c
> +++ b/t/helper/test-progress.c
> @@ -47,7 +47,7 @@ int cmd__progress(int argc, const char **argv)
>  		char *end;
>  
>  		if (skip_prefix(line.buf, "progress ", (const char **) &end)) {
> -			uint64_t item_count = strtoull(end, &end, 10);
> +			uint64_t item_count = strtoumax(end, &end, 10);
>  			if (*end != '\0')
>  				die("invalid input: '%s'\n", line.buf);
>  			display_progress(progress, item_count);
> @@ -55,10 +55,10 @@ int cmd__progress(int argc, const char **argv)
>  				       (const char **) &end)) {
>  			uint64_t byte_count, test_ms;
>  
> -			byte_count = strtoull(end, &end, 10);
> +			byte_count = strtoumax(end, &end, 10);
>  			if (*end != ' ')
>  				die("invalid input: '%s'\n", line.buf);
> -			test_ms = strtoull(end + 1, &end, 10);
> +			test_ms = strtoumax(end + 1, &end, 10);
>  			if (*end != '\0')
>  				die("invalid input: '%s'\n", line.buf);
>  			progress_test_ns = test_ms * 1000 * 1000;
Previous: Darren TuckerNext: Darren Tucker
Message 3 of 24 in “Redirect grep's stderr top null too.”
  1. 1/7 Redirect grep's stderr top null too.Darren Tucker, May 18, 2020
  2. 4/7 Use strtoumax instead of strtoull.Darren Tucker, May 18, 2020
  3. Junio C HamanoMay 18, 2020
  4. 5/7 Define LLONG_MAX/MIN etc if not already defined.Darren Tucker, May 18, 2020
  5. Andreas SchwabMay 18, 2020
  6. Darren TuckerMay 18, 2020
  7. 6/7 Check if strtoumax is a macro (eg HP-UX 11.11).Darren Tucker, May 18, 2020
  8. Junio C HamanoMay 18, 2020
  9. Darren TuckerMay 20, 2020
  10. Junio C HamanoMay 20, 2020
  11. 2/7 Define NO_PREAD for HPUX 11.11 and 11.00.Darren Tucker, May 18, 2020
  12. 3/7 Test for strtoull in configure.Darren Tucker, May 18, 2020
  13. 7/7 Define SCNuMAX if not already defined.Darren Tucker, May 18, 2020
  14. Đoàn Trần Công DanhMay 18, 2020
  15. Darren TuckerMay 18, 2020
  16. Đoàn Trần Công DanhMay 18, 2020
  17. Darren TuckerMay 18, 2020
  18. t5703: replace "grep -a" usage by perlĐoàn Trần Công Danh, May 19, 2020
  19. Darren TuckerMay 19, 2020
  20. Christian CouderMay 19, 2020
  21. Đoàn Trần Công DanhMay 19, 2020
  22. Christian CouderMay 19, 2020
  23. Eric SunshineMay 19, 2020
  24. Junio C HamanoMay 18, 2020

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.