Fix explicit casts of signed integer types to unsigned long long

* 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.
diff --git a/defs.h b/defs.h
index ceb535a..d72f5c2 100644
--- a/defs.h
+++ b/defs.h
@@ -770,6 +770,14 @@
 # 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[];
diff --git a/dirent.c b/dirent.c
index 7d882ae..75e3635 100644
--- a/dirent.c
+++ b/dirent.c
@@ -48,8 +48,8 @@
 		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);
@@ -127,8 +127,8 @@
 
 			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) {
diff --git a/fetch_struct_statfs.c b/fetch_struct_statfs.c
index 0717e4b..0cfe5ba 100644
--- a/fetch_struct_statfs.c
+++ b/fetch_struct_statfs.c
@@ -39,14 +39,6 @@
 
 #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)
 {
@@ -55,26 +47,26 @@
 	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;
@@ -103,26 +95,26 @@
 	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;
diff --git a/io.c b/io.c
index 3c4ef59..87b5f47 100644
--- a/io.c
+++ b/io.c
@@ -202,8 +202,8 @@
 	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
 }
 
diff --git a/lseek.c b/lseek.c
index cfc6b58..133ddd8 100644
--- a/lseek.c
+++ b/lseek.c
@@ -108,8 +108,8 @@
 	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(", ");
diff --git a/printsiginfo.c b/printsiginfo.c
index a14ebb4..98755b2 100644
--- a/printsiginfo.c
+++ b/printsiginfo.c
@@ -171,8 +171,8 @@
 			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:
diff --git a/printstat.h b/printstat.h
index c7e1bb2..5bf745c 100644
--- a/printstat.h
+++ b/printstat.h
@@ -55,7 +55,7 @@
 		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,
@@ -65,8 +65,7 @@
 		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));
@@ -85,8 +84,7 @@
 #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;
 	}
 
diff --git a/sysinfo.c b/sysinfo.c
index e418f95..c3cb9ad 100644
--- a/sysinfo.c
+++ b/sysinfo.c
@@ -59,19 +59,19 @@
 			", 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
 			);
 	}
diff --git a/times.c b/times.c
index d3f6daf..04df462 100644
--- a/times.c
+++ b/times.c
@@ -46,11 +46,11 @@
 
 	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 :