My understanding is the parentheses make no difference, so is there any reason (other than to “improve“ code-clarity) that Clang warns this as a default? I prefer not to add the parentheses as I dislike adding code for code’s sake.
src/websocket.c:420:43: warning: '&&' within '||' [-Wlogical-op-parentheses]
if (rv == 0 && N != 0 || rv == -1 && errno == ECONNRESET) {
~~ ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
src/websocket.c:420:43: note: place parentheses around the '&&' expression to
silence this warning
if (rv == 0 && N != 0 || rv == -1 && errno == ECONNRESET) {
~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
&&
and||
(which don't all that often come up). – cHao Jun 5 '13 at 12:30if (x = 3)
, which is perfectly legal. The point is, it's deemed something that people often get wrong, so the compiler writers decided it's worth a warning. – Daniel Fischer Jun 5 '13 at 12:43