Whitespace cleanups. No code changes.

* count.c: Place opening curly brace after if (),
  not on the next line. Almost all strace code alredy
  uses this style.
* desc.c: Likewise.
* file.c: Likewise.
* net.c: Likewise.
* pathtrace.c: Likewise.
* process.c: Likewise.
* quota.c: Likewise.
* signal.c: Likewise.
* strace.c: Likewise.
* syscall.c: Likewise.
* time.c: Likewise.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
This commit is contained in:
Denys Vlasenko 2011-06-22 14:32:43 +02:00
parent 3d5ed41252
commit 7b609d5ba0
11 changed files with 67 additions and 131 deletions

38
count.c
View File

@ -53,11 +53,9 @@ count_syscall(struct tcb *tcp, struct timeval *tv)
if (tcp->scno < 0 || tcp->scno >= nsyscalls)
return 0;
if (!counts)
{
if (!counts) {
counts = calloc(nsyscalls, sizeof(*counts));
if (!counts)
{
if (!counts) {
fprintf(stderr,
"strace: out of memory for call counts\n");
exit(1);
@ -70,12 +68,10 @@ count_syscall(struct tcb *tcp, struct timeval *tv)
tv_sub(tv, tv, &tcp->etime);
#ifdef LINUX
if (tv_cmp(tv, &tcp->dtime) > 0)
{
if (tv_cmp(tv, &tcp->dtime) > 0) {
static struct timeval one_tick;
if (one_tick.tv_usec == 0)
{
if (one_tick.tv_usec == 0) {
/* Initialize it. */
struct itimerval it;
@ -88,8 +84,7 @@ count_syscall(struct tcb *tcp, struct timeval *tv)
if (tv_nz(&tcp->dtime))
*tv = tcp->dtime;
else if (tv_cmp(tv, &one_tick) > 0)
{
else if (tv_cmp(tv, &one_tick) > 0) {
if (tv_cmp(&shortest, &one_tick) < 0)
*tv = shortest;
else
@ -141,8 +136,7 @@ set_sortby(const char *sortby)
sortfun = syscall_cmp;
else if (strcmp(sortby, "nothing") == 0)
sortfun = NULL;
else
{
else {
fprintf(stderr, "invalid sortby: `%s'\n", sortby);
exit(1);
}
@ -165,20 +159,17 @@ call_summary_pers(FILE *outf)
char error_str[16];
int *sorted_count = calloc(sizeof(int), nsyscalls);
if (!sorted_count)
{
if (!sorted_count) {
fprintf(stderr, "strace: out of memory for call summary\n");
return;
}
call_cum = error_cum = tv_cum.tv_sec = tv_cum.tv_usec = 0;
if (overhead.tv_sec == -1)
{
if (overhead.tv_sec == -1) {
tv_mul(&overhead, &shortest, 8);
tv_div(&overhead, &overhead, 10);
}
for (i = 0; i < nsyscalls; i++)
{
for (i = 0; i < nsyscalls; i++) {
sorted_count[i] = i;
if (counts == NULL || counts[i].calls == 0)
continue;
@ -195,10 +186,8 @@ call_summary_pers(FILE *outf)
"calls", "errors", "syscall");
fprintf(outf, "%6.6s %11.11s %11.11s %9.9s %9.9s %-16.16s\n",
dashes, dashes, dashes, dashes, dashes, dashes);
if (counts)
{
for (i = 0; i < nsyscalls; i++)
{
if (counts) {
for (i = 0; i < nsyscalls; i++) {
j = sorted_count[i];
if (counts[j].calls == 0)
continue;
@ -232,10 +221,9 @@ call_summary_pers(FILE *outf)
void
call_summary(FILE *outf)
{
int i, old_pers = current_personality;
int i, old_pers = current_personality;
for (i = 0; i < SUPPORTED_PERSONALITIES; ++i)
{
for (i = 0; i < SUPPORTED_PERSONALITIES; ++i) {
if (!countv[i])
continue;

3
desc.c
View File

@ -531,8 +531,7 @@ decode_select(struct tcb *tcp, long *args, enum bitness_t bitness)
tprintf(", ");
printtv_bitness(tcp, args[4], bitness, 0);
}
else
{
else {
unsigned int cumlen = 0;
const char *sep = "";

3
file.c
View File

@ -335,8 +335,7 @@ print_dirfd(struct tcb *tcp, int fd)
{
if (fd == AT_FDCWD)
tprintf("AT_FDCWD, ");
else
{
else {
printfd(tcp, fd);
tprintf(", ");
}

3
net.c
View File

@ -1467,8 +1467,7 @@ tprint_sock_type(struct tcb *tcp, int flags)
{
const char *str = xlookup(socktypes, flags & SOCK_TYPE_MASK);
if (str)
{
if (str) {
tprintf("%s", str);
flags &= ~SOCK_TYPE_MASK;
if (!flags)

View File

@ -51,8 +51,7 @@ pathmatch(const char *path)
{
unsigned int i;
for (i = 0; i < ARRAY_SIZE(selected); ++i)
{
for (i = 0; i < ARRAY_SIZE(selected); ++i) {
if (selected[i] == NULL)
return 0;
if (!strcmp(path, selected[i]))
@ -67,7 +66,7 @@ pathmatch(const char *path)
static int
upathmatch(struct tcb *tcp, unsigned long upath)
{
char path[PATH_MAX + 1];
char path[PATH_MAX + 1];
return umovestr(tcp, upath, sizeof path, path) == 0 &&
pathmatch(path);
@ -93,11 +92,9 @@ storepath(const char *path)
{
unsigned int i;
if (path == NULL)
{
if (path == NULL) {
for (i = 0; i < ARRAY_SIZE(selected); ++i)
if (selected[i])
{
if (selected[i]) {
free((char *) selected[i]);
selected[i] = NULL;
}
@ -105,8 +102,7 @@ storepath(const char *path)
}
for (i = 0; i < ARRAY_SIZE(selected); ++i)
if (!selected[i])
{
if (!selected[i]) {
selected[i] = path;
return 0;
}
@ -161,8 +157,7 @@ pathtrace_select(const char *path)
return 0;
/* if realpath and specified path are same, we're done */
if (!strcmp(path, rpath))
{
if (!strcmp(path, rpath)) {
free(rpath);
return 0;
}
@ -247,29 +242,25 @@ pathtrace_match(struct tcb *tcp)
upathmatch(tcp, tcp->u_arg[3]);
}
if (s->sys_func == sys_old_mmap || s->sys_func == sys_mmap)
{
if (s->sys_func == sys_old_mmap || s->sys_func == sys_mmap) {
/* x, x, x, x, fd */
return fdmatch(tcp, tcp->u_arg[4]);
}
if (s->sys_func == sys_symlinkat)
{
if (s->sys_func == sys_symlinkat) {
/* path, fd, path */
return fdmatch(tcp, tcp->u_arg[1]) ||
upathmatch(tcp, tcp->u_arg[0]) ||
upathmatch(tcp, tcp->u_arg[2]);
}
if (!strcmp(s->sys_name, "splice"))
{
if (!strcmp(s->sys_name, "splice")) {
/* fd, x, fd, x, x */
return fdmatch(tcp, tcp->u_arg[0]) ||
fdmatch(tcp, tcp->u_arg[2]);
}
if (s->sys_func == sys_epoll_ctl)
{
if (s->sys_func == sys_epoll_ctl) {
/* x, x, fd, x */
return fdmatch(tcp, tcp->u_arg[2]);
}
@ -283,8 +274,7 @@ pathtrace_match(struct tcb *tcp)
unsigned fdsize;
fd_set *fds;
if (s->sys_func == sys_oldselect)
{
if (s->sys_func == sys_oldselect) {
if (umoven(tcp, tcp->u_arg[0], sizeof oldargs,
(char*) oldargs) < 0)
{
@ -300,26 +290,22 @@ pathtrace_match(struct tcb *tcp)
& -sizeof(long));
fds = malloc(fdsize);
if (fds == NULL)
{
if (fds == NULL) {
fprintf(stderr, "out of memory\n");
return 0;
}
for (i = 1; i <= 3; ++i)
{
for (i = 1; i <= 3; ++i) {
if (args[i] == 0)
continue;
if (umoven(tcp, args[i], fdsize, (char *) fds) < 0)
{
if (umoven(tcp, args[i], fdsize, (char *) fds) < 0) {
fprintf(stderr, "umoven() failed\n");
continue;
}
for (j = 0; j < nfds; ++j)
if (FD_ISSET(j, fds) && fdmatch(tcp, j))
{
if (FD_ISSET(j, fds) && fdmatch(tcp, j)) {
free(fds);
return 1;
}

View File

@ -845,8 +845,7 @@ Process %u resumed (parent %d ready)\n",
}
#ifdef TCB_CLONE_THREAD
if (sysent[tcp->scno].sys_func == sys_clone)
{
if (sysent[tcp->scno].sys_func == sys_clone) {
/*
* Save the flags used in this call,
* in case we point TCP to our parent below.

87
quota.c
View File

@ -330,20 +330,17 @@ struct xfs_dqstats
static void
decode_cmd_data(struct tcb *tcp, u_int32_t cmd, unsigned long data)
{
switch (cmd)
{
switch (cmd) {
case Q_GETQUOTA:
case Q_SETQUOTA:
{
struct if_dqblk dq;
if (cmd == Q_GETQUOTA && syserror(tcp))
{
if (cmd == Q_GETQUOTA && syserror(tcp)) {
tprintf("%#lx", data);
break;
}
if (umove(tcp, data, &dq) < 0)
{
if (umove(tcp, data, &dq) < 0) {
tprintf("{???} %#lx", data);
break;
}
@ -353,8 +350,7 @@ decode_cmd_data(struct tcb *tcp, u_int32_t cmd, unsigned long data)
tprintf("ihardlimit=%" PRIu64 ", ", dq.dqb_ihardlimit);
tprintf("isoftlimit=%" PRIu64 ", ", dq.dqb_isoftlimit);
tprintf("curinodes=%" PRIu64 ", ", dq.dqb_curinodes);
if (!abbrev(tcp))
{
if (!abbrev(tcp)) {
tprintf("btime=%" PRIu64 ", ", dq.dqb_btime);
tprintf("itime=%" PRIu64 ", ", dq.dqb_itime);
tprintf("valid=");
@ -370,13 +366,11 @@ decode_cmd_data(struct tcb *tcp, u_int32_t cmd, unsigned long data)
{
struct v1_dqblk dq;
if (cmd == Q_V1_GETQUOTA && syserror(tcp))
{
if (cmd == Q_V1_GETQUOTA && syserror(tcp)) {
tprintf("%#lx", data);
break;
}
if (umove(tcp, data, &dq) < 0)
{
if (umove(tcp, data, &dq) < 0) {
tprintf("{???} %#lx", data);
break;
}
@ -395,13 +389,11 @@ decode_cmd_data(struct tcb *tcp, u_int32_t cmd, unsigned long data)
{
struct v2_dqblk dq;
if (cmd == Q_V2_GETQUOTA && syserror(tcp))
{
if (cmd == Q_V2_GETQUOTA && syserror(tcp)) {
tprintf("%#lx", data);
break;
}
if (umove(tcp, data, &dq) < 0)
{
if (umove(tcp, data, &dq) < 0) {
tprintf("{???} %#lx", data);
break;
}
@ -420,13 +412,11 @@ decode_cmd_data(struct tcb *tcp, u_int32_t cmd, unsigned long data)
{
struct xfs_dqblk dq;
if (cmd == Q_XGETQUOTA && syserror(tcp))
{
if (cmd == Q_XGETQUOTA && syserror(tcp)) {
tprintf("%#lx", data);
break;
}
if (umove(tcp, data, &dq) < 0)
{
if (umove(tcp, data, &dq) < 0) {
tprintf("{???} %#lx", data);
break;
}
@ -442,8 +432,7 @@ decode_cmd_data(struct tcb *tcp, u_int32_t cmd, unsigned long data)
tprintf("ino_softlimit=%" PRIu64 ", ", dq.d_ino_softlimit);
tprintf("bcount=%" PRIu64 ", ", dq.d_bcount);
tprintf("icount=%" PRIu64 ", ", dq.d_icount);
if (!abbrev(tcp))
{
if (!abbrev(tcp)) {
tprintf("itimer=%d, ", dq.d_itimer);
tprintf("btimer=%d, ", dq.d_btimer);
tprintf("iwarns=%u, ", dq.d_iwarns);
@ -459,13 +448,11 @@ decode_cmd_data(struct tcb *tcp, u_int32_t cmd, unsigned long data)
{
u_int32_t fmt;
if (syserror(tcp))
{
if (syserror(tcp)) {
tprintf("%#lx", data);
break;
}
if (umove(tcp, data, &fmt) < 0)
{
if (umove(tcp, data, &fmt) < 0) {
tprintf("{???} %#lx", data);
break;
}
@ -479,13 +466,11 @@ decode_cmd_data(struct tcb *tcp, u_int32_t cmd, unsigned long data)
{
struct if_dqinfo dq;
if (cmd == Q_GETINFO && syserror(tcp))
{
if (cmd == Q_GETINFO && syserror(tcp)) {
tprintf("%#lx", data);
break;
}
if (umove(tcp, data, &dq) < 0)
{
if (umove(tcp, data, &dq) < 0) {
tprintf("{???} %#lx", data);
break;
}
@ -502,13 +487,11 @@ decode_cmd_data(struct tcb *tcp, u_int32_t cmd, unsigned long data)
{
struct v2_dqinfo dq;
if (cmd == Q_V2_GETINFO && syserror(tcp))
{
if (cmd == Q_V2_GETINFO && syserror(tcp)) {
tprintf("%#lx", data);
break;
}
if (umove(tcp, data, &dq) < 0)
{
if (umove(tcp, data, &dq) < 0) {
tprintf("{???} %#lx", data);
break;
}
@ -524,13 +507,11 @@ decode_cmd_data(struct tcb *tcp, u_int32_t cmd, unsigned long data)
{
struct v1_dqstats dq;
if (syserror(tcp))
{
if (syserror(tcp)) {
tprintf("%#lx", data);
break;
}
if (umove(tcp, data, &dq) < 0)
{
if (umove(tcp, data, &dq) < 0) {
tprintf("{???} %#lx", data);
break;
}
@ -548,13 +529,11 @@ decode_cmd_data(struct tcb *tcp, u_int32_t cmd, unsigned long data)
{
struct v2_dqstats dq;
if (syserror(tcp))
{
if (syserror(tcp)) {
tprintf("%#lx", data);
break;
}
if (umove(tcp, data, &dq) < 0)
{
if (umove(tcp, data, &dq) < 0) {
tprintf("{???} %#lx", data);
break;
}
@ -573,19 +552,16 @@ decode_cmd_data(struct tcb *tcp, u_int32_t cmd, unsigned long data)
{
struct xfs_dqstats dq;
if (syserror(tcp))
{
if (syserror(tcp)) {
tprintf("%#lx", data);
break;
}
if (umove(tcp, data, &dq) < 0)
{
if (umove(tcp, data, &dq) < 0) {
tprintf("{???} %#lx", data);
break;
}
tprintf("{version=%d, ", dq.qs_version);
if (abbrev(tcp))
{
if (abbrev(tcp)) {
tprintf("...}");
break;
}
@ -610,8 +586,7 @@ decode_cmd_data(struct tcb *tcp, u_int32_t cmd, unsigned long data)
{
u_int32_t flag;
if (umove(tcp, data, &flag) < 0)
{
if (umove(tcp, data, &flag) < 0) {
tprintf("{???} %#lx", data);
break;
}
@ -643,16 +618,14 @@ sys_quotactl(struct tcb *tcp)
if (!verbose(tcp))
return printargs(tcp);
if (entering(tcp))
{
if (entering(tcp)) {
printxval(quotacmds, cmd, "Q_???");
tprintf("|");
printxval(quotatypes, type, "???QUOTA");
tprintf(", ");
printstr(tcp, tcp->u_arg[1], -1);
tprintf(", ");
switch (cmd)
{
switch (cmd) {
case Q_V1_QUOTAON:
case Q_QUOTAON:
printxval(quota_formats, id, "QFMT_VFS_???");
@ -675,8 +648,7 @@ sys_quotactl(struct tcb *tcp)
break;
}
tprintf(", ");
} else
{
} else {
if (!tcp->u_arg[3])
tprintf("NULL");
else
@ -716,8 +688,7 @@ int
sys_quotactl(struct tcb *tcp)
{
/* fourth arg (addr) not interpreted here */
if (entering(tcp))
{
if (entering(tcp)) {
#ifdef SUNOS4
printxval(quotacmds, tcp->u_arg[0], "Q_???");
tprintf(", ");

View File

@ -894,16 +894,14 @@ sigishandled(struct tcb *tcp, int sig)
* command name has any spaces in it. So be it.
*/
s = strstr(buf, "SigIgn:\t");
if (!s)
{
if (!s) {
fprintf(stderr, "/proc/pid/status format error\n");
return 1;
}
parse_sigset_t(s + 8, &ignored);
s = strstr(buf, "SigCgt:\t");
if (!s)
{
if (!s) {
fprintf(stderr, "/proc/pid/status format error\n");
return 1;
}

View File

@ -317,8 +317,7 @@ swap_uid(void)
#ifndef SVR4
int euid = geteuid(), uid = getuid();
if (euid != uid && setreuid(euid, uid) < 0)
{
if (euid != uid && setreuid(euid, uid) < 0) {
fprintf(stderr, "%s: setreuid: %s\n",
progname, strerror(errno));
exit(1);

View File

@ -2419,8 +2419,7 @@ trace_syscall_exiting(struct tcb *tcp)
if (cflag) {
struct timeval t = tv;
int rc = count_syscall(tcp, &t);
if (cflag == CFLAG_ONLY_STATS)
{
if (cflag == CFLAG_ONLY_STATS) {
tcp->flags &= ~TCB_INSYSCALL;
return rc;
}

5
time.c
View File

@ -359,7 +359,7 @@ printitv_bitness(struct tcb *tcp, long addr, enum bitness_t bitness)
} else {
struct itimerval itv;
if ((rc = umove(tcp, addr, &itv)) >= 0) {
if ((rc = umove(tcp, addr, &itv)) >= 0) {
tprintf("{it_interval=");
tprint_timeval(tcp, &itv.it_interval);
tprintf(", it_value=");
@ -784,8 +784,7 @@ printsigevent(struct tcb *tcp, long arg)
struct sigevent sev;
#if SUPPORTED_PERSONALITIES > 1
if (personality_wordsize[current_personality] == 4)
{
if (personality_wordsize[current_personality] == 4) {
printsigevent32(tcp, arg);
return;
}