diff options
Diffstat (limited to 'toys')
36 files changed, 76 insertions, 69 deletions
diff --git a/toys/lsb/killall.c b/toys/lsb/killall.c index 3b316ecc..2772b432 100644 --- a/toys/lsb/killall.c +++ b/toys/lsb/killall.c @@ -94,7 +94,7 @@ void killall_main(void) if (TT.err[i]) { toys.exitval = 1; errno = TT.err[i]; - perror_msg("%s", TT.names[i]); + perror_msg_raw(TT.names[i]); } } if (CFG_TOYBOX_FREE) free(TT.err); diff --git a/toys/lsb/mknod.c b/toys/lsb/mknod.c index 39073fad..1a467b01 100644 --- a/toys/lsb/mknod.c +++ b/toys/lsb/mknod.c @@ -54,5 +54,5 @@ void mknod_main(void) if (-1 == lsm_set_create(TT.arg_context)) perror_exit("-Z '%s' failed", TT.arg_context); if (mknod(*toys.optargs, mode|modes[type], makedev(major, minor))) - perror_exit("%s", *toys.optargs); + perror_exit_raw(*toys.optargs); } diff --git a/toys/lsb/seq.c b/toys/lsb/seq.c index f1ca0d00..c6204742 100644 --- a/toys/lsb/seq.c +++ b/toys/lsb/seq.c @@ -47,7 +47,7 @@ static void insanitize(char *f) } // The @ is a byte offset, not utf8 chars. Waiting for somebody to complain... - if (*s || !found) error_exit("bad -f '%s'@%d", f, s-f+1); + if (*s || !found) error_exit("bad -f '%s'@%ld", f, s-f+1); } void seq_main(void) diff --git a/toys/lsb/umount.c b/toys/lsb/umount.c index c7998e41..e6994f19 100644 --- a/toys/lsb/umount.c +++ b/toys/lsb/umount.c @@ -101,7 +101,7 @@ static void do_umount(char *dir, char *dev, int flags) } } - perror_msg("%s", dir); + perror_msg_raw(dir); } void umount_main(void) diff --git a/toys/other/acpi.c b/toys/other/acpi.c index 363cfb99..bca53814 100644 --- a/toys/other/acpi.c +++ b/toys/other/acpi.c @@ -35,7 +35,7 @@ int read_int_at(int dirfd, char *name) FILE *fil; if ((fd = openat(dirfd, name, O_RDONLY)) < 0) return -1; - if (!fscanf(fil = xfdopen(fd, "r"), "%d", &ret)) perror_exit("%s", name); + if (!fscanf(fil = xfdopen(fd, "r"), "%d", &ret)) perror_exit_raw(name); fclose(fil); return ret; diff --git a/toys/other/blkid.c b/toys/other/blkid.c index 4883b607..8aab8f74 100644 --- a/toys/other/blkid.c +++ b/toys/other/blkid.c @@ -149,7 +149,7 @@ void blkid_main(void) sprintf(device, "/dev/%.20s", name); if (-1 == (fd = open(device, O_RDONLY))) { - if (errno != ENOMEDIUM) perror_msg("%s", device); + if (errno != ENOMEDIUM) perror_msg_raw(device); } else { do_blkid(fd, device); close(fd); diff --git a/toys/other/bzcat.c b/toys/other/bzcat.c index 850c51ce..1081b5e9 100644 --- a/toys/other/bzcat.c +++ b/toys/other/bzcat.c @@ -663,7 +663,7 @@ static void do_bzcat(int fd, char *name) { char *err = bunzipStream(fd, 1); - if (err) error_exit(err); + if (err) error_exit_raw(err); } void bzcat_main(void) @@ -700,7 +700,7 @@ static void do_bunzip2(int fd, char *name) if (toys.optflags&FLAG_v) { printf("%s\n", err ? err : "ok"); toys.exitval |= !!err; - } else if (err) error_msg(err); + } else if (err) error_msg_raw(err); // can't test outfd==1 because may have been called with stdin+stdout closed if (rename) { @@ -709,7 +709,7 @@ static void do_bunzip2(int fd, char *name) tmp = 0; } else { if (dotbz) *dotbz = '.'; - if (!unlink(name)) perror_msg("%s", name); + if (!unlink(name)) perror_msg_raw(name); } (err ? delete_tempfile : replace_tempfile)(-1, outfd, &tmp); } diff --git a/toys/other/chroot.c b/toys/other/chroot.c index 4260d98f..b6ef17d6 100644 --- a/toys/other/chroot.c +++ b/toys/other/chroot.c @@ -24,7 +24,7 @@ void chroot_main(void) { char *binsh[] = {"/bin/sh", "-i", 0}; - if (chdir(*toys.optargs) || chroot(".")) perror_exit("%s", *toys.optargs); + if (chdir(*toys.optargs) || chroot(".")) perror_exit_raw(*toys.optargs); if (toys.optargs[1]) xexec(toys.optargs+1); else xexec(binsh); } diff --git a/toys/other/dos2unix.c b/toys/other/dos2unix.c index 021ba384..083a8140 100644 --- a/toys/other/dos2unix.c +++ b/toys/other/dos2unix.c @@ -42,7 +42,7 @@ static void do_dos2unix(int fd, char *name) int len, in, out; len = read(fd, toybuf+(sizeof(toybuf)/2), sizeof(toybuf)/2); - if (len<0) perror_msg("%s",name); + if (len<0) perror_msg_raw(name); if (len<1) break; for (in = out = 0; in < len; in++) { diff --git a/toys/other/hexedit.c b/toys/other/hexedit.c index b3bde2e5..c45ef1ca 100644 --- a/toys/other/hexedit.c +++ b/toys/other/hexedit.c @@ -173,7 +173,7 @@ void hexedit_main(void) // Display cursor and flush output highlight(x, y, ro ? 3 : side); - xprintf(""); + xflush(); // Wait for next key key = scan_key(keybuf, 1); diff --git a/toys/other/ifconfig.c b/toys/other/ifconfig.c index bfd9a306..1d2a41dc 100644 --- a/toys/other/ifconfig.c +++ b/toys/other/ifconfig.c @@ -110,7 +110,7 @@ static void display_ifconfig(char *name, int always, unsigned long long val[]) short flags; xstrncpy(ifre.ifr_name, name, IFNAMSIZ); - if (ioctl(TT.sockfd, SIOCGIFFLAGS, &ifre)<0) perror_exit("%s", name); + if (ioctl(TT.sockfd, SIOCGIFFLAGS, &ifre)<0) perror_exit_raw(name); flags = ifre.ifr_flags; if (!always && !(flags & IFF_UP)) return; diff --git a/toys/other/inotifyd.c b/toys/other/inotifyd.c index f2e11ca4..42d1d76e 100644 --- a/toys/other/inotifyd.c +++ b/toys/other/inotifyd.c @@ -65,7 +65,7 @@ void inotifyd_main(void) // This returns increasing numbers starting from 1, which coincidentally // is the toys.optargs position of the file. (0 is program to run.) - if (inotify_add_watch(fds.fd, path, mask) < 0) perror_exit("%s", path); + if (inotify_add_watch(fds.fd, path, mask) < 0) perror_exit_raw(path); } for (;;) { diff --git a/toys/other/ionice.c b/toys/other/ionice.c index 152a8c33..37d35456 100644 --- a/toys/other/ionice.c +++ b/toys/other/ionice.c @@ -82,7 +82,7 @@ void iorenice_main(void) if (p == -1) perror_exit("read priority"); TT.class = (p>>13)&3; p &= 7; - xprintf("Pid %d, class %s (%d), prio %d\n", + xprintf("Pid %ld, class %s (%ld), prio %d\n", TT.pid, classes[TT.class], TT.class, p); return; } diff --git a/toys/other/losetup.c b/toys/other/losetup.c index a40d9e42..4e467a9c 100644 --- a/toys/other/losetup.c +++ b/toys/other/losetup.c @@ -88,7 +88,7 @@ static void loopback_setup(char *device, char *file) if (-1 == lfd || ioctl(lfd, LOOP_GET_STATUS64, loop)) { if (errno == ENXIO && (flags & (FLAG_a|FLAG_j))) goto done; if (errno != ENXIO || !file) { - perror_msg("%s", device ? device : "-f"); + perror_msg_raw(device ? device : "-f"); goto done; } } @@ -101,7 +101,7 @@ static void loopback_setup(char *device, char *file) if (flags & (FLAG_c|FLAG_d)) { // The constant is LOOP_SET_CAPACITY if (ioctl(lfd, (flags & FLAG_c) ? 0x4C07 : LOOP_CLR_FD, 0)) { - perror_msg("%s", device); + perror_msg_raw(device); goto done; } // Associate file with this device? diff --git a/toys/other/modinfo.c b/toys/other/modinfo.c index 3a7e821f..61155b46 100644 --- a/toys/other/modinfo.c +++ b/toys/other/modinfo.c @@ -50,7 +50,7 @@ static void modinfo_file(char *full_name) } if (!buf) { - perror_msg("%s", full_name); + perror_msg_raw(full_name); return; } diff --git a/toys/other/mountpoint.c b/toys/other/mountpoint.c index 150865ca..ce1d23cd 100644 --- a/toys/other/mountpoint.c +++ b/toys/other/mountpoint.c @@ -33,7 +33,7 @@ void mountpoint_main(void) char *arg = *toys.optargs; int quiet = toys.optflags & FLAG_q; - if (lstat(arg, &st1)) perror_exit("%s", arg); + if (lstat(arg, &st1)) perror_exit_raw(arg); if (toys.optflags & FLAG_x) { if (S_ISBLK(st1.st_mode)) { diff --git a/toys/other/realpath.c b/toys/other/realpath.c index ec981082..8f75d3f2 100644 --- a/toys/other/realpath.c +++ b/toys/other/realpath.c @@ -20,7 +20,7 @@ void realpath_main(void) char **s = toys.optargs; for (s = toys.optargs; *s; s++) { - if (!realpath(*s, toybuf)) perror_msg("%s", *s); + if (!realpath(*s, toybuf)) perror_msg_raw(*s); else xputs(toybuf); } } diff --git a/toys/other/shred.c b/toys/other/shred.c index 64db5edf..5b018ea0 100644 --- a/toys/other/shred.c +++ b/toys/other/shred.c @@ -57,7 +57,7 @@ void shred_main(void) fd = open(*try, O_RDWR); } if (fd == -1) { - perror_msg("%s", *try); + perror_msg_raw(*try); continue; } @@ -84,7 +84,7 @@ void shred_main(void) if (pos < TT.offset) { if (TT.offset != lseek(fd, TT.offset, SEEK_SET)) { - perror_msg("%s", *try); + perror_msg_raw(*try); break; } pos = TT.offset; @@ -97,7 +97,7 @@ void shred_main(void) if (len-pos < throw) throw = len-pos; if (iter != TT.iterations) xread(TT.ufd, toybuf, throw); - if (throw != writeall(fd, toybuf, throw)) perror_msg("%s"); + if (throw != writeall(fd, toybuf, throw)) perror_msg_raw(*try); pos += throw; } if (toys.optflags & FLAG_u) diff --git a/toys/other/stat.c b/toys/other/stat.c index fe522b08..fb5922c6 100644 --- a/toys/other/stat.c +++ b/toys/other/stat.c @@ -2,7 +2,7 @@ * Copyright 2012 <warior.linux@gmail.com> * Copyright 2013 <anand.sinha85@gmail.com> -USE_STAT(NEWTOY(stat, "c:f", TOYFLAG_BIN)) +USE_STAT(NEWTOY(stat, "<1c:f", TOYFLAG_BIN)) config STAT bool stat @@ -55,24 +55,31 @@ static void date_stat_format(struct timespec *ts) { strftime(toybuf, sizeof(toybuf), "%Y-%m-%d %H:%M:%S", localtime(&(ts->tv_sec))); - xprintf("%s.%09d", toybuf, ts->tv_nsec); + xprintf("%s.%09ld", toybuf, ts->tv_nsec); +} + +// Force numeric output to long long instead of manually typecasting everything +static void out(char c, long long val) +{ + sprintf(toybuf, "%%ll%c", c); + printf(toybuf, val); } static void print_stat(char type) { struct stat *stat = (struct stat *)&TT.stat; - if (type == 'a') xprintf("%lo", stat->st_mode & ~S_IFMT); + if (type == 'a') out('o', stat->st_mode&~S_IFMT); else if (type == 'A') { char str[11]; mode_to_string(stat->st_mode, str); xprintf("%s", str); - } else if (type == 'b') xprintf("%llu", stat->st_blocks); - else if (type == 'B') xprintf("%lu", stat->st_blksize); - else if (type == 'd') xprintf("%ld", stat->st_dev); - else if (type == 'D') xprintf("%llx", stat->st_dev); - else if (type == 'f') xprintf("%lx", stat->st_mode); + } else if (type == 'b') out('u', stat->st_blocks); + else if (type == 'B') out('u', stat->st_blksize); + else if (type == 'd') out('d', stat->st_dev); + else if (type == 'D') out('x', stat->st_dev); + else if (type == 'f') out('x', stat->st_mode); else if (type == 'F') { char *t = "character device\0directory\0block device\0" \ "regular file\0symbolic link\0socket\0FIFO (named pipe)"; @@ -81,38 +88,38 @@ static void print_stat(char type) for (i = 1; filetype != (i*8192) && i < 7; i++) t += strlen(t)+1; if (!stat->st_size && filetype == S_IFREG) t = "regular empty file"; xprintf("%s", t); - } else if (type == 'g') xprintf("%lu", stat->st_gid); + } else if (type == 'g') out('u', stat->st_gid); else if (type == 'G') xprintf("%8s", TT.group_name->gr_name); - else if (type == 'h') xprintf("%lu", stat->st_nlink); - else if (type == 'i') xprintf("%llu", stat->st_ino); + else if (type == 'h') out('u', stat->st_nlink); + else if (type == 'i') out('u', stat->st_ino); else if (type == 'N') { xprintf("`%s'", *toys.optargs); if (S_ISLNK(stat->st_mode)) if (0<readlink(*toys.optargs, toybuf, sizeof(toybuf))) xprintf(" -> `%s'", toybuf); - } else if (type == 'o') xprintf("%lu", stat->st_blksize); - else if (type == 's') xprintf("%llu", stat->st_size); - else if (type == 'u') xprintf("%lu", stat->st_uid); + } else if (type == 'o') out('u', stat->st_blksize); + else if (type == 's') out('u', stat->st_size); + else if (type == 'u') out('u', stat->st_uid); else if (type == 'U') xprintf("%8s", TT.user_name->pw_name); else if (type == 'x') date_stat_format((void *)&stat->st_atime); - else if (type == 'X') xprintf("%llu", (long long)stat->st_atime); + else if (type == 'X') out('u', stat->st_atime); else if (type == 'y') date_stat_format((void *)&stat->st_mtime); - else if (type == 'Y') xprintf("%llu", (long long)stat->st_mtime); + else if (type == 'Y') out('u', stat->st_mtime); else if (type == 'z') date_stat_format((void *)&stat->st_ctime); - else if (type == 'Z') xprintf("%llu", (long long)stat->st_ctime); + else if (type == 'Z') out('u', stat->st_ctime); else xprintf("?"); } static void print_statfs(char type) { struct statfs *statfs = (struct statfs *)&TT.stat; - if (type == 'a') xprintf("%llu", statfs->f_bavail); - else if (type == 'b') xprintf("%llu", statfs->f_blocks); - else if (type == 'c') xprintf("%llu", statfs->f_files); - else if (type == 'd') xprintf("%llu", statfs->f_ffree); - else if (type == 'f') xprintf("%llu", statfs->f_bfree); - else if (type == 'l') xprintf("%ld", statfs->f_namelen); - else if (type == 't') xprintf("%lx", statfs->f_type); + if (type == 'a') out('u', statfs->f_bavail); + else if (type == 'b') out('u', statfs->f_blocks); + else if (type == 'c') out('u', statfs->f_files); + else if (type == 'd') out('u', statfs->f_ffree); + else if (type == 'f') out('u', statfs->f_bfree); + else if (type == 'l') out('d', statfs->f_namelen); + else if (type == 't') out('x', statfs->f_type); else if (type == 'T') { char *s = "unknown"; struct {unsigned num; char *name;} nn[] = { @@ -129,11 +136,11 @@ static void print_statfs(char type) { for (i=0; i<ARRAY_LEN(nn); i++) if (nn[i].num == statfs->f_type) s = nn[i].name; - xprintf(s); + fputs(s, stdout); } else if (type == 'i') xprintf("%08x%08x", statfs->f_fsid.__val[0], statfs->f_fsid.__val[1]); - else if (type == 's') xprintf("%d", statfs->f_frsize); - else if (type == 'S') xprintf("%d", statfs->f_bsize); + else if (type == 's') out('d', statfs->f_frsize); + else if (type == 'S') out('d', statfs->f_bsize); else xprintf("?"); } diff --git a/toys/posix/cat.c b/toys/posix/cat.c index 3aae4a19..4da2ec27 100644 --- a/toys/posix/cat.c +++ b/toys/posix/cat.c @@ -59,7 +59,7 @@ static void do_cat(int fd, char *name) len = read(fd, toybuf, size); if (len < 0) { toys.exitval = EXIT_FAILURE; - perror_msg("%s", name); + perror_msg_raw(name); } if (len < 1) break; if ((CFG_CAT_V || CFG_CATV) && (toys.optflags&~FLAG_u)) { diff --git a/toys/posix/cksum.c b/toys/posix/cksum.c index 60edc091..bcb2843d 100644 --- a/toys/posix/cksum.c +++ b/toys/posix/cksum.c @@ -52,7 +52,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); + if (len<0) perror_msg_raw(name); if (len<1) break; llen += len; diff --git a/toys/posix/cp.c b/toys/posix/cp.c index 9260d04b..f932ca4f 100644 --- a/toys/posix/cp.c +++ b/toys/posix/cp.c @@ -483,7 +483,7 @@ void install_main(void) if (flags & FLAG_d) { for (ss = toys.optargs; *ss; ss++) { - if (mkpathat(AT_FDCWD, *ss, 0777, 3)) perror_msg("%s", *ss); + if (mkpathat(AT_FDCWD, *ss, 0777, 3)) perror_msg_raw(*ss); if (flags & FLAG_v) printf("%s\n", *ss); } diff --git a/toys/posix/cpio.c b/toys/posix/cpio.c index 0316cc9d..981d6c5a 100644 --- a/toys/posix/cpio.c +++ b/toys/posix/cpio.c @@ -211,7 +211,7 @@ void cpio_main(void) } } - if (err) perror_msg("'%s'", name); + if (err) perror_msg_raw(name); free(tofree); // Output cpio archive @@ -233,7 +233,7 @@ void cpio_main(void) if (lstat(name, &st) || (S_ISREG(st.st_mode) && st.st_size && (fd = open(name, O_RDONLY))<0)) { - perror_msg("%s", name); + perror_msg_raw(name); continue; } diff --git a/toys/posix/cut.c b/toys/posix/cut.c index bb2b22d4..1acefe2b 100644 --- a/toys/posix/cut.c +++ b/toys/posix/cut.c @@ -113,7 +113,7 @@ static void get_data(void) else { int fd = open(*argv, O_RDONLY, 0); if(fd < 0) {//if file not present then continue with other files. - perror_msg("%s", *argv); + perror_msg_raw(*argv); continue; } TT.do_cut(fd); diff --git a/toys/posix/expand.c b/toys/posix/expand.c index 7e668fa7..a25848ad 100644 --- a/toys/posix/expand.c +++ b/toys/posix/expand.c @@ -38,7 +38,7 @@ static void do_expand(int fd, char *name) for (;;) { len = readall(fd, toybuf, sizeof(toybuf)); if (len<0) { - perror_msg("%s", name); + perror_msg_raw(name); return; } if (!len) break; diff --git a/toys/posix/grep.c b/toys/posix/grep.c index d44a92d6..1cb4f9cf 100644 --- a/toys/posix/grep.c +++ b/toys/posix/grep.c @@ -72,7 +72,7 @@ static void do_grep(int fd, char *name) if (!fd) name = "(standard input)"; if (!file) { - perror_msg("%s", name); + perror_msg_raw(name); return; } diff --git a/toys/posix/head.c b/toys/posix/head.c index 5867dfb5..f300760d 100644 --- a/toys/posix/head.c +++ b/toys/posix/head.c @@ -39,7 +39,7 @@ static void do_head(int fd, char *name) while (lines) { len = read(fd, toybuf, size); - if (len<0) perror_msg("%s",name); + if (len<0) perror_msg_raw(name); if (len<1) break; for(i=0; i<len;) if (toybuf[i++] == '\n' && !--lines) break; diff --git a/toys/posix/ls.c b/toys/posix/ls.c index d313457a..5177dd9a 100644 --- a/toys/posix/ls.c +++ b/toys/posix/ls.c @@ -293,7 +293,7 @@ static void listfiles(int dirfd, struct dirtree *indir) if (-1 == dirfd) { strwidth(indir->name); - perror_msg("%s", indir->name); + perror_msg_raw(indir->name); return; } diff --git a/toys/posix/mkfifo.c b/toys/posix/mkfifo.c index 9fc3829e..942dfdc5 100644 --- a/toys/posix/mkfifo.c +++ b/toys/posix/mkfifo.c @@ -46,5 +46,5 @@ void mkfifo_main(void) perror_exit("-Z '%s' failed", TT.Z); for (s = toys.optargs; *s; s++) - if (mknod(*s, S_IFIFO | TT.mode, 0) < 0) perror_msg("%s", *s); + if (mknod(*s, S_IFIFO | TT.mode, 0) < 0) perror_msg_raw(*s); } diff --git a/toys/posix/nl.c b/toys/posix/nl.c index 60c0a52e..9b02bfaa 100644 --- a/toys/posix/nl.c +++ b/toys/posix/nl.c @@ -51,7 +51,7 @@ static void do_nl(int fd, char *name) int match = *TT.b != 'n'; if (getline(&line, &temp, f) < 1) { - if (ferror(f)) perror_msg("%s", name); + if (ferror(f)) perror_msg_raw(name); break; } diff --git a/toys/posix/od.c b/toys/posix/od.c index 8919ad16..99219bf4 100644 --- a/toys/posix/od.c +++ b/toys/posix/od.c @@ -207,7 +207,7 @@ static void do_od(int fd, char *name) len = readall(fd, buf, len); if (len < 0) { - perror_msg("%s", name); + perror_msg_raw(name); break; } if (TT.max_count) TT.max_count -= len; diff --git a/toys/posix/paste.c b/toys/posix/paste.c index 0e170cdb..5ab3448d 100644 --- a/toys/posix/paste.c +++ b/toys/posix/paste.c @@ -50,7 +50,7 @@ void paste_main(void) for (; *args; args++) { if ((*args)[0] == '-' && !(*args)[1]) f = stdin; - else if (!(f = fopen(*args, "r"))) perror_exit("%s", *args); + else if (!(f = fopen(*args, "r"))) perror_exit_raw(*args); for (i = 0, c = 0; c != EOF;) { switch(c = getc(f)) { case '\n': @@ -72,7 +72,7 @@ void paste_main(void) files = (FILE**)(buf + 1); for (; *args; args++, files++) { if ((*args)[0] == '-' && !(*args)[1]) *files = stdin; - else if (!(*files = fopen(*args, "r"))) perror_exit("%s", *args); + else if (!(*files = fopen(*args, "r"))) perror_exit_raw(*args); } while (anyopen) { anyopen = 0; diff --git a/toys/posix/rm.c b/toys/posix/rm.c index f591c64d..99fa8edf 100644 --- a/toys/posix/rm.c +++ b/toys/posix/rm.c @@ -69,7 +69,7 @@ static int do_rm(struct dirtree *try) skip: if (unlinkat(fd, try->name, using)) { - if (!dir || try->symlink != (char *)2) perror_msg("%s", try->name); + if (!dir || try->symlink != (char *)2) perror_msg_raw(try->name); nodelete: if (try->parent) try->parent->symlink = (char *)2; } diff --git a/toys/posix/rmdir.c b/toys/posix/rmdir.c index 23266c31..7421bb38 100644 --- a/toys/posix/rmdir.c +++ b/toys/posix/rmdir.c @@ -25,7 +25,7 @@ static void do_rmdir(char *name) for (;;) { if (rmdir(name)) { - perror_msg("%s",name); + perror_msg_raw(name); return; } diff --git a/toys/posix/strings.c b/toys/posix/strings.c index e87ccde8..f3ce70ce 100644 --- a/toys/posix/strings.c +++ b/toys/posix/strings.c @@ -37,7 +37,7 @@ static void do_strings(int fd, char *filename) for (;;) { nread = read(fd, toybuf, sizeof(toybuf)); - if (nread < 0) perror_msg("%s", filename); + if (nread < 0) perror_msg_raw(filename); if (nread < 1) break; for (i = 0; i < nread; i++, offset++) { if (((toybuf[i] >= 32) && (toybuf[i] <= 126)) || (toybuf[i] == '\t')) { diff --git a/toys/posix/wc.c b/toys/posix/wc.c index 815e08b1..b7f09b4e 100644 --- a/toys/posix/wc.c +++ b/toys/posix/wc.c @@ -52,7 +52,7 @@ static void do_wc(int fd, char *name) for (;;) { len = read(fd, toybuf, sizeof(toybuf)); - if (len<0) perror_msg("%s", name); + if (len<0) perror_msg_raw(name); if (len<1) break; for (i=0; i<len; i+=clen) { wchar_t wchar; |