]> granicus.if.org Git - strace/commitdiff
Fold is_restart_error() into its sole user
authorDenys Vlasenko <dvlasenk@redhat.com>
Sun, 30 Jun 2013 21:53:49 +0000 (23:53 +0200)
committerDenys Vlasenko <dvlasenk@redhat.com>
Sun, 30 Jun 2013 21:53:49 +0000 (23:53 +0200)
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
defs.h
syscall.c
time.c

diff --git a/defs.h b/defs.h
index 56467ffcb35fece757ac28b475c54f40cfbbba65..3b027e8472c393abace0a7b9b11f030178b5e2ef 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -174,6 +174,19 @@ extern long ptrace(int, int, char *, long);
 # include <asm/ptrace.h>  /* 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);
index 8220906e6b13fe2151823013f3c568283c0c8a13..105b28c99cee6450c15057e51eee5192e8d84516 100644 (file)
--- a/syscall.c
+++ b/syscall.c
 # include <asm/ptrace.h>
 #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 e457a5ff06a14cce29aa37b4646c8e64e0cb4f57..49ebcea0303e5e007b56b3e59bd37115967d68ed 100644 (file)
--- 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;
 }