]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
Do not drop const qualifier for Basename
authorChristian Göttsche <cgzones@googlemail.com>
Mon, 3 Jan 2022 11:17:22 +0000 (12:17 +0100)
committerChristian Göttsche <cgzones@googlemail.com>
Mon, 3 Jan 2022 14:09:17 +0000 (15:09 +0100)
The private Basename() implementation does not modify its argument, so
a cast to a non-const char pointer is not necessary.

newgrp.c:790:39: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
  790 |         progbase = (char *) Basename ((char *) prog);
      |                                       ^
newgrp.c:790:20: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
  790 |         progbase = (char *) Basename ((char *) prog);
      |                    ^

shell.c:48:70: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
   48 |                 (void) snprintf (arg0, sizeof arg0, "-%s", Basename ((char *) file));
      |                                                                      ^

libmisc/shell.c
src/newgrp.c

index 297240639e429368665486cc635f4505a8aeb8ce..7c67500d0e73ef6f42518b214d8a4183307bf536 100644 (file)
@@ -45,7 +45,7 @@ int shell (const char *file, /*@null@*/const char *arg, char *const envp[])
         * don't want to tell us what it is themselves.
         */
        if (arg == (char *) 0) {
-               (void) snprintf (arg0, sizeof arg0, "-%s", Basename ((char *) file));
+               (void) snprintf (arg0, sizeof arg0, "-%s", Basename (file));
                arg0[sizeof arg0 - 1] = '\0';
                arg = arg0;
        }
index cb88f6d7e27212f293e199d2dc51ac0117dfc25a..9982083214427d5dced19470875fcf214128787c 100644 (file)
@@ -379,7 +379,7 @@ int main (int argc, char **argv)
        int err = 0;
        gid_t gid;
        char *cp;
-       char *progbase;
+       const char *progbase;
        const char *name, *prog;
        char *group = NULL;
        char *command = NULL;
@@ -787,7 +787,7 @@ int main (int argc, char **argv)
         * Now I try to find the basename of the login shell. This will
         * become argv[0] of the spawned command.
         */
-       progbase = (char *) Basename ((char *) prog);
+       progbase = Basename (prog);
 
        /*
         * Switch back to her home directory if i am doing login