fix double fclose in aofrewrite#7919
Conversation
minor fix
d69615e to
668d897
Compare
| if (fclose(fp) == EOF) goto werr; | ||
| if (fflush(fp)) goto werr; | ||
| if (fsync(fileno(fp))) goto werr; | ||
| if (fclose(fp)) { fp = NULL; goto werr; } |
There was a problem hiding this comment.
I saw that Oran was okay with this in the previous CR, but it seems very inconsistent to have multiple statements on the same line.
There was a problem hiding this comment.
I generally don't even like code statements that change the code flow (return, goto, break, continue, etc) being at the same line with the if.
However, when writing error handling code, I don't like it to consume too many lines and make it harder to read the actual code. So a boilerplate repatriation checking a condition and doing goto or return if each action fails, is ok with me to be on the same line with the action..
Regarding multiple statements in the same line, as you can tell by defrag.c, I'm actually a big fan of these (even without curly braces (not possible in this case).
So with regards to the above two concerns, I actually prefer the way @hwware wrote it.
However, I'm not necessarily the one who decides, and I think that 1) we should try to be consistent with the rest of the code in Redis, and 2) try to style each piece of code in a way that it's most readable (no strict rules), so a compromise between these two.
wow.. So much text about a damn white space... LOL.
There was a problem hiding this comment.
since there's already one of these in the code base, we need to decide if we can merge that one, or (considering the other one is recent), reformat both.
i did a search in the project to see if this pattern was used elsewhere and found only two other cases (added by Salvatore a year ago):
if (tio_debug) { printf("E"); fflush(stdout); }i suppose being a debug code that's rarely executed, he didn't want to pollute many lines with it.
similarly, in our case, trivial error handling code.
personally i think we can keep using this pattern.
minor fix for a bug which happen on error handling code and doesn't look like it could have caused any real harm (fd number wouldn't have been reused yet) (cherry picked from commit 04a0af9)
minor fix for a bug which happen on error handling code and doesn't look like it could have caused any real harm (fd number wouldn't have been reused yet)
minor fix for a bug which happen on error handling code and doesn't look like it could have caused any real harm (fd number wouldn't have been reused yet) (cherry picked from commit 04a0af9)
Similar to #7307, in aof rewrite we also did double fclose, this PR fixed issue: #3834