libselinux/utils: fix all the noreturn errors
PATCH 1/1 libselinux/utils: fix all the noreturn errors
From: William Roberts <[email protected]>
When building with clang, multiple noreturn issues arise, for instance:
selabel_partial_match.c:11:1: error: function 'usage' could be declared with attribute 'noreturn' [-Werror,-Wmissing-noreturn]
Fix these.
Signed-off-by William Roberts <[email protected]>
--- libselinux/utils/avcstat.c | 2 +- libselinux/utils/getconlist.c | 2 +- libselinux/utils/getdefaultcon.c | 2 +- libselinux/utils/getsebool.c | 2 +- libselinux/utils/matchpathcon.c | 2 +- libselinux/utils/selabel_digest.c | 2 +- libselinux/utils/selabel_lookup.c | 2 +- libselinux/utils/selabel_lookup_best_match.c | 2 +- libselinux/utils/selabel_partial_match.c | 2 +- libselinux/utils/selinux_check_securetty_context.c | 2 +- libselinux/utils/selinux_restorecon.c | 2 +- libselinux/utils/selinuxexeccon.c | 2 +- libselinux/utils/setenforce.c | 2 +- libselinux/utils/togglesebool.c | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-)
libselinux/utils/avcstat.c +1 -1
@@ -43,7 +43,7 @@ static char buf[DEF_BUF_SIZE];/* selinuxfs mount point */ extern char *selinux_mnt; -static __attribute__((__format__ (printf,1 ,2 )))void die (const char *msg, ...) +static __attribute__((__format__ (printf,1 ,2 ),__noreturn__))void die (const char *msg, ...) {va_list args;
libselinux/utils/getconlist.c +1 -1
@@ -9,7 +9,7 @@#include <selinux/selinux.h> #include <selinux/get_context_list.h> -static void usage (const char *name,const char *detail,int rc) +static __attribute__ ((__noreturn__))void usage (const char *name,const char *detail,int rc) {fprintf (stderr,"usage: %s [-l level] user [context]\n" , name);if (detail)
libselinux/utils/getdefaultcon.c +1 -1
@@ -9,7 +9,7 @@#include <selinux/selinux.h> #include <selinux/get_context_list.h> -static void usage (const char *name,const char *detail,int rc) +static __attribute__ ((__noreturn__))void usage (const char *name,const char *detail,int rc) {fprintf (stderr,"usage: %s [-l level] [-s service] user [fromcon]\n" , name);if (detail)
libselinux/utils/getsebool.c +1 -1
@@ -6,7 +6,7 @@#include <string.h> #include <selinux/selinux.h> -static void usage (const char *progname) +static __attribute__ ((__noreturn__))void usage (const char *progname) {fprintf (stderr,"usage: %s -a or %s boolean...\n" , progname, progname);exit (1 );
libselinux/utils/matchpathcon.c +1 -1
@@ -12,7 +12,7 @@#include <limits.h> #include <stdlib.h> -static void usage (const char *progname) +static __attribute__ ((__noreturn__))void usage (const char *progname) { fprintf(stderr, "usage: %s [-N] [-n] [-f file_contexts] [ -P policy_root_path ] [-p prefix] [-Vq] path...\n",
libselinux/utils/selabel_digest.c +1 -1
@@ -8,7 +8,7 @@static size_t digest_len; -static void usage (const char *progname) +static __attribute__ ((__noreturn__))void usage (const char *progname) {fprintf (stderr, "usage: %s -b backend [-d] [-v] [-B] [-i] [-f file]\n\n"
libselinux/utils/selabel_lookup.c +1 -1
@@ -6,7 +6,7 @@#include <selinux/selinux.h> #include <selinux/label.h> -static void usage (const char *progname) +static __attribute__ ((__noreturn__))void usage (const char *progname) {fprintf (stderr, "usage: %s -b backend [-v] [-r] -k key [-t type] [-f file]\n\n"
libselinux/utils/selabel_lookup_best_match.c +1 -1
@@ -7,7 +7,7 @@#include <selinux/selinux.h> #include <selinux/label.h> -static void usage (const char *progname) +static __attribute__ ((__noreturn__))void usage (const char *progname) {fprintf (stderr, "usage: %s [-v] [-r] -p path [-m mode] [-f file] [link...]\n\n"
libselinux/utils/selabel_partial_match.c +1 -1
@@ -7,7 +7,7 @@#include <selinux/selinux.h> #include <selinux/label.h> -static void usage (const char *progname) +static __attribute__ ((__noreturn__))void usage (const char *progname) {fprintf (stderr, "usage: %s [-v] -p <path> [-f file]\n\n"
libselinux/utils/selinux_check_securetty_context.c +1 -1
@@ -9,7 +9,7 @@#include <sys/errno.h> #include <selinux/selinux.h> -static void usage (const char *progname) +static __attribute__ ((__noreturn__))void usage (const char *progname) {fprintf (stderr,"usage: %s tty_context...\n" , progname);exit (1 );
libselinux/utils/selinux_restorecon.c +1 -1
@@ -34,7 +34,7 @@ static int validate_context(char **contextp)return 0 ; } -static void usage (const char *progname) +static __attribute__ ((__noreturn__))void usage (const char *progname) {fprintf (stderr, "\nusage: %s [-FCnRrdmiIaAsl] [-e dir] [-v|-P]\n"
libselinux/utils/selinuxexeccon.c +1 -1
@@ -8,7 +8,7 @@#include <ctype.h> #include <selinux/selinux.h> -static void usage (const char *name,const char *detail,int rc) +static __attribute__ ((__noreturn__))void usage (const char *name,const char *detail,int rc) {fprintf (stderr,"usage: %s command [ fromcon ]\n" , name);if (detail)
libselinux/utils/setenforce.c +1 -1
@@ -6,7 +6,7 @@#include <strings.h> #include <selinux/selinux.h> -static void usage (const char *progname) +static __attribute__ ((__noreturn__))void usage (const char *progname) {fprintf (stderr,"usage: %s [ Enforcing | Permissive | 1 | 0 ]\n" , progname);
libselinux/utils/togglesebool.c +1 -1
@@ -10,7 +10,7 @@/* Attempt to rollback the transaction. No need to check error codes since this is rolling back something that blew up. */ -static void rollback (int argc,char **argv) +static __attribute__ ((__noreturn__))void rollback (int argc,char **argv) {int i;
Signature · 1 line
2.7.4
Stephen Smalley
AppliedQuoted 8 lines · On 11/01/2016 05:23 PM, [email protected] wrote:
From: William Roberts <[email protected]>
When building with clang, multiple noreturn issues arise, for instance:
selabel_partial_match.c:11:1: error: function 'usage' could be declared with attribute 'noreturn' [-Werror,-Wmissing-noreturn]
Fix these.
Thanks, applied.
Quoted 202 lines
Signed-off-by William Roberts <[email protected]>--- libselinux/utils/avcstat.c | 2 +- libselinux/utils/getconlist.c | 2 +- libselinux/utils/getdefaultcon.c | 2 +- libselinux/utils/getsebool.c | 2 +- libselinux/utils/matchpathcon.c | 2 +- libselinux/utils/selabel_digest.c | 2 +- libselinux/utils/selabel_lookup.c | 2 +- libselinux/utils/selabel_lookup_best_match.c | 2 +- libselinux/utils/selabel_partial_match.c | 2 +- libselinux/utils/selinux_check_securetty_context.c | 2 +- libselinux/utils/selinux_restorecon.c | 2 +- libselinux/utils/selinuxexeccon.c | 2 +- libselinux/utils/setenforce.c | 2 +- libselinux/utils/togglesebool.c | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-)libselinux/utils/avcstat.c +1
-1@@ -43,7 +43,7 @@ static char buf[DEF_BUF_SIZE];/* selinuxfs mount point */ extern char *selinux_mnt; -static __attribute__((__format__ (printf,1 ,2 )))void die (const char *msg, ...) +static __attribute__((__format__ (printf,1 ,2 ),__noreturn__))void die (const char *msg, ...) {va_list args;libselinux/utils/getconlist.c +1
-1@@ -9,7 +9,7 @@#include <selinux/selinux.h> #include <selinux/get_context_list.h> -static void usage (const char *name,const char *detail,int rc) +static __attribute__ ((__noreturn__))void usage (const char *name,const char *detail,int rc) {fprintf (stderr,"usage: %s [-l level] user [context]\n" , name);if (detail)libselinux/utils/getdefaultcon.c +1
-1@@ -9,7 +9,7 @@#include <selinux/selinux.h> #include <selinux/get_context_list.h> -static void usage (const char *name,const char *detail,int rc) +static __attribute__ ((__noreturn__))void usage (const char *name,const char *detail,int rc) {fprintf (stderr,"usage: %s [-l level] [-s service] user [fromcon]\n" , name);if (detail)libselinux/utils/getsebool.c +1
-1@@ -6,7 +6,7 @@#include <string.h> #include <selinux/selinux.h> -static void usage (const char *progname) +static __attribute__ ((__noreturn__))void usage (const char *progname) {fprintf (stderr,"usage: %s -a or %s boolean...\n" , progname, progname);exit (1 );libselinux/utils/matchpathcon.c +1
-1@@ -12,7 +12,7 @@#include <limits.h> #include <stdlib.h> -static void usage (const char *progname) +static __attribute__ ((__noreturn__))void usage (const char *progname) { fprintf(stderr, "usage: %s [-N] [-n] [-f file_contexts] [ -P policy_root_path ] [-p prefix] [-Vq] path...\n",libselinux/utils/selabel_digest.c +1
-1@@ -8,7 +8,7 @@static size_t digest_len; -static void usage (const char *progname) +static __attribute__ ((__noreturn__))void usage (const char *progname) {fprintf (stderr, "usage: %s -b backend [-d] [-v] [-B] [-i] [-f file]\n\n"libselinux/utils/selabel_lookup.c +1
-1@@ -6,7 +6,7 @@#include <selinux/selinux.h> #include <selinux/label.h> -static void usage (const char *progname) +static __attribute__ ((__noreturn__))void usage (const char *progname) {fprintf (stderr, "usage: %s -b backend [-v] [-r] -k key [-t type] [-f file]\n\n"libselinux/utils/selabel_lookup_best_match.c +1
-1@@ -7,7 +7,7 @@#include <selinux/selinux.h> #include <selinux/label.h> -static void usage (const char *progname) +static __attribute__ ((__noreturn__))void usage (const char *progname) {fprintf (stderr, "usage: %s [-v] [-r] -p path [-m mode] [-f file] [link...]\n\n"libselinux/utils/selabel_partial_match.c +1
-1@@ -7,7 +7,7 @@#include <selinux/selinux.h> #include <selinux/label.h> -static void usage (const char *progname) +static __attribute__ ((__noreturn__))void usage (const char *progname) {fprintf (stderr, "usage: %s [-v] -p <path> [-f file]\n\n"libselinux/utils/selinux_check_securetty_context.c +1
-1@@ -9,7 +9,7 @@#include <sys/errno.h> #include <selinux/selinux.h> -static void usage (const char *progname) +static __attribute__ ((__noreturn__))void usage (const char *progname) {fprintf (stderr,"usage: %s tty_context...\n" , progname);exit (1 );libselinux/utils/selinux_restorecon.c +1
-1@@ -34,7 +34,7 @@ static int validate_context(char **contextp)return 0 ; } -static void usage (const char *progname) +static __attribute__ ((__noreturn__))void usage (const char *progname) {fprintf (stderr, "\nusage: %s [-FCnRrdmiIaAsl] [-e dir] [-v|-P]\n"libselinux/utils/selinuxexeccon.c +1
-1@@ -8,7 +8,7 @@#include <ctype.h> #include <selinux/selinux.h> -static void usage (const char *name,const char *detail,int rc) +static __attribute__ ((__noreturn__))void usage (const char *name,const char *detail,int rc) {fprintf (stderr,"usage: %s command [ fromcon ]\n" , name);if (detail)libselinux/utils/setenforce.c +1
-1@@ -6,7 +6,7 @@#include <strings.h> #include <selinux/selinux.h> -static void usage (const char *progname) +static __attribute__ ((__noreturn__))void usage (const char *progname) {fprintf (stderr,"usage: %s [ Enforcing | Permissive | 1 | 0 ]\n" , progname);libselinux/utils/togglesebool.c +1
-1@@ -10,7 +10,7 @@/* Attempt to rollback the transaction. No need to check error codes since this is rolling back something that blew up. */ -static void rollback (int argc,char **argv) +static __attribute__ ((__noreturn__))void rollback (int argc,char **argv) {int i;