]> granicus.if.org Git - strace/commitdiff
print_xattr_val: do not fetch data in case of !verbose || syserror
authorDmitry V. Levin <ldv@altlinux.org>
Tue, 14 Jul 2015 23:34:06 +0000 (23:34 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 14 Jul 2015 23:34:06 +0000 (23:34 +0000)
* xattr.c (print_xattr_val): Do not fetch data in case
of !verbose || syserror.   Use printaddr.

xattr.c

diff --git a/xattr.c b/xattr.c
index da22fceef61cd3dd8fe8a17e0155e8b397471c56..7a14eea6a32c40c9b1325d8e38bf5ea454ea80f6 100644 (file)
--- a/xattr.c
+++ b/xattr.c
@@ -12,43 +12,48 @@ print_xattr_val(struct tcb *tcp,
                unsigned long insize,
                unsigned long size)
 {
-       char *buf;
+       char *buf = NULL;
        unsigned int len;
 
+       tprints(", ");
+
        if (insize == 0)
-               goto failed;
+               goto done;
 
        len = size;
        if (size != (unsigned long) len)
-               goto failed;
+               goto done;
 
        if (!len) {
-               tprintf("\"\", %ld", insize);
+               tprintf("\"\", %ld", insize);
                return;
        }
 
+       if (!verbose(tcp) || (exiting(tcp) && syserror(tcp)))
+               goto done;
+
        buf = malloc(len);
        if (!buf)
-               goto failed;
+               goto done;
 
-       if (umoven(tcp, arg, len, buf) < 0) {
+       if (umoven(tcp, addr, len, buf) < 0) {
                free(buf);
-               goto failed;
+               buf = NULL;
+               goto done;
        }
 
        /* Don't print terminating NUL if there is one. */
        if (buf[len - 1] == '\0')
                --len;
 
-       tprints(", ");
-       print_quoted_string(buf, len, 0);
+done:
+       if (buf) {
+               print_quoted_string(buf, len, 0);
+               free(buf);
+       } else {
+               printaddr(addr);
+       }
        tprintf(", %ld", insize);
-
-       free(buf);
-       return;
-
-failed:
-       tprintf(", 0x%lx, %ld", arg, insize);
 }
 
 SYS_FUNC(setxattr)