Annotate internal_error with the attribute noreturn

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>
This commit is contained in:
Justus Winter 2012-09-24 17:21:19 +02:00 committed by David Bremner
parent faf6ede3ef
commit 2f40ca28a4
2 changed files with 5 additions and 5 deletions

View file

@ -24,7 +24,7 @@
#include "error_util.h" #include "error_util.h"
int void
_internal_error (const char *format, ...) _internal_error (const char *format, ...)
{ {
va_list va_args; va_list va_args;
@ -35,7 +35,5 @@ _internal_error (const char *format, ...)
vfprintf (stderr, format, va_args); vfprintf (stderr, format, va_args);
exit (1); exit (1);
return 1;
} }

View file

@ -23,14 +23,16 @@
#include <talloc.h> #include <talloc.h>
#include "function-attributes.h"
/* There's no point in continuing when we've detected that we've done /* 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 * something wrong internally (as opposed to the user passing in a
* bogus value). * bogus value).
* *
* Note that PRINTF_ATTRIBUTE comes from talloc.h * Note that PRINTF_ATTRIBUTE comes from talloc.h
*/ */
int void
_internal_error (const char *format, ...) PRINTF_ATTRIBUTE (1, 2); _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 /* 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 * something wrong internally (as opposed to the user passing in a