'simple' error message functions by Loic Grenie <loic.grenie@gmail.com>.
263 bytes saved.
This commit is contained in:
@ -63,7 +63,7 @@ static int fileAction(const char *fileName, struct stat *statbuf, void* param, i
|
||||
}
|
||||
err:
|
||||
if (!OPT_QUIET)
|
||||
bb_perror_msg("%s", fileName);
|
||||
bb_simple_perror_msg(fileName);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ static int fileAction(const char *fileName, struct stat *statbuf,
|
||||
return TRUE;
|
||||
}
|
||||
if (!OPT_QUIET)
|
||||
bb_perror_msg("%s", fileName); /* A filename can have % in it... */
|
||||
bb_simple_perror_msg(fileName); /* A filename can have % in it... */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -278,7 +278,7 @@ int dd_main(int argc, char **argv)
|
||||
if (n < 0) {
|
||||
if (flags & FLAG_NOERROR) {
|
||||
n = ibs;
|
||||
bb_perror_msg("%s", infile);
|
||||
bb_simple_perror_msg(infile);
|
||||
} else
|
||||
goto die_infile;
|
||||
}
|
||||
@ -320,12 +320,12 @@ int dd_main(int argc, char **argv)
|
||||
}
|
||||
if (close(ifd) < 0) {
|
||||
die_infile:
|
||||
bb_perror_msg_and_die("%s", infile);
|
||||
bb_simple_perror_msg_and_die(infile);
|
||||
}
|
||||
|
||||
if (close(ofd) < 0) {
|
||||
die_outfile:
|
||||
bb_perror_msg_and_die("%s", outfile);
|
||||
bb_simple_perror_msg_and_die(outfile);
|
||||
}
|
||||
out_status:
|
||||
dd_output_status(0);
|
||||
|
@ -100,7 +100,7 @@ int df_main(int argc, char **argv)
|
||||
mount_point = mount_entry->mnt_dir;
|
||||
|
||||
if (statfs(mount_point, &s) != 0) {
|
||||
bb_perror_msg("%s", mount_point);
|
||||
bb_simple_perror_msg(mount_point);
|
||||
goto SET_ERROR;
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ static unsigned long du(const char *filename)
|
||||
unsigned long sum;
|
||||
|
||||
if (lstat(filename, &statbuf) != 0) {
|
||||
bb_perror_msg("%s", filename);
|
||||
bb_simple_perror_msg(filename);
|
||||
G.status = EXIT_FAILURE;
|
||||
return 0;
|
||||
}
|
||||
@ -85,7 +85,7 @@ static unsigned long du(const char *filename)
|
||||
if (S_ISLNK(statbuf.st_mode)) {
|
||||
if (G.slink_depth > G.du_depth) { /* -H or -L */
|
||||
if (stat(filename, &statbuf) != 0) {
|
||||
bb_perror_msg("%s", filename);
|
||||
bb_simple_perror_msg(filename);
|
||||
G.status = EXIT_FAILURE;
|
||||
return 0;
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ int env_main(int argc, char** argv)
|
||||
BB_EXECVP(*argv, argv);
|
||||
/* SUSv3-mandated exit codes. */
|
||||
xfunc_error_retval = (errno == ENOENT) ? 127 : 126;
|
||||
bb_perror_msg_and_die("%s", *argv);
|
||||
bb_simple_perror_msg_and_die(*argv);
|
||||
}
|
||||
|
||||
for (ep = environ; *ep; ep++) {
|
||||
|
@ -192,7 +192,7 @@ int expand_main(int argc, char **argv)
|
||||
/* Check and close the file */
|
||||
/* We do want all of them to execute, thus | instead of || */
|
||||
if (ferror(file) | fclose_if_not_stdin(file)) {
|
||||
bb_perror_msg("%s", *argv);
|
||||
bb_simple_perror_msg(*argv);
|
||||
exit_status = EXIT_FAILURE;
|
||||
}
|
||||
/* If stdin also clear EOF */
|
||||
|
@ -145,7 +145,7 @@ int fold_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (ferror(istream) || fclose_if_not_stdin(istream)) {
|
||||
bb_perror_msg("%s", *argv); /* Avoid multibyte problems. */
|
||||
bb_simple_perror_msg(*argv); /* Avoid multibyte problems. */
|
||||
errs |= EXIT_FAILURE;
|
||||
}
|
||||
} while (*++argv);
|
||||
|
@ -128,7 +128,7 @@ int head_main(int argc, char **argv)
|
||||
putchar(c);
|
||||
}
|
||||
if (fclose_if_not_stdin(fp)) {
|
||||
bb_perror_msg("%s", *argv); /* Avoid multibyte problems. */
|
||||
bb_simple_perror_msg(*argv); /* Avoid multibyte problems. */
|
||||
retval = EXIT_FAILURE;
|
||||
}
|
||||
die_if_ferror_stdout();
|
||||
|
@ -64,7 +64,7 @@ int ln_main(int argc, char **argv)
|
||||
if (!(flag & LN_SYMLINK) && stat(*argv, &statbuf)) {
|
||||
// coreutils: "ln dangling_symlink new_hardlink" works
|
||||
if (lstat(*argv, &statbuf) || !S_ISLNK(statbuf.st_mode)) {
|
||||
bb_perror_msg("%s", *argv);
|
||||
bb_simple_perror_msg(*argv);
|
||||
status = EXIT_FAILURE;
|
||||
free(src_name);
|
||||
continue;
|
||||
@ -75,7 +75,7 @@ int ln_main(int argc, char **argv)
|
||||
char *backup;
|
||||
backup = xasprintf("%s%s", src, suffix);
|
||||
if (rename(src, backup) < 0 && errno != ENOENT) {
|
||||
bb_perror_msg("%s", src);
|
||||
bb_simple_perror_msg(src);
|
||||
status = EXIT_FAILURE;
|
||||
free(backup);
|
||||
continue;
|
||||
@ -97,7 +97,7 @@ int ln_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (link_func(*argv, src) != 0) {
|
||||
bb_perror_msg("%s", src);
|
||||
bb_simple_perror_msg(src);
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -171,7 +171,7 @@ static struct dnode *my_stat(const char *fullname, const char *name, int force_f
|
||||
}
|
||||
#endif
|
||||
if (stat(fullname, &dstat)) {
|
||||
bb_perror_msg("%s", fullname);
|
||||
bb_simple_perror_msg(fullname);
|
||||
status = EXIT_FAILURE;
|
||||
return 0;
|
||||
}
|
||||
@ -182,7 +182,7 @@ static struct dnode *my_stat(const char *fullname, const char *name, int force_f
|
||||
}
|
||||
#endif
|
||||
if (lstat(fullname, &dstat)) {
|
||||
bb_perror_msg("%s", fullname);
|
||||
bb_simple_perror_msg(fullname);
|
||||
status = EXIT_FAILURE;
|
||||
return 0;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ int mkfifo_main(int argc, char **argv)
|
||||
|
||||
do {
|
||||
if (mkfifo(*argv, mode) < 0) {
|
||||
bb_perror_msg("%s", *argv); /* Avoid multibyte problems. */
|
||||
bb_simple_perror_msg(*argv); /* Avoid multibyte problems. */
|
||||
retval = EXIT_FAILURE;
|
||||
}
|
||||
} while (*++argv);
|
||||
|
@ -44,7 +44,7 @@ int mknod_main(int argc, char **argv)
|
||||
if (mknod(name, mode, dev) == 0) {
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
bb_perror_msg_and_die("%s", name);
|
||||
bb_simple_perror_msg_and_die(name);
|
||||
}
|
||||
}
|
||||
bb_show_usage();
|
||||
|
@ -51,5 +51,5 @@ int nice_main(int argc, char **argv)
|
||||
|
||||
/* The exec failed... */
|
||||
xfunc_error_retval = (errno == ENOENT) ? 127 : 126; /* SUSv3 */
|
||||
bb_perror_msg_and_die("%s", *argv);
|
||||
bb_simple_perror_msg_and_die(*argv);
|
||||
}
|
||||
|
@ -56,5 +56,5 @@ int nohup_main(int argc, char **argv)
|
||||
BB_EXECVP(argv[1], argv+1);
|
||||
if (ENABLE_FEATURE_CLEAN_UP && home)
|
||||
free((char*)nohupout);
|
||||
bb_perror_msg_and_die("%s", argv[1]);
|
||||
bb_simple_perror_msg_and_die(argv[1]);
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ int realpath_main(int argc, char **argv)
|
||||
puts(resolved_path);
|
||||
} else {
|
||||
retval = EXIT_FAILURE;
|
||||
bb_perror_msg("%s", *argv);
|
||||
bb_simple_perror_msg(*argv);
|
||||
}
|
||||
} while (--argc);
|
||||
|
||||
|
@ -104,7 +104,7 @@ int split_main(int argc, char **argv)
|
||||
if (!bytes_read)
|
||||
break;
|
||||
if (bytes_read < 0)
|
||||
bb_perror_msg_and_die("%s", argv[0]);
|
||||
bb_simple_perror_msg_and_die(argv[0]);
|
||||
src = read_buffer;
|
||||
do {
|
||||
if (!remaining) {
|
||||
|
@ -49,7 +49,7 @@ int touch_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
status = EXIT_FAILURE;
|
||||
bb_perror_msg("%s", *argv);
|
||||
bb_simple_perror_msg(*argv);
|
||||
}
|
||||
} while (*++argv);
|
||||
|
||||
|
@ -150,7 +150,7 @@ int wc_main(int argc, char **argv)
|
||||
}
|
||||
} else if (c == EOF) {
|
||||
if (ferror(fp)) {
|
||||
bb_perror_msg("%s", arg);
|
||||
bb_simple_perror_msg(arg);
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
--counts[WC_CHARS];
|
||||
|
Reference in New Issue
Block a user