From: Austin Clements Date: Sat, 22 Sep 2012 16:12:56 +0000 (+2000) Subject: Re: [PATCH 1/2] Annotate internal_error with the attribute noreturn X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=aa9f78cdaec8a9e5811320878432d54b7c0f8cef;p=notmuch-archives.git Re: [PATCH 1/2] Annotate internal_error with the attribute noreturn --- diff --git a/4c/37a30a4f7f6bc6b75eb3b0a538dc039f37e8bc b/4c/37a30a4f7f6bc6b75eb3b0a538dc039f37e8bc new file mode 100644 index 000000000..7900b7885 --- /dev/null +++ b/4c/37a30a4f7f6bc6b75eb3b0a538dc039f37e8bc @@ -0,0 +1,126 @@ +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 5E29F431FB6 + for ; Sat, 22 Sep 2012 09:13:01 -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 YIS1LyeUFTfG for ; + Sat, 22 Sep 2012 09:13:00 -0700 (PDT) +Received: from dmz-mailsec-scanner-8.mit.edu (DMZ-MAILSEC-SCANNER-8.MIT.EDU + [18.7.68.37]) + by olra.theworths.org (Postfix) with ESMTP id C6ADC431FAE + for ; Sat, 22 Sep 2012 09:13:00 -0700 (PDT) +X-AuditID: 12074425-b7fcc6d00000091f-ba-505de38b666c +Received: from mailhub-auth-1.mit.edu ( [18.9.21.35]) + by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP + id 77.7C.02335.B83ED505; Sat, 22 Sep 2012 12:12:59 -0400 (EDT) +Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) + by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id q8MGCwRg025912; + Sat, 22 Sep 2012 12:12:59 -0400 +Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) + (authenticated bits=0) + (User authenticated as amdragon@ATHENA.MIT.EDU) + by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q8MGCuUU003058 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Sat, 22 Sep 2012 12:12:58 -0400 (EDT) +Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77) + (envelope-from ) + id 1TFSK8-0005S4-Jk; Sat, 22 Sep 2012 12:12:56 -0400 +Date: Sat, 22 Sep 2012 12:12:56 -0400 +From: Austin Clements +To: Justus Winter <4winter@informatik.uni-hamburg.de> +Subject: Re: [PATCH 1/2] Annotate internal_error with the attribute noreturn +Message-ID: <20120922161256.GE26662@mit.edu> +References: + <1348231837-21700-1-git-send-email-4winter@informatik.uni-hamburg.de> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: + <1348231837-21700-1-git-send-email-4winter@informatik.uni-hamburg.de> +User-Agent: Mutt/1.5.21 (2010-09-15) +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFmpmleLIzCtJLcpLzFFi42IR4hRV1u1+HBtgcKHbymJ26w8mi+s3ZzI7 + MHlMPH+azePZqlvMAUxRXDYpqTmZZalF+nYJXBnz3txgKvjDW7FyzSTWBsap3F2MnBwSAiYS + cyc/Z4SwxSQu3FvP1sXIxSEksI9Rom/nM2YIZwOjRNv7G+wgVUICJ5kkVqwVg0gsYZSYuGMx + G0iCRUBVYvfBuSwgNpuAhsS2/cvBxooImEpsePAArJlZQFri2+9mJhBbWMBHYtvc68wgNq+A + jsSG/v2MEAsCJWZNeAsVF5Q4OfMJC0SvlsSNfy+BejnA5iz/xwES5hQIkjh8fQ9YiaiAisSU + k9vYJjAKzULSPQtJ9yyE7gWMzKsYZVNyq3RzEzNzilOTdYuTE/PyUot0LfRyM0v0UlNKNzGC + wprdRXUH44RDSocYBTgYlXh4N0yOCRBiTSwrrsw9xCjJwaQkynv4QmyAEF9SfkplRmJxRnxR + aU5q8SFGCQ5mJRFe85NAOd6UxMqq1KJ8mJQ0B4uSOO+NlJv+QgLpiSWp2ampBalFMFkZDg4l + Cd47j4AaBYtS01Mr0jJzShDSTBycIMN5gIZfAqnhLS5IzC3OTIfIn2JUlBLnfQuSEABJZJTm + wfXC0s4rRnGgV4R5b4BU8QBTFlz3K6DBTECD31yPAhlckoiQkmpgnPA8tChA71yT91vv7xWW + aydrOd1kTNfNNCqYYvmO98HW0ucfxDlYrnKzXlL6snWlCC/P5VV2v649ifJ939r//X0I1yQl + C7aDd57bnz5g+rrxT4fMGZ0oN38poRvFUZ1FL7VeeZqtT2bYdsf3qUDCVPY+B3vZOeluVaVR + H1q0VDV2+X5JyXdTYinOSDTUYi4qTgQAoMJxoRYDAAA= +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 16:13:01 -0000 + +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? + +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