From: Dmitry V. Levin Date: Sat, 19 Nov 2016 16:33:37 +0000 (+0000) Subject: Cleanup fetch part of printstr_ex X-Git-Tag: v4.15~110 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ead746af18c2a4304320e9421eab646e052bfd43;p=strace Cleanup fetch part of printstr_ex * util.c (printstr_ex): Initialize "style" early, unify error handling. --- diff --git a/util.c b/util.c index c75b64cd..54a77e69 100644 --- a/util.c +++ b/util.c @@ -836,7 +836,8 @@ printstr_ex(struct tcb *tcp, long addr, long len, unsigned int user_style) static char *str = NULL; static char *outstr; unsigned int size; - unsigned int style; + unsigned int style = user_style; + int rc; int ellipsis; if (!addr) { @@ -859,24 +860,18 @@ printstr_ex(struct tcb *tcp, long addr, long len, unsigned int user_style) * Treat as a NUL-terminated string: fetch one byte more * because string_quote may look one byte ahead. */ - if (umovestr(tcp, addr, size, str) < 0) { - printaddr(addr); - return; - } - style = QUOTE_0_TERMINATED; + style |= QUOTE_0_TERMINATED; + rc = umovestr(tcp, addr, size, str); + } else { + if (size > (unsigned long) len) + size = (unsigned long) len; + rc = umoven(tcp, addr, size, str); } - else { - if (size > (unsigned long)len) - size = (unsigned long)len; - if (umoven(tcp, addr, size, str) < 0) { - printaddr(addr); - return; - } - style = 0; + if (rc < 0) { + printaddr(addr); + return; } - style |= user_style; - if (style & QUOTE_0_TERMINATED) { if (size) { --size;