Re: [PATCH 1/2] Annotate internal_error with the attribute noreturn
authorAustin Clements <amdragon@MIT.EDU>
Sat, 22 Sep 2012 16:12:56 +0000 (12:12 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:49:34 +0000 (09:49 -0800)
4c/37a30a4f7f6bc6b75eb3b0a538dc039f37e8bc [new file with mode: 0644]

diff --git a/4c/37a30a4f7f6bc6b75eb3b0a538dc039f37e8bc b/4c/37a30a4f7f6bc6b75eb3b0a538dc039f37e8bc
new file mode 100644 (file)
index 0000000..7900b78
--- /dev/null
@@ -0,0 +1,126 @@
+Return-Path: <amdragon@mit.edu>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 5E29F431FB6\r
+       for <notmuch@notmuchmail.org>; Sat, 22 Sep 2012 09:13:01 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id YIS1LyeUFTfG for <notmuch@notmuchmail.org>;\r
+       Sat, 22 Sep 2012 09:13:00 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-8.mit.edu (DMZ-MAILSEC-SCANNER-8.MIT.EDU\r
+       [18.7.68.37])\r
+       by olra.theworths.org (Postfix) with ESMTP id C6ADC431FAE\r
+       for <notmuch@notmuchmail.org>; Sat, 22 Sep 2012 09:13:00 -0700 (PDT)\r
+X-AuditID: 12074425-b7fcc6d00000091f-ba-505de38b666c\r
+Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])\r
+       by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id 77.7C.02335.B83ED505; Sat, 22 Sep 2012 12:12:59 -0400 (EDT)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+       by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id q8MGCwRg025912; \r
+       Sat, 22 Sep 2012 12:12:59 -0400\r
+Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
+       (authenticated bits=0)\r
+       (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+       by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q8MGCuUU003058\r
+       (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+       Sat, 22 Sep 2012 12:12:58 -0400 (EDT)\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77)\r
+       (envelope-from <amdragon@mit.edu>)\r
+       id 1TFSK8-0005S4-Jk; Sat, 22 Sep 2012 12:12:56 -0400\r
+Date: Sat, 22 Sep 2012 12:12:56 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: Justus Winter <4winter@informatik.uni-hamburg.de>\r
+Subject: Re: [PATCH 1/2] Annotate internal_error with the attribute noreturn\r
+Message-ID: <20120922161256.GE26662@mit.edu>\r
+References:\r
+ <1348231837-21700-1-git-send-email-4winter@informatik.uni-hamburg.de>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Content-Disposition: inline\r
+In-Reply-To:\r
+ <1348231837-21700-1-git-send-email-4winter@informatik.uni-hamburg.de>\r
+User-Agent: Mutt/1.5.21 (2010-09-15)\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFmpmleLIzCtJLcpLzFFi42IR4hRV1u1+HBtgcKHbymJ26w8mi+s3ZzI7\r
+       MHlMPH+azePZqlvMAUxRXDYpqTmZZalF+nYJXBnz3txgKvjDW7FyzSTWBsap3F2MnBwSAiYS\r
+       cyc/Z4SwxSQu3FvP1sXIxSEksI9Rom/nM2YIZwOjRNv7G+wgVUICJ5kkVqwVg0gsYZSYuGMx\r
+       G0iCRUBVYvfBuSwgNpuAhsS2/cvBxooImEpsePAArJlZQFri2+9mJhBbWMBHYtvc68wgNq+A\r
+       jsSG/v2MEAsCJWZNeAsVF5Q4OfMJC0SvlsSNfy+BejnA5iz/xwES5hQIkjh8fQ9YiaiAisSU\r
+       k9vYJjAKzULSPQtJ9yyE7gWMzKsYZVNyq3RzEzNzilOTdYuTE/PyUot0LfRyM0v0UlNKNzGC\r
+       wprdRXUH44RDSocYBTgYlXh4N0yOCRBiTSwrrsw9xCjJwaQkynv4QmyAEF9SfkplRmJxRnxR\r
+       aU5q8SFGCQ5mJRFe85NAOd6UxMqq1KJ8mJQ0B4uSOO+NlJv+QgLpiSWp2ampBalFMFkZDg4l\r
+       Cd47j4AaBYtS01Mr0jJzShDSTBycIMN5gIZfAqnhLS5IzC3OTIfIn2JUlBLnfQuSEABJZJTm\r
+       wfXC0s4rRnGgV4R5b4BU8QBTFlz3K6DBTECD31yPAhlckoiQkmpgnPA8tChA71yT91vv7xWW\r
+       aydrOd1kTNfNNCqYYvmO98HW0ucfxDlYrnKzXlL6snWlCC/P5VV2v649ifJ939r//X0I1yQl\r
+       C7aDd57bnz5g+rrxT4fMGZ0oN38poRvFUZ1FL7VeeZqtT2bYdsf3qUDCVPY+B3vZOeluVaVR\r
+       H1q0VDV2+X5JyXdTYinOSDTUYi4qTgQAoMJxoRYDAAA=\r
+Cc: notmuch@notmuchmail.org\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sat, 22 Sep 2012 16:13:01 -0000\r
+\r
+LGTM, though I agree with David that this should return void now, if\r
+that's possible.\r
+\r
+Do we want to wrap the __attribute__((noreturn)) in an #ifdef __GNUC__\r
+(or provide a PRINTF_ATTRIBUTE-like macro) or is that already a lost\r
+cause?\r
+\r
+Quoth Justus Winter on Sep 21 at  2:50 pm:\r
+> Annotating functions that do not return with the noreturn attribute\r
+> (which is understood by both gcc and clang) prevents static analyzers\r
+> from generating false positives (internal_error is used to terminate\r
+> the process and is used extensively in error handling code paths).\r
+> \r
+> Remove the return statement that was placed there to appease the\r
+> compiler. Functions annotated with noreturn are not supposed to return\r
+> any values.\r
+> \r
+> Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>\r
+> ---\r
+>  util/error_util.c |    2 --\r
+>  util/error_util.h |    2 +-\r
+>  2 files changed, 1 insertion(+), 3 deletions(-)\r
+> \r
+> diff --git a/util/error_util.c b/util/error_util.c\r
+> index 630d228..3cf353a 100644\r
+> --- a/util/error_util.c\r
+> +++ b/util/error_util.c\r
+> @@ -35,7 +35,5 @@ _internal_error (const char *format, ...)\r
+>      vfprintf (stderr, format, va_args);\r
+>  \r
+>      exit (1);\r
+> -\r
+> -    return 1;\r
+>  }\r
+>  \r
+> diff --git a/util/error_util.h b/util/error_util.h\r
+> index bb15822..24a644b 100644\r
+> --- a/util/error_util.h\r
+> +++ b/util/error_util.h\r
+> @@ -30,7 +30,7 @@\r
+>   * Note that PRINTF_ATTRIBUTE comes from talloc.h\r
+>   */\r
+>  int\r
+> -_internal_error (const char *format, ...) PRINTF_ATTRIBUTE (1, 2);\r
+> +_internal_error (const char *format, ...) PRINTF_ATTRIBUTE (1, 2) __attribute__ ((noreturn));\r
+>  \r
+>  /* There's no point in continuing when we've detected that we've done\r
+>   * something wrong internally (as opposed to the user passing in a\r