Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mmapstress01: Fix printf format modifiers #1204

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ilove737
Copy link
Contributor

mmapstress01: Fix printf format modifiers

Signed-off-by: Li Xiaosong [email protected]

@pevik
Copy link
Member

pevik commented Oct 17, 2024

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++) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants