]> git.notmuchmail.org Git - notmuch/commitdiff
Annotate internal_error with the attribute noreturn
authorJustus Winter <4winter@informatik.uni-hamburg.de>
Mon, 24 Sep 2012 15:21:19 +0000 (17:21 +0200)
committerDavid Bremner <bremner@debian.org>
Thu, 27 Sep 2012 15:52:06 +0000 (12:52 -0300)
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
util/error_util.h

index 630d22817539b39c4da66db3f84f647abef6187e..d6e60fc99e4e3dfb0de12fc5ebca09177f8fdea6 100644 (file)
@@ -24,7 +24,7 @@
 
 #include "error_util.h"
 
 
 #include "error_util.h"
 
-int
+void
 _internal_error (const char *format, ...)
 {
     va_list va_args;
 _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);
     vfprintf (stderr, format, va_args);
 
     exit (1);
-
-    return 1;
 }
 
 }
 
index bb158220a3d8d4c8cc09e1f7e9af731135f1f160..17c8727d13b2a743dd3afd9642026f3a73b2b1ea 100644 (file)
 
 #include <talloc.h>
 
 
 #include <talloc.h>
 
+#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
  */
 /* 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
 
 /* 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