Consistently use both leading and trailing spaces inside of the {}'s

when pretty-printing structures.  Most structures used both spaces,
but some only used a trailing space and some used neither.
This commit is contained in:
John Baldwin 2015-08-06 20:05:40 +00:00
parent a046541623
commit 1e2ec671fc
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=286388

View File

@ -847,7 +847,7 @@ print_arg(struct syscall_args *sc, unsigned long *args, long retval,
struct timespec ts; struct timespec ts;
if (get_struct(pid, (void *)args[sc->offset], &ts, if (get_struct(pid, (void *)args[sc->offset], &ts,
sizeof(ts)) != -1) sizeof(ts)) != -1)
asprintf(&tmp, "{%ld.%09ld }", (long)ts.tv_sec, asprintf(&tmp, "{ %ld.%09ld }", (long)ts.tv_sec,
ts.tv_nsec); ts.tv_nsec);
else else
asprintf(&tmp, "0x%lx", args[sc->offset]); asprintf(&tmp, "0x%lx", args[sc->offset]);
@ -863,7 +863,7 @@ print_arg(struct syscall_args *sc, unsigned long *args, long retval,
if (get_struct(pid, (void *)args[sc->offset], &ts, sizeof(ts)) if (get_struct(pid, (void *)args[sc->offset], &ts, sizeof(ts))
!= -1) { != -1) {
fp = open_memstream(&tmp, &len); fp = open_memstream(&tmp, &len);
fputc('{', fp); fputs("{ ", fp);
sep = ""; sep = "";
for (i = 0; i < nitems(ts); i++) { for (i = 0; i < nitems(ts); i++) {
fputs(sep, fp); fputs(sep, fp);
@ -881,7 +881,7 @@ print_arg(struct syscall_args *sc, unsigned long *args, long retval,
break; break;
} }
} }
fputc('}', fp); fputs(" }", fp);
fclose(fp); fclose(fp);
} else } else
asprintf(&tmp, "0x%lx", args[sc->offset]); asprintf(&tmp, "0x%lx", args[sc->offset]);
@ -891,7 +891,7 @@ print_arg(struct syscall_args *sc, unsigned long *args, long retval,
struct timeval tv; struct timeval tv;
if (get_struct(pid, (void *)args[sc->offset], &tv, sizeof(tv)) if (get_struct(pid, (void *)args[sc->offset], &tv, sizeof(tv))
!= -1) != -1)
asprintf(&tmp, "{%ld.%06ld }", (long)tv.tv_sec, asprintf(&tmp, "{ %ld.%06ld }", (long)tv.tv_sec,
tv.tv_usec); tv.tv_usec);
else else
asprintf(&tmp, "0x%lx", args[sc->offset]); asprintf(&tmp, "0x%lx", args[sc->offset]);
@ -901,7 +901,7 @@ print_arg(struct syscall_args *sc, unsigned long *args, long retval,
struct timeval tv[2]; struct timeval tv[2];
if (get_struct(pid, (void *)args[sc->offset], &tv, sizeof(tv)) if (get_struct(pid, (void *)args[sc->offset], &tv, sizeof(tv))
!= -1) != -1)
asprintf(&tmp, "{%ld.%06ld, %ld.%06ld }", asprintf(&tmp, "{ %ld.%06ld, %ld.%06ld }",
(long)tv[0].tv_sec, tv[0].tv_usec, (long)tv[0].tv_sec, tv[0].tv_usec,
(long)tv[1].tv_sec, tv[1].tv_usec); (long)tv[1].tv_sec, tv[1].tv_usec);
else else
@ -912,7 +912,7 @@ print_arg(struct syscall_args *sc, unsigned long *args, long retval,
struct itimerval itv; struct itimerval itv;
if (get_struct(pid, (void *)args[sc->offset], &itv, if (get_struct(pid, (void *)args[sc->offset], &itv,
sizeof(itv)) != -1) sizeof(itv)) != -1)
asprintf(&tmp, "{%ld.%06ld, %ld.%06ld }", asprintf(&tmp, "{ %ld.%06ld, %ld.%06ld }",
(long)itv.it_interval.tv_sec, (long)itv.it_interval.tv_sec,
itv.it_interval.tv_usec, itv.it_interval.tv_usec,
(long)itv.it_value.tv_sec, (long)itv.it_value.tv_sec,
@ -1016,6 +1016,7 @@ print_arg(struct syscall_args *sc, unsigned long *args, long retval,
tmpsize); tmpsize);
tmp[used++] = '{'; tmp[used++] = '{';
tmp[used++] = ' ';
for (i = 0; i < numfds; i++) { for (i = 0; i < numfds; i++) {
u = snprintf(tmp + used, per_fd, "%s%d/%s", u = snprintf(tmp + used, per_fd, "%s%d/%s",
@ -1024,6 +1025,7 @@ print_arg(struct syscall_args *sc, unsigned long *args, long retval,
if (u > 0) if (u > 0)
used += u < per_fd ? u : per_fd; used += u < per_fd ? u : per_fd;
} }
tmp[used++] = ' ';
tmp[used++] = '}'; tmp[used++] = '}';
tmp[used++] = '\0'; tmp[used++] = '\0';
} else { } else {
@ -1056,6 +1058,7 @@ print_arg(struct syscall_args *sc, unsigned long *args, long retval,
"output", tmpsize); "output", tmpsize);
tmp[used++] = '{'; tmp[used++] = '{';
tmp[used++] = ' ';
for (i = 0; i < numfds; i++) { for (i = 0; i < numfds; i++) {
if (FD_ISSET(i, fds)) { if (FD_ISSET(i, fds)) {
u = snprintf(tmp + used, per_fd, "%d ", u = snprintf(tmp + used, per_fd, "%d ",
@ -1064,8 +1067,6 @@ print_arg(struct syscall_args *sc, unsigned long *args, long retval,
used += u < per_fd ? u : per_fd; used += u < per_fd ? u : per_fd;
} }
} }
if (tmp[used-1] == ' ')
used--;
tmp[used++] = '}'; tmp[used++] = '}';
tmp[used++] = '\0'; tmp[used++] = '\0';
} else } else
@ -1266,8 +1267,9 @@ print_arg(struct syscall_args *sc, unsigned long *args, long retval,
default: default:
sa = (struct sockaddr *)&ss; sa = (struct sockaddr *)&ss;
asprintf(&tmp, "{ sa_len = %d, sa_family = %d, sa_data " asprintf(&tmp, "{ sa_len = %d, sa_family = %d, sa_data "
"= {%n%*s } }", (int)sa->sa_len, (int)sa->sa_family, "= { %n%*s } }", (int)sa->sa_len,
&i, 6 * (int)(sa->sa_len - ((char *)&sa->sa_data - (int)sa->sa_family, &i,
6 * (int)(sa->sa_len - ((char *)&sa->sa_data -
(char *)sa)), ""); (char *)sa)), "");
if (tmp != NULL) { if (tmp != NULL) {
p = tmp + i; p = tmp + i;
@ -1333,6 +1335,7 @@ print_arg(struct syscall_args *sc, unsigned long *args, long retval,
"output", tmpsize); "output", tmpsize);
tmp[used++] = '{'; tmp[used++] = '{';
tmp[used++] = ' ';
for (i = 0; i < numevents; i++) { for (i = 0; i < numevents; i++) {
u = snprintf(tmp + used, per_ke, u = snprintf(tmp + used, per_ke,
"%s%p,%s,%s,%d,%p,%p", "%s%p,%s,%s,%d,%p,%p",
@ -1346,6 +1349,7 @@ print_arg(struct syscall_args *sc, unsigned long *args, long retval,
if (u > 0) if (u > 0)
used += u < per_ke ? u : per_ke; used += u < per_ke ? u : per_ke;
} }
tmp[used++] = ' ';
tmp[used++] = '}'; tmp[used++] = '}';
tmp[used++] = '\0'; tmp[used++] = '\0';
} else { } else {