diff options
author | Denys Vlasenko <dvlasenk@redhat.com> | 2013-11-11 12:31:18 +0100 |
---|---|---|
committer | Denys Vlasenko <dvlasenk@redhat.com> | 2013-11-11 12:31:18 +0100 |
commit | abd2fda38003f61f50e5b4ed4f77f7997d7172ac (patch) | |
tree | 0d5f7ef4ee30de7230762481dee8ffdc266d1337 | |
parent | ab24d5182847b52095efb129bbd47dfdc1f21662 (diff) | |
download | strace-abd2fda38003f61f50e5b4ed4f77f7997d7172ac.tar.gz strace-abd2fda38003f61f50e5b4ed4f77f7997d7172ac.tar.bz2 strace-abd2fda38003f61f50e5b4ed4f77f7997d7172ac.tar.xz |
sys_io_submit: simplify iocb_cmd_lookup() helper.
This helper returns two values (a string and an enum).
The caller prints the string. It's simpler to just print
the string in the caller itself. This eliminates
"return by reference" and more importantly, an intermediate
static string buffer for the string result.
Since function of the helper is different now,
it is renamed to tprint_lio_opcode().
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
-rw-r--r-- | desc.c | 20 |
1 files changed, 9 insertions, 11 deletions
@@ -843,10 +843,9 @@ enum iocb_sub { SUB_NONE, SUB_COMMON, SUB_POLL, SUB_VECTOR }; -static const char * -iocb_cmd_lookup(unsigned cmd, enum iocb_sub *sub) +static enum iocb_sub +tprint_lio_opcode(unsigned cmd) { - static char buf[sizeof("%u /* SUB_??? */") + sizeof(int)*3]; static const struct { const char *name; enum iocb_sub sub; @@ -863,12 +862,11 @@ iocb_cmd_lookup(unsigned cmd, enum iocb_sub *sub) }; if (cmd < ARRAY_SIZE(cmds)) { - *sub = cmds[cmd].sub; - return cmds[cmd].name; + tprints(cmds[cmd].name); + return cmds[cmd].sub; } - *sub = SUB_NONE; - sprintf(buf, "%u /* SUB_??? */", cmd); - return buf; + tprintf("%u /* SUB_??? */", cmd); + return SUB_NONE; } /* Not defined in libaio.h */ @@ -925,10 +923,10 @@ sys_io_submit(struct tcb *tcp) tprintf("data:%p, ", iocb.data); if (iocb.key) tprintf("key:%u, ", iocb.key); - tprintf("%s, ", iocb_cmd_lookup(iocb.aio_lio_opcode, &sub)); + sub = tprint_lio_opcode(iocb.aio_lio_opcode); if (iocb.aio_reqprio) - tprintf("reqprio:%d, ", iocb.aio_reqprio); - tprintf("filedes:%d", iocb.aio_fildes); + tprintf(", reqprio:%d", iocb.aio_reqprio); + tprintf(", filedes:%d", iocb.aio_fildes); switch (sub) { case SUB_COMMON: #if HAVE_DECL_IO_CMD_PWRITE |