[CRIU] [PATCH 3/3] arm/test: fix printing formats in tests
Dmitry Safonov
dsafonov at virtuozzo.com
Tue Aug 30 06:18:34 PDT 2016
Fixes:
cow01.c: In function 'parent_check':
../lib/zdtmtst.h:120:11: error: format '%lx' expects argument of type 'long unsigned int', but argument 7 has type 'uint64_t {aka long long unsigned int}' [-Werror=format=]
test_msg("FAIL: %s:%d: " format " (errno = %d (%s))\n", \
^
cow01.c:287:5: note: in expansion of macro 'fail'
fail("%s[%#x]: %p is not COW-ed (pagemap of "
^~~~
In file included from inotify_system.c:14:0:
inotify_system.c: In function 'read_set':
../lib/zdtmtst.h:117:11: error: format '%lu' expects argument of type 'long unsigned int', but argument 5 has type 'unsigned int' [-Werror=form
at=]
test_msg("ERR: %s:%d: " format " (errno = %d (%s))\n", \
^
inotify_system.c:299:3: note: in expansion of macro 'pr_perror'
pr_perror("read(%d, buf, %lu) Failed, errno=%d",
^~~~~~~~~
deleted_dev.c:53:36: error: format '%lx' expects argument of type 'long unsigned int', but argument 4 has type '__dev_t {aka long long unsigned
int}' [-Werror=format=]
test_msg("mode %x want %x, dev %lx want %lx\n",
^
deleted_dev.c:53:45: error: format '%lx' expects argument of type 'long unsigned int', but argument 5 has type 'dev_t {aka long long unsigned i
nt}' [-Werror=format=]
test_msg("mode %x want %x, dev %lx want %lx\n",
^
../lib/zdtmtst.h:117:11: error: format '%lx' expects argument of type 'long unsigned int', but argument 5 has type 'off64_t {aka long long int
' [-Werror=format=]
test_msg("ERR: %s:%d: " format " (errno = %d (%s))\n", \
^
Nothing really interesting, but printings with right format specifier.
Signed-off-by: Dmitry Safonov <0x7f454c46 at gmail.com>
---
test/zdtm/static/autofs.c | 14 ++++++++------
test/zdtm/static/cow01.c | 3 ++-
test/zdtm/static/deleted_dev.c | 6 ++++--
test/zdtm/static/eventfs00.c | 3 ++-
test/zdtm/static/inotify_system.c | 2 +-
test/zdtm/static/inotify_system_nodel.c | 3 ++-
test/zdtm/static/mntns_link_remap.c | 3 ++-
test/zdtm/static/unlink_largefile.c | 3 ++-
8 files changed, 23 insertions(+), 14 deletions(-)
diff --git a/test/zdtm/static/autofs.c b/test/zdtm/static/autofs.c
index 8d75b6e68892..6a9282652cae 100644
--- a/test/zdtm/static/autofs.c
+++ b/test/zdtm/static/autofs.c
@@ -188,9 +188,10 @@ static int check_fd(struct autofs_params *p)
}
if (st.st_dev != p->fd_stat.st_dev) {
- skip("%s: st_dev differs: %lu != %lu "
+ skip("%s: st_dev differs: %llu != %llu "
"(waiting for \"device namespaces\")", p->mountpoint,
- st.st_dev, p->fd_stat.st_dev);
+ (long long unsigned)st.st_dev,
+ (long long unsigned)p->fd_stat.st_dev);
// ret++;
}
if (st.st_mode != p->fd_stat.st_mode) {
@@ -200,7 +201,7 @@ static int check_fd(struct autofs_params *p)
}
if (st.st_nlink != p->fd_stat.st_nlink) {
pr_err("%s: st_nlink differs: %ld != %ld\n", p->mountpoint,
- st.st_nlink, p->fd_stat.st_nlink);
+ (long)st.st_nlink, (long)p->fd_stat.st_nlink);
ret++;
}
if (st.st_uid != p->fd_stat.st_uid) {
@@ -214,8 +215,9 @@ static int check_fd(struct autofs_params *p)
ret++;
}
if (st.st_rdev != p->fd_stat.st_rdev) {
- pr_err("%s: st_rdev differs: %ld != %ld\n", p->mountpoint,
- st.st_rdev, p->fd_stat.st_rdev);
+ pr_err("%s: st_rdev differs: %lld != %lld\n", p->mountpoint,
+ (long long)st.st_rdev,
+ (long long)p->fd_stat.st_rdev);
ret++;
}
if (st.st_size != p->fd_stat.st_size) {
@@ -484,7 +486,7 @@ static int automountd_loop(int pipe, const char *mountpoint, struct autofs_param
return -EINVAL;
}
if (bytes != sizeof(*packet)) {
- pr_err("read less than expected: %ld\n", bytes);
+ pr_err("read less than expected: %zd\n", bytes);
return -EINVAL;
}
err = automountd_serve(mountpoint, param, packet);
diff --git a/test/zdtm/static/cow01.c b/test/zdtm/static/cow01.c
index 895dd9005824..9ccd6500e2e8 100644
--- a/test/zdtm/static/cow01.c
+++ b/test/zdtm/static/cow01.c
@@ -4,6 +4,7 @@
#include <string.h>
#include <signal.h>
#include <unistd.h>
+#include <inttypes.h>
#include <sys/wait.h>
#include <linux/limits.h>
#include <sys/user.h>
@@ -285,7 +286,7 @@ static int parent_check(struct test_cases *test_cases, int fd)
if (is_cow_ret == 1) {
errno = 0;
fail("%s[%#x]: %p is not COW-ed (pagemap of "
- "child=[%#08lx], parent=[%#08lx])",
+ "child=[%"PRIx64"], parent=[%"PRIx64"])",
test_cases->tname, i, addr + i * PAGE_SIZE,
map_child, map_parent);
}
diff --git a/test/zdtm/static/deleted_dev.c b/test/zdtm/static/deleted_dev.c
index 6c95c6189ff3..28545196532b 100644
--- a/test/zdtm/static/deleted_dev.c
+++ b/test/zdtm/static/deleted_dev.c
@@ -50,8 +50,10 @@ int main(int argc, char **argv)
if (st.st_mode != mode || st.st_rdev != dev) {
fail("%s is no longer the device file we had", filename);
- test_msg("mode %x want %x, dev %lx want %lx\n",
- st.st_mode, mode, st.st_rdev, dev);
+ test_msg("mode %x want %x, dev %llx want %llx\n",
+ st.st_mode, mode,
+ (long long unsigned)st.st_rdev,
+ (long long unsigned)dev);
goto out;
}
diff --git a/test/zdtm/static/eventfs00.c b/test/zdtm/static/eventfs00.c
index 69fc88186986..e05f514c4abc 100644
--- a/test/zdtm/static/eventfs00.c
+++ b/test/zdtm/static/eventfs00.c
@@ -17,6 +17,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
+#include <inttypes.h>
#include "zdtmtst.h"
@@ -65,7 +66,7 @@ int main(int argc, char *argv[])
exit(1);
}
- test_msg("created eventfd with %lx\n", v);
+ test_msg("created eventfd with %"PRIu64"\n", v);
ret = write(efd, &v, sizeof(v));
if (ret != sizeof(v)) {
diff --git a/test/zdtm/static/inotify_system.c b/test/zdtm/static/inotify_system.c
index 360779be5226..684119940474 100644
--- a/test/zdtm/static/inotify_system.c
+++ b/test/zdtm/static/inotify_system.c
@@ -297,7 +297,7 @@ int read_set(int inot_fd, char *event_set) {
int len;
if ((len = read(inot_fd, event_set, EVENT_BUF_LEN)) < 0) {
pr_perror("read(%d, buf, %lu) Failed, errno=%d",
- inot_fd, EVENT_BUF_LEN, errno);
+ inot_fd, (unsigned long)EVENT_BUF_LEN, errno);
return -1;
}
return len;
diff --git a/test/zdtm/static/inotify_system_nodel.c b/test/zdtm/static/inotify_system_nodel.c
index af1370b66041..4633f7c1643e 100644
--- a/test/zdtm/static/inotify_system_nodel.c
+++ b/test/zdtm/static/inotify_system_nodel.c
@@ -296,7 +296,8 @@ next_event:
int read_set(int inot_fd, char *event_set) {
int len;
if ((len = read(inot_fd, event_set, EVENT_BUF_LEN)) < 0) {
- pr_perror("read(%d, buf, %lu) Failed", inot_fd, EVENT_BUF_LEN);
+ pr_perror("read(%d, buf, %lu) Failed",
+ inot_fd, (unsigned long)EVENT_BUF_LEN);
return -1;
}
return len;
diff --git a/test/zdtm/static/mntns_link_remap.c b/test/zdtm/static/mntns_link_remap.c
index dac89e601a4d..a148a9e0cca5 100644
--- a/test/zdtm/static/mntns_link_remap.c
+++ b/test/zdtm/static/mntns_link_remap.c
@@ -118,7 +118,8 @@ int ns_child(void *_arg)
#else
if (st1.st_nlink != 0) {
#endif
- pr_perror("Wrong number of links: %lu", st1.st_nlink);
+ pr_perror("Wrong number of links: %lu",
+ (long unsigned)st1.st_nlink);
exit(1);
}
diff --git a/test/zdtm/static/unlink_largefile.c b/test/zdtm/static/unlink_largefile.c
index 8f0bd87495e2..f47391238865 100644
--- a/test/zdtm/static/unlink_largefile.c
+++ b/test/zdtm/static/unlink_largefile.c
@@ -28,7 +28,8 @@ int main(int argc, char ** argv)
}
if (lseek64(fd, offset, SEEK_SET) < 0) {
- pr_perror("can't lseek %s, offset= %lx", filename, offset);
+ pr_perror("can't lseek %s, offset= %llx", filename,
+ (long long unsigned)offset);
goto failed;
}
--
2.9.0
More information about the CRIU
mailing list