From 662a267c9b52f256b027d0f176a846b1d973ab99 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Wed, 2 Jan 2013 02:00:35 -0600 Subject: Have error_msg() and friends set TT.exitval to 1 if it's still 0, clean out other places that were setting it that no longer need to. --- toys/posix/cat.c | 5 +---- toys/posix/chgrp.c | 3 +-- toys/posix/cksum.c | 5 +---- toys/posix/cut.c | 1 - toys/posix/df.c | 1 - toys/posix/expand.c | 1 - toys/posix/head.c | 5 +---- toys/posix/kill.c | 5 +---- toys/posix/mkdir.c | 7 +------ toys/posix/mkfifo.c | 8 ++------ toys/posix/rm.c | 2 -- toys/posix/touch.c | 5 +---- toys/posix/wc.c | 5 +---- 13 files changed, 10 insertions(+), 43 deletions(-) (limited to 'toys/posix') diff --git a/toys/posix/cat.c b/toys/posix/cat.c index 431c7751..78881c4c 100644 --- a/toys/posix/cat.c +++ b/toys/posix/cat.c @@ -25,10 +25,7 @@ static void do_cat(int fd, char *name) for (;;) { len = read(fd, toybuf, size); - if (len<0) { - perror_msg("%s",name); - toys.exitval = EXIT_FAILURE; - } + if (len<0) perror_msg("%s",name); if (len<1) break; xwrite(1, toybuf, len); } diff --git a/toys/posix/chgrp.c b/toys/posix/chgrp.c index 6e1e16f0..e416f27f 100644 --- a/toys/posix/chgrp.c +++ b/toys/posix/chgrp.c @@ -60,8 +60,7 @@ static int do_chgrp(struct dirtree *node) toys.which->name[2]=='o' && TT.group_name ? ":" : "", TT.group_name ? TT.group_name : "", path); if (ret == -1 && !(toys.optflags & FLAG_f)) - perror_msg("changing owner:group of '%s' to '%s:%s'", path, - TT.owner_name, TT.group_name); + perror_msg("'%s' to '%s:%s'", path, TT.owner_name, TT.group_name); free(path); } toys.exitval |= ret; diff --git a/toys/posix/cksum.c b/toys/posix/cksum.c index 1192077c..9f6aa42b 100644 --- a/toys/posix/cksum.c +++ b/toys/posix/cksum.c @@ -51,10 +51,7 @@ static void do_cksum(int fd, char *name) int len, i; len = read(fd, toybuf, sizeof(toybuf)); - if (len<0) { - perror_msg("%s",name); - toys.exitval = EXIT_FAILURE; - } + if (len<0) perror_msg("%s", name); if (len<1) break; llen += len; diff --git a/toys/posix/cut.c b/toys/posix/cut.c index af4a1d9a..6f813102 100644 --- a/toys/posix/cut.c +++ b/toys/posix/cut.c @@ -127,7 +127,6 @@ static void get_data(void) int fd = open(*argv, O_RDONLY, 0); if(fd < 0) {//if file not present then continue with other files. perror_msg(*argv); - toys.exitval = EXIT_FAILURE; continue; } do_cut(fd); diff --git a/toys/posix/df.c b/toys/posix/df.c index 5641ff34..957e80b2 100644 --- a/toys/posix/df.c +++ b/toys/posix/df.c @@ -120,7 +120,6 @@ void df_main(void) // Stat it (complain if we can't). if(stat(*next, &st)) { perror_msg("`%s'", *next); - toys.exitval = 1; continue; } diff --git a/toys/posix/expand.c b/toys/posix/expand.c index 789364bb..7bc37169 100644 --- a/toys/posix/expand.c +++ b/toys/posix/expand.c @@ -39,7 +39,6 @@ static void expand_file(int fd, char *name) len = read(fd, toybuf, sizeof(toybuf)); if (len<0) { perror_msg("%s", name); - toys.exitval = 1; return; } if (!len) break; diff --git a/toys/posix/head.c b/toys/posix/head.c index ba7b7385..e8517d44 100644 --- a/toys/posix/head.c +++ b/toys/posix/head.c @@ -39,10 +39,7 @@ static void do_head(int fd, char *name) while (lines) { len = read(fd, toybuf, size); - if (len<0) { - perror_msg("%s",name); - toys.exitval = EXIT_FAILURE; - } + if (len<0) perror_msg("%s",name); if (len<1) break; for(i=0; iname, using)) { perror_msg("%s", try->name); - toys.exitval = 1; nodelete: if (try->parent) try->parent->symlink = (char *)1; } @@ -82,7 +81,6 @@ void rm_main(void) for (s = toys.optargs; *s; s++) { if (!strcmp(*s, "/")) { error_msg("rm /. if you mean it"); - toys.exitval = 1; continue; } diff --git a/toys/posix/touch.c b/toys/posix/touch.c index e350e754..76884be2 100644 --- a/toys/posix/touch.c +++ b/toys/posix/touch.c @@ -116,9 +116,6 @@ void touch_main(void) if ((!flag || !fetch(*ss, tv, flag)) && !utimes(*ss, tv)) ss++; else if (toys.optflags & FLAG_c) ss++; else if (-1 != (fd = open(*ss, O_CREAT, 0666))) close(fd); - else { - perror_msg("'%s'", *ss++); - toys.exitval = 1; - } + else perror_msg("'%s'", *ss++); } } diff --git a/toys/posix/wc.c b/toys/posix/wc.c index 56c9673a..3a6540b1 100644 --- a/toys/posix/wc.c +++ b/toys/posix/wc.c @@ -52,10 +52,7 @@ static void do_wc(int fd, char *name) for (;;) { len = read(fd, toybuf, sizeof(toybuf)); - if (len<0) { - perror_msg("%s",name); - toys.exitval = 1; - } + if (len<0) perror_msg("%s", name); if (len<1) break; for (i=0; i