static const char *
sprintmode(int mode)
{
- static char buf[64];
+ static char buf[sizeof("S_IFSOCK|S_ISUID|S_ISGID|S_ISVTX|%o")
+ + sizeof(int)*3
+ + /*paranoia:*/ 8];
const char *s;
if ((mode & S_IFMT) == 0)
sprintf(buf, "%#o", mode);
return buf;
}
- sprintf(buf, "%s%s%s%s", s,
+ s = buf + sprintf(buf, "%s%s%s%s", s,
(mode & S_ISUID) ? "|S_ISUID" : "",
(mode & S_ISGID) ? "|S_ISGID" : "",
(mode & S_ISVTX) ? "|S_ISVTX" : "");
mode &= ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX);
if (mode)
- sprintf(buf + strlen(buf), "|%#o", mode);
+ sprintf((char*)s, "|%#o", mode);
s = (*buf == '|') ? buf + 1 : buf;
return *s ? s : "0";
}
sprinttime(time_t t)
{
struct tm *tmp;
- static char buf[32];
+ static char buf[sizeof("yyyy/mm/dd-hh:mm:ss")];
if (t == 0) {
strcpy(buf, "0");
if (!abbrev(tcp)) {
tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
- tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
- tprints("}");
+ tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
}
else
tprints("...}");
if (!abbrev(tcp)) {
tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
- tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
- tprints("}");
+ tprintf("st_ctime=%s}", sprinttime(statbuf.st_ctime));
}
else
tprints("...}");
statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen);
tprintf(", f_frsize=%lu", (unsigned long)statbuf.f_frsize);
- tprintf(", f_flags=%lu", (unsigned long)statbuf.f_frsize);
- tprints("}");
+ tprintf(", f_flags=%lu}", (unsigned long)statbuf.f_frsize);
}
int
long utl[2];
int uti[2];
} u;
+ unsigned wordsize = personality_wordsize[current_personality];
if (entering(tcp)) {
printpath(tcp, tcp->u_arg[0]);
tprints("NULL");
else if (!verbose(tcp))
tprintf("%#lx", tcp->u_arg[1]);
- else if (umoven(tcp, tcp->u_arg[1],
- 2 * personality_wordsize[current_personality],
- (char *) &u) < 0)
+ else if (umoven(tcp, tcp->u_arg[1], 2 * wordsize, (char *) &u) < 0)
tprints("[?, ?]");
- else if (personality_wordsize[current_personality]
- == sizeof u.utl[0]) {
+ else if (wordsize == sizeof u.utl[0]) {
tprintf("[%s,", sprinttime(u.utl[0]));
tprintf(" %s]", sprinttime(u.utl[1]));
}
- else if (personality_wordsize[current_personality]
- == sizeof u.uti[0]) {
+ else if (wordsize == sizeof u.uti[0]) {
tprintf("[%s,", sprinttime(u.uti[0]));
tprintf(" %s]", sprinttime(u.uti[1]));
}
} cp;
const char *sep;
int n = 0;
+ unsigned wordsize = personality_wordsize[current_personality];
cp.p64 = 1;
for (sep = ""; !abbrev(tcp) || n < max_strlen / 2; sep = ", ", ++n) {
- if (umoven(tcp, addr, personality_wordsize[current_personality],
- cp.data) < 0) {
+ if (umoven(tcp, addr, wordsize, cp.data) < 0) {
tprintf("%#lx", addr);
return;
}
- if (personality_wordsize[current_personality] == 4)
+ if (wordsize == 4)
cp.p64 = cp.p32;
if (cp.p64 == 0)
break;
tprints(sep);
printstr(tcp, cp.p64, -1);
- addr += personality_wordsize[current_personality];
+ addr += wordsize;
}
if (cp.p64)
tprintf("%s...", sep);
};
#if !HAVE_LONG_LONG_RLIM_T
-static char *
+static const char *
sprintrlim(long lim)
{
- static char buf[32];
+ static char buf[sizeof(long)*3 + sizeof("%ld*1024")];
if (lim == RLIM_INFINITY)
- sprintf(buf, "RLIM_INFINITY");
- else if (lim > 1024 && lim%1024 == 0)
+ return "RLIM_INFINITY";
+
+ if (lim > 1024 && lim%1024 == 0)
sprintf(buf, "%ld*1024", lim/1024);
else
sprintf(buf, "%ld", lim);
#endif /* !HAVE_LONG_LONG_RLIM_T */
#if _LFS64_LARGEFILE || HAVE_LONG_LONG_RLIM_T
-static char *
+static const char *
sprintrlim64(rlim64_t lim)
{
- static char buf[64];
+ static char buf[sizeof(long long)*3 + sizeof("%lld*1024")];
if (lim == RLIM64_INFINITY)
- sprintf(buf, "RLIM64_INFINITY");
- else if (lim > 1024 && lim%1024 == 0)
+ return "RLIM64_INFINITY";
+
+ if (lim > 1024 && lim%1024 == 0)
sprintf(buf, "%lld*1024", (long long) lim/1024);
else
sprintf(buf, "%lld", (long long) lim);