From c64dc37a0215e196fde761b07516217ae87da6b5 Mon Sep 17 00:00:00 2001 From: Tomi Ollila Date: Sat, 22 Sep 2012 23:03:40 +0300 Subject: [PATCH] Re: [PATCH 1/2] Annotate internal_error with the attribute noreturn --- 3d/04d2995232255de5ff5883bb0b25840b3f7cb5 | 120 ++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 3d/04d2995232255de5ff5883bb0b25840b3f7cb5 diff --git a/3d/04d2995232255de5ff5883bb0b25840b3f7cb5 b/3d/04d2995232255de5ff5883bb0b25840b3f7cb5 new file mode 100644 index 000000000..f3c4147b3 --- /dev/null +++ b/3d/04d2995232255de5ff5883bb0b25840b3f7cb5 @@ -0,0 +1,120 @@ +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 42511431FAF + for ; Sat, 22 Sep 2012 13:03:37 -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 KHrDBtxqfPtx for ; + Sat, 22 Sep 2012 13:03:36 -0700 (PDT) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by olra.theworths.org (Postfix) with ESMTP id 33198431FAE + for ; Sat, 22 Sep 2012 13:03:36 -0700 (PDT) +Received: from guru.guru-group.fi (localhost [IPv6:::1]) + by guru.guru-group.fi (Postfix) with ESMTP id 9E0E310014F; + Sat, 22 Sep 2012 23:03:40 +0300 (EEST) +From: Tomi Ollila +To: Austin Clements , + Justus Winter <4winter@informatik.uni-hamburg.de> +Subject: Re: [PATCH 1/2] Annotate internal_error with the attribute noreturn +In-Reply-To: <20120922161256.GE26662@mit.edu> +References: + <1348231837-21700-1-git-send-email-4winter@informatik.uni-hamburg.de> + <20120922161256.GE26662@mit.edu> +User-Agent: Notmuch/0.13.2+177~g6720ee8 (http://notmuchmail.org) Emacs/24.2.1 + (x86_64-unknown-linux-gnu) +X-Face: HhBM'cA~ +MIME-Version: 1.0 +Content-Type: text/plain +Cc: notmuch@notmuchmail.org +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: Sat, 22 Sep 2012 20:03:37 -0000 + +On Sat, Sep 22 2012, Austin Clements wrote: + +> LGTM, though I agree with David that this should return void now, if +> that's possible. +> +> Do we want to wrap the __attribute__((noreturn)) in an #ifdef __GNUC__ +> (or provide a PRINTF_ATTRIBUTE-like macro) or is that already a lost +> cause? + +Good point -- this should be NORETURN_ATTRIBUTE instead... + +Also, http://gcc.gnu.org/onlinedocs/gcc-4.3.2//gcc/Function-Attributes.html states: + +"It does not make sense for a noreturn function to have a return type other +than void." + +(I think that hasn't changed since :) + +Tomi + +> +> Quoth Justus Winter on Sep 21 at 2:50 pm: +>> 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 +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch -- 2.26.2