]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
cast NULL to char * when using execl
authorEgor Chelak <egor.chelak@gmail.com>
Thu, 29 Oct 2020 17:49:07 +0000 (19:49 +0200)
committerEgor Chelak <egor.chelak@gmail.com>
Thu, 29 Oct 2020 17:49:07 +0000 (19:49 +0200)
When calling variadic functions, NULL must be explicitly cast to a
desired type.
This is noted in the exec(3) manpage.

The call in newgrp.c was changed for consistency.

Signed-off-by: Egor Chelak <egor.chelak@gmail.com>
lib/exec_shell.c
lib/pty-session.c
login-utils/newgrp.c
login-utils/sulogin.c
login-utils/vipw.c
sys-utils/eject.c
sys-utils/setarch.c
term-utils/script.c
term-utils/scriptlive.c
text-utils/pg.c

index 18798ebe4e2ffd73f53ea7d50e55a64aa5488ffc..6fef6c7a326dbe5a2b2c3ec74148152afd4c1af9 100644 (file)
@@ -46,6 +46,6 @@ void __attribute__((__noreturn__)) exec_shell(void)
        arg0[0] = '-';
        strcpy(arg0 + 1, shell_basename);
 
-       execl(shell, arg0, NULL);
+       execl(shell, arg0, (char *)NULL);
        errexec(shell);
 }
index 6d8ba4eb792529ae3e3350229b5dfd4c298fe8eb..f4bb0045a225521879999130216437b075670890 100644 (file)
@@ -699,9 +699,9 @@ int main(int argc, char *argv[])
                shname = shname ? shname + 1 : shell;
 
                if (command)
-                       execl(shell, shname, "-c", command, NULL);
+                       execl(shell, shname, "-c", command, (char *)NULL);
                else
-                       execl(shell, shname, "-i", NULL);
+                       execl(shell, shname, "-i", (char *)NULL);
                err(EXIT_FAILURE, "failed to execute %s", shell);
                break;
 
index 5e4b4caa025ebfe2f301b3fa1f2b3513047c3177..2c0aab114295c206fc2a5c16a1eecd2b53de8a12 100644 (file)
@@ -234,6 +234,6 @@ int main(int argc, char *argv[])
        fflush(NULL);
        shell = (pw_entry->pw_shell && *pw_entry->pw_shell ?
                                pw_entry->pw_shell : _PATH_BSHELL);
-       execl(shell, shell, (char *)0);
+       execl(shell, shell, (char *)NULL);
        errexec(shell);
 }
index 9091caf14ff23dd63d47647974a9b76463463f59..bac2754cadd966ce248a68d652a357091c9c08e4 100644 (file)
@@ -789,11 +789,11 @@ static void sushell(struct passwd *pwd)
                free(level);
        }
 #endif
-       execl(su_shell, shell, NULL);
+       execl(su_shell, shell, (char *)NULL);
        warn(_("failed to execute %s"), su_shell);
 
        xsetenv("SHELL", "/bin/sh", 1);
-       execl("/bin/sh", profile ? "-sh" : "sh", NULL);
+       execl("/bin/sh", profile ? "-sh" : "sh", (char *)NULL);
        warn(_("failed to execute %s"), "/bin/sh");
 }
 
index a071b639dd03e1926c07405941de64479bd62a8e..3a205f0a780fbc41f80602bce36e41a00c6e9daf 100644 (file)
@@ -208,7 +208,7 @@ static void pw_edit(void)
                err(EXIT_FAILURE, _("fork failed"));
 
        if (!pid) {
-               execlp(editor, p, tmp_file, NULL);
+               execlp(editor, p, tmp_file, (char *)NULL);
                errexec(editor);
        }
        for (;;) {
index fa85243b0f3af2d12dd9f6c769df9c0a9a2cf506..e0f540e9d8751638500dc76ac6a1211560c090c1 100644 (file)
@@ -663,9 +663,9 @@ static void umount_one(const struct eject_control *ctl, const char *name)
                        err(EXIT_FAILURE, _("cannot set user id"));
 
                if (ctl->p_option)
-                       execl("/bin/umount", "/bin/umount", name, "-n", NULL);
+                       execl("/bin/umount", "/bin/umount", name, "-n", (char *)NULL);
                else
-                       execl("/bin/umount", "/bin/umount", name, NULL);
+                       execl("/bin/umount", "/bin/umount", name, (char *)NULL);
 
                errexec("/bin/umount");
 
index 6914d791b446bb98c777fffbf17ef3d3d0ea5aad..b86be1e29da1d3d8c4d1302fd68f53690acd01e5 100644 (file)
@@ -469,7 +469,7 @@ set_arch:
 
        /* Execute shell */
        if (shell) {
-               execl(shell, shell_arg, NULL);
+               execl(shell, shell_arg, (char *)NULL);
                errexec(shell);
        }
 
index e9daaf00b789b89dce468fb32a2b3e3d95a70aef..eca63f7f49659ed27db33fda551d7d03a7437ecb 100644 (file)
@@ -967,14 +967,14 @@ int main(int argc, char **argv)
 
                if (access(shell, X_OK) == 0) {
                        if (command)
-                               execl(shell, shname, "-c", command, NULL);
+                               execl(shell, shname, "-c", command, (char *)NULL);
                        else
-                               execl(shell, shname, "-i", NULL);
+                               execl(shell, shname, "-i", (char *)NULL);
                } else {
                        if (command)
-                               execlp(shname, "-c", command, NULL);
+                               execlp(shname, "-c", command, (char *)NULL);
                        else
-                               execlp(shname, "-i", NULL);
+                               execlp(shname, "-i", (char *)NULL);
                }
 
                err(EXIT_FAILURE, "failed to execute %s", shell);
index ee2573a72b5fb0d2735ddec54cc76daaf407c3b6..ac75588cd5eeeb35349db46f5f02bf566c69ec2b 100644 (file)
@@ -316,14 +316,14 @@ main(int argc, char *argv[])
 
                if (access(shell, X_OK) == 0) {
                        if (command)
-                               execl(shell, shname, "-c", command, NULL);
+                               execl(shell, shname, "-c", command, (char *)NULL);
                        else
-                               execl(shell, shname, "-i", NULL);
+                               execl(shell, shname, "-i", (char *)NULL);
                } else {
                        if (command)
-                               execlp(shname, "-c", command, NULL);
+                               execlp(shname, "-c", command, (char *)NULL);
                        else
-                               execlp(shname, "-i", NULL);
+                               execlp(shname, "-i", (char *)NULL);
                }
                err(EXIT_FAILURE, "failed to execute %s", shell);
                break;
index fba77007184b8224e435513be539ebb3282db1a3..9da0070c513c6ad74631e5595ac990e0ac0304f4 100644 (file)
@@ -1382,7 +1382,7 @@ static void pgfile(FILE *f, const char *name)
                                                my_sigset(SIGQUIT, oldquit);
                                                my_sigset(SIGTERM, oldterm);
                                                execl(sh, sh, "-c",
-                                                     cmd.cmdline + 1, NULL);
+                                                     cmd.cmdline + 1, (char *)NULL);
                                                errexec(sh);
                                                break;
                                        }