Re: [PATCH] trace2: refactor to avoid gcc warning under -O3
From: Jeff King <hidden>
Date: 2021-05-05 13:34:54
On Wed, May 05, 2021 at 06:47:29PM +0900, Junio C Hamano wrote:
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