]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/, src/: Rename 'unused' macro as 'MAYBE_UNUSED'
authorPablo Saavedra <psaavedra@igalia.com>
Mon, 22 Jan 2024 09:00:54 +0000 (10:00 +0100)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Tue, 30 Jan 2024 15:19:56 +0000 (16:19 +0100)
Related-To: https://github.com/shadow-maint/shadow/issues/918
Suggested-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Pablo Saavedra <psaavedra@igalia.com>
20 files changed:
lib/attr.h
lib/audit_help.c
lib/cleanup_group.c
lib/cleanup_user.c
lib/copydir.c
lib/getdate.y
lib/logind.c
lib/loginprompt.c
lib/obscure.c
lib/pam_pass_non_interactive.c
lib/prototypes.h
lib/pwdcheck.c
lib/semanage.c
src/expiry.c
src/gpasswd.c
src/grpconv.c
src/grpunconv.c
src/login.c
src/su.c
src/sulogin.c

index 8b0dd26caf6973874fe6859d738193c7c5425c2a..3835848ddf483eabd4d5c99588506cc7b281ddff 100644 (file)
@@ -6,12 +6,12 @@
 
 
 #if defined(__GNUC__)
-# define unused                      __attribute__((unused))
+# define MAYBE_UNUSED                __attribute__((unused))
 # define NORETURN                    __attribute__((__noreturn__))
 # define format_attr(type, fmt, va)  __attribute__((format(type, fmt, va)))
 # define ATTR_ACCESS(...)            __attribute__((access(__VA_ARGS__)))
 #else
-# define unused
+# define MAYBE_UNUSED
 # define NORETURN
 # define format_attr(type, fmt, va)
 # define ATTR_ACCESS(...)
index 060814399bf4bb22b477b9dac2f41f9491f7346c..54109f04ff1da146bb9747e27ec95ced14796510 100644 (file)
@@ -56,7 +56,7 @@ void audit_help_open (void)
  * id  -  uid or gid that the operation is being performed on. This is used
  *       only when user is NULL.
  */
-void audit_logger (int type, unused const char *pgname, const char *op,
+void audit_logger (int type, MAYBE_UNUSED const char *pgname, const char *op,
                    const char *name, unsigned int id,
                    shadow_audit_result result)
 {
index 5da38de471c1aff21cf41811f8518f0c51302c50..50c7084ac79b0383218e1e9ca18d107a0e1fea09 100644 (file)
@@ -179,7 +179,7 @@ void cleanup_report_del_group_gshadow (void *group_name)
  *
  * It should be registered after the group file is successfully locked.
  */
-void cleanup_unlock_group (unused void *arg)
+void cleanup_unlock_group (MAYBE_UNUSED void *arg)
 {
        if (gr_unlock () == 0) {
                fprintf (log_get_logfd(),
@@ -199,7 +199,7 @@ void cleanup_unlock_group (unused void *arg)
  *
  * It should be registered after the gshadow file is successfully locked.
  */
-void cleanup_unlock_gshadow (unused void *arg)
+void cleanup_unlock_gshadow (MAYBE_UNUSED void *arg)
 {
        if (sgr_unlock () == 0) {
                fprintf (log_get_logfd(),
index ec8681ee58b03a9d8f09a1a299ee36da6bbd7a11..9c4bda9cae4de10ca79e4b5352454fa8cc6dd4c2 100644 (file)
@@ -96,7 +96,7 @@ void cleanup_report_add_user_shadow (void *user_name)
  *
  * It should be registered after the passwd database is successfully locked.
  */
-void cleanup_unlock_passwd (unused void *arg)
+void cleanup_unlock_passwd (MAYBE_UNUSED void *arg)
 {
        if (pw_unlock () == 0) {
                fprintf (log_get_logfd(),
@@ -115,7 +115,7 @@ void cleanup_unlock_passwd (unused void *arg)
  *
  * It should be registered after the shadow database is successfully locked.
  */
-void cleanup_unlock_shadow (unused void *arg)
+void cleanup_unlock_shadow (MAYBE_UNUSED void *arg)
 {
        if (spw_unlock () == 0) {
                fprintf (log_get_logfd(),
index d61902524841f8d6bcdf034e90ed462f4ffd6a02..3a22738fc414c8b04cb8295043b02e9c0ad3caa9 100644 (file)
@@ -68,12 +68,12 @@ static int copy_dir (const struct path_info *src, const struct path_info *dst,
                      gid_t old_gid, gid_t new_gid);
 static /*@null@*/char *readlink_malloc (const char *filename);
 static int copy_symlink (const struct path_info *src, const struct path_info *dst,
-                         unused bool reset_selinux,
+                         MAYBE_UNUSED bool reset_selinux,
                          const struct stat *statp, const struct timespec mt[],
                          uid_t old_uid, uid_t new_uid,
                          gid_t old_gid, gid_t new_gid);
 static int copy_hardlink (const struct path_info *dst,
-                          unused bool reset_selinux,
+                          MAYBE_UNUSED bool reset_selinux,
                           struct link_name *lp);
 static int copy_special (const struct path_info *src, const struct path_info *dst,
                          bool reset_selinux,
@@ -97,7 +97,7 @@ static int fchown_if_needed (int fdst, const struct stat *statp,
  * error_acl - format the error messages for the ACL and EQ libraries.
  */
 format_attr(printf, 2, 3)
-static void error_acl (unused struct error_context *ctx, const char *fmt, ...)
+static void error_acl (MAYBE_UNUSED struct error_context *ctx, const char *fmt, ...)
 {
        va_list ap;
        FILE *shadow_logfd = log_get_logfd();
@@ -582,7 +582,7 @@ static /*@null@*/char *readlink_malloc (const char *filename)
  *     Return 0 on success, -1 on error.
  */
 static int copy_symlink (const struct path_info *src, const struct path_info *dst,
-                         unused bool reset_selinux,
+                         MAYBE_UNUSED bool reset_selinux,
                          const struct stat *statp, const struct timespec mt[],
                          uid_t old_uid, uid_t new_uid,
                          gid_t old_gid, gid_t new_gid)
@@ -654,7 +654,7 @@ static int copy_symlink (const struct path_info *src, const struct path_info *ds
  *     Return 0 on success, -1 on error.
  */
 static int copy_hardlink (const struct path_info *dst,
-                          unused bool reset_selinux,
+                          MAYBE_UNUSED bool reset_selinux,
                           struct link_name *lp)
 {
        /* FIXME: selinux, ACL, Extended Attributes needed? */
index 59d8ffbbcf728f3ba12955fc8f1f753bf5aeb482..cb7d0e8b95cce3ef9351c0e321460f2eab1d68de 100644 (file)
@@ -570,7 +570,7 @@ static TABLE const MilitaryTable[] = {
 \f
 
 
-static int yyerror (unused const char *s)
+static int yyerror (MAYBE_UNUSED const char *s)
 {
   return 0;
 }
index c73ebccc62bdae713d44bb5488766f771a7f4a93..88f433148bac9651d14d1bdfa7ff0a4ad35ae6df 100644 (file)
@@ -36,7 +36,7 @@ done:
     return ret;
 }
 
-unsigned long active_sessions_count(const char *name, unsigned long unused(limit))
+unsigned long active_sessions_count(const char *name, unsigned long MAYBE_UNUSED(limit))
 {
     struct passwd *pw;
     unsigned long count = 0;
index 2adea200d2754a334c27f3d1d179f49fb2b54a33..9b2aa25c2d1d37d010db4e89e47a470d7df36fc1 100644 (file)
@@ -22,7 +22,7 @@
 #include "defines.h"
 #include "getdef.h"
 
-static void login_exit (unused int sig)
+static void login_exit (MAYBE_UNUSED int sig)
 {
        _exit (EXIT_FAILURE);
 }
index 21e20031a435c0c98b22e98bb3d4bbdac7b9d790..549c2a8dfaddd14bf842304bca2392eba98eedbb 100644 (file)
@@ -29,7 +29,7 @@
 /*
  * can't be a palindrome - like `R A D A R' or `M A D A M'
  */
-static bool palindrome (unused const char *old, const char *new)
+static bool palindrome (MAYBE_UNUSED const char *old, const char *new)
 {
        size_t i, j;
 
@@ -88,7 +88,7 @@ static char *str_lower (/*@returned@*/char *string)
 static /*@observer@*//*@null@*/const char *password_check (
        /*@notnull@*/const char *old,
        /*@notnull@*/const char *new,
-       /*@notnull@*/unused const struct passwd *pwdp)
+       /*@notnull@*/MAYBE_UNUSED const struct passwd *pwdp)
 {
        const char *msg = NULL;
        char *oldmono, *newmono, *wrapped;
index 6e21e76fbea4910330cac78537b31619dd0b9dc9..12dad4dd1ef8d4c6275d61ee95ce20985bf61537 100644 (file)
@@ -26,7 +26,7 @@
 static int ni_conv (int num_msg,
                     const struct pam_message **msg,
                     struct pam_response **resp,
-                    unused void *appdata_ptr);
+                    MAYBE_UNUSED void *appdata_ptr);
 static const struct pam_conv non_interactive_pam_conv = {
        ni_conv,
        NULL
@@ -37,7 +37,7 @@ static const struct pam_conv non_interactive_pam_conv = {
 static int ni_conv (int num_msg,
                     const struct pam_message **msg,
                     struct pam_response **resp,
-                    unused void *appdata_ptr)
+                    MAYBE_UNUSED void *appdata_ptr)
 {
        struct pam_response *responses;
        int count;
index 6aa48e9b0eb9d2c37e35b4dab9a4b87fd6b41f41..2fb38cd06691a384778d81eb7d6780bc037829af 100644 (file)
@@ -92,11 +92,11 @@ void cleanup_report_del_group_gshadow (void *group_name);
 void cleanup_report_mod_passwd (void *cleanup_info);
 void cleanup_report_mod_group (void *cleanup_info);
 void cleanup_report_mod_gshadow (void *cleanup_info);
-void cleanup_unlock_group (/*@null@*/void *unused);
+void cleanup_unlock_group (/*@null@*/void *MAYBE_UNUSED);
 #ifdef SHADOWGRP
-void cleanup_unlock_gshadow (/*@null@*/void *unused);
+void cleanup_unlock_gshadow (/*@null@*/void *MAYBE_UNUSED);
 #endif
-void cleanup_unlock_passwd (/*@null@*/void *unused);
+void cleanup_unlock_passwd (/*@null@*/void *MAYBE_UNUSED);
 
 /* console.c */
 extern bool console (const char *);
index e343fdafe011167c29913d43cba5df2c64943498..93c9f5ced42cd0f63152b5228a83ff569ca19103 100644 (file)
@@ -20,7 +20,7 @@
 #include "pwauth.h"
 #include "shadowlog.h"
 
-void passwd_check (const char *user, const char *passwd, unused const char *progname)
+void passwd_check (const char *user, const char *passwd, MAYBE_UNUSED const char *progname)
 {
        struct spwd *sp;
 
index 742cf1124ba1f48710bce9e2fee0b53cbbd800d2..277e20ec4cdb2cacba13240533778fa16166831c 100644 (file)
@@ -28,7 +28,7 @@
 
 
 format_attr(printf, 3, 4)
-static void semanage_error_callback (unused void *varg,
+static void semanage_error_callback (MAYBE_UNUSED void *varg,
                                      semanage_handle_t *handle,
                                      const char *fmt, ...)
 {
index acccc2c8b4ed92c00be82e7a62ebcb1096c49401..16f63dcc2e0987e35136c1cce0b7584b76db4fce 100644 (file)
@@ -29,14 +29,14 @@ const char *Prog;
 static bool cflg = false;
 
 /* local function prototypes */
-static void catch_signals (unused int sig);
+static void catch_signals (MAYBE_UNUSED int sig);
 NORETURN static void usage (int status);
 static void process_flags (int argc, char **argv);
 
 /*
  * catch_signals - signal catcher
  */
-static void catch_signals (unused int sig)
+static void catch_signals (MAYBE_UNUSED int sig)
 {
        _exit (10);
 }
index 15606eff5a8d3a997a5989f604f4db6f9156d8f3..0fd513e69dff1e3fc44eb9819df371a7e1be9b3b 100644 (file)
@@ -101,14 +101,14 @@ static void update_group (struct group *gr);
 static void change_passwd (struct group *gr);
 #endif
 static void log_gpasswd_failure (const char *suffix);
-static void log_gpasswd_failure_system (/*@null@*/unused void *arg);
-static void log_gpasswd_failure_group (/*@null@*/unused void *arg);
+static void log_gpasswd_failure_system (/*@null@*/MAYBE_UNUSED void *arg);
+static void log_gpasswd_failure_group (/*@null@*/MAYBE_UNUSED void *arg);
 #ifdef SHADOWGRP
-static void log_gpasswd_failure_gshadow (/*@null@*/unused void *arg);
+static void log_gpasswd_failure_gshadow (/*@null@*/MAYBE_UNUSED void *arg);
 #endif
 static void log_gpasswd_success (const char *suffix);
-static void log_gpasswd_success_system (/*@null@*/unused void *arg);
-static void log_gpasswd_success_group (/*@null@*/unused void *arg);
+static void log_gpasswd_success_system (/*@null@*/MAYBE_UNUSED void *arg);
+static void log_gpasswd_success_group (/*@null@*/MAYBE_UNUSED void *arg);
 
 /*
  * usage - display usage message
@@ -480,12 +480,12 @@ static void log_gpasswd_failure (const char *suffix)
        }
 }
 
-static void log_gpasswd_failure_system (unused void *arg)
+static void log_gpasswd_failure_system (MAYBE_UNUSED void *arg)
 {
        log_gpasswd_failure ("");
 }
 
-static void log_gpasswd_failure_group (unused void *arg)
+static void log_gpasswd_failure_group (MAYBE_UNUSED void *arg)
 {
        char  buf[1024];
 
@@ -494,7 +494,7 @@ static void log_gpasswd_failure_group (unused void *arg)
 }
 
 #ifdef SHADOWGRP
-static void log_gpasswd_failure_gshadow (unused void *arg)
+static void log_gpasswd_failure_gshadow (MAYBE_UNUSED void *arg)
 {
        char  buf[1024];
 
@@ -601,12 +601,12 @@ static void log_gpasswd_success (const char *suffix)
        }
 }
 
-static void log_gpasswd_success_system (unused void *arg)
+static void log_gpasswd_success_system (MAYBE_UNUSED void *arg)
 {
        log_gpasswd_success ("");
 }
 
-static void log_gpasswd_success_group (unused void *arg)
+static void log_gpasswd_success_group (MAYBE_UNUSED void *arg)
 {
        char  buf[1024];
 
index f60cae0fb050d379e4bae1edc02b36fcce8126b7..2bed145e000319f8c11093ff76e268e70fc5f0d9 100644 (file)
@@ -262,7 +262,7 @@ int main (int argc, char **argv)
        return 0;
 }
 #else                          /* !SHADOWGRP */
-int main (int unused(argc), char **argv)
+int main (int MAYBE_UNUSED(argc), char **argv)
 {
        fprintf (stderr,
                 "%s: not configured for shadow group support.\n", argv[0]);
index 418245e1adb8b27bcbf549741377283d84a7becd..7932088966a79419359035a3e9e86e66e2c9b72d 100644 (file)
@@ -224,7 +224,7 @@ int main (int argc, char **argv)
        return 0;
 }
 #else                          /* !SHADOWGRP */
-int main (int unused(argc), char **argv)
+int main (int MAYBE_UNUSED(argc), char **argv)
 {
        fprintf (stderr,
                 "%s: not configured for shadow group support.\n", argv[0]);
index 1317b8d7f799863428f8411d1c66d8ac7fdf39e8..77c58d4eeaf67696dbfec7e5bbaaa68dc9f230a8 100644 (file)
@@ -397,12 +397,12 @@ static void init_env (void)
 #endif                         /* !USE_PAM */
 }
 
-static void exit_handler (unused int sig)
+static void exit_handler (MAYBE_UNUSED int sig)
 {
        _exit (0);
 }
 
-static void alarm_handler (unused int sig)
+static void alarm_handler (MAYBE_UNUSED int sig)
 {
        write_full(STDERR_FILENO, tmsg, strlen(tmsg));
        signal(SIGALRM, exit_handler);
index 07f0eea1916ad8791dc3e49eae219d3c660374ce..9639c78bf9de9c153321a5521504f0c0488eea1f 100644 (file)
--- a/src/su.c
+++ b/src/su.c
@@ -111,7 +111,7 @@ static void execve_shell (const char *shellname,
                           char *args[],
                           char *const envp[]);
 #ifdef USE_PAM
-static void kill_child (int unused(s));
+static void kill_child (int MAYBE_UNUSED(s));
 static void prepare_pam_close_session (void);
 #else                          /* !USE_PAM */
 static void die (int);
@@ -165,7 +165,7 @@ static bool iswheel (const char *username)
        return is_on_list (grp->gr_mem, username);
 }
 #else                          /* USE_PAM */
-static void kill_child (int unused(s))
+static void kill_child (int MAYBE_UNUSED(s))
 {
        if (0 != pid_child) {
                (void) kill (-pid_child, SIGKILL);
index c21f425dc4168d3f4995f09779453ff1c670ec2f..2ef00b6dfc78526f38a038f9d4deaf37da171ea9 100644 (file)
@@ -50,7 +50,7 @@ static void catch_signals (int);
 static int pw_entry(const char *name, struct passwd *pwent);
 
 
-static void catch_signals (unused int sig)
+static void catch_signals (MAYBE_UNUSED int sig)
 {
        _exit (1);
 }