[PATCH] lib: fix warnings when building with clang
authorJani Nikula <jani@nikula.org>
Mon, 1 Oct 2012 07:36:11 +0000 (09:36 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:49:40 +0000 (09:49 -0800)
3e/560c24231ec0b827cd7529c6e00a3d78d38220 [new file with mode: 0644]

diff --git a/3e/560c24231ec0b827cd7529c6e00a3d78d38220 b/3e/560c24231ec0b827cd7529c6e00a3d78d38220
new file mode 100644 (file)
index 0000000..8a8163d
--- /dev/null
@@ -0,0 +1,119 @@
+Return-Path: <jani@nikula.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id A8EB3431FBC\r
+       for <notmuch@notmuchmail.org>; Mon,  1 Oct 2012 00:36:16 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id 1RCVd2g-pxAM for <notmuch@notmuchmail.org>;\r
+       Mon,  1 Oct 2012 00:36:16 -0700 (PDT)\r
+Received: from mail-qa0-f53.google.com (mail-qa0-f53.google.com\r
+       [209.85.216.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id DC612431FAE\r
+       for <notmuch@notmuchmail.org>; Mon,  1 Oct 2012 00:36:15 -0700 (PDT)\r
+Received: by qaas11 with SMTP id s11so1589880qaa.5\r
+       for <notmuch@notmuchmail.org>; Mon, 01 Oct 2012 00:36:15 -0700 (PDT)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+       d=google.com; s=20120113;\r
+       h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state;\r
+       bh=e2Oax5anIKqwX844uyRG7rUlMOlHDvAfJySib1U/XB8=;\r
+       b=DByZuJM6XBJFa2yIgRR2EPaL4Q4T7DOznu9aOpbA2IfIzqkBU8SwcLIFTnOiRtD/87\r
+       G50K918vnmEQTw0MNdF1eHxJvfrlfCSe+Dg90Yu05LfvXUF6qO5zr3uTiFhPwemqR+zh\r
+       IdF6A8t7LsKLvxTAqU7Kvnj8nJnrLxP4YGDVGir1o7oYu2I9IDxluwpJORQ0N1yAjNVD\r
+       axZeogjOh7bc+c8CDHN696dJ/W5Sn+zwuifukZHjXKdKvBFHlfGAC0HeTEPdPxsqRbfU\r
+       ejdWFpU0yRFsH5Vva7n38WH9nU3/kOI41QTC6+/oBsfo9MyYXQNVcvjE8se0wWfcqQKZ\r
+       +Xhg==\r
+Received: by 10.224.190.2 with SMTP id dg2mr34809229qab.51.1349076975231;\r
+       Mon, 01 Oct 2012 00:36:15 -0700 (PDT)\r
+Received: from localhost ([2001:4b98:dc0:43:216:3eff:fe1b:25f3])\r
+       by mx.google.com with ESMTPS id gw9sm23604976qab.4.2012.10.01.00.36.13\r
+       (version=SSLv3 cipher=OTHER); Mon, 01 Oct 2012 00:36:14 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] lib: fix warnings when building with clang\r
+Date: Mon,  1 Oct 2012 09:36:11 +0200\r
+Message-Id: <1349076971-2065-1-git-send-email-jani@nikula.org>\r
+X-Mailer: git-send-email 1.7.2.5\r
+X-Gm-Message-State:\r
+ ALoCoQkIOQVwDNsV//sUH0Q1vTFMIx4v8h+1WQXEVMZFK417Z6noAdg1Ya3SYlaid4SZsqlQIsbY\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 01 Oct 2012 07:36:16 -0000\r
+\r
+Building notmuch with CC=clang and CXX=clang++ produces the warnings:\r
+\r
+CC -O2 lib/tags.o\r
+lib/tags.c:43:5: warning: expression result unused [-Wunused-value]\r
+    talloc_steal (tags, list);\r
+    ^~~~~~~~~~~~~~~~~~~~~~~~~\r
+/usr/include/talloc.h:345:143: note: expanded from:\r
+  ...__location__); __talloc_steal_ret; })\r
+                    ^~~~~~~~~~~~~~~~~~\r
+1 warning generated.\r
+\r
+CXX -O2 lib/message.o\r
+lib/message.cc:791:5: warning: expression result unused [-Wunused-value]\r
+    talloc_reference (message, message->tag_list);\r
+    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r
+/usr/include/talloc.h:932:36: note: expanded from:\r
+  ...(_TALLOC_TYPEOF(ptr))_talloc_reference_loc((ctx),(ptr), __location__)\r
+     ^                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r
+1 warning generated.\r
+\r
+Check talloc_reference() return value, and explicitly ignore\r
+talloc_steal() return value as it has no failure modes, to silence the\r
+warnings.\r
+---\r
+ lib/message.cc |    4 +++-\r
+ lib/tags.c     |    2 +-\r
+ 2 files changed, 4 insertions(+), 2 deletions(-)\r
+\r
+diff --git a/lib/message.cc b/lib/message.cc\r
+index 978de06..320901f 100644\r
+--- a/lib/message.cc\r
++++ b/lib/message.cc\r
+@@ -788,7 +788,9 @@ notmuch_message_get_tags (notmuch_message_t *message)\r
+      * possible to modify the message tags (which talloc_unlink's the\r
+      * current list from the message) while still iterating because\r
+      * the iterator will keep the current list alive. */\r
+-    talloc_reference (message, message->tag_list);\r
++    if (!talloc_reference (message, message->tag_list))\r
++      return NULL;\r
++\r
+     return tags;\r
+ }\r
+ \r
+diff --git a/lib/tags.c b/lib/tags.c\r
+index c58924f..b7e5602 100644\r
+--- a/lib/tags.c\r
++++ b/lib/tags.c\r
+@@ -40,7 +40,7 @@ _notmuch_tags_create (const void *ctx, notmuch_string_list_t *list)\r
+       return NULL;\r
+ \r
+     tags->iterator = list->head;\r
+-    talloc_steal (tags, list);\r
++    (void) talloc_steal (tags, list);\r
+ \r
+     return tags;\r
+ }\r
+-- \r
+1.7.2.5\r
+\r