From 33d4481c365aab9e9a1485227f0ce576dc17b539 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Mon, 24 Sep 2012 12:31:56 +0200 Subject: [PATCH] [PATCH 4/5] Annotate internal_error with the attribute noreturn --- e3/5ec7e9f106310e5fa1ba0006125411f3c38e09 | 116 ++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 e3/5ec7e9f106310e5fa1ba0006125411f3c38e09 diff --git a/e3/5ec7e9f106310e5fa1ba0006125411f3c38e09 b/e3/5ec7e9f106310e5fa1ba0006125411f3c38e09 new file mode 100644 index 000000000..1128e8cd5 --- /dev/null +++ b/e3/5ec7e9f106310e5fa1ba0006125411f3c38e09 @@ -0,0 +1,116 @@ +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 ECF91431FBD + for ; Mon, 24 Sep 2012 03:32:25 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0.001 +X-Spam-Level: +X-Spam-Status: No, score=0.001 tagged_above=-999 required=5 + tests=[UNPARSEABLE_RELAY=0.001] 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 C502J7KjonSk for ; + Mon, 24 Sep 2012 03:32:24 -0700 (PDT) +Received: from mail.cryptobitch.de (cryptobitch.de [88.198.7.68]) + (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id D4B84431FC3 + for ; Mon, 24 Sep 2012 03:32:19 -0700 (PDT) +Received: from mail.jade-hamburg.de (mail.jade-hamburg.de [85.183.11.228]) + (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.cryptobitch.de (Postfix) with ESMTPSA id 9D1B85AA9C2 + for ; Mon, 24 Sep 2012 12:32:18 +0200 (CEST) +Received: by mail.jade-hamburg.de (Postfix, from userid 401) + id 10C03DF2A7; Mon, 24 Sep 2012 12:32:18 +0200 (CEST) +Received: from thinkbox.jade-hamburg.de (unknown + [IPv6:fe80::216:d3ff:fe3e:5058%br0]) + (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) + (No client certificate requested) (Authenticated sender: teythoon) + by mail.jade-hamburg.de (Postfix) with ESMTPSA id 252BCDF2A2; + Mon, 24 Sep 2012 12:32:11 +0200 (CEST) +Received: from teythoon by thinkbox.jade-hamburg.de with local (Exim 4.80) + (envelope-from ) + id 1TG5xR-0002iD-T3; Mon, 24 Sep 2012 12:32:09 +0200 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +To: notmuch@notmuchmail.org +Subject: [PATCH 4/5] Annotate internal_error with the attribute noreturn +Date: Mon, 24 Sep 2012 12:31:56 +0200 +Message-Id: + <1348482717-10340-5-git-send-email-4winter@informatik.uni-hamburg.de> +X-Mailer: git-send-email 1.7.10.4 +In-Reply-To: + <1348482717-10340-1-git-send-email-4winter@informatik.uni-hamburg.de> +References: <20120922161256.GE26662@mit.edu> + <1348482717-10340-1-git-send-email-4winter@informatik.uni-hamburg.de> +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, 24 Sep 2012 10:32:26 -0000 + +Annotating functions that do not return with the noreturn attribute +(which is understood by both gcc and clang) prevents static analyzers +from generating false positives (internal_error is used to terminate +the process and is used extensively in error handling code paths). + +Remove the return statement that was placed there to appease the +compiler. Functions annotated with noreturn are not supposed to return +any values. + +Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de> +--- + util/error_util.c | 4 +--- + util/error_util.h | 4 ++-- + 2 files changed, 3 insertions(+), 5 deletions(-) + +diff --git a/util/error_util.c b/util/error_util.c +index 630d228..d6e60fc 100644 +--- a/util/error_util.c ++++ b/util/error_util.c +@@ -24,7 +24,7 @@ + + #include "error_util.h" + +-int ++void + _internal_error (const char *format, ...) + { + va_list va_args; +@@ -35,7 +35,5 @@ _internal_error (const char *format, ...) + vfprintf (stderr, format, va_args); + + exit (1); +- +- return 1; + } + +diff --git a/util/error_util.h b/util/error_util.h +index 27e119f..d4d4584 100644 +--- a/util/error_util.h ++++ b/util/error_util.h +@@ -53,8 +53,8 @@ + * + * Note that PRINTF_ATTRIBUTE comes from talloc.h + */ +-int +-_internal_error (const char *format, ...) PRINTF_ATTRIBUTE (1, 2); ++void ++_internal_error (const char *format, ...) PRINTF_ATTRIBUTE (1, 2) NORETURN_ATTRIBUTE; + + /* There's no point in continuing when we've detected that we've done + * something wrong internally (as opposed to the user passing in a +-- +1.7.10.4 + -- 2.26.2