diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2012-01-20 11:04:04 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2012-01-20 11:04:04 +0100 |
commit | a1d541ec56e2fb4716f083fcc814b1dedde63d87 (patch) | |
tree | dd93ffd232792fac178a1de6bf646c099bdbdc49 /net.c | |
parent | b3c52cf02ae536634898cd12afa5f3fcad17fbf2 (diff) | |
download | strace-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.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -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; } |