Fixed warnings given by clang 3.4's new -Wlogical-not-parentheses warning

In most cases, the warning revealed a real bug.  In other cases, the
warning is technically a false positive but the code was made clearer.

Change-Id: I9e23d33b4d60c706ecb2189d211a10c7eda4d087
Merge topic 'Wlogical-not-parentheses' into master

ba56a23b Fixed warnings given by clang 3.4's new -Wlogical-not-parentheses warning