From a300ba8a50b351991d7397057db872496fa8386b Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Fri, 21 Sep 2012 14:50:36 +0200 Subject: [PATCH] [PATCH 1/2] Annotate internal_error with the attribute noreturn --- a2/04fa60ccc2c298ddb35fb47649bacc69917073 | 100 ++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 a2/04fa60ccc2c298ddb35fb47649bacc69917073 diff --git a/a2/04fa60ccc2c298ddb35fb47649bacc69917073 b/a2/04fa60ccc2c298ddb35fb47649bacc69917073 new file mode 100644 index 000000000..bad4a9353 --- /dev/null +++ b/a2/04fa60ccc2c298ddb35fb47649bacc69917073 @@ -0,0 +1,100 @@ +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 19356431FB6 + for ; Fri, 21 Sep 2012 05:50:54 -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 hRB5NkDDRnXE for ; + Fri, 21 Sep 2012 05:50:53 -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 0A932431FAE + for ; Fri, 21 Sep 2012 05:50:53 -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 9F9B85AB092 + for ; Fri, 21 Sep 2012 14:50:51 +0200 (CEST) +Received: by mail.jade-hamburg.de (Postfix, from userid 401) + id 19ECCDF2A4; Fri, 21 Sep 2012 14:50:51 +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 E81B5DF2A2; + Fri, 21 Sep 2012 14:50:47 +0200 (CEST) +Received: from teythoon by thinkbox.jade-hamburg.de with local (Exim 4.80) + (envelope-from ) + id 1TF2gv-0005fI-Bd; Fri, 21 Sep 2012 14:50:45 +0200 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +To: notmuch@notmuchmail.org +Subject: [PATCH 1/2] Annotate internal_error with the attribute noreturn +Date: Fri, 21 Sep 2012 14:50:36 +0200 +Message-Id: + <1348231837-21700-1-git-send-email-4winter@informatik.uni-hamburg.de> +X-Mailer: git-send-email 1.7.10.4 +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: Fri, 21 Sep 2012 12:50:54 -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 | 2 -- + util/error_util.h | 2 +- + 2 files changed, 1 insertion(+), 3 deletions(-) + +diff --git a/util/error_util.c b/util/error_util.c +index 630d228..3cf353a 100644 +--- a/util/error_util.c ++++ b/util/error_util.c +@@ -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..24a644b 100644 +--- a/util/error_util.h ++++ b/util/error_util.h +@@ -30,7 +30,7 @@ + * Note that PRINTF_ATTRIBUTE comes from talloc.h + */ + int +-_internal_error (const char *format, ...) PRINTF_ATTRIBUTE (1, 2); ++_internal_error (const char *format, ...) PRINTF_ATTRIBUTE (1, 2) __attribute__ ((noreturn)); + + /* 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