From f7245d23721fd06686c58bb7a42a677d9ed9550a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Tue, 15 Dec 2015 12:40:40 +0100 Subject: [PATCH] mu-store: Silence confusing code that's throwing a clang warning Doing: !access(...) == 0 Is equivalent to: (!access(...)) == 0 Not: !(access(...) == 0) And throws this warning under clang: mu-store.cc:77:6: warning: logical not is only applied to the left hand side of this comparison [-Wlogical-not-parentheses] if (!access(xpath, F_OK) == 0) { ^ ~~ mu-store.cc:77:6: note: add parentheses after the '!' to evaluate the comparison first if (!access(xpath, F_OK) == 0) { ^ ( ) mu-store.cc:77:6: note: add parentheses around left hand side expression to silence this warning if (!access(xpath, F_OK) == 0) { ^ ( ) It ends up doing what the author intended anyway since access() returns -1 on error, and !-1 == 0, but just do the more obvious check and check that we don't get 0 here with !=. --- lib/mu-store.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mu-store.cc b/lib/mu-store.cc index 21410064..ff23e78b 100644 --- a/lib/mu-store.cc +++ b/lib/mu-store.cc @@ -74,7 +74,7 @@ xapian_get_metadata (const gchar *xpath, const gchar *key) g_return_val_if_fail (xpath, NULL); g_return_val_if_fail (key, NULL); - if (!access(xpath, F_OK) == 0) { + if (access(xpath, F_OK) != 0) { g_warning ("cannot access %s: %s", xpath, strerror(errno)); return NULL; }