[PATCH 5/7] Cast to long for %l in printf

H.J. Lu hongjiu.lu at intel.com
Fri Feb 3 18:16:03 UTC 2012


Hi,

This patch casts a value to long for %l in printf to avoid compiler
warning on systems where it may be long long.


H.J.
---
2012-02-02  H.J. Lu  <hongjiu.lu at intel.com>

	* count.c (call_summary_pers): Cast to long.
	* ipc.c (sys_mq_open): Likewise.
	(printmqattr): Likewise.
	* quota.c (decode_cmd_data): Likewise.
	* resource.c (sys_sysinfo): Likewise.
	* time.c (tprint_timex): Likewise.
 
diff --git a/count.c b/count.c
index 1785242..e2a0e76 100644
--- a/count.c
+++ b/count.c
@@ -193,7 +193,7 @@ call_summary_pers(FILE *outf)
 				   / tv_float(&tv_cum));
 			fprintf(outf, "%6.2f %11.6f %11ld %9d %9.9s %s\n",
 				percent, tv_float(&counts[j].time),
-				(long) 1000000 * dtv.tv_sec + dtv.tv_usec,
+				(long) (1000000 * dtv.tv_sec + dtv.tv_usec),
 				counts[j].calls,
 				error_str, sysent[j].sys_name);
 		}
diff --git a/ipc.c b/ipc.c
index 5fb2c67..bac9938 100644
--- a/ipc.c
+++ b/ipc.c
@@ -482,7 +482,8 @@ sys_mq_open(struct tcb *tcp)
 				tprints("{ ??? }");
 			else
 				tprintf("{mq_maxmsg=%ld, mq_msgsize=%ld}",
-					attr.mq_maxmsg, attr.mq_msgsize);
+					(long) attr.mq_maxmsg,
+					(long) attr.mq_msgsize);
 # endif
 		}
 	}
@@ -541,7 +542,8 @@ printmqattr(struct tcb *tcp, long addr)
 		tprints("{mq_flags=");
 		tprint_open_modes(attr.mq_flags);
 		tprintf(", mq_maxmsg=%ld, mq_msgsize=%ld, mq_curmsg=%ld}",
-			attr.mq_maxmsg, attr.mq_msgsize, attr.mq_curmsgs);
+			(long) attr.mq_maxmsg, (long) attr.mq_msgsize,
+			(long) attr.mq_curmsgs);
 # endif
 	}
 }
diff --git a/quota.c b/quota.c
index b0b7257..2ba297c 100644
--- a/quota.c
+++ b/quota.c
@@ -380,8 +380,8 @@ decode_cmd_data(struct tcb *tcp, u_int32_t cmd, unsigned long data)
 			tprintf("ihardlimit=%u, ", dq.dqb_ihardlimit);
 			tprintf("isoftlimit=%u, ", dq.dqb_isoftlimit);
 			tprintf("curinodes=%u, ", dq.dqb_curinodes);
-			tprintf("btime=%lu, ", dq.dqb_btime);
-			tprintf("itime=%lu}", dq.dqb_itime);
+			tprintf("btime=%lu, ", (long) dq.dqb_btime);
+			tprintf("itime=%lu}", (long) dq.dqb_itime);
 			break;
 		}
 		case Q_V2_GETQUOTA:
@@ -403,8 +403,8 @@ decode_cmd_data(struct tcb *tcp, u_int32_t cmd, unsigned long data)
 			tprintf("bhardlimit=%u, ", dq.dqb_bhardlimit);
 			tprintf("bsoftlimit=%u, ", dq.dqb_bsoftlimit);
 			tprintf("curspace=%" PRIu64 ", ", dq.dqb_curspace);
-			tprintf("btime=%lu, ", dq.dqb_btime);
-			tprintf("itime=%lu}", dq.dqb_itime);
+			tprintf("btime=%lu, ", (long) dq.dqb_btime);
+			tprintf("itime=%lu}", (long) dq.dqb_itime);
 			break;
 		}
 		case Q_XGETQUOTA:
diff --git a/resource.c b/resource.c
index 9a90ad8..199ddf8 100644
--- a/resource.c
+++ b/resource.c
@@ -399,14 +399,15 @@ sys_sysinfo(struct tcb *tcp)
 			tprints("{...}");
 		else {
 			tprintf("{uptime=%lu, loads=[%lu, %lu, %lu] ",
-				si.uptime, si.loads[0], si.loads[1],
-				si.loads[2]);
+				(long) si.uptime, (long) si.loads[0],
+				(long) si.loads[1], (long) si.loads[2]);
 			tprintf("totalram=%lu, freeram=%lu, ",
-				si.totalram, si.freeram);
+				(long) si.totalram, (long) si.freeram);
 			tprintf("sharedram=%lu, bufferram=%lu} ",
-				si.sharedram, si.bufferram);
+				(long) si.sharedram, (long) si.bufferram);
 			tprintf("totalswap=%lu, freeswap=%lu, procs=%hu}",
-				si.totalswap, si.freeswap, si.procs);
+				(long) si.totalswap, (long) si.freeswap,
+				si.procs);
 		}
 	}
 	return 0;
diff --git a/time.c b/time.c
index 0c938f8..897af3b 100644
--- a/time.c
+++ b/time.c
@@ -580,19 +580,19 @@ tprint_timex(struct tcb *tcp, long addr)
 	tprints("{modes=");
 	printflags(adjtimex_modes, tx.modes, "ADJ_???");
 	tprintf(", offset=%ld, freq=%ld, maxerror=%ld, ",
-		tx.offset, tx.freq, tx.maxerror);
-	tprintf("esterror=%lu, status=", tx.esterror);
+		(long) tx.offset, (long) tx.freq, (long) tx.maxerror);
+	tprintf("esterror=%lu, status=", (long) tx.esterror);
 	printflags(adjtimex_status, tx.status, "STA_???");
 	tprintf(", constant=%ld, precision=%lu, ",
-		tx.constant, tx.precision);
-	tprintf("tolerance=%ld, time=", tx.tolerance);
+		(long) tx.constant, (long) tx.precision);
+	tprintf("tolerance=%ld, time=", (long) tx.tolerance);
 	tprint_timeval(tcp, &tx.time);
 	tprintf(", tick=%ld, ppsfreq=%ld, jitter=%ld",
-		tx.tick, tx.ppsfreq, tx.jitter);
+		(long) tx.tick, (long) tx.ppsfreq, (long) tx.jitter);
 	tprintf(", shift=%d, stabil=%ld, jitcnt=%ld",
-		tx.shift, tx.stabil, tx.jitcnt);
+		tx.shift, (long) tx.stabil, (long) tx.jitcnt);
 	tprintf(", calcnt=%ld, errcnt=%ld, stbcnt=%ld",
-		tx.calcnt, tx.errcnt, tx.stbcnt);
+		(long) tx.calcnt, (long) tx.errcnt, (long) tx.stbcnt);
 #endif
 	tprints("}");
 	return 0;
-- 
1.7.6.5





More information about the Strace-devel mailing list