* defs.h (widen_to_ull): New macro.
* dirent.c (print_old_dirent, SYS_FUNC(getdents)): Use it in place
of explicit casts to unsigned long long.
* io.c (print_lld_from_low_high_val): Likewise.
* lseek.c (SYS_FUNC(llseek)): Likewise.
* printsiginfo.c (print_si_info): Likewise.
* printstat.h (DO_PRINTSTAT): Likewise.
* sysinfo.c (SYS_FUNC(sysinfo)): Likewise.
* times.c (SYS_FUNC(times)): Likewise.
* fetch_struct_statfs.c (ASSIGN_NUMBER): Remove.
(fetch_struct_statfs, fetch_struct_statfs64): Replace ASSIGN_NUMBER
with widen_to_ull.
# define widen_to_long(v) ((long)(v))
#endif
+/*
+ * Widen without sign-extension a signed integer type to unsigned long long.
+ */
+#define widen_to_ull(v) \
+ (sizeof(v) == sizeof(int) ? (unsigned long long) (unsigned int) (v) : \
+ sizeof(v) == sizeof(long) ? (unsigned long long) (unsigned long) (v) : \
+ (unsigned long long) (v))
+
extern const struct_sysent sysent0[];
extern const char *const errnoent0[];
extern const char *const signalent0[];
return;
tprintf("{d_ino=%llu, d_off=%llu, d_reclen=%u, d_name=",
- (unsigned long long) d.d_ino,
- (unsigned long long) d.d_off, d.d_reclen);
+ widen_to_ull(d.d_ino),
+ widen_to_ull(d.d_off), d.d_reclen);
if (d.d_reclen > D_NAME_LEN_MAX)
d.d_reclen = D_NAME_LEN_MAX;
printpathn(tcp, addr + offsetof(kernel_dirent, d_name), d.d_reclen);
tprintf("%s{d_ino=%llu, d_off=%llu, d_reclen=%u"
", d_name=", i ? ", " : "",
- (unsigned long long) d->d_ino,
- (unsigned long long) d->d_off, d->d_reclen);
+ widen_to_ull(d->d_ino),
+ widen_to_ull(d->d_off), d->d_reclen);
if (print_quoted_string(d->d_name, d_name_len,
QUOTE_0_TERMINATED) > 0) {
#include "statfs.h"
-#define ASSIGN_NUMBER(dst, src) \
- if (sizeof(src) == sizeof(int)) \
- dst = (unsigned int) (src); \
- else if (sizeof(src) == sizeof(long)) \
- dst = (unsigned long) (src); \
- else \
- dst = (unsigned long long) (src)
-
MPERS_PRINTER_DECL(bool, fetch_struct_statfs,
struct tcb *tcp, const long addr, struct strace_statfs *p)
{
if (umove_or_printaddr(tcp, addr, &b))
return false;
- ASSIGN_NUMBER(p->f_type, b.f_type);
- ASSIGN_NUMBER(p->f_bsize, b.f_bsize);
- ASSIGN_NUMBER(p->f_blocks, b.f_blocks);
- ASSIGN_NUMBER(p->f_bfree, b.f_bfree);
- ASSIGN_NUMBER(p->f_bavail, b.f_bavail);
- ASSIGN_NUMBER(p->f_files, b.f_files);
- ASSIGN_NUMBER(p->f_ffree, b.f_ffree);
+ p->f_type = widen_to_ull(b.f_type);
+ p->f_bsize = widen_to_ull(b.f_bsize);
+ p->f_blocks = widen_to_ull(b.f_blocks);
+ p->f_bfree = widen_to_ull(b.f_bfree);
+ p->f_bavail = widen_to_ull(b.f_bavail);
+ p->f_files = widen_to_ull(b.f_files);
+ p->f_ffree = widen_to_ull(b.f_ffree);
#if defined HAVE_STRUCT_STATFS_F_FSID_VAL
- ASSIGN_NUMBER(p->f_fsid[0], b.f_fsid.val[0]);
- ASSIGN_NUMBER(p->f_fsid[1], b.f_fsid.val[1]);
+ p->f_fsid[0] = widen_to_ull(b.f_fsid.val[0]);
+ p->f_fsid[1] = widen_to_ull(b.f_fsid.val[1]);
#elif defined HAVE_STRUCT_STATFS_F_FSID___VAL
- ASSIGN_NUMBER(p->f_fsid[0], b.f_fsid.__val[0]);
- ASSIGN_NUMBER(p->f_fsid[1], b.f_fsid.__val[1]);
+ p->f_fsid[0] = widen_to_ull(b.f_fsid.__val[0]);
+ p->f_fsid[1] = widen_to_ull(b.f_fsid.__val[1]);
#endif
- ASSIGN_NUMBER(p->f_namelen, b.f_namelen);
+ p->f_namelen = widen_to_ull(b.f_namelen);
#ifdef HAVE_STRUCT_STATFS_F_FRSIZE
- ASSIGN_NUMBER(p->f_frsize, b.f_frsize);
+ p->f_frsize = widen_to_ull(b.f_frsize);
#endif
#ifdef HAVE_STRUCT_STATFS_F_FLAGS
- ASSIGN_NUMBER(p->f_flags, b.f_flags);
+ p->f_flags = widen_to_ull(b.f_flags);
#endif
return true;
if (umove_or_printaddr(tcp, addr, &b))
return false;
- ASSIGN_NUMBER(p->f_type, b.f_type);
- ASSIGN_NUMBER(p->f_bsize, b.f_bsize);
- ASSIGN_NUMBER(p->f_blocks, b.f_blocks);
- ASSIGN_NUMBER(p->f_bfree, b.f_bfree);
- ASSIGN_NUMBER(p->f_bavail, b.f_bavail);
- ASSIGN_NUMBER(p->f_files, b.f_files);
- ASSIGN_NUMBER(p->f_ffree, b.f_ffree);
+ p->f_type = widen_to_ull(b.f_type);
+ p->f_bsize = widen_to_ull(b.f_bsize);
+ p->f_blocks = widen_to_ull(b.f_blocks);
+ p->f_bfree = widen_to_ull(b.f_bfree);
+ p->f_bavail = widen_to_ull(b.f_bavail);
+ p->f_files = widen_to_ull(b.f_files);
+ p->f_ffree = widen_to_ull(b.f_ffree);
#if defined HAVE_STRUCT_STATFS64_F_FSID_VAL
- ASSIGN_NUMBER(p->f_fsid[0], b.f_fsid.val[0]);
- ASSIGN_NUMBER(p->f_fsid[1], b.f_fsid.val[1]);
+ p->f_fsid[0] = widen_to_ull(b.f_fsid.val[0]);
+ p->f_fsid[1] = widen_to_ull(b.f_fsid.val[1]);
#elif defined HAVE_STRUCT_STATFS64_F_FSID___VAL
- ASSIGN_NUMBER(p->f_fsid[0], b.f_fsid.__val[0]);
- ASSIGN_NUMBER(p->f_fsid[1], b.f_fsid.__val[1]);
+ p->f_fsid[0] = widen_to_ull(b.f_fsid.__val[0]);
+ p->f_fsid[1] = widen_to_ull(b.f_fsid.__val[1]);
#endif
- ASSIGN_NUMBER(p->f_namelen, b.f_namelen);
+ p->f_namelen = widen_to_ull(b.f_namelen);
#ifdef HAVE_STRUCT_STATFS64_F_FRSIZE
- ASSIGN_NUMBER(p->f_frsize, b.f_frsize);
+ p->f_frsize = widen_to_ull(b.f_frsize);
#endif
#ifdef HAVE_STRUCT_STATFS64_F_FLAGS
- ASSIGN_NUMBER(p->f_flags, b.f_flags);
+ p->f_flags = widen_to_ull(b.f_flags);
#endif
return true;
else
# endif
tprintf("%lld",
- ((unsigned long long) (unsigned long) tcp->u_arg[arg + 1] << sizeof(long) * 8)
- | (unsigned long long) (unsigned long) tcp->u_arg[arg]);
+ (widen_to_ull(tcp->u_arg[arg + 1]) << sizeof(long) * 8)
+ | widen_to_ull(tcp->u_arg[arg]));
#endif
}
if (entering(tcp)) {
printfd(tcp, tcp->u_arg[0]);
tprintf(", %lld, ",
- ((unsigned long long) (unsigned long) tcp->u_arg[1]) << 32
- | (unsigned long long) (unsigned long) tcp->u_arg[2]);
+ (widen_to_ull(tcp->u_arg[1]) << 32)
+ | widen_to_ull(tcp->u_arg[2]));
} else {
printnum_int64(tcp, tcp->u_arg[3], "%" PRIu64);
tprints(", ");
else
printsignal(sip->si_status);
tprintf(", si_utime=%llu, si_stime=%llu",
- (unsigned long long) sip->si_utime,
- (unsigned long long) sip->si_stime);
+ widen_to_ull(sip->si_utime),
+ widen_to_ull(sip->si_stime));
break;
case SIGILL: case SIGFPE:
case SIGSEGV: case SIGBUS:
tprintf("{st_dev=makedev(%u, %u), st_ino=%llu, st_mode=%s, ",
(unsigned int) STAT_MAJOR(statbuf->st_dev),
(unsigned int) STAT_MINOR(statbuf->st_dev),
- (unsigned long long) statbuf->st_ino,
+ widen_to_ull(statbuf->st_ino),
sprintmode(statbuf->st_mode));
tprintf("st_nlink=%u, st_uid=%u, st_gid=%u, ",
(unsigned int) statbuf->st_nlink,
tprintf("st_blksize=%u, ", (unsigned int) statbuf->st_blksize);
#endif
#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
- tprintf("st_blocks=%llu, ",
- (unsigned long long) statbuf->st_blocks);
+ tprintf("st_blocks=%llu, ", widen_to_ull(statbuf->st_blocks));
#endif
} else {
tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode));
#endif /* !HAVE_STRUCT_STAT_ST_RDEV */
break;
default:
- tprintf("st_size=%llu, ",
- (unsigned long long) statbuf->st_size);
+ tprintf("st_size=%llu, ", widen_to_ull(statbuf->st_size));
break;
}
", freehigh=%llu"
", mem_unit=%u"
"}",
- (unsigned long long) si.uptime
- , (unsigned long long) si.loads[0]
- , (unsigned long long) si.loads[1]
- , (unsigned long long) si.loads[2]
- , (unsigned long long) si.totalram
- , (unsigned long long) si.freeram
- , (unsigned long long) si.sharedram
- , (unsigned long long) si.bufferram
- , (unsigned long long) si.totalswap
- , (unsigned long long) si.freeswap
+ widen_to_ull(si.uptime)
+ , widen_to_ull(si.loads[0])
+ , widen_to_ull(si.loads[1])
+ , widen_to_ull(si.loads[2])
+ , widen_to_ull(si.totalram)
+ , widen_to_ull(si.freeram)
+ , widen_to_ull(si.sharedram)
+ , widen_to_ull(si.bufferram)
+ , widen_to_ull(si.totalswap)
+ , widen_to_ull(si.freeswap)
, (unsigned) si.procs
- , (unsigned long long) si.totalhigh
- , (unsigned long long) si.freehigh
+ , widen_to_ull(si.totalhigh)
+ , widen_to_ull(si.freehigh)
, si.mem_unit
);
}
if (!umove_or_printaddr(tcp, tcp->u_arg[0], &tbuf)) {
tprintf("{tms_utime=%llu, tms_stime=%llu, ",
- (unsigned long long) tbuf.tms_utime,
- (unsigned long long) tbuf.tms_stime);
+ widen_to_ull(tbuf.tms_utime),
+ widen_to_ull(tbuf.tms_stime));
tprintf("tms_cutime=%llu, tms_cstime=%llu}",
- (unsigned long long) tbuf.tms_cutime,
- (unsigned long long) tbuf.tms_cstime);
+ widen_to_ull(tbuf.tms_cutime),
+ widen_to_ull(tbuf.tms_cstime));
}
return syserror(tcp) ? RVAL_DECIMAL :