* [PATCH 1/3] a pointer should not be compared to zero [coccinelle] @ 2013-01-30 20:33 Sami Kerola 2013-01-30 20:33 ` [PATCH 2/3] translation: unify exec error messages Sami Kerola ` (2 more replies) 0 siblings, 3 replies; 9+ messages in thread From: Sami Kerola @ 2013-01-30 20:33 UTC (permalink / raw) To: util-linux; +Cc: kerolasa Signed-off-by: Sami Kerola <kerolasa@iki.fi> --- lib/ismounted.c | 2 +- libblkid/src/devno.c | 2 +- misc-utils/whereis.c | 6 +++--- mount-deprecated/mount.c | 2 +- term-utils/agetty.c | 4 ++-- text-utils/more.c | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/ismounted.c b/lib/ismounted.c index 5611ab3..d9f1f57 100644 --- a/lib/ismounted.c +++ b/lib/ismounted.c @@ -91,7 +91,7 @@ static int check_mntent_file(const char *mtab_file, const char *file, } } - if (mnt == 0) { + if (mnt == NULL) { #ifndef __GNU__ /* The GNU hurd is broken with respect to stat devices */ /* * Do an extra check to see if this is the root device. We diff --git a/libblkid/src/devno.c b/libblkid/src/devno.c index c549035..906c91f 100644 --- a/libblkid/src/devno.c +++ b/libblkid/src/devno.c @@ -115,7 +115,7 @@ void blkid__scan_dir(char *dirname, dev_t devno, struct dir_list **list, if ((dir = opendir(dirname)) == NULL) return; - while ((dp = readdir(dir)) != 0) { + while ((dp = readdir(dir)) != NULL) { #ifdef _DIRENT_HAVE_D_TYPE if (dp->d_type != DT_UNKNOWN && dp->d_type != DT_BLK && dp->d_type != DT_LNK && dp->d_type != DT_DIR) diff --git a/misc-utils/whereis.c b/misc-utils/whereis.c index 3528d62..b85320b 100644 --- a/misc-utils/whereis.c +++ b/misc-utils/whereis.c @@ -304,7 +304,7 @@ findv(char **dirv, int dirc, char *cp) static void looksrc(char *cp) { - if (Sflag == 0) + if (Sflag == NULL) findv(srcdirs, ARRAY_SIZE(srcdirs)-1, cp); else findv(Sflag, Scnt, cp); @@ -313,7 +313,7 @@ looksrc(char *cp) static void lookbin(char *cp) { - if (Bflag == 0) { + if (Bflag == NULL) { findv(bindirs, ARRAY_SIZE(bindirs)-1, cp); while (*pathdir_p) findin(*pathdir_p++, cp); /* look $PATH */ @@ -324,7 +324,7 @@ lookbin(char *cp) static void lookman(char *cp) { - if (Mflag == 0) + if (Mflag == NULL) findv(mandirs, ARRAY_SIZE(mandirs)-1, cp); else findv(Mflag, Mcnt, cp); diff --git a/mount-deprecated/mount.c b/mount-deprecated/mount.c index 3190d2f..5031683 100644 --- a/mount-deprecated/mount.c +++ b/mount-deprecated/mount.c @@ -1668,7 +1668,7 @@ try_mount_one (const char *spec0, const char *node0, const char *types0, /* Mount failed, complain, but don't die. */ - if (types == 0) { + if (types == NULL) { if (restricted) error (_("mount: I could not determine the filesystem type, " "and none was specified")); diff --git a/term-utils/agetty.c b/term-utils/agetty.c index aee853c..104ea18 100644 --- a/term-utils/agetty.c +++ b/term-utils/agetty.c @@ -358,7 +358,7 @@ int main(int argc, char **argv) /* Read the login name. */ debug("reading login name\n"); while ((username = - get_logname(&options, &termios, &chardata)) == 0) + get_logname(&options, &termios, &chardata)) == NULL) if ((options.flags & F_VCONSOLE) == 0) next_speed(&options, &termios); } @@ -747,7 +747,7 @@ static void parse_speeds(struct options *op, char *arg) char *cp; debug("entered parse_speeds\n"); - for (cp = strtok(arg, ","); cp != 0; cp = strtok((char *)0, ",")) { + for (cp = strtok(arg, ","); cp != NULL; cp = strtok((char *)0, ",")) { if ((op->speeds[op->numspeed++] = bcode(cp)) <= 0) log_err(_("bad speed: %s"), cp); if (op->numspeed >= MAX_SPEED) diff --git a/text-utils/more.c b/text-utils/more.c index 2c97950..7d1aeee 100644 --- a/text-utils/more.c +++ b/text-utils/more.c @@ -1786,7 +1786,7 @@ void initterm(void) } } #endif /* do_SIGTTOU */ - if ((term = getenv("TERM")) == 0) { + if ((term = getenv("TERM")) == NULL) { dumb++; ul_opt = 0; } @@ -1857,7 +1857,7 @@ void initterm(void) if ((padstr = my_tgetstr(TERM_PAD_CHAR)) != NULL) PC = *padstr; Home = my_tgetstr(TERM_HOME); - if (Home == 0 || *Home == '\0') { + if (Home == NULL || *Home == '\0') { if ((cursorm = my_tgetstr(TERM_CURSOR_ADDRESS)) != NULL) { const char *t = -- 1.8.1.2 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/3] translation: unify exec error messages 2013-01-30 20:33 [PATCH 1/3] a pointer should not be compared to zero [coccinelle] Sami Kerola @ 2013-01-30 20:33 ` Sami Kerola 2013-02-06 10:53 ` Karel Zak 2013-01-30 20:33 ` [PATCH 3/3] eject: remove a duplicate command name from error message Sami Kerola 2013-02-02 22:58 ` [PATCH 1/3] a pointer should not be compared to zero [coccinelle] Ángel González 2 siblings, 1 reply; 9+ messages in thread From: Sami Kerola @ 2013-01-30 20:33 UTC (permalink / raw) To: util-linux; +Cc: kerolasa Signed-off-by: Sami Kerola <kerolasa@iki.fi> --- login-utils/newgrp.c | 2 +- login-utils/su-common.c | 4 ++-- login-utils/sulogin.c | 4 ++-- schedutils/chrt.c | 1 - schedutils/ionice.c | 2 +- schedutils/taskset.c | 2 +- sys-utils/flock.c | 2 +- sys-utils/nsenter.c | 2 +- sys-utils/prlimit.c | 2 +- sys-utils/rtcwake.c | 2 +- sys-utils/setarch.c | 4 ++-- sys-utils/setsid.c | 2 +- sys-utils/swapon.c | 2 +- sys-utils/unshare.c | 2 +- text-utils/pg.c | 2 +- 15 files changed, 17 insertions(+), 18 deletions(-) diff --git a/login-utils/newgrp.c b/login-utils/newgrp.c index 4f6de12..093f042 100644 --- a/login-utils/newgrp.c +++ b/login-utils/newgrp.c @@ -178,7 +178,7 @@ int main(int argc, char *argv[]) fflush(stdout); fflush(stderr); execl(shell, shell, (char *)0); - warn(_("exec %s failed"), shell); + warn(_("failed to execute %s"), shell); fflush(stderr); return EXIT_FAILURE; diff --git a/login-utils/su-common.c b/login-utils/su-common.c index 47e05ff..3ef4ec4 100644 --- a/login-utils/su-common.c +++ b/login-utils/su-common.c @@ -593,7 +593,7 @@ run_shell (char const *shell, char const *command, char **additional_args, { int exit_status = (errno == ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE); - warn ("%s", shell); + warn (_("failed to execute %s"), shell); exit (exit_status); } } @@ -913,7 +913,7 @@ su_main (int argc, char **argv, int mode) run_shell (shell, command, argv + optind, max (0, argc - optind)); else { execvp(argv[optind], &argv[optind]); - err(EXIT_FAILURE, _("executing %s failed"), argv[optind]); + err(EXIT_FAILURE, _("failed to execute %s"), argv[optind]); } } diff --git a/login-utils/sulogin.c b/login-utils/sulogin.c index cf429fe..db5f41e 100644 --- a/login-utils/sulogin.c +++ b/login-utils/sulogin.c @@ -736,11 +736,11 @@ static void sushell(struct passwd *pwd) } #endif execl(su_shell, shell, NULL); - warn(_("%s: exec failed"), su_shell); + warn(_("failed to execute %s"), su_shell); setenv("SHELL", "/bin/sh", 1); execl("/bin/sh", profile ? "-sh" : "sh", NULL); - warn(_("%s: exec failed"), "/bin/sh"); + warn(_("failed to execute %s"), "/bin/sh"); } static void usage(FILE *out) diff --git a/schedutils/chrt.c b/schedutils/chrt.c index 0347914..60ec73e 100644 --- a/schedutils/chrt.c +++ b/schedutils/chrt.c @@ -331,7 +331,6 @@ int main(int argc, char **argv) if (!pid) { argv += optind + 1; execvp(argv[0], argv); - perror("execvp"); err(EXIT_FAILURE, _("failed to execute %s"), argv[0]); } diff --git a/schedutils/ionice.c b/schedutils/ionice.c index f74e3c4..b7e6087 100644 --- a/schedutils/ionice.c +++ b/schedutils/ionice.c @@ -229,7 +229,7 @@ int main(int argc, char **argv) */ ioprio_setpid(0, ioclass, data); execvp(argv[optind], &argv[optind]); - err(EXIT_FAILURE, _("executing %s failed"), argv[optind]); + err(EXIT_FAILURE, _("failed to execute %s"), argv[optind]); } else usage(stderr); diff --git a/schedutils/taskset.c b/schedutils/taskset.c index 9039598..aba0b6f 100644 --- a/schedutils/taskset.c +++ b/schedutils/taskset.c @@ -234,7 +234,7 @@ int main(int argc, char **argv) if (!pid) { argv += optind + 1; execvp(argv[0], argv); - err(EXIT_FAILURE, _("executing %s failed"), argv[0]); + err(EXIT_FAILURE, _("failed to execute %s"), argv[0]); } return EXIT_SUCCESS; diff --git a/sys-utils/flock.c b/sys-utils/flock.c index 11c44b6..beda20f 100644 --- a/sys-utils/flock.c +++ b/sys-utils/flock.c @@ -318,7 +318,7 @@ int main(int argc, char *argv[]) close(fd); execvp(cmd_argv[0], cmd_argv); /* execvp() failed */ - warn("%s", cmd_argv[0]); + warn(_("failed to execute %s"), cmd_argv[0]); _exit((errno == ENOMEM) ? EX_OSERR : EX_UNAVAILABLE); } else { do { diff --git a/sys-utils/nsenter.c b/sys-utils/nsenter.c index b6e6dc1..3df4338 100644 --- a/sys-utils/nsenter.c +++ b/sys-utils/nsenter.c @@ -319,5 +319,5 @@ int main(int argc, char *argv[]) execvp(argv[optind], argv + optind); - err(EXIT_FAILURE, _("exec %s failed"), argv[optind]); + err(EXIT_FAILURE, _("failed to execute %s"), argv[optind]); } diff --git a/sys-utils/prlimit.c b/sys-utils/prlimit.c index a619bea..9098e49 100644 --- a/sys-utils/prlimit.c +++ b/sys-utils/prlimit.c @@ -637,7 +637,7 @@ int main(int argc, char **argv) if (argc > optind) { /* prlimit [options] COMMAND */ execvp(argv[optind], &argv[optind]); - err(EXIT_FAILURE, _("executing %s failed"), argv[optind]); + err(EXIT_FAILURE, _("failed to execute %s"), argv[optind]); } return EXIT_SUCCESS; diff --git a/sys-utils/rtcwake.c b/sys-utils/rtcwake.c index 0edf7dc..f0dada2 100644 --- a/sys-utils/rtcwake.c +++ b/sys-utils/rtcwake.c @@ -573,7 +573,7 @@ int main(int argc, char **argv) if (!dryrun) { execv(arg[0], arg); - warn(_("unable to execute %s"), _PATH_SHUTDOWN); + warn(_("failed to execute %s"), _PATH_SHUTDOWN); rc = EXIT_FAILURE; } diff --git a/sys-utils/setarch.c b/sys-utils/setarch.c index d13cdd6..afa2d1b 100644 --- a/sys-utils/setarch.c +++ b/sys-utils/setarch.c @@ -279,7 +279,7 @@ int main(int argc, char *argv[]) if (set_arch(p, 0L)) err(EXIT_FAILURE, _("Failed to set personality to %s"), p); execl("/bin/bash", NULL); - err(EXIT_FAILURE, "/bin/bash"); + err(EXIT_FAILURE, _("failed to execute %s"), "/bin/bash"); } #endif @@ -342,7 +342,7 @@ int main(int argc, char *argv[]) if (!argc) { execl("/bin/sh", "-sh", NULL); - err(EXIT_FAILURE, "/bin/sh"); + err(EXIT_FAILURE, _("failed to execute %s"), "/bin/sh"); } execvp(argv[0], argv); diff --git a/sys-utils/setsid.c b/sys-utils/setsid.c index 071ccc4..6c35280 100644 --- a/sys-utils/setsid.c +++ b/sys-utils/setsid.c @@ -94,5 +94,5 @@ int main(int argc, char **argv) warn(_("failed to set the controlling terminal")); } execvp(argv[optind], argv + optind); - err(EXIT_FAILURE, _("execvp failed")); + err(EXIT_FAILURE, _("failed to execute %s"), argv[optind]); } diff --git a/sys-utils/swapon.c b/sys-utils/swapon.c index 6efe482..d5b7e37 100644 --- a/sys-utils/swapon.c +++ b/sys-utils/swapon.c @@ -279,7 +279,7 @@ static int swap_reinitialize(const char *device, cmd[idx++] = (char *) device; cmd[idx++] = NULL; execv(cmd[0], cmd); - err(EXIT_FAILURE, _("execv failed")); + err(EXIT_FAILURE, _("failed to execute %s"), cmd[0]); default: /* parent */ do { diff --git a/sys-utils/unshare.c b/sys-utils/unshare.c index 4639ac8..62d2fcb 100644 --- a/sys-utils/unshare.c +++ b/sys-utils/unshare.c @@ -115,5 +115,5 @@ int main(int argc, char *argv[]) execvp(argv[optind], argv + optind); - err(EXIT_FAILURE, _("exec %s failed"), argv[optind]); + err(EXIT_FAILURE, _("failed to execute %s"), argv[optind]); } diff --git a/text-utils/pg.c b/text-utils/pg.c index 95f59a9..ab7a85a 100644 --- a/text-utils/pg.c +++ b/text-utils/pg.c @@ -1348,7 +1348,7 @@ static void pgfile(FILE *f, const char *name) my_sigset(SIGTERM, oldterm); execl(sh, sh, "-c", cmd.cmdline + 1, NULL); - warn("%s", sh); + warn(_("failed to execute %s"), sh); _exit(0177); /* NOTREACHED */ } -- 1.8.1.2 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 2/3] translation: unify exec error messages 2013-01-30 20:33 ` [PATCH 2/3] translation: unify exec error messages Sami Kerola @ 2013-02-06 10:53 ` Karel Zak 0 siblings, 0 replies; 9+ messages in thread From: Karel Zak @ 2013-02-06 10:53 UTC (permalink / raw) To: Sami Kerola; +Cc: util-linux On Wed, Jan 30, 2013 at 08:33:24PM +0000, Sami Kerola wrote: > login-utils/newgrp.c | 2 +- > login-utils/su-common.c | 4 ++-- > login-utils/sulogin.c | 4 ++-- > schedutils/chrt.c | 1 - > schedutils/ionice.c | 2 +- > schedutils/taskset.c | 2 +- > sys-utils/flock.c | 2 +- > sys-utils/nsenter.c | 2 +- > sys-utils/prlimit.c | 2 +- > sys-utils/rtcwake.c | 2 +- > sys-utils/setarch.c | 4 ++-- > sys-utils/setsid.c | 2 +- > sys-utils/swapon.c | 2 +- > sys-utils/unshare.c | 2 +- > text-utils/pg.c | 2 +- Applied, thanks. -- Karel Zak <kzak@redhat.com> http://karelzak.blogspot.com ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 3/3] eject: remove a duplicate command name from error message 2013-01-30 20:33 [PATCH 1/3] a pointer should not be compared to zero [coccinelle] Sami Kerola 2013-01-30 20:33 ` [PATCH 2/3] translation: unify exec error messages Sami Kerola @ 2013-01-30 20:33 ` Sami Kerola 2013-02-02 23:00 ` Ángel González 2013-02-06 10:53 ` Karel Zak 2013-02-02 22:58 ` [PATCH 1/3] a pointer should not be compared to zero [coccinelle] Ángel González 2 siblings, 2 replies; 9+ messages in thread From: Sami Kerola @ 2013-01-30 20:33 UTC (permalink / raw) To: util-linux; +Cc: kerolasa Let the err() print the command name. Signed-off-by: Sami Kerola <kerolasa@iki.fi> --- sys-utils/eject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys-utils/eject.c b/sys-utils/eject.c index e288371..a5b5656 100644 --- a/sys-utils/eject.c +++ b/sys-utils/eject.c @@ -655,7 +655,7 @@ static void umount_one(const char *name) err(EXIT_FAILURE, _("cannot set group id")); if (setuid(getuid()) < 0) - err(EXIT_FAILURE, _("eject: cannot set user id")); + err(EXIT_FAILURE, _("cannot set user id")); if (p_option) execl("/bin/umount", "/bin/umount", name, "-n", NULL); -- 1.8.1.2 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 3/3] eject: remove a duplicate command name from error message 2013-01-30 20:33 ` [PATCH 3/3] eject: remove a duplicate command name from error message Sami Kerola @ 2013-02-02 23:00 ` Ángel González 2013-02-06 10:53 ` Karel Zak 1 sibling, 0 replies; 9+ messages in thread From: Ángel González @ 2013-02-02 23:00 UTC (permalink / raw) To: Sami Kerola; +Cc: util-linux On 30/01/13 21:33, Sami Kerola wrote: > Let the err() print the command name. > > Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Ángel González <ingenit@zoho.com> ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 3/3] eject: remove a duplicate command name from error message 2013-01-30 20:33 ` [PATCH 3/3] eject: remove a duplicate command name from error message Sami Kerola 2013-02-02 23:00 ` Ángel González @ 2013-02-06 10:53 ` Karel Zak 1 sibling, 0 replies; 9+ messages in thread From: Karel Zak @ 2013-02-06 10:53 UTC (permalink / raw) To: Sami Kerola; +Cc: util-linux On Wed, Jan 30, 2013 at 08:33:25PM +0000, Sami Kerola wrote: > sys-utils/eject.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Applied, thanks. -- Karel Zak <kzak@redhat.com> http://karelzak.blogspot.com ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/3] a pointer should not be compared to zero [coccinelle] 2013-01-30 20:33 [PATCH 1/3] a pointer should not be compared to zero [coccinelle] Sami Kerola 2013-01-30 20:33 ` [PATCH 2/3] translation: unify exec error messages Sami Kerola 2013-01-30 20:33 ` [PATCH 3/3] eject: remove a duplicate command name from error message Sami Kerola @ 2013-02-02 22:58 ` Ángel González 2013-02-06 11:01 ` Karel Zak 2 siblings, 1 reply; 9+ messages in thread From: Ángel González @ 2013-02-02 22:58 UTC (permalink / raw) To: Sami Kerola; +Cc: util-linux On 30/01/13 21:33, Sami Kerola wrote "a pointer should not be compared to zero": > Signed-off-by: Sami Kerola <kerolasa@iki.fi> Why not? It is perfectly legal. See http://www.c-faq.com/null/null2.html > --- > - if (mnt == 0) { > + if (mnt == NULL) { > - while ((dp = readdir(dir)) != 0) { > + while ((dp = readdir(dir)) != NULL) { > - if (Sflag == 0) > + if (Sflag == NULL) > - if (Bflag == 0) { > + if (Bflag == NULL) { > - if (Mflag == 0) > + if (Mflag == NULL) > - if (types == 0) { > + if (types == NULL) { > - get_logname(&options, &termios, &chardata)) == 0) > + get_logname(&options, &termios, &chardata)) == NULL) > - for (cp = strtok(arg, ","); cp != 0; cp = strtok((char *)0, ",")) { > + for (cp = strtok(arg, ","); cp != NULL; cp = strtok((char *)0, ",")) { > - if ((term = getenv("TERM")) == 0) { > + if ((term = getenv("TERM")) == NULL) { > - if (Home == 0 || *Home == '\0') { > + if (Home == NULL || *Home == '\0') { ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/3] a pointer should not be compared to zero [coccinelle] 2013-02-02 22:58 ` [PATCH 1/3] a pointer should not be compared to zero [coccinelle] Ángel González @ 2013-02-06 11:01 ` Karel Zak 2013-02-06 17:47 ` Ángel González 0 siblings, 1 reply; 9+ messages in thread From: Karel Zak @ 2013-02-06 11:01 UTC (permalink / raw) To: Ángel González; +Cc: Sami Kerola, util-linux On Sat, Feb 02, 2013 at 11:58:05PM +0100, Ángel González wrote: > On 30/01/13 21:33, Sami Kerola wrote "a pointer should not be compared > to zero": > > Signed-off-by: Sami Kerola <kerolasa@iki.fi> Applied, thanks. > Why not? It is perfectly legal. > See http://www.c-faq.com/null/null2.html It's usually legal from compiler or C standard point of view, but it's horrible coding style manner. For example: http://lwn.net/Articles/93574/ Karel -- Karel Zak <kzak@redhat.com> http://karelzak.blogspot.com ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/3] a pointer should not be compared to zero [coccinelle] 2013-02-06 11:01 ` Karel Zak @ 2013-02-06 17:47 ` Ángel González 0 siblings, 0 replies; 9+ messages in thread From: Ángel González @ 2013-02-06 17:47 UTC (permalink / raw) To: Karel Zak; +Cc: util-linux, kerolasa On 06/02/13 12:01, Karel Zak wrote: > On Sat, Feb 02, 2013 at 11:58:05PM +0100, Ángel González wrote: >> On 30/01/13 21:33, Sami Kerola wrote "a pointer should not be compared >> to zero": >>> Signed-off-by: Sami Kerola <kerolasa@iki.fi> > > Applied, thanks. > >> Why not? It is perfectly legal. >> See http://www.c-faq.com/null/null2.html > > It's usually legal from compiler or C standard point of view, but > it's horrible coding style manner. I agree it's nicer, but if it's just for coding style I would have expected a commit message about that, not "should not be compared". > For example: > http://lwn.net/Articles/93574/ Funny Linus remarks :) ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2013-02-06 17:47 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2013-01-30 20:33 [PATCH 1/3] a pointer should not be compared to zero [coccinelle] Sami Kerola 2013-01-30 20:33 ` [PATCH 2/3] translation: unify exec error messages Sami Kerola 2013-02-06 10:53 ` Karel Zak 2013-01-30 20:33 ` [PATCH 3/3] eject: remove a duplicate command name from error message Sami Kerola 2013-02-02 23:00 ` Ángel González 2013-02-06 10:53 ` Karel Zak 2013-02-02 22:58 ` [PATCH 1/3] a pointer should not be compared to zero [coccinelle] Ángel González 2013-02-06 11:01 ` Karel Zak 2013-02-06 17:47 ` Ángel González
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.