]> granicus.if.org Git - strace/commitdiff
Fix "format not a string literal" warning caused by tprintf(str)
authorDenys Vlasenko <dvlasenk@redhat.com>
Thu, 1 Sep 2011 07:55:05 +0000 (09:55 +0200)
committerDenys Vlasenko <dvlasenk@redhat.com>
Thu, 1 Sep 2011 07:55:05 +0000 (09:55 +0200)
* 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 <dvlasenk@redhat.com>
defs.h
desc.c
file.c
io.c
net.c
process.c
signal.c
strace.c
syscall.c
util.c

diff --git a/defs.h b/defs.h
index bb2e395d5c17eae45924eb194eb27c9ebd12c7ee..59d4c7a4df8a87c6224ad8e9b00fbf045210401d 100644 (file)
--- 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 e77a2387d779a93ac007bf08a02af4a3a10f4540..5cb8a1a973dc82d35b02b1e31119abc6bea71471 100644 (file)
--- 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 09977e9c434a092cf3125aea764a0befea02e80f..7bf1814813443b2866948dd959a6894b5dcdea8e 100644 (file)
--- 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 e3cad664500e032dbdb5d972c8187cb7685cfb02..fa51cefb99224ad6e214fdd1aa69eb0671162b13 100644 (file)
--- 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 d52d2e590a406a8cec4eb4e598f7217579c55cd3..51a599762b3a1ca43b95c812e84079f6691db7cc 100644 (file)
--- 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;
index 5e0626289fe1a527229c61f7e99d1bcdcf54510e..4ae74a473448a9d8476bdc650c83b521d37b1717 100644 (file)
--- 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];
        }
index 31c5a65464e95f15d5c81b22c98362b281bd014f..84af14f4cf98028056be0f6d3bbcfec72c627f30 100644 (file)
--- 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
index 83ebc5b0d51d28812d2ba56d8c7ac51833a0e53f..9c633887265228a6c6c0f00783dba7b5c99e2367 100644 (file)
--- 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
+                              ? "<writing to pipe>" : outfname);
+       }
 }
 
 void
@@ -2705,7 +2719,7 @@ void
 tabto(void)
 {
        if (curcol < acolumn)
-               tprintf(acolumn_spaces + curcol);
+               tprints(acolumn_spaces + curcol);
 }
 
 void
index b21ce01925f22145fcdc0a1bd1727d10d3627997..02dce959c7860a8d2f15008f12040e2040bd3af2 100644 (file)
--- 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 75a449dc8c78406039ae24d2ee9b213d1326c791..7f1c62657f10db1e8549c18af78a21ab2606a2e6 100644 (file)
--- 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];