From 5940e6593911dcace424c668a1c0934c71fccb9e Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 1 Sep 2011 09:55:05 +0200 Subject: [PATCH] Fix "format not a string literal" warning caused by tprintf(str) * defs.h: Declare tprints(). * strace.c: Define tprints(). (tabto): Use tprints(str), since tprintf(str) was throwing a warning. * desc.c: Use tprints(str) instead of tprintf("%s", str). * file.c: Likewise. * io.c: Likewise. * net.c: Likewise. * process.c: Likewise. * signal.c: Likewise. * syscall.c: Likewise. * util.c: Likewise. Signed-off-by: Denys Vlasenko --- defs.h | 1 + desc.c | 2 +- file.c | 2 +- io.c | 2 +- net.c | 2 +- process.c | 2 +- signal.c | 4 ++-- strace.c | 18 ++++++++++++++++-- syscall.c | 2 +- util.c | 7 +++---- 10 files changed, 28 insertions(+), 14 deletions(-) diff --git a/defs.h b/defs.h index bb2e395d..59d4c7a4 100644 --- a/defs.h +++ b/defs.h @@ -708,6 +708,7 @@ extern int proc_open(struct tcb *tcp, int attaching); printtv_bitness((tcp), (addr), BITNESS_CURRENT, 1) extern void tprintf(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); +extern void tprints(const char *str); #ifndef HAVE_STRERROR const char *strerror(int); diff --git a/desc.c b/desc.c index e77a2387..5cb8a1a9 100644 --- a/desc.c +++ b/desc.c @@ -519,7 +519,7 @@ decode_select(struct tcb *tcp, long *args, enum bitness_t bitness) tprintf(", ["); for (j = 0, sep = ""; j < nfds; j++) { if (FD_ISSET(j, fds)) { - tprintf("%s", sep); + tprints(sep); printfd(tcp, j); sep = " "; } diff --git a/file.c b/file.c index 09977e9c..7bf18148 100644 --- a/file.c +++ b/file.c @@ -386,7 +386,7 @@ sprint_open_modes(mode_t flags) void tprint_open_modes(mode_t flags) { - tprintf("%s", sprint_open_modes(flags) + sizeof("flags")); + tprints(sprint_open_modes(flags) + sizeof("flags")); } static int diff --git a/io.c b/io.c index e3cad664..fa51cefb 100644 --- a/io.c +++ b/io.c @@ -426,7 +426,7 @@ sys_ioctl(struct tcb *tcp) tprintf(", "); iop = ioctl_lookup(tcp->u_arg[1]); if (iop) { - tprintf("%s", iop->symbol); + tprints(iop->symbol); while ((iop = ioctl_next_match(iop))) tprintf(" or %s", iop->symbol); } else diff --git a/net.c b/net.c index d52d2e59..51a59976 100644 --- a/net.c +++ b/net.c @@ -1468,7 +1468,7 @@ tprint_sock_type(struct tcb *tcp, int flags) const char *str = xlookup(socktypes, flags & SOCK_TYPE_MASK); if (str) { - tprintf("%s", str); + tprints(str); flags &= ~SOCK_TYPE_MASK; if (!flags) return; diff --git a/process.c b/process.c index 5e062628..4ae74a47 100644 --- a/process.c +++ b/process.c @@ -1505,7 +1505,7 @@ printargv(struct tcb *tcp, long addr) cp.p64 = cp.p32; if (cp.p64 == 0) break; - tprintf("%s", sep); + tprints(sep); printstr(tcp, cp.p64, -1); addr += personality_wordsize[current_personality]; } diff --git a/signal.c b/signal.c index 31c5a654..84af14f4 100644 --- a/signal.c +++ b/signal.c @@ -385,13 +385,13 @@ sprintsigmask(const char *str, sigset_t *mask, int rt) static void printsigmask(sigset_t *mask, int rt) { - tprintf("%s", sprintsigmask("", mask, rt)); + tprints(sprintsigmask("", mask, rt)); } void printsignal(int nr) { - tprintf("%s", signame(nr)); + tprints(signame(nr)); } void diff --git a/strace.c b/strace.c index 83ebc5b0..9c633887 100644 --- a/strace.c +++ b/strace.c @@ -2646,7 +2646,21 @@ tprintf(const char *fmt, ...) curcol += n; } va_end(args); - return; +} + +void +tprints(const char *str) +{ + if (outf) { + int n = fputs(str, outf); + if (n >= 0) { + curcol += strlen(str); + return; + } + if (outf != stderr) + perror(outfname == NULL + ? "" : outfname); + } } void @@ -2705,7 +2719,7 @@ void tabto(void) { if (curcol < acolumn) - tprintf(acolumn_spaces + curcol); + tprints(acolumn_spaces + curcol); } void diff --git a/syscall.c b/syscall.c index b21ce019..02dce959 100644 --- a/syscall.c +++ b/syscall.c @@ -683,7 +683,7 @@ sys_indir(struct tcb *tcp) return 0; } nargs = sysent[scno].nargs; - tprintf("%s", sysent[scno].sys_name); + tprints(sysent[scno].sys_name); for (i = 0; i < nargs; i++) tprintf(", %#lx", tcp->u_arg[i+1]); } diff --git a/util.c b/util.c index 75a449dc..7f1c6265 100644 --- a/util.c +++ b/util.c @@ -236,7 +236,7 @@ printxval(const struct xlat *xlat, int val, const char *dflt) const char *str = xlookup(xlat, val); if (str) - tprintf("%s", str); + tprints(str); else tprintf("%#x /* %s */", val, dflt); } @@ -340,7 +340,7 @@ printflags(const struct xlat *xlat, int flags, const char *dflt) const char *sep; if (flags == 0 && xlat->val == 0) { - tprintf("%s", xlat->str); + tprints(xlat->str); return 1; } @@ -423,8 +423,7 @@ printfd(struct tcb *tcp, int fd) void printuid(const char *text, unsigned long uid) { - tprintf("%s", text); - tprintf((uid == -1) ? "%ld" : "%lu", uid); + tprintf((uid == -1) ? "%s%ld" : "%s%lu", text, uid); } static char path[MAXPATHLEN + 1]; -- 2.40.0