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

Re: [PATCH] trace2: refactor to avoid gcc warning under -O3

From
Jeff King <peff@peff.net>
Date
May 5, 2021, 13:34 UTC
Message-ID
<YJKe+ncDqrqq1i8P@coredump.intra.peff.net>
In-Reply-To
<xmqqwnsd3426.fsf@gitster.g>
On Wed, May 05, 2021 at 06:47:29PM +0900, Junio C Hamano wrote:
Show 20 quoted lines
> The patch makes sense to me, modulo that the way the variable
> "saved_errno" introduced by this patch is used and the way a
> variable with that name is typically used in our codebase are at
> odds.  I.e. we typically call a variable "saved_errno" when it is
> used in this pattern:
> 
>     if (a_syscall_whose_error_condition_we_care_about()) {
> 	int saved_errno = errno;
> 	perform_some_cleanup_operation_that_might_clobber_errno();
> 	return error_errno(..., saved_errno);
> 	/*
> 	 * or
> 	 * errno = saved_errno;
> 	 * return -1;
> 	 * and let the caller handle 'errno'
> 	 */
>     }
> 
> But since I do not think of a better name for this new variable that
> is not exactly used like so, let's queue it as-is.

I'd probably have just called it "err", but I think it is fine either way. :)

The patch also looks good to me. I used to compile with -O3 occasionally to fix warnings, but given the date on this commit, it seems I have not done so in quite a while. (It reproduces on gcc 10 for me, which is not surprising).

-Peff
Previous: Junio C HamanoNext: Johannes Schindelin
Message 10 of 31 in “Fix -Wmaybe-uninitialized warnings under -O0”
  1. Fix -Wmaybe-uninitialized warnings under -O0Denton Liu, Apr 1, 2020
  2. Jeff KingApr 1, 2020
  3. Denton LiuApr 1, 2020
  4. Jeff KingApr 3, 2020
  5. Jeff KingApr 3, 2020
  6. Denton LiuApr 4, 2020
  7. Jeff KingApr 4, 2020
  8. trace2: refactor to avoid gcc warning under -O3Ævar Arnfjörð Bjarmason, May 5, 2021
  9. Junio C HamanoMay 5, 2021
  10. Jeff KingMay 5, 2021
  11. Johannes SchindelinMay 5, 2021
  12. Junio C HamanoMay 6, 2021
  13. Johannes SchindelinMay 6, 2021
  14. Junio C HamanoMay 6, 2021
  15. Johannes SchindelinMay 11, 2021
  16. Jeff KingMay 11, 2021
  17. Junio C HamanoMay 11, 2021
  18. Jeff KingMay 11, 2021
  19. Junio C HamanoMay 11, 2021
  20. Junio C HamanoMay 11, 2021
  21. trace2: refactor to avoid gcc warning under -O3Ævar Arnfjörð Bjarmason, May 11, 2021
  22. Jeff HostetlerMay 11, 2021
  23. Jeff KingMay 11, 2021
  24. Jeff KingMay 11, 2021
  25. Junio C HamanoMay 11, 2021
  26. Junio C HamanoMay 20, 2021
  27. trace2: refactor to avoid gcc warning under -O3Ævar Arnfjörð Bjarmason, May 20, 2021
  28. Jeff KingMay 20, 2021
  29. Junio C HamanoMay 20, 2021
  30. Jeff KingMay 21, 2021
  31. Denton LiuApr 1, 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.