低级错误

真是三十老娘倒绷孩儿,这个低级错误害我调了一个小时:

    if (roftcp->flags & ROFTC_INITIALIZED == 0) {
cmn_err(CE_WARN, "Client uninitialized!");
return ENXIO;
}

& 的优先级比 == 还低,ROFTC_INITIALIZED 值为 4,因此整个条件判断始终不成立。逻辑或和逻辑与也一样优先级比 == 和 != 低。老老实实加括号吧。

Wikipedia: Operator precedence in C and C++

0 Comments so far

  1. There are currently no comments.
Leave a Comment?


« Vim tip 两条  —  wallop, ies4linux »

Tags

Blogroll

Fairy World | STUPiD | 阅微草堂 | ShelleX | 流浪五天