From 5c0df561bfc192584384cf8c8a70daf114a1f899 Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Mon, 1 Oct 2012 09:36:11 +0200 Subject: [PATCH] [PATCH] lib: fix warnings when building with clang --- 3e/560c24231ec0b827cd7529c6e00a3d78d38220 | 119 ++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 3e/560c24231ec0b827cd7529c6e00a3d78d38220 diff --git a/3e/560c24231ec0b827cd7529c6e00a3d78d38220 b/3e/560c24231ec0b827cd7529c6e00a3d78d38220 new file mode 100644 index 000000000..8a8163dac --- /dev/null +++ b/3e/560c24231ec0b827cd7529c6e00a3d78d38220 @@ -0,0 +1,119 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id A8EB3431FBC + for ; Mon, 1 Oct 2012 00:36:16 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 1RCVd2g-pxAM for ; + Mon, 1 Oct 2012 00:36:16 -0700 (PDT) +Received: from mail-qa0-f53.google.com (mail-qa0-f53.google.com + [209.85.216.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id DC612431FAE + for ; Mon, 1 Oct 2012 00:36:15 -0700 (PDT) +Received: by qaas11 with SMTP id s11so1589880qaa.5 + for ; Mon, 01 Oct 2012 00:36:15 -0700 (PDT) +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=google.com; s=20120113; + h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; + bh=e2Oax5anIKqwX844uyRG7rUlMOlHDvAfJySib1U/XB8=; + b=DByZuJM6XBJFa2yIgRR2EPaL4Q4T7DOznu9aOpbA2IfIzqkBU8SwcLIFTnOiRtD/87 + G50K918vnmEQTw0MNdF1eHxJvfrlfCSe+Dg90Yu05LfvXUF6qO5zr3uTiFhPwemqR+zh + IdF6A8t7LsKLvxTAqU7Kvnj8nJnrLxP4YGDVGir1o7oYu2I9IDxluwpJORQ0N1yAjNVD + axZeogjOh7bc+c8CDHN696dJ/W5Sn+zwuifukZHjXKdKvBFHlfGAC0HeTEPdPxsqRbfU + ejdWFpU0yRFsH5Vva7n38WH9nU3/kOI41QTC6+/oBsfo9MyYXQNVcvjE8se0wWfcqQKZ + +Xhg== +Received: by 10.224.190.2 with SMTP id dg2mr34809229qab.51.1349076975231; + Mon, 01 Oct 2012 00:36:15 -0700 (PDT) +Received: from localhost ([2001:4b98:dc0:43:216:3eff:fe1b:25f3]) + by mx.google.com with ESMTPS id gw9sm23604976qab.4.2012.10.01.00.36.13 + (version=SSLv3 cipher=OTHER); Mon, 01 Oct 2012 00:36:14 -0700 (PDT) +From: Jani Nikula +To: notmuch@notmuchmail.org +Subject: [PATCH] lib: fix warnings when building with clang +Date: Mon, 1 Oct 2012 09:36:11 +0200 +Message-Id: <1349076971-2065-1-git-send-email-jani@nikula.org> +X-Mailer: git-send-email 1.7.2.5 +X-Gm-Message-State: + ALoCoQkIOQVwDNsV//sUH0Q1vTFMIx4v8h+1WQXEVMZFK417Z6noAdg1Ya3SYlaid4SZsqlQIsbY +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Mon, 01 Oct 2012 07:36:16 -0000 + +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 | 4 +++- + lib/tags.c | 2 +- + 2 files changed, 4 insertions(+), 2 deletions(-) + +diff --git a/lib/message.cc b/lib/message.cc +index 978de06..320901f 100644 +--- a/lib/message.cc ++++ b/lib/message.cc +@@ -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. */ +- talloc_reference (message, message->tag_list); ++ if (!talloc_reference (message, message->tag_list)) ++ return NULL; ++ + return tags; + } + +diff --git a/lib/tags.c b/lib/tags.c +index c58924f..b7e5602 100644 +--- a/lib/tags.c ++++ b/lib/tags.c +@@ -40,7 +40,7 @@ _notmuch_tags_create (const void *ctx, notmuch_string_list_t *list) + return NULL; + + tags->iterator = list->head; +- talloc_steal (tags, list); ++ (void) talloc_steal (tags, list); + + return tags; + } +-- +1.7.2.5 + -- 2.26.2