aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Tomasz Napierala <trasz@FreeBSD.org>2009-09-02 05:26:59 +0000
committerEdward Tomasz Napierala <trasz@FreeBSD.org>2009-09-02 05:26:59 +0000
commitf0246686c68e2a3279f3b98eeb7fbd3b20fffde6 (patch)
tree6c8b3fcef068471f28eb78a5c7a6334fb67de81c
parentb9a10b58106882b8972792b65c32ddcd412c67ac (diff)
downloadsrc-f0246686c68e2a3279f3b98eeb7fbd3b20fffde6.tar.gz
src-f0246686c68e2a3279f3b98eeb7fbd3b20fffde6.zip
- Don't include both <sys/types.h> and <sys/param.h>
- Keep variables sorted - Fix logic error with -f and -v options - don't print the usual -v output if there was an error, whether or not we were passed -f - Don't call free(3) just before exit(2) - Whitespace fixes Submitted by: bde
Notes
Notes: svn path=/head/; revision=196753
-rw-r--r--bin/chmod/chmod.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/bin/chmod/chmod.c b/bin/chmod/chmod.c
index f70161120f45..dc51faa39b01 100644
--- a/bin/chmod/chmod.c
+++ b/bin/chmod/chmod.c
@@ -41,7 +41,6 @@ static char sccsid[] = "@(#)chmod.c 8.8 (Berkeley) 4/1/94";
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include <sys/types.h>
#include <sys/param.h>
#include <sys/stat.h>
@@ -63,7 +62,7 @@ main(int argc, char *argv[])
FTS *ftsp;
FTSENT *p;
mode_t *set;
- int Hflag, Lflag, Rflag, ch, fflag, fts_options, hflag, rval, error;
+ int Hflag, Lflag, Rflag, ch, error, fflag, fts_options, hflag, rval;
int vflag;
char *mode;
mode_t newmode;
@@ -170,7 +169,6 @@ done: argv += optind;
*/
if (!hflag)
continue;
- /* else */
/* FALLTHROUGH */
default:
break;
@@ -188,9 +186,11 @@ done: argv += optind;
error = lchmod(p->fts_accpath, newmode);
else
error = chmod(p->fts_accpath, newmode);
- if (error && !fflag) {
- warn("%s", p->fts_path);
- rval = 1;
+ if (error) {
+ if (!fflag) {
+ warn("%s", p->fts_path);
+ rval = 1;
+ }
} else {
if (vflag) {
(void)printf("%s", p->fts_path);
@@ -201,7 +201,6 @@ done: argv += optind;
strmode(p->fts_statp->st_mode, m1);
strmode((p->fts_statp->st_mode &
S_IFMT) | newmode, m2);
-
(void)printf(": 0%o [%s] -> 0%o [%s]",
p->fts_statp->st_mode, m1,
(p->fts_statp->st_mode & S_IFMT) |
@@ -209,12 +208,10 @@ done: argv += optind;
}
(void)printf("\n");
}
-
}
}
if (errno)
err(1, "fts_read");
- free(set);
exit(rval);
}