aboutsummaryrefslogtreecommitdiff
path: root/toys/posix
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2016-01-05 22:26:58 -0600
committerRob Landley <rob@landley.net>2016-01-05 22:26:58 -0600
commitd3a435e53c94ec25b4ae5fa2614f49ef8884e08a (patch)
tree12e38a4739bd1832040b7d7e3efd2e054351fbf0 /toys/posix
parent8dfbf2efc89154fd74b34b5f4d8bf774dba63abf (diff)
downloadtoybox-d3a435e53c94ec25b4ae5fa2614f49ef8884e08a.tar.gz
Add error_msg_raw() and friends, replace error_msg("%s", s) uses, enable format
checking, and fix up format checking complaints. Added out(type, value) function to stat to avoid a zillion printf typecasts.
Diffstat (limited to 'toys/posix')
-rw-r--r--toys/posix/cat.c2
-rw-r--r--toys/posix/cksum.c2
-rw-r--r--toys/posix/cp.c2
-rw-r--r--toys/posix/cpio.c4
-rw-r--r--toys/posix/cut.c2
-rw-r--r--toys/posix/expand.c2
-rw-r--r--toys/posix/grep.c2
-rw-r--r--toys/posix/head.c2
-rw-r--r--toys/posix/ls.c2
-rw-r--r--toys/posix/mkfifo.c2
-rw-r--r--toys/posix/nl.c2
-rw-r--r--toys/posix/od.c2
-rw-r--r--toys/posix/paste.c4
-rw-r--r--toys/posix/rm.c2
-rw-r--r--toys/posix/rmdir.c2
-rw-r--r--toys/posix/strings.c2
-rw-r--r--toys/posix/wc.c2
17 files changed, 19 insertions, 19 deletions
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;