From 0afb829560db190d8e829183835592aaf2ce2712 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Mon, 24 Sep 2012 17:21:19 +0200 Subject: [PATCH] [PATCH 5/6] Annotate internal_error with the attribute noreturn --- a8/af825b56d55e2974f5ccacddee76202502f4a6 | 123 ++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 a8/af825b56d55e2974f5ccacddee76202502f4a6 diff --git a/a8/af825b56d55e2974f5ccacddee76202502f4a6 b/a8/af825b56d55e2974f5ccacddee76202502f4a6 new file mode 100644 index 000000000..eeb7f6864 --- /dev/null +++ b/a8/af825b56d55e2974f5ccacddee76202502f4a6 @@ -0,0 +1,123 @@ +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 B8F40431FC0 + for ; Mon, 24 Sep 2012 08:21:38 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] + 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 L-6Ze7C1mmwQ for ; + Mon, 24 Sep 2012 08:21:37 -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 056E0431FAF + for ; Mon, 24 Sep 2012 08:21:36 -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 B28075AB283 + for ; Mon, 24 Sep 2012 17:21:35 +0200 (CEST) +Received: by mail.jade-hamburg.de (Postfix, from userid 401) + id 1B0F0DF2A9; Mon, 24 Sep 2012 17:21:35 +0200 (CEST) +Received: from thinkbox.jade-hamburg.de (mail.jade-hamburg.de [85.183.11.228]) + (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 0B627DF2A2; + Mon, 24 Sep 2012 17:21:32 +0200 (CEST) +Received: from teythoon by thinkbox.jade-hamburg.de with local (Exim 4.80) + (envelope-from ) + id 1TGATR-0007lJ-0x; Mon, 24 Sep 2012 17:21:29 +0200 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +To: notmuch@notmuchmail.org +Subject: [PATCH 5/6] Annotate internal_error with the attribute noreturn +Date: Mon, 24 Sep 2012 17:21:19 +0200 +Message-Id: + <1348500080-29726-5-git-send-email-4winter@informatik.uni-hamburg.de> +X-Mailer: git-send-email 1.7.10.4 +In-Reply-To: + <1348500080-29726-1-git-send-email-4winter@informatik.uni-hamburg.de> +References: <873927eb5i.fsf@convex-new.cs.unb.ca> + <1348500080-29726-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 15:21:38 -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 | 6 ++++-- + 2 files changed, 5 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 bb15822..17c8727 100644 +--- a/util/error_util.h ++++ b/util/error_util.h +@@ -23,14 +23,16 @@ + + #include + ++#include "function-attributes.h" ++ + /* 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 + * bogus value). + * + * 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