]> git.notmuchmail.org Git - notmuch/commitdiff
lib: fix warnings when building with clang
authorJani Nikula <jani@nikula.org>
Mon, 1 Oct 2012 07:36:11 +0000 (09:36 +0200)
committerDavid Bremner <bremner@debian.org>
Sat, 1 Dec 2012 12:10:32 +0000 (08:10 -0400)
Building notmuch with CC=clang and CXX=clang++ produces the warnings:

CC -O2 lib/tags.o
lib/tags.c:43:5: warning: expression result unused [-Wunused-value]
    talloc_steal (tags, list);
    ^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/talloc.h:345:143: note: expanded from:
  ...__location__); __talloc_steal_ret; })
                    ^~~~~~~~~~~~~~~~~~
1 warning generated.

CXX -O2 lib/message.o
lib/message.cc:791:5: warning: expression result unused [-Wunused-value]
    talloc_reference (message, message->tag_list);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/talloc.h:932:36: note: expanded from:
  ...(_TALLOC_TYPEOF(ptr))_talloc_reference_loc((ctx),(ptr), __location__)
     ^                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.

Check talloc_reference() return value, and explicitly ignore
talloc_steal() return value as it has no failure modes, to silence the
warnings.

lib/message.cc
lib/tags.c

index 978de066d4185ee991794bfad1f50140dd9424d6..320901f77eb010a1cab4502c79db6faccbc6d49c 100644 (file)
@@ -788,7 +788,9 @@ notmuch_message_get_tags (notmuch_message_t *message)
      * possible to modify the message tags (which talloc_unlink's the
      * current list from the message) while still iterating because
      * the iterator will keep the current list alive. */
      * possible to modify the message tags (which talloc_unlink's the
      * current list from the message) while still iterating because
      * the iterator will keep the current list alive. */
-    talloc_reference (message, message->tag_list);
+    if (!talloc_reference (message, message->tag_list))
+       return NULL;
+
     return tags;
 }
 
     return tags;
 }
 
index c58924f87b56de56a7799dd23aadcef35056d15d..b7e5602cfbac9a33637f310c2c3498cc42851ef1 100644 (file)
@@ -40,7 +40,7 @@ _notmuch_tags_create (const void *ctx, notmuch_string_list_t *list)
        return NULL;
 
     tags->iterator = list->head;
        return NULL;
 
     tags->iterator = list->head;
-    talloc_steal (tags, list);
+    (void) talloc_steal (tags, list);
 
     return tags;
 }
 
     return tags;
 }