From: Denys Vlasenko Date: Sun, 30 Jun 2013 21:53:49 +0000 (+0200) Subject: Fold is_restart_error() into its sole user X-Git-Tag: v4.9~210 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4793221a53fb69aa519bc91ab19a79524c0df097;p=strace Fold is_restart_error() into its sole user Signed-off-by: Denys Vlasenko --- diff --git a/defs.h b/defs.h index 56467ffc..3b027e84 100644 --- a/defs.h +++ b/defs.h @@ -174,6 +174,19 @@ extern long ptrace(int, int, char *, long); # include /* struct pt_regs */ #endif +#ifndef ERESTARTSYS +# define ERESTARTSYS 512 +#endif +#ifndef ERESTARTNOINTR +# define ERESTARTNOINTR 513 +#endif +#ifndef ERESTARTNOHAND +# define ERESTARTNOHAND 514 +#endif +#ifndef ERESTART_RESTARTBLOCK +# define ERESTART_RESTARTBLOCK 516 +#endif + #if !HAVE_DECL_PTRACE_SETOPTIONS # define PTRACE_SETOPTIONS 0x4200 #endif @@ -621,7 +634,6 @@ extern int setbpt(struct tcb *); extern int clearbpt(struct tcb *); extern const char *signame(int); -extern int is_restart_error(struct tcb *); extern void pathtrace_select(const char *); extern int pathtrace_match(struct tcb *); extern int getfdpath(struct tcb *, int, char *, unsigned); diff --git a/syscall.c b/syscall.c index 8220906e..105b28c9 100644 --- a/syscall.c +++ b/syscall.c @@ -80,19 +80,6 @@ # include #endif -#ifndef ERESTARTSYS -# define ERESTARTSYS 512 -#endif -#ifndef ERESTARTNOINTR -# define ERESTARTNOINTR 513 -#endif -#ifndef ERESTARTNOHAND -# define ERESTARTNOHAND 514 /* restart if no handler */ -#endif -#ifndef ERESTART_RESTARTBLOCK -# define ERESTART_RESTARTBLOCK 516 /* restart by calling sys_restart_syscall */ -#endif - #ifndef NSIG # warning: NSIG is not defined, using 32 # define NSIG 32 @@ -694,21 +681,6 @@ getrval2(struct tcb *tcp) } #endif -int -is_restart_error(struct tcb *tcp) -{ - switch (tcp->u_error) { - case ERESTARTSYS: - case ERESTARTNOINTR: - case ERESTARTNOHAND: - case ERESTART_RESTARTBLOCK: - return 1; - default: - break; - } - return 0; -} - #if defined(I386) struct user_regs_struct i386_regs; # define ARCH_REGS_FOR_GETREGSET i386_regs diff --git a/time.c b/time.c index e457a5ff..49ebcea0 100644 --- a/time.c +++ b/time.c @@ -256,15 +256,25 @@ sys_nanosleep(struct tcb *tcp) tprints(", "); } else { /* Second (returned) timespec is only significant - * if syscall was interrupted. We print only its address - * on _success_, since kernel doesn't modify its value. + * if syscall was interrupted. On success, we print + * only its address, since kernel doesn't modify it, + * and printing the value may show uninitialized data. */ - if (is_restart_error(tcp) || !tcp->u_arg[1]) - /* Interrupted (or NULL) */ + switch (tcp->u_error) { + default: + /* Not interrupted (slept entire interval) */ + if (tcp->u_arg[1]) { + tprintf("%#lx", tcp->u_arg[1]); + break; + } + /* Fall through: print_timespec(NULL) prints "NULL" */ + case ERESTARTSYS: + case ERESTARTNOINTR: + case ERESTARTNOHAND: + case ERESTART_RESTARTBLOCK: + /* Interrupted */ print_timespec(tcp, tcp->u_arg[1]); - else - /* Success */ - tprintf("%#lx", tcp->u_arg[1]); + } } return 0; }