[CRIU] [PATCH 4/9] cr: generalized format strings
Alexander Kartashov
alekskartashov at parallels.com
Wed Jan 16 03:28:26 EST 2013
This patch replaces the format specifier %ld with PRIx64
in the following places:
* the format string argument of the functions scanf() and printf(),
* in the macros GEN_SYSCTL_*_FUNC.
We need explicit specification of the integer size there.
Signed-off-by: Alexander Kartashov <alekskartashov at parallels.com>
---
cr-restore.c | 6 +++---
cr-show.c | 18 +++++++++---------
eventfd.c | 2 +-
eventpoll.c | 2 +-
files-reg.c | 2 +-
fsnotify.c | 8 ++++----
ipc_ns.c | 4 ++--
parasite-syscall.c | 2 +-
pie/restorer.c | 6 +++---
proc_parse.c | 16 ++++++++--------
shmem.c | 10 +++++-----
sk-packet.c | 2 +-
sysctl.c | 6 +++---
util.c | 5 +++--
14 files changed, 45 insertions(+), 44 deletions(-)
diff --git a/cr-restore.c b/cr-restore.c
index c262c73..a30b896 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -215,7 +215,7 @@ static int map_private_vma(pid_t pid, struct vma_area *vma, void *tgt_addr,
if (p->vma.end == vma->vma.end &&
p->vma.start == vma->vma.start) {
- pr_info("COW 0x%016lx-0x%016lx 0x%016lx vma\n",
+ pr_info("COW 0x%016"PRIx64"-0x%016"PRIx64" 0x%016"PRIx64" vma\n",
vma->vma.start, vma->vma.end, vma->vma.pgoff);
paddr = (void *)P(vma_premmaped_start(&p->vma));
break;
@@ -226,7 +226,7 @@ static int map_private_vma(pid_t pid, struct vma_area *vma, void *tgt_addr,
*pvma = p;
if (paddr == NULL) {
- pr_info("Map 0x%016lx-0x%016lx 0x%016lx vma\n",
+ pr_info("Map 0x%016"PRIx64"-0x%016"PRIx64" 0x%016"PRIx64" vma\n",
vma->vma.start, vma->vma.end, vma->vma.pgoff);
addr = mmap(tgt_addr, vma_entry_len(&vma->vma),
@@ -472,7 +472,7 @@ static int open_vmas(int pid)
if (!(vma_entry_is(&vma->vma, VMA_AREA_REGULAR)))
continue;
- pr_info("Opening 0x%016lx-0x%016lx 0x%016lx (%x) vma\n",
+ pr_info("Opening 0x%016"PRIx64"-0x%016"PRIx64" 0x%016"PRIx64" (%x) vma\n",
vma->vma.start, vma->vma.end,
vma->vma.pgoff, vma->vma.status);
diff --git a/cr-show.c b/cr-show.c
index 8ad2361..57bdbef 100644
--- a/cr-show.c
+++ b/cr-show.c
@@ -232,7 +232,7 @@ void show_pages(int fd_pages, struct cr_options *o)
goto out;
}
- pr_msg("0x%16lx ", e.va);
+ pr_msg("0x%16"PRIx64" ", e.va);
}
pr_msg("\n");
}
@@ -306,19 +306,19 @@ static inline char *task_state_str(int state)
static void show_core_regs(UserX86RegsEntry *regs)
{
#define pr_regs4(s, n1, n2, n3, n4) \
- pr_msg("\t%8s: 0x%-16lx " \
- "%8s: 0x%-16lx " \
- "%8s: 0x%-16lx " \
- "%8s: 0x%-16lx\n", \
+ pr_msg("\t%8s: 0x%-16"PRIx64" " \
+ "%8s: 0x%-16"PRIx64" " \
+ "%8s: 0x%-16"PRIx64" " \
+ "%8s: 0x%-16"PRIx64"\n", \
#n1, s->n1, \
#n2, s->n2, \
#n3, s->n3, \
#n4, s->n4)
#define pr_regs3(s, n1, n2, n3) \
- pr_msg("\t%8s: 0x%-16lx " \
- "%8s: 0x%-16lx " \
- "%8s: 0x%-16lx\n", \
+ pr_msg("\t%8s: 0x%-16"PRIx64" " \
+ "%8s: 0x%-16"PRIx64" " \
+ "%8s: 0x%-16"PRIx64"\n", \
#n1, s->n1, \
#n2, s->n2, \
#n3, s->n3)
@@ -341,7 +341,7 @@ void show_thread_info(ThreadInfoX86 *thread_info)
return;
pr_msg("\t---[ Thread info ]---\n");
- pr_msg("\tclear_tid_addr: 0x%lx\n", thread_info->clear_tid_addr);
+ pr_msg("\tclear_tid_addr: 0x%"PRIx64"\n", thread_info->clear_tid_addr);
pr_msg("\n");
show_core_regs(thread_info->gpregs);
diff --git a/eventfd.c b/eventfd.c
index 1a8fca3..9854a70 100644
--- a/eventfd.c
+++ b/eventfd.c
@@ -40,7 +40,7 @@ int is_eventfd_link(int lfd)
static void pr_info_eventfd(char *action, EventfdFileEntry *efe)
{
- pr_info("%s: id %#08x flags %#04x counter %#016lx\n",
+ pr_info("%s: id %#08x flags %#04x counter %#016"PRIx64"\n",
action, efe->id, efe->flags, efe->counter);
}
diff --git a/eventpoll.c b/eventpoll.c
index 3c77bc6..ed09190 100644
--- a/eventpoll.c
+++ b/eventpoll.c
@@ -47,7 +47,7 @@ int is_eventpoll_link(int lfd)
static void pr_info_eventpoll_tfd(char *action, EventpollTfdEntry *e)
{
- pr_info("%seventpoll-tfd: id %#08x tfd %#08x events %#08x data %#016lx\n",
+ pr_info("%seventpoll-tfd: id %#08x tfd %#08x events %#08x data %#016"PRIx64"\n",
action, e->id, e->tfd, e->events, e->data);
}
diff --git a/files-reg.c b/files-reg.c
index 66dfadd..1d48d3c 100644
--- a/files-reg.c
+++ b/files-reg.c
@@ -288,7 +288,7 @@ static int dump_ghost_remap(char *path, const struct stat *st, int lfd, u32 id)
pr_info("Dumping ghost file for fd %d id %#x\n", lfd, id);
if (st->st_size > MAX_GHOST_FILE_SIZE) {
- pr_err("Can't dump ghost file %s of %lu size\n",
+ pr_err("Can't dump ghost file %s of %"PRIu64" size\n",
path, st->st_size);
return -1;
}
diff --git a/fsnotify.c b/fsnotify.c
index 6b0d625..6459c48 100644
--- a/fsnotify.c
+++ b/fsnotify.c
@@ -102,9 +102,9 @@ static int dump_inotify_entry(union fdinfo_entries *e, void *arg)
InotifyWdEntry *we = &e->ify;
we->id = *(u32 *)arg;
- pr_info("wd: wd 0x%08x s_dev 0x%08x i_ino 0x%16lx mask 0x%08x\n",
+ pr_info("wd: wd 0x%08x s_dev 0x%08x i_ino 0x%16"PRIx64" mask 0x%08x\n",
we->wd, we->s_dev, we->i_ino, we->mask);
- pr_info("\t[fhandle] bytes 0x%08x type 0x%08x __handle 0x%016lx:0x%016lx\n",
+ pr_info("\t[fhandle] bytes 0x%08x type 0x%08x __handle 0x%016"PRIx64":0x%016"PRIx64"\n",
we->f_handle->bytes, we->f_handle->type,
we->f_handle->handle[0], we->f_handle->handle[1]);
return pb_write_one(fdset_fd(glob_fdset, CR_FD_INOTIFY_WD), we, PB_INOTIFY_WD);
@@ -146,10 +146,10 @@ static int dump_fanotify_entry(union fdinfo_entries *e, void *arg)
BUG_ON(!fme->ie);
- pr_info("mark: s_dev 0x%08x i_ino 0x%016lx mask 0x%08x\n",
+ pr_info("mark: s_dev 0x%08x i_ino 0x%016"PRIx64" mask 0x%08x\n",
fme->s_dev, fme->ie->i_ino, fme->mask);
- pr_info("\t[fhandle] bytes 0x%08x type 0x%08x __handle 0x%016lx:0x%016lx\n",
+ pr_info("\t[fhandle] bytes 0x%08x type 0x%08x __handle 0x%016"PRIx64":0x%016"PRIx64"\n",
fme->ie->f_handle->bytes, fme->ie->f_handle->type,
fme->ie->f_handle->handle[0], fme->ie->f_handle->handle[1]);
}
diff --git a/ipc_ns.c b/ipc_ns.c
index c94b3b5..a5942fd 100644
--- a/ipc_ns.c
+++ b/ipc_ns.c
@@ -156,7 +156,7 @@ static int dump_ipc_sem(int fd)
static void pr_info_ipc_msg(int nr, const IpcMsg *msg)
{
- print_on_level(LOG_INFO, " %-5d: type: %-20ld size: %-10d\n",
+ print_on_level(LOG_INFO, " %-5d: type: %-20"PRId64" size: %-10d\n",
nr++, msg->mtype, msg->msize);
}
@@ -281,7 +281,7 @@ static int dump_ipc_msg(int fd)
static void pr_info_ipc_shm(const IpcShmEntry *shm)
{
pr_ipc_desc_entry(LOG_INFO, shm->desc);
- print_on_level(LOG_INFO, "size: %-10lu\n", shm->size);
+ print_on_level(LOG_INFO, "size: %-10"PRIu64"\n", shm->size);
}
static int ipc_sysctl_req(IpcVarEntry *e, int op)
diff --git a/parasite-syscall.c b/parasite-syscall.c
index 33a58da..9518d58 100644
--- a/parasite-syscall.c
+++ b/parasite-syscall.c
@@ -546,7 +546,7 @@ int parasite_dump_pages_seized(struct parasite_ctl *ctl, struct list_head *vma_a
goto out_fini;
}
- pr_info("vma %lx-%lx dumped: %lu pages %lu skipped %lu total\n",
+ pr_info("vma %"PRIx64"-%"PRIx64" dumped: %lu pages %lu skipped %lu total\n",
vma_area->vma.start, vma_area->vma.end,
parasite_dumppages->nrpages_dumped,
parasite_dumppages->nrpages_skipped,
diff --git a/pie/restorer.c b/pie/restorer.c
index 76b7371..9f6fdb6 100644
--- a/pie/restorer.c
+++ b/pie/restorer.c
@@ -410,7 +410,7 @@ long __export_restore_task(struct task_restore_core_args *args)
if (!vma_entry_is(vma_entry, VMA_AREA_REGULAR))
continue;
- pr_debug("Examine %lx-%lx\n", vma_entry->start, vma_entry->end);
+ pr_debug("Examine %"PRIx64"-%"PRIx64"\n", vma_entry->start, vma_entry->end);
if (addr < args->premmapped_addr) {
if (vma_entry->end >= args->premmapped_addr)
@@ -492,7 +492,7 @@ long __export_restore_task(struct task_restore_core_args *args)
va = restore_mapping(vma_entry);
if (va != vma_entry->start) {
- pr_err("Can't restore %lx mapping with %lx\n", vma_entry->start, va);
+ pr_err("Can't restore %"PRIx64" mapping with %"PRIx64"\n", vma_entry->start, va);
goto core_restore_end;
}
}
@@ -537,7 +537,7 @@ long __export_restore_task(struct task_restore_core_args *args)
vma_entry_len(vma_entry),
i);
if (ret) {
- pr_err("madvise(%lx, %ld, %ld) "
+ pr_err("madvise(%"PRIx64", %"PRIu64", %ld) "
"failed with %ld\n",
vma_entry->start,
vma_entry_len(vma_entry),
diff --git a/proc_parse.c b/proc_parse.c
index e641cb4..63033ca 100644
--- a/proc_parse.c
+++ b/proc_parse.c
@@ -162,7 +162,7 @@ static int is_anon_shmem_map(dev_t dev)
munmap(map, PAGE_SIZE);
shmem_dev = buf.st_dev;
- pr_info("Found anon-shmem piggie at %lx\n", shmem_dev);
+ pr_info("Found anon-shmem piggie at %"PRIx64"\n", shmem_dev);
}
return shmem_dev == dev;
@@ -197,7 +197,7 @@ int parse_smaps(pid_t pid, struct list_head *vma_area_list, bool use_map_files)
if (!is_vma_range_fmt(buf)) {
if (!strncmp(buf, "Nonlinear", 9)) {
BUG_ON(!vma_area);
- pr_err("Nonlinear mapping found %016lx-%016lx\n",
+ pr_err("Nonlinear mapping found %016"PRIx64"-%016"PRIx64"\n",
vma_area->vma.start, vma_area->vma.end);
/*
* VMA is already on list and will be
@@ -249,7 +249,7 @@ int parse_smaps(pid_t pid, struct list_head *vma_area_list, bool use_map_files)
if (!S_ISSOCK(buf.st_mode))
goto err_bogus_mapfile;
- pr_info("Found socket %lu mapping @%lx\n", buf.st_ino, start);
+ pr_info("Found socket %"PRIu64" mapping @%lx\n", buf.st_ino, start);
vma_area->vma.status |= VMA_AREA_SOCKET | VMA_AREA_REGULAR;
vma_area->vm_socket_id = buf.st_ino;
} else if (errno != ENOENT)
@@ -358,7 +358,7 @@ err:
return ret;
err_bogus_mapping:
- pr_err("Bogus mapping 0x%lx-0x%lx (flags: %#x vm_file_fd: %d)\n",
+ pr_err("Bogus mapping 0x%"PRIx64"-0x%"PRIx64" (flags: %#x vm_file_fd: %d)\n",
vma_area->vma.start, vma_area->vma.end,
vma_area->vma.flags, vma_area->vm_file_fd);
goto err;
@@ -880,7 +880,7 @@ int parse_fdinfo(int fd, int type,
if (type != FD_TYPES__EVENTFD)
goto parse_err;
- ret = sscanf(str, "eventfd-count: %lx",
+ ret = sscanf(str, "eventfd-count: %"PRIx64,
&entry.efd.counter);
if (ret != 1)
goto parse_err;
@@ -896,7 +896,7 @@ int parse_fdinfo(int fd, int type,
if (type != FD_TYPES__EVENTPOLL)
goto parse_err;
- ret = sscanf(str, "tfd: %d events: %x data: %lx",
+ ret = sscanf(str, "tfd: %d events: %x data: %"PRIx64,
&entry.epl.tfd, &entry.epl.events, &entry.epl.data);
if (ret != 3)
goto parse_err;
@@ -949,7 +949,7 @@ int parse_fdinfo(int fd, int type,
entry.ffy.ie = &ie;
ret = sscanf(str,
- "fanotify ino:%lx sdev:%x mflags:%x mask:%x ignored_mask:%x "
+ "fanotify ino:%"PRIx64" sdev:%x mflags:%x mask:%x ignored_mask:%x "
"fhandle-bytes:%x fhandle-type:%x f_handle: %n",
&ie.i_ino, &entry.ffy.s_dev,
&entry.ffy.mflags, &entry.ffy.mask, &entry.ffy.ignored_mask,
@@ -1010,7 +1010,7 @@ int parse_fdinfo(int fd, int type,
if (type != FD_TYPES__INOTIFY)
goto parse_err;
ret = sscanf(str,
- "inotify wd:%x ino:%lx sdev:%x "
+ "inotify wd:%x ino:%"PRIx64" sdev:%x "
"mask:%x ignored_mask:%x "
"fhandle-bytes:%x fhandle-type:%x "
"f_handle: %n",
diff --git a/shmem.c b/shmem.c
index cb52634..5e2c4a3 100644
--- a/shmem.c
+++ b/shmem.c
@@ -58,7 +58,7 @@ static int collect_shmem(int pid, VmaEntry *vi)
return -1;
}
- pr_info("Add new shmem 0x%lx (0x0160x%lx-0x0160x%lx)",
+ pr_info("Add new shmem 0x%"PRIx64" (0x0160x%"PRIx64"-0x0160x%"PRIx64")",
vi->shmid, vi->start, vi->end);
si = &rst_shmems->entries[nr_shmems];
@@ -94,7 +94,7 @@ int prepare_shmem_pid(int pid)
if (ret <= 0)
break;
- pr_info("vma 0x%lx 0x%lx\n", vi->start, vi->end);
+ pr_info("vma 0x%"PRIx64" 0x%"PRIx64"\n", vi->start, vi->end);
if (!vma_entry_is(vi, VMA_ANON_SHARED) ||
vma_entry_is(vi, VMA_AREA_SYSVIPC)) {
@@ -167,9 +167,9 @@ int get_shmem_fd(int pid, VmaEntry *vi)
int f;
si = find_shmem(rst_shmems, vi->shmid);
- pr_info("Search for 0x%016lx shmem 0x%lx %p/%d\n", vi->start, vi->shmid, si, si ? si->pid : -1);
+ pr_info("Search for 0x%016"PRIx64" shmem 0x%"PRIx64" %p/%d\n", vi->start, vi->shmid, si, si ? si->pid : -1);
if (!si) {
- pr_err("Can't find my shmem 0x%016lx\n", vi->start);
+ pr_err("Can't find my shmem 0x%016"PRIx64"\n", vi->start);
return -1;
}
@@ -190,7 +190,7 @@ int get_shmem_fd(int pid, VmaEntry *vi)
PROT_WRITE | PROT_READ,
MAP_SHARED | MAP_ANONYMOUS, -1, 0);
if (addr == MAP_FAILED) {
- pr_err("Can't mmap shmid=0x%lx size=%ld\n",
+ pr_err("Can't mmap shmid=0x%"PRIx64" size=%ld\n",
vi->shmid, si->size);
return -1;
}
diff --git a/sk-packet.c b/sk-packet.c
index e05caa3..bce2cbf 100644
--- a/sk-packet.c
+++ b/sk-packet.c
@@ -228,7 +228,7 @@ int dump_socket_map(struct vma_area *vma)
return -1;
}
- pr_info("Dumping socket map %x -> %lx\n", sd->file_id, vma->vma.start);
+ pr_info("Dumping socket map %x -> %"PRIx64"\n", sd->file_id, vma->vma.start);
vma->vma.shmid = sd->file_id;
return 0;
}
diff --git a/sysctl.c b/sysctl.c
index 0a791e1..62236db 100644
--- a/sysctl.c
+++ b/sysctl.c
@@ -134,14 +134,14 @@ GEN_SYSCTL_READ_FUNC(u32, strtoul);
GEN_SYSCTL_READ_FUNC(u64, strtoull);
GEN_SYSCTL_WRITE_FUNC(u32, "%u ");
-GEN_SYSCTL_WRITE_FUNC(u64, "%lu ");
+GEN_SYSCTL_WRITE_FUNC(u64, "%"PRIu64" ");
GEN_SYSCTL_PRINT_FUNC(u32, "%u ");
-GEN_SYSCTL_PRINT_FUNC(u64, "%lu ");
+GEN_SYSCTL_PRINT_FUNC(u64, "%"PRIu64" ");
GEN_SYSCTL_PRINT_FUNC(char, "%c");
GEN_SYSCTL_SHOW_FUNC(u32, "%u ");
-GEN_SYSCTL_SHOW_FUNC(u64, "%lu ");
+GEN_SYSCTL_SHOW_FUNC(u64, "%"PRIu64" ");
GEN_SYSCTL_SHOW_FUNC(char, "%c");
static int
diff --git a/util.c b/util.c
index ca7de97..2cb82f0 100644
--- a/util.c
+++ b/util.c
@@ -87,13 +87,14 @@ static void vma_opt_str(const struct vma_area *v, char *opt)
void pr_vma(unsigned int loglevel, const struct vma_area *vma_area)
{
char opt[VMA_OPT_LEN];
+ memset(opt, 0, VMA_OPT_LEN);
if (!vma_area)
return;
vma_opt_str(vma_area, opt);
- print_on_level(loglevel, "%#lx-%#lx (%liK) prot %#x flags %#x off %#lx "
- "%s shmid: %#lx\n",
+ print_on_level(loglevel, "%#"PRIx64"-%#"PRIx64" (%"PRIi64"K) prot %#x flags %#x off %#"PRIx64" "
+ "%s shmid: %#"PRIx64"\n",
vma_area->vma.start, vma_area->vma.end,
KBYTES(vma_area_len(vma_area)),
vma_area->vma.prot,
--
1.7.10.4
More information about the CRIU
mailing list