Improve code readability by avoiding assignments inside if()
* desc.c (decode_select): Move assignment out of if() condition.
* file.c (sprinttime): Likewise.
(sys_getdirentries): Likewise.
* io.c (sys_ioctl): Likewise.
* strace.c (test_ptrace_setoptions_followfork): Likewise.
(main): Likewise.
(proc_open): Likewise.
(detach): Likewise.
(proc_poll): Likewise.
(trace): Likewise.
* syscall.c (qualify): Likewise.
(sys_indir): Likewise.
* test/procpollable.c (main): Likewise.
* test/sfd.c (main): Likewise.
* time.c (printtv_bitness): Likewise.
(sprinttv): Likewise.
(print_timespec): Likewise.
(void sprint_timespec): Likewise.
(printitv_bitness): Likewise.
* util.c (dumpstr): Likewise.
(umovestr): Likewise.
(fixvfork): Likewise.
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
diff --git a/file.c b/file.c
index 38bf976..5d5a0fe 100644
--- a/file.c
+++ b/file.c
@@ -738,7 +738,8 @@
strcpy(buf, "0");
return buf;
}
- if ((tmp = localtime(&t)))
+ tmp = localtime(&t);
+ if (tmp)
snprintf(buf, sizeof buf, "%02d/%02d/%02d-%02d:%02d:%02d",
tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
@@ -2590,7 +2591,8 @@
return 0;
}
len = tcp->u_rval;
- if ((buf = malloc(len)) == NULL) {
+ buf = malloc(len);
+ if (buf == NULL) {
tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
fprintf(stderr, "out of memory\n");
return 0;