From a44b6ce0a22bfec55c5b1abbff2ac42393e8b49d Mon Sep 17 00:00:00 2001 From: Steve Beattie Date: Thu, 2 Oct 2014 12:58:54 -0700 Subject: [PATCH] C tools: rename __unused macro to unused Bug: https://bugzilla.novell.com/show_bug.cgi?id=895495 We define the __unused macro as a shortcut for __attribute__((unused)) to quiet compiler warnings for functions where an argument is unused, for whatever reason. However, on 64 bit architectures, older glibc's bits/stat.h header defines an array variable with the name __unused that collides with our macro and causes the parser to fail to build, because the resulting macro expansion generates invalid C code. This commit fixes the issue by removing the __unused macro where it's not needed (mod_apparmor) and renaming it to 'unused' elsewhere. It also in some instances reorders the arguments so that the unused macro appears last consistently. Signed-off-by: Steve Beattie Acked-by: Seth Arnold Acked-by: John Johansen Acked-by: Tyler Hicks --- changehat/mod_apparmor/mod_apparmor.c | 3 --- parser/af_rule.h | 2 +- parser/af_unix.h | 2 +- parser/dbus.h | 2 +- parser/mount.cc | 2 +- parser/mount.h | 4 ++-- parser/parser.h | 4 ++-- parser/parser_alias.c | 4 ++-- parser/parser_lex.l | 2 +- parser/parser_main.c | 6 +++--- parser/parser_misc.c | 6 +++--- parser/parser_symtab.c | 6 +++--- parser/ptrace.h | 2 +- parser/signal.h | 2 +- 14 files changed, 22 insertions(+), 25 deletions(-) diff --git a/changehat/mod_apparmor/mod_apparmor.c b/changehat/mod_apparmor/mod_apparmor.c index 743cbbea8..a5b351c8e 100644 --- a/changehat/mod_apparmor/mod_apparmor.c +++ b/changehat/mod_apparmor/mod_apparmor.c @@ -29,9 +29,6 @@ #include /* #define DEBUG */ -#ifndef __unused -#define __unused __attribute__((unused)) -#endif /* should the following be configurable? */ #define DEFAULT_HAT "HANDLING_UNTRUSTED_INPUT" diff --git a/parser/af_rule.h b/parser/af_rule.h index 3af0f6144..ef4080550 100644 --- a/parser/af_rule.h +++ b/parser/af_rule.h @@ -72,7 +72,7 @@ public: virtual ostream &dump(ostream &os); virtual int expand_variables(void); virtual int gen_policy_re(Profile &prof) = 0; - virtual void post_process(Profile &prof __unused) { }; + virtual void post_process(Profile &prof unused) { }; }; #endif /* __AA_AF_RULE_H */ diff --git a/parser/af_unix.h b/parser/af_unix.h index ca98784f3..d1d1fc8fa 100644 --- a/parser/af_unix.h +++ b/parser/af_unix.h @@ -57,7 +57,7 @@ public: virtual ostream &dump_peer(ostream &os); virtual int expand_variables(void); virtual int gen_policy_re(Profile &prof); - virtual void post_process(Profile &prof __unused) { }; + virtual void post_process(Profile &prof unused) { }; }; #endif /* __AA_AF_UNIX_H */ diff --git a/parser/dbus.h b/parser/dbus.h index e777522d0..cb113c2ec 100644 --- a/parser/dbus.h +++ b/parser/dbus.h @@ -57,7 +57,7 @@ public: virtual ostream &dump(ostream &os); virtual int expand_variables(void); virtual int gen_policy_re(Profile &prof); - virtual void post_process(Profile &prof __unused) { }; + virtual void post_process(Profile &prof unused) { }; }; diff --git a/parser/mount.cc b/parser/mount.cc index 7be2c4b2f..0f6408036 100644 --- a/parser/mount.cc +++ b/parser/mount.cc @@ -386,7 +386,7 @@ static struct value_list *extract_options(struct cond_entry **conds, int eq) } mnt_rule::mnt_rule(struct cond_entry *src_conds, char *device_p, - struct cond_entry *dst_conds __unused, char *mnt_point_p, + struct cond_entry *dst_conds unused, char *mnt_point_p, int allow_p): mnt_point(mnt_point_p), device(device_p), trans(NULL), opts(NULL), flags(0), inv_flags(0), audit(0), deny(0) diff --git a/parser/mount.h b/parser/mount.h index 0331da8be..04873cfab 100644 --- a/parser/mount.h +++ b/parser/mount.h @@ -127,7 +127,7 @@ public: int deny; mnt_rule(struct cond_entry *src_conds, char *device_p, - struct cond_entry *dst_conds __unused, char *mnt_point_p, + struct cond_entry *dst_conds unused, char *mnt_point_p, int allow_p); virtual ~mnt_rule() { @@ -141,7 +141,7 @@ public: virtual ostream &dump(ostream &os); virtual int expand_variables(void); virtual int gen_policy_re(Profile &prof); - virtual void post_process(Profile &prof __unused); + virtual void post_process(Profile &prof unused); }; int is_valid_mnt_cond(const char *name, int src); diff --git a/parser/parser.h b/parser/parser.h index cfeb39f7f..d4d97a236 100644 --- a/parser/parser.h +++ b/parser/parser.h @@ -183,8 +183,8 @@ extern int preprocess_only; #define MIN_PORT 0 #define MAX_PORT 65535 -#ifndef __unused -#define __unused __attribute__ ((unused)) +#ifndef unused +#define unused __attribute__ ((unused)) #endif diff --git a/parser/parser_alias.c b/parser/parser_alias.c index 381ea4cfb..f5b6da4ee 100644 --- a/parser/parser_alias.c +++ b/parser/parser_alias.c @@ -106,7 +106,7 @@ static char *do_alias(struct alias_rule *alias, const char *target) static Profile *target_prof; static struct cod_entry *target_list; -static void process_entries(const void *nodep, VISIT value, int __unused level) +static void process_entries(const void *nodep, VISIT value, int level unused) { struct alias_rule **t = (struct alias_rule **) nodep; struct cod_entry *entry, *dup = NULL; @@ -150,7 +150,7 @@ static void process_entries(const void *nodep, VISIT value, int __unused level) } } -static void process_name(const void *nodep, VISIT value, int __unused level) +static void process_name(const void *nodep, VISIT value, int level unused) { struct alias_rule **t = (struct alias_rule **) nodep; Profile *prof = target_prof; diff --git a/parser/parser_lex.l b/parser/parser_lex.l index 499ba7cab..0b0be2265 100644 --- a/parser/parser_lex.l +++ b/parser/parser_lex.l @@ -119,7 +119,7 @@ struct cb_struct { const char *filename; }; -static int include_dir_cb(__unused DIR *dir, const char *name, struct stat *st, +static int include_dir_cb(DIR *dir unused, const char *name, struct stat *st, void *data) { struct cb_struct *d = (struct cb_struct *) data; diff --git a/parser/parser_main.c b/parser/parser_main.c index fbc087f0a..a7d94e15f 100644 --- a/parser/parser_main.c +++ b/parser/parser_main.c @@ -1026,7 +1026,7 @@ out: } /* data - name of parent dir */ -static int profile_dir_cb(__unused DIR *dir, const char *name, struct stat *st, +static int profile_dir_cb(DIR *dir unused, const char *name, struct stat *st, void *data) { int rc = 0; @@ -1043,7 +1043,7 @@ static int profile_dir_cb(__unused DIR *dir, const char *name, struct stat *st, } /* data - name of parent dir */ -static int binary_dir_cb(__unused DIR *dir, const char *name, struct stat *st, +static int binary_dir_cb(DIR *dir unused, const char *name, struct stat *st, void *data) { int rc = 0; @@ -1060,7 +1060,7 @@ static int binary_dir_cb(__unused DIR *dir, const char *name, struct stat *st, } static int clear_cache_cb(DIR *dir, const char *path, struct stat *st, - __unused void *data) + void *data unused) { /* remove regular files */ if (S_ISREG(st->st_mode)) diff --git a/parser/parser_misc.c b/parser/parser_misc.c index ec3c29904..97a2103de 100644 --- a/parser/parser_misc.c +++ b/parser/parser_misc.c @@ -183,7 +183,7 @@ static struct keyword_table rlimit_table[] = { }; /* for alpha matches, check for keywords */ -static int get_table_token(const char *name __unused, struct keyword_table *table, +static int get_table_token(const char *name unused, struct keyword_table *table, const char *keyword) { int i; @@ -342,7 +342,7 @@ void warn_uppercase(void) } } -static int parse_sub_mode(const char *str_mode, const char *mode_desc __unused) +static int parse_sub_mode(const char *str_mode, const char *mode_desc unused) { #define IS_DIFF_QUAL(mode, q) (((mode) & AA_MAY_EXEC) && (((mode) & AA_EXEC_TYPE) != ((q) & AA_EXEC_TYPE))) @@ -529,7 +529,7 @@ int parse_mode(const char *str_mode) return mode; } -static int parse_X_sub_mode(const char *X, const char *str_mode, int *result, int fail, const char *mode_desc __unused) +static int parse_X_sub_mode(const char *X, const char *str_mode, int *result, int fail, const char *mode_desc unused) { int mode = 0; const char *p; diff --git a/parser/parser_symtab.c b/parser/parser_symtab.c index 1484c927d..3e667d87a 100644 --- a/parser/parser_symtab.c +++ b/parser/parser_symtab.c @@ -495,7 +495,7 @@ out: return retval; } -static void expand_variable(const void *nodep, VISIT value, int __unused level) +static void expand_variable(const void *nodep, VISIT value, int level unused) { struct symtab **t = (struct symtab **) nodep; @@ -547,7 +547,7 @@ static void __dump_symtab_entry(struct symtab *entry, int do_expanded) } } -static void dump_symtab_entry(const void *nodep, VISIT value, int __unused level) +static void dump_symtab_entry(const void *nodep, VISIT value, int level unused) { struct symtab **t = (struct symtab **) nodep; @@ -557,7 +557,7 @@ static void dump_symtab_entry(const void *nodep, VISIT value, int __unused level __dump_symtab_entry(*t, 0); } -static void dump_expanded_symtab_entry(const void *nodep, VISIT value, int __unused level) +static void dump_expanded_symtab_entry(const void *nodep, VISIT value, int level unused) { struct symtab **t = (struct symtab **) nodep; diff --git a/parser/ptrace.h b/parser/ptrace.h index bbcf1eaf1..315d9214b 100644 --- a/parser/ptrace.h +++ b/parser/ptrace.h @@ -46,7 +46,7 @@ public: virtual ostream &dump(ostream &os); virtual int expand_variables(void); virtual int gen_policy_re(Profile &prof); - virtual void post_process(Profile &prof __unused) { }; + virtual void post_process(Profile &prof unused) { }; }; #endif /* __AA_PTRACE_H */ diff --git a/parser/signal.h b/parser/signal.h index afdb10057..f79a3d02f 100644 --- a/parser/signal.h +++ b/parser/signal.h @@ -52,7 +52,7 @@ public: virtual ostream &dump(ostream &os); virtual int expand_variables(void); virtual int gen_policy_re(Profile &prof); - virtual void post_process(Profile &prof __unused) { }; + virtual void post_process(Profile &prof unused) { }; }; #endif /* __AA_SIGNAL_H */