From: Dmitry V. Levin Date: Thu, 29 Mar 2018 16:00:18 +0000 (+0000) Subject: Treat RVAL_DECIMAL the same way as RVAL_UDECIMAL X-Git-Tag: v4.22~45 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=92d7499fbf483c4765679443076c00a4cf302d35;p=strace Treat RVAL_DECIMAL the same way as RVAL_UDECIMAL 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) : 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. --- diff --git a/clone.c b/clone.c index e1dcd713..4bff999d 100644 --- 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 04b0aa39..4f000eec 100644 --- 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 18d847b6..3a07fe42 100644 --- 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 07bb768b..428f69fc 100644 --- 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(", "); diff --git a/syscall.c b/syscall.c index 87f41d93..367e955d 100644 --- 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("= "); diff --git a/tests/inject-nf.c b/tests/inject-nf.c index 249a3e44..b0d8431b 100644 --- a/tests/inject-nf.c +++ b/tests/inject-nf.c @@ -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 1ba01684..95fa8e1c 100644 --- 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 418c737d..d8b169a4 100644 --- a/uid.c +++ b/uid.c @@ -71,14 +71,14 @@ 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)