]> granicus.if.org Git - strace/commitdiff
Treat RVAL_DECIMAL the same way as RVAL_UDECIMAL
authorDmitry V. Levin <ldv@altlinux.org>
Thu, 29 Mar 2018 16:00:18 +0000 (16:00 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Thu, 29 Mar 2018 16:00:18 +0000 (16:00 +0000)
Assuming that syscalls may return negative values only as error codes,
always print non-error syscall return codes as unsigned.

* defs.h (RVAL_UDECIMAL): Remove.
(RVAL_DECIMAL): Rename to RVAL_UDECIMAL.
* syscall.c (syscall_exiting_trace) <case RVAL_DECIMAL>: Remove.
* clone.c (SYS_FUNC(fork)): Remove RVAL_UDECIMAL.
* lseek.c (SYS_FUNC(lseek)): Likewise.
* prctl.c (SYS_FUNC(prctl)): Likewise.
* uid.c (SYS_FUNC(getuid), SYS_FUNC(setfsuid)): Likewise.
* times.c (SYS_FUNC(times)): Always return 0.
* tests/inject-nf.c (main): Update expected output.

clone.c
defs.h
lseek.c
prctl.c
syscall.c
tests/inject-nf.c
times.c
uid.c

diff --git a/clone.c b/clone.c
index e1dcd713029776c1cf365c537273a33e1531415a..4bff999d78bc8c7e6705da01f03397478fbba06c 100644 (file)
--- a/clone.c
+++ b/clone.c
@@ -161,5 +161,5 @@ SYS_FUNC(unshare)
 
 SYS_FUNC(fork)
 {
-       return RVAL_DECODED | RVAL_UDECIMAL;
+       return RVAL_DECODED;
 }
diff --git a/defs.h b/defs.h
index 04b0aa39edd572f861446daf768cf5e6b4a214cf..4f000eec58b01ba210b1b42fcab5f4b5304f7dba 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -320,10 +320,9 @@ extern const struct xlat tcp_states[];
 extern const struct xlat whence_codes[];
 
 /* Format of syscall return values */
-#define RVAL_DECIMAL   000     /* decimal format */
+#define RVAL_UDECIMAL  000     /* unsigned decimal format */
 #define RVAL_HEX       001     /* hex format */
 #define RVAL_OCTAL     002     /* octal format */
-#define RVAL_UDECIMAL  003     /* unsigned decimal format */
 #define RVAL_FD                010     /* file descriptor */
 #define RVAL_MASK      013     /* mask for these values */
 
diff --git a/lseek.c b/lseek.c
index 18d847b682fffa334143d3bbf3381474a958284f..3a07fe42c37182b22f8ce568d990a9d627937fbb 100644 (file)
--- a/lseek.c
+++ b/lseek.c
@@ -62,7 +62,7 @@ SYS_FUNC(lseek)
 
        printxval(whence_codes, tcp->u_arg[2], "SEEK_???");
 
-       return RVAL_DECODED | RVAL_UDECIMAL;
+       return RVAL_DECODED;
 }
 
 /* llseek syscall takes explicitly two ulong arguments hi, lo,
diff --git a/prctl.c b/prctl.c
index 07bb768b1ad53360904c21b07f30596f629c0624..428f69fc12b5af8af270da38048c887eee12b957 100644 (file)
--- a/prctl.c
+++ b/prctl.c
@@ -373,7 +373,7 @@ SYS_FUNC(prctl)
                        return 0;
                tcp->auxstr = xlookup(pr_mce_kill_policy,
                                      (kernel_ulong_t) tcp->u_rval);
-               return tcp->auxstr ? RVAL_STR : RVAL_UDECIMAL;
+               return RVAL_STR;
 
        case PR_SET_FP_MODE:
                tprints(", ");
index 87f41d93f3d4542944963dd3f7f147e95db82d6d..367e955d376168891bec44fd42054f59ae1c524f 100644 (file)
--- a/syscall.c
+++ b/syscall.c
@@ -935,16 +935,6 @@ syscall_exiting_trace(struct tcb *tcp, struct timespec *ts, int res)
                                        tprintf("= %" PRI_klu, tcp->u_rval);
                                }
                                break;
-                       case RVAL_DECIMAL:
-#if ANY_WORDSIZE_LESS_THAN_KERNEL_LONG
-                               if (current_klongsize < sizeof(tcp->u_rval)) {
-                                       tprintf("= %d", (int) tcp->u_rval);
-                               } else
-#endif
-                               {
-                                       tprintf("= %" PRI_kld, tcp->u_rval);
-                               }
-                               break;
                        case RVAL_FD:
                                if (show_fd_path) {
                                        tprints("= ");
index 249a3e44ff6fb4c482c63029cb3d53bda27118a4..b0d8431b244a4c28ec805e0b985094243398c8f3 100644 (file)
@@ -76,8 +76,8 @@ main(int ac, char **av)
                                   (unsigned long long) err);
 
        if (ac == 2) {
-               printf("%s() = %lld (INJECTED)\n",
-                      SC_NAME, sign_extend_unsigned_to_ll(rc));
+               printf("%s() = %llu (INJECTED)\n",
+                      SC_NAME, (unsigned long long) rc);
 
                puts("+++ exited with 0 +++");
        }
diff --git a/times.c b/times.c
index 1ba0168455b8528536504ca54d4f0d60501b2695..95fa8e1cadb2baae94efdeffa3a1f6bbf139486b 100644 (file)
--- a/times.c
+++ b/times.c
@@ -42,10 +42,7 @@ SYS_FUNC(times)
 {
        tms_t tbuf;
 
-       if (entering(tcp))
-               return 0;
-
-       if (!umove_or_printaddr(tcp, tcp->u_arg[0], &tbuf)) {
+       if (exiting(tcp) && !umove_or_printaddr(tcp, tcp->u_arg[0], &tbuf)) {
                tprintf("{tms_utime=%llu, tms_stime=%llu, ",
                        zero_extend_signed_to_ull(tbuf.tms_utime),
                        zero_extend_signed_to_ull(tbuf.tms_stime));
@@ -54,5 +51,5 @@ SYS_FUNC(times)
                        zero_extend_signed_to_ull(tbuf.tms_cstime));
        }
 
-       return syserror(tcp) ? RVAL_DECIMAL : RVAL_UDECIMAL;
+       return 0;
 }
diff --git a/uid.c b/uid.c
index 418c737dac0a28ff2949027a84c371cbedde9e6f..d8b169a477fa8ddb7f11d8fa50a79d886f81bc2a 100644 (file)
--- a/uid.c
+++ b/uid.c
 
 SYS_FUNC(getuid)
 {
-       return RVAL_UDECIMAL | RVAL_DECODED;
+       return RVAL_DECODED;
 }
 
 SYS_FUNC(setfsuid)
 {
        printuid("", tcp->u_arg[0]);
 
-       return RVAL_UDECIMAL | RVAL_DECODED;
+       return RVAL_DECODED;
 }
 
 SYS_FUNC(setuid)