]> granicus.if.org Git - strace/commitdiff
Use err_name, print unrecognized errno values as numbers
authorDmitry V. Levin <ldv@altlinux.org>
Mon, 3 Oct 2016 11:59:39 +0000 (11:59 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 3 Oct 2016 12:03:03 +0000 (12:03 +0000)
* syscall.c (trace_syscall_exiting): Use err_name() instead
of open-coding it.  Print unrecognized errno values using %lu format
instead of ERRNO_%lu as the latter prodices an invalid constant.

syscall.c

index a4eb5cd19c63814e6a1738e30e05b9b8fe8223f0..90770857419c27f72d2f1898d3a612efe0bd6b85 100644 (file)
--- a/syscall.c
+++ b/syscall.c
@@ -887,6 +887,7 @@ trace_syscall_exiting(struct tcb *tcp)
        struct timeval tv;
        int res;
        unsigned long u_error;
+       const char *u_error_str;
 
        /* Measure the exit time as early as possible to avoid errors. */
        if (Tflag || cflag)
@@ -1028,12 +1029,13 @@ trace_syscall_exiting(struct tcb *tcp)
                        tprints("= ? ERESTART_RESTARTBLOCK (Interrupted by signal)");
                        break;
                default:
-                       if (u_error < nerrnos && errnoent[u_error])
-                               tprintf("= -1 %s (%s)", errnoent[u_error],
-                                       strerror(u_error));
+                       u_error_str = err_name(u_error);
+                       if (u_error_str)
+                               tprintf("= -1 %s (%s)",
+                                       u_error_str, strerror(u_error));
                        else
-                               tprintf("= -1 ERRNO_%lu (%s)", u_error,
-                                       strerror(u_error));
+                               tprintf("= -1 %lu (%s)",
+                                       u_error, strerror(u_error));
                        break;
                }
                if ((sys_res & RVAL_STR) && tcp->auxstr)