Use xappendstr instead of xsnprintf where suitable
Replace occurrences of outptr += xsnprintf(outptr, sizeof(outstr) - (outptr - outstr), ...) with much more sleek outptr = xappendstr(outstr, outptr, ...) * desc.c (decode_select): Replace xsnprintf with xappendstr. * open.c (sprint_open_modes): Likewise. * poll.c (decode_poll_exiting): Likewise. * signal.c (sprintsigmask_n): Likewise. * xlat.c (sprintflags): Likewise.
This commit is contained in:
parent
fdec47f63f
commit
0b803f8edd
13
desc.c
13
desc.c
@ -158,8 +158,8 @@ decode_select(struct tcb *const tcp, const kernel_ulong_t *const args,
|
||||
/* +2 chars needed at the end: ']',NUL */
|
||||
if (outptr < end_outstr - (sizeof(", except [") + sizeof(int)*3 + 2)) {
|
||||
if (first) {
|
||||
outptr += xsnprintf(outptr,
|
||||
sizeof(outstr) - (outptr - outstr),
|
||||
outptr = xappendstr(outstr,
|
||||
outptr,
|
||||
"%s%s [%u",
|
||||
sep,
|
||||
i == 0 ? "in" : i == 1 ? "out" : "except",
|
||||
@ -168,8 +168,8 @@ decode_select(struct tcb *const tcp, const kernel_ulong_t *const args,
|
||||
first = 0;
|
||||
sep = ", ";
|
||||
} else {
|
||||
outptr += xsnprintf(outptr,
|
||||
sizeof(outstr) - (outptr - outstr),
|
||||
outptr = xappendstr(outstr,
|
||||
outptr,
|
||||
" %u", j);
|
||||
}
|
||||
}
|
||||
@ -184,9 +184,8 @@ decode_select(struct tcb *const tcp, const kernel_ulong_t *const args,
|
||||
if (args[4]) {
|
||||
const char *str = sprint_tv_ts(tcp, args[4]);
|
||||
if (outptr + sizeof("left ") + strlen(sep) + strlen(str) < end_outstr) {
|
||||
outptr += xsnprintf(outptr,
|
||||
sizeof(outstr) - (outptr - outstr),
|
||||
"%sleft %s", sep, str);
|
||||
outptr = xappendstr(outstr, outptr,
|
||||
"%sleft %s", sep, str);
|
||||
}
|
||||
}
|
||||
*outptr = '\0';
|
||||
|
2
open.c
2
open.c
@ -111,7 +111,7 @@ sprint_open_modes(unsigned int flags)
|
||||
}
|
||||
/* flags is still nonzero */
|
||||
*p++ = sep;
|
||||
xsnprintf(p, sizeof(outstr) - (p - outstr), "%#x", flags);
|
||||
p = xappendstr(outstr, p, "%#x", flags);
|
||||
return outstr;
|
||||
}
|
||||
|
||||
|
4
poll.c
4
poll.c
@ -97,9 +97,7 @@ decode_poll_exiting(struct tcb *const tcp, const kernel_ulong_t pts)
|
||||
*outptr++ = '[';
|
||||
else
|
||||
outptr = stpcpy(outptr, ", ");
|
||||
outptr += xsnprintf(outptr,
|
||||
sizeof(outstr) - (outptr - outstr),
|
||||
"%#" PRI_klx, cur);
|
||||
outptr = xappendstr(outstr, outptr, "%#" PRI_klx, cur);
|
||||
break;
|
||||
}
|
||||
if (!fds.revents)
|
||||
|
6
signal.c
6
signal.c
@ -210,13 +210,11 @@ sprintsigmask_n(const char *prefix, const void *sig_mask, unsigned int bytes)
|
||||
}
|
||||
#ifdef ASM_SIGRTMAX
|
||||
else if (i >= ASM_SIGRTMIN && i <= ASM_SIGRTMAX) {
|
||||
s += xsnprintf(s, sizeof(outstr) - (s - outstr),
|
||||
"RT_%u", i - ASM_SIGRTMIN);
|
||||
s = xappendstr(outstr, s, "RT_%u", i - ASM_SIGRTMIN);
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
s += xsnprintf(s, sizeof(outstr) - (s - outstr),
|
||||
"%u", i);
|
||||
s = xappendstr(outstr, s, "%u", i);
|
||||
}
|
||||
sep = ' ';
|
||||
}
|
||||
|
3
xlat.c
3
xlat.c
@ -190,8 +190,7 @@ sprintflags(const char *prefix, const struct xlat *xlat, uint64_t flags)
|
||||
if (flags) {
|
||||
if (found)
|
||||
*outptr++ = '|';
|
||||
outptr += xsnprintf(outptr, sizeof(outstr) - (outptr - outstr),
|
||||
"%#" PRIx64, flags);
|
||||
outptr = xappendstr(outstr, outptr, "%#" PRIx64, flags);
|
||||
}
|
||||
|
||||
return outstr;
|
||||
|
Loading…
x
Reference in New Issue
Block a user