diff mbox

[1/6] restorecond: add noreturn attribute to exitApp()

Message ID 20170305171305.23170-1-nicolas.iooss@m4x.org (mailing list archive)
State Not Applicable
Headers show

Commit Message

Nicolas Iooss March 5, 2017, 5:13 p.m. UTC
This makes it possible for static analyzers such as clang's one to
understand that strings_list_add() cannot dereference a NULL pointer in
the following code:

    if (!newptr)
        exitApp("Out of Memory");
    newptr->string = strdup(string);

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
---
 restorecond/restorecond.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

James Carter March 7, 2017, 7:23 p.m. UTC | #1
On 03/05/2017 12:13 PM, Nicolas Iooss wrote:
> This makes it possible for static analyzers such as clang's one to
> understand that strings_list_add() cannot dereference a NULL pointer in
> the following code:
>
>     if (!newptr)
>         exitApp("Out of Memory");
>     newptr->string = strdup(string);
>
> Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>

I applied these six patches.

Thanks,
Jim

> ---
>  restorecond/restorecond.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/restorecond/restorecond.h b/restorecond/restorecond.h
> index a6be584c84a5..db7e50f72d2d 100644
> --- a/restorecond/restorecond.h
> +++ b/restorecond/restorecond.h
> @@ -33,7 +33,7 @@ extern int run_as_user;
>  extern int start(void);
>  extern int server(int, const char *watch_file);
>
> -extern void exitApp(const char *msg);
> +extern void exitApp(const char *msg) __attribute__((__noreturn__));
>  extern void read_config(int fd,	const char *watch_file);
>
>  extern int watch(int fd, const char *watch_file);
>
diff mbox

Patch

diff --git a/restorecond/restorecond.h b/restorecond/restorecond.h
index a6be584c84a5..db7e50f72d2d 100644
--- a/restorecond/restorecond.h
+++ b/restorecond/restorecond.h
@@ -33,7 +33,7 @@  extern int run_as_user;
 extern int start(void);
 extern int server(int, const char *watch_file);
 
-extern void exitApp(const char *msg);
+extern void exitApp(const char *msg) __attribute__((__noreturn__));
 extern void read_config(int fd,	const char *watch_file);
 
 extern int watch(int fd, const char *watch_file);