summaryrefslogtreecommitdiff
path: root/net.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2012-01-20 11:04:04 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2012-01-20 11:04:04 +0100
commita1d541ec56e2fb4716f083fcc814b1dedde63d87 (patch)
treedd93ffd232792fac178a1de6bf646c099bdbdc49 /net.c
parentb3c52cf02ae536634898cd12afa5f3fcad17fbf2 (diff)
downloadstrace-a1d541ec56e2fb4716f083fcc814b1dedde63d87.tar.gz
strace-a1d541ec56e2fb4716f083fcc814b1dedde63d87.tar.bz2
strace-a1d541ec56e2fb4716f083fcc814b1dedde63d87.tar.xz
Eliminate code duplication in time printing, reduce a few static buffers
text data bss dec hex filename 238454 664 28772 267890 41672 strace.before 238106 664 28676 267446 414b6 strace * defs.h: Add TIMESPEC_TEXT_BUFSIZE and TIMEVAL_TEXT_BUFSIZE defines. Add 'int special' parameter to sprinttv(). * time.c (sprinttv): Add 'int special' parameter, and use it similarly to 'int special' parameter of printtv_bitness(). (printtv_bitness): Use sprinttv() instead of duplicating its code. (print_timespec): Use sprint_timespec() instead of duplicating its code. * desc.c (decode_select): Use TIMEVAL_TEXT_BUFSIZE instead of 128 when checking remaining buffer size. * net.c (sys_recvmsg): Use TIMESPEC_TEXT_BUFSIZE instead of 128 for static buffer size. * stream.c (decode_poll): Use TIMESPEC_TEXT_BUFSIZE instead of 128 when checking remaining buffer size. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'net.c')
-rw-r--r--net.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/net.c b/net.c
index 4e8df10..67acfb8 100644
--- a/net.c
+++ b/net.c
@@ -1753,12 +1753,16 @@ sys_recvmsg(struct tcb *tcp)
int
sys_recvmmsg(struct tcb *tcp)
{
- static char str[128];
- if (entering(tcp)) {
+ /* +5 chars are for "left " prefix */
+ static char str[5 + TIMESPEC_TEXT_BUFSIZE];
+ if (entering(tcp)) {
tprintf("%ld, ", tcp->u_arg[0]);
if (verbose(tcp)) {
sprint_timespec(str, tcp, tcp->u_arg[4]);
+ /* Abusing tcp->auxstr as temp storage.
+ * Will be used and freed on syscall exit.
+ */
tcp->auxstr = strdup(str);
} else {
tprintf("%#lx, %ld, ", tcp->u_arg[1], tcp->u_arg[2]);
@@ -1790,8 +1794,7 @@ sys_recvmmsg(struct tcb *tcp)
if (!verbose(tcp))
return 0;
/* timeout on exit */
- strcpy(str, "left ");
- sprint_timespec(str + strlen(str), tcp, tcp->u_arg[4]);
+ sprint_timespec(stpcpy(str, "left "), tcp, tcp->u_arg[4]);
tcp->auxstr = str;
return RVAL_STR;
}