summaryrefslogtreecommitdiffstats
path: root/misc-utils/rename.c
diff options
context:
space:
mode:
authorG.raud Meyer2018-04-09 14:44:52 +0200
committerG.raud Meyer2018-04-09 17:21:17 +0200
commit7ac394f84b3479723ffa6f235940fec0f4b29dac (patch)
tree04501677a0c9d051ccf84408b97703e759ddb2d5 /misc-utils/rename.c
parentrename: test availability of __fpurge() and fpurge() (diff)
downloadkernel-qcow2-util-linux-7ac394f84b3479723ffa6f235940fec0f4b29dac.tar.gz
kernel-qcow2-util-linux-7ac394f84b3479723ffa6f235940fec0f4b29dac.tar.xz
kernel-qcow2-util-linux-7ac394f84b3479723ffa6f235940fec0f4b29dac.zip
rename: fixup & style (no functional changes)
Diffstat (limited to 'misc-utils/rename.c')
-rw-r--r--misc-utils/rename.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/misc-utils/rename.c b/misc-utils/rename.c
index 2bbf7589a..0e3e1b9e1 100644
--- a/misc-utils/rename.c
+++ b/misc-utils/rename.c
@@ -73,7 +73,6 @@ static int ask(char *name)
fflush(stdout);
if ((c = fgetc(stdin)) == EOF) {
buf[0] = 'n';
- clearerr(stdin); errno = 0;
printf("n\n");
}
else {
@@ -130,7 +129,7 @@ static int do_symlink(char *from, char *to, char *s, int verbose, int noact,
return 2;
}
target[sb.st_size] = '\0';
- if (string_replace(from, to, target, target, &newname))
+ if (string_replace(from, to, target, target, &newname) != 0)
ret = 0;
if (ret == 1 && (nooverwrite || interactive) && lstat(newname, &sb) != 0)
@@ -148,14 +147,14 @@ static int do_symlink(char *from, char *to, char *s, int verbose, int noact,
if (!noact && 0 > unlink(s)) {
warn(_("%s: unlink failed"), s);
ret = 2;
- } else if (!noact && symlink(newname, s) != 0) {
+ }
+ else if (!noact && symlink(newname, s) != 0) {
warn(_("%s: symlinking to %s failed"), s, newname);
ret = 2;
}
}
if (verbose && (noact || ret == 1))
- if (verbose)
- printf("%s: `%s' -> `%s'\n", s, target, newname);
+ printf("%s: `%s' -> `%s'\n", s, target, newname);
free(newname);
free(target);
return ret;
@@ -176,7 +175,7 @@ static int do_file(char *from, char *to, char *s, int verbose, int noact,
file = strrchr(s, '/');
if (file == NULL)
file = s;
- if (string_replace(from, to, file, s, &newname))
+ if (string_replace(from, to, file, s, &newname) != 0)
return 0;
if ((nooverwrite || interactive) && access(newname, F_OK) != 0)