ltp
ltp copied to clipboard
mmapstress01: Fix printf format modifiers
While this is technically correct thus should be merged, automatic conversion works thus it does not produce a warning. IMHO more useful would be to fix a conversion warning when compiled for 32 bit:
$ PKG_CONFIG_LIBDIR=/usr/lib/pkgconfig CFLAGS=-m32 LDFLAGS=-m32 ./configure
...
In file included from mmapstress01.c:37:
mmapstress01.c: In function ‘fileokay’:
../../../../include/tst_test.h:121:55: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 5 has type ‘unsigned int’ [-Wformat=]
121 | tst_brk_(__FILE__, __LINE__, (ttype), (arg_fmt), ##__VA_ARGS__);\
| ^~~~~~~~~
mmapstress01.c:227:33: note: in expansion of macro ‘tst_brk’
227 | tst_brk(TFAIL, "missing data: read %lu of %ld bytes",
| ^~~~~~~
Fix would be trivial (+ avoid unnecessary brackets for multiplicating):
--- testcases/kernel/mem/mmapstress/mmapstress01.c
+++ testcases/kernel/mem/mmapstress/mmapstress01.c
@@ -225,7 +225,7 @@ static void fileokay(char *file, unsigned char *expbuf)
/* Okay if at last page in file... */
if ((i * pagesize) + cnt != mapsize)
tst_brk(TFAIL, "missing data: read %lu of %ld bytes",
- (i * pagesize) + cnt, (long)mapsize);
+ (long)(i * pagesize + cnt), (long)mapsize);
}
/* Compare read bytes of data. */
for (j = 0; j < (unsigned int)cnt; j++) {
Applied, thanks.