]> granicus.if.org Git - strace/commitdiff
syscall: move definitions of automatic variables closer to their use
authorDmitry V. Levin <ldv@altlinux.org>
Tue, 11 Apr 2017 04:04:37 +0000 (04:04 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 11 Apr 2017 04:04:37 +0000 (04:04 +0000)
* syscall.c (trace_syscall_entering, trace_syscall_exiting): Move
definitions of automatic variables closer to their first use.  This
change slightly improves readability.

syscall.c

index 36d57fb6173273696edd4ec900f11acb6ba9d582..f82a0c4a9e149824485f7f30bece9c8bd8a7d802 100644 (file)
--- a/syscall.c
+++ b/syscall.c
@@ -644,11 +644,11 @@ tamper_with_syscall_exiting(struct tcb *tcp)
 static int
 trace_syscall_entering(struct tcb *tcp, unsigned int *sig)
 {
-       int res, scno_good;
-
-       scno_good = res = get_scno(tcp);
+       int res = get_scno(tcp);
        if (res == 0)
                return res;
+
+       int scno_good = res;
        if (res == 1)
                res = get_syscall_args(tcp);
 
@@ -753,11 +753,7 @@ syscall_tampered(struct tcb *tcp)
 static int
 trace_syscall_exiting(struct tcb *tcp)
 {
-       int sys_res;
        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)
@@ -773,7 +769,7 @@ trace_syscall_exiting(struct tcb *tcp)
 #if SUPPORTED_PERSONALITIES > 1
        update_personality(tcp, tcp->currpers);
 #endif
-       res = (get_regs_error ? -1 : get_syscall_result(tcp));
+       int res = (get_regs_error ? -1 : get_syscall_result(tcp));
        if (filtered(tcp) || hide_log(tcp))
                goto ret;
 
@@ -817,7 +813,7 @@ trace_syscall_exiting(struct tcb *tcp)
        }
        tcp->s_prev_ent = tcp->s_ent;
 
-       sys_res = 0;
+       int sys_res = 0;
        if (tcp->qual_flg & QUAL_RAW) {
                /* sys_res = printargs(tcp); - but it's nop on sysexit */
        } else {
@@ -839,7 +835,7 @@ trace_syscall_exiting(struct tcb *tcp)
 
        tprints(") ");
        tabto();
-       u_error = tcp->u_error;
+       unsigned long u_error = tcp->u_error;
 
        if (tcp->qual_flg & QUAL_RAW) {
                if (u_error) {
@@ -851,6 +847,8 @@ trace_syscall_exiting(struct tcb *tcp)
                        tprints(" (INJECTED)");
        }
        else if (!(sys_res & RVAL_NONE) && u_error) {
+               const char *u_error_str;
+
                switch (u_error) {
                /* Blocked signals do not interrupt any syscalls.
                 * In this case syscalls don't return ERESTARTfoo codes.