我的理解是括号没有区别,所以Clang是否有任何理由(除了“改善”代码清晰度以外)警告它为默认值?我宁愿不添加括号,因为我不喜欢为代码而添加代码。

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) {
                                 ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~

最佳答案

自然的趋势是从左到右阅读它,很容易忘记运算符的优先级。就是说,这只是一个警告,如果您知道自己在做什么,并且自己的风格允许,请随时进行抑制。

10-07 19:32
查看更多