[CRIU] [PATCH 42/44] multiarch: prevented integer size mismatches.
Alexander Kartashov
alekskartashov at parallels.com
Mon Jan 7 10:05:11 EST 2013
Introduced the macro P() to convert an integer to unsigned long.
Signed-off-by: Alexander Kartashov <alekskartashov at parallels.com>
---
arch/x86/include/asm/types.h | 2 ++
cr-dump.c | 6 +++---
cr-restore.c | 26 +++++++++++++-------------
cr-show.c | 18 +++++++++---------
eventfd.c | 2 +-
eventpoll.c | 2 +-
files-reg.c | 2 +-
inotify.c | 8 ++++----
ipc_ns.c | 4 ++--
parasite-syscall.c | 6 +++---
pie/log-simple.c | 2 ++
pie/parasite.c | 4 ++--
pie/restorer.c | 20 ++++++++++----------
pipes.c | 2 +-
proc_parse.c | 16 ++++++++--------
shmem.c | 10 +++++-----
sk-inet.c | 4 ++--
sk-packet.c | 4 ++--
sysctl.c | 6 +++---
util.c | 13 +++++++------
20 files changed, 81 insertions(+), 76 deletions(-)
diff --git a/arch/x86/include/asm/types.h b/arch/x86/include/asm/types.h
index 9722c99..468ac23 100644
--- a/arch/x86/include/asm/types.h
+++ b/arch/x86/include/asm/types.h
@@ -260,4 +260,6 @@ typedef struct {
typedef uint64_t auxv_t;
+#define P(i) i
+
#endif /* __CR_ASM_TYPES_H__ */
diff --git a/cr-dump.c b/cr-dump.c
index ff41fe0..12d0988 100644
--- a/cr-dump.c
+++ b/cr-dump.c
@@ -616,7 +616,7 @@ static int get_task_futex_robust_list(pid_t pid, ThreadCoreEntry *info)
return -1;
}
- info->futex_rla = (u64)head;
+ info->futex_rla = (u64)P(head);
info->futex_rla_len = (u32)len;
return 0;
@@ -1184,8 +1184,8 @@ static int dump_task_thread(struct parasite_ctl *parasite_ctl, struct pid *tid)
core_put_tls(core, tls);
pr_info("%d: virt_pid=%d tid_address=%p sig_blocked=0x%lx\n", pid,
- tid->virt, taddr, core->thread_core->blk_sigset);
- CORE_THREAD_INFO(core)->clear_tid_addr = (u64) taddr;
+ tid->virt, taddr, P(core->thread_core->blk_sigset));
+ CORE_THREAD_INFO(core)->clear_tid_addr = (u64) P(taddr);
ret = dump_sched_info(pid, core->thread_core);
if (ret)
diff --git a/cr-restore.c b/cr-restore.c
index 01fbe4b..cc944fb 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -215,8 +215,8 @@ 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",
- vma->vma.start, vma->vma.end, vma->vma.pgoff);
- paddr = (void *) vma_premmaped_start(&p->vma);
+ P(vma->vma.start), P(vma->vma.end), P(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,
if (paddr == NULL) {
pr_info("Map 0x%016lx-0x%016lx 0x%016lx vma\n",
- vma->vma.start, vma->vma.end, vma->vma.pgoff);
+ P(vma->vma.start), P(vma->vma.end), P(vma->vma.pgoff));
addr = mmap(tgt_addr, vma_entry_len(&vma->vma),
vma->vma.prot | PROT_WRITE,
@@ -276,7 +276,7 @@ static int restore_priv_vma_content(pid_t pid)
* Read page contents.
*/
while (1) {
- u64 va, page_offset;
+ unsigned long va, page_offset;
char buf[PAGE_SIZE];
void *p;
@@ -308,8 +308,8 @@ static int restore_priv_vma_content(pid_t pid)
return -1;
}
- p = (void *) (va - vma->vma.start +
- vma_premmaped_start(&vma->vma));
+ p = (void *) (va - P(vma->vma.start) +
+ P(vma_premmaped_start(&vma->vma)));
if (memcmp(p, buf, PAGE_SIZE) == 0) {
nr_shared++;
continue;
@@ -323,7 +323,7 @@ static int restore_priv_vma_content(pid_t pid)
/* Remove pages, which were not shared with a child */
list_for_each_entry(vma, &rst_vma_list, list) {
unsigned long size, i = 0;
- void *addr = (void *) vma_premmaped_start(&vma->vma);
+ void *addr = (void *) P(vma_premmaped_start(&vma->vma));
if (vma->ppage_bitmap == NULL)
continue;
@@ -472,8 +472,8 @@ static int open_vmas(int pid)
continue;
pr_info("Opening 0x%016lx-0x%016lx 0x%016lx (%x) vma\n",
- vma->vma.start, vma->vma.end,
- vma->vma.pgoff, vma->vma.status);
+ P(vma->vma.start), P(vma->vma.end),
+ P(vma->vma.pgoff), vma->vma.status);
if (vma_entry_is(&vma->vma, VMA_AREA_SYSVIPC))
ret = vma->vma.shmid;
@@ -528,9 +528,9 @@ static int prepare_sigactions(int pid)
if (ret < 0)
break;
- ASSIGN_TYPED(act.rt_sa_handler, e->sigaction);
+ ASSIGN_TYPED(act.rt_sa_handler, P(e->sigaction));
ASSIGN_TYPED(act.rt_sa_flags, e->flags);
- ASSIGN_TYPED(act.rt_sa_restorer, e->restorer);
+ ASSIGN_TYPED(act.rt_sa_restorer, P(e->restorer));
ASSIGN_TYPED(act.rt_sa_mask.sig[0], e->mask);
sa_entry__free_unpacked(e, NULL);
@@ -1640,9 +1640,9 @@ static void show_rt_xsave_frame(struct xsave_struct *x)
(int)i387->fop, (int)i387->mxcsr, (int)i387->mxcsr_mask);
pr_debug("magic1:%x extended_size:%x xstate_bv:%lx xstate_size:%x\n",
- fpx->magic1, fpx->extended_size, fpx->xstate_bv, fpx->xstate_size);
+ fpx->magic1, fpx->extended_size, P(fpx->xstate_bv), fpx->xstate_size);
- pr_debug("xstate_bv: %lx\n", xsave_hdr->xstate_bv);
+ pr_debug("xstate_bv: %lx\n", P(xsave_hdr->xstate_bv));
pr_debug("-----------------------\n");
}
diff --git a/cr-show.c b/cr-show.c
index 63bda96..b1d2444 100644
--- a/cr-show.c
+++ b/cr-show.c
@@ -227,7 +227,7 @@ void show_pages(int fd_pages, struct cr_options *o)
goto out;
}
- pr_msg("0x%16lx ", e.va);
+ pr_msg("0x%16lx ", P(e.va));
}
pr_msg("\n");
}
@@ -305,18 +305,18 @@ static void show_core_regs(UserX86RegsEntry *regs)
"%8s: 0x%-16lx " \
"%8s: 0x%-16lx " \
"%8s: 0x%-16lx\n", \
- #n1, s->n1, \
- #n2, s->n2, \
- #n3, s->n3, \
- #n4, s->n4)
+ #n1, P(s->n1), \
+ #n2, P(s->n2), \
+ #n3, P(s->n3), \
+ #n4, P(s->n4))
#define pr_regs3(s, n1, n2, n3) \
pr_msg("\t%8s: 0x%-16lx " \
"%8s: 0x%-16lx " \
"%8s: 0x%-16lx\n", \
- #n1, s->n1, \
- #n2, s->n2, \
- #n3, s->n3)
+ #n1, P(s->n1), \
+ #n2, P(s->n2), \
+ #n3, P(s->n3))
pr_msg("\t---[ GP registers set ]---\n");
@@ -336,7 +336,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%lx\n", P(thread_info->clear_tid_addr));
pr_msg("\n");
show_core_regs(thread_info->gpregs);
diff --git a/eventfd.c b/eventfd.c
index 1e48af2..9e6fd3f 100644
--- a/eventfd.c
+++ b/eventfd.c
@@ -41,7 +41,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",
- action, efe->id, efe->flags, efe->counter);
+ action, efe->id, efe->flags, P(efe->counter));
}
void show_eventfds(int fd, struct cr_options *o)
diff --git a/eventpoll.c b/eventpoll.c
index ccce771..02a9e09 100644
--- a/eventpoll.c
+++ b/eventpoll.c
@@ -48,7 +48,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",
- action, e->id, e->tfd, e->events, e->data);
+ action, e->id, e->tfd, e->events, P(e->data));
}
static void pr_info_eventpoll(char *action, EventpollFileEntry *e)
diff --git a/files-reg.c b/files-reg.c
index cf4fd71..d357e64 100644
--- a/files-reg.c
+++ b/files-reg.c
@@ -289,7 +289,7 @@ static int dump_ghost_remap(char *path, const struct stat *st, int lfd, u32 id)
if (st->st_size > MAX_GHOST_FILE_SIZE) {
pr_err("Can't dump ghost file %s of %lu size\n",
- path, st->st_size);
+ path, P(st->st_size));
return -1;
}
diff --git a/inotify.c b/inotify.c
index c7f7365..998d600 100644
--- a/inotify.c
+++ b/inotify.c
@@ -78,10 +78,10 @@ static int dump_inotify_entry(union fdinfo_entries *e, void *arg)
we->id = *(u32 *)arg;
pr_info("wd: wd 0x%08x s_dev 0x%08x i_ino 0x%16lx mask 0x%08x\n",
- we->wd, we->s_dev, we->i_ino, we->mask);
+ we->wd, we->s_dev, P(we->i_ino), we->mask);
pr_info("\t[fhandle] bytes 0x%08x type 0x%08x __handle 0x%016lx:0x%016lx\n",
we->f_handle->bytes, we->f_handle->type,
- we->f_handle->handle[0], we->f_handle->handle[1]);
+ P(we->f_handle->handle[0]), P(we->f_handle->handle[1]));
return pb_write_one(fdset_fd(glob_fdset, CR_FD_INOTIFY_WD), we, PB_INOTIFY_WD);
}
@@ -136,14 +136,14 @@ static int restore_one_inotify(int inotify_fd, struct inotify_wd_info *info)
target = sys_open_by_handle_at(mntfd, (void *)&handle, 0);
if (target < 0) {
pr_perror("Can't open file handle for 0x%08x:0x%016lx",
- iwe->s_dev, iwe->i_ino);
+ iwe->s_dev, P(iwe->i_ino));
goto err;
}
snprintf(buf, sizeof(buf), "/proc/self/fd/%d", target);
} else
path = info->remap->path;
- pr_debug("\t\tRestore watch for 0x%08x:0x%016lx\n", iwe->s_dev, iwe->i_ino);
+ pr_debug("\t\tRestore watch for 0x%08x:0x%016lx\n", iwe->s_dev, P(iwe->i_ino));
/*
* FIXME The kernel allocates wd-s sequentially,
diff --git a/ipc_ns.c b/ipc_ns.c
index 223a436..f4463bd 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",
- nr++, msg->mtype, msg->msize);
+ nr++, P(msg->mtype), msg->msize);
}
static void pr_info_ipc_msg_entry(const IpcMsgEntry *msg)
@@ -280,7 +280,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: %-10lu\n", P(shm->size));
}
static int ipc_sysctl_req(IpcVarEntry *e, int op)
diff --git a/parasite-syscall.c b/parasite-syscall.c
index 0ba5439..b6c9132 100644
--- a/parasite-syscall.c
+++ b/parasite-syscall.c
@@ -403,9 +403,9 @@ int parasite_dump_sigacts_seized(struct parasite_ctl *ctl, struct cr_fdset *cr_f
if (sig == SIGSTOP || sig == SIGKILL)
continue;
- ASSIGN_TYPED(se.sigaction, args->sas[i].rt_sa_handler);
+ ASSIGN_TYPED(se.sigaction, P(args->sas[i].rt_sa_handler));
ASSIGN_TYPED(se.flags, args->sas[i].rt_sa_flags);
- ASSIGN_TYPED(se.restorer, args->sas[i].rt_sa_restorer);
+ ASSIGN_TYPED(se.restorer, P(args->sas[i].rt_sa_restorer));
ASSIGN_TYPED(se.mask, args->sas[i].rt_sa_mask.sig[0]);
if (pb_write_one(fd, &se, PB_SIGACT) < 0)
@@ -562,7 +562,7 @@ int parasite_dump_pages_seized(struct parasite_ctl *ctl, struct list_head *vma_a
}
pr_info("vma %lx-%lx dumped: %lu pages %lu skipped %lu total\n",
- vma_area->vma.start, vma_area->vma.end,
+ P(vma_area->vma.start), P(vma_area->vma.end),
parasite_dumppages->nrpages_dumped,
parasite_dumppages->nrpages_skipped,
parasite_dumppages->nrpages_total);
diff --git a/pie/log-simple.c b/pie/log-simple.c
index eb940c1..58bc6c5 100644
--- a/pie/log-simple.c
+++ b/pie/log-simple.c
@@ -136,6 +136,7 @@ static void print_hex_l(unsigned long num)
hexdigit(num >> 24, &buf[11], &z);
hexdigit(num >> 28, &buf[10], &z);
+#ifdef CONFIG_X86
hexdigit(num >> 32, &buf[9], &z);
hexdigit(num >> 36, &buf[8], &z);
hexdigit(num >> 40, &buf[7], &z);
@@ -144,6 +145,7 @@ static void print_hex_l(unsigned long num)
hexdigit(num >> 52, &buf[4], &z);
hexdigit(num >> 56, &buf[3], &z);
hexdigit(num >> 60, &buf[2], &z);
+#endif
z -= 2;
z[0] = '0';
diff --git a/pie/parasite.c b/pie/parasite.c
index 3d3fd85..fed2df2 100644
--- a/pie/parasite.c
+++ b/pie/parasite.c
@@ -179,7 +179,7 @@ static int dump_pages(struct parasite_dump_pages_args *args)
if (!(args->vma_entry.prot & PROT_READ)) {
prot_old = (unsigned long)args->vma_entry.prot;
prot_new = prot_old | PROT_READ;
- ret = sys_mprotect((void *)args->vma_entry.start,
+ ret = sys_mprotect((void *)P(args->vma_entry.start),
(unsigned long)vma_entry_len(&args->vma_entry),
prot_new);
if (ret) {
@@ -215,7 +215,7 @@ static int dump_pages(struct parasite_dump_pages_args *args)
* Don't left pages readable if they were not.
*/
if (prot_old != prot_new) {
- ret = sys_mprotect((void *)args->vma_entry.start,
+ ret = sys_mprotect((void *)P(args->vma_entry.start),
(unsigned long)vma_entry_len(&args->vma_entry),
prot_old);
if (ret) {
diff --git a/pie/restorer.c b/pie/restorer.c
index b80e413..fe89cbb 100644
--- a/pie/restorer.c
+++ b/pie/restorer.c
@@ -146,10 +146,10 @@ static void restore_sched_info(struct rst_sched_param *p)
static int restore_thread_common(struct rt_sigframe *sigframe,
struct thread_restore_args *args)
{
- sys_set_tid_address((int *)args->clear_tid_addr);
+ sys_set_tid_address((int *)P(args->clear_tid_addr));
if (args->has_futex) {
- if (sys_set_robust_list((void *)args->futex_rla, args->futex_rla_len)) {
+ if (sys_set_robust_list((void *)P(args->futex_rla), args->futex_rla_len)) {
pr_err("Robust list err\n");
return -1;
}
@@ -230,7 +230,7 @@ static u64 restore_mapping(const VmaEntry *vma_entry)
u64 addr;
if (vma_entry_is(vma_entry, VMA_AREA_SYSVIPC))
- return sys_shmat(vma_entry->fd, (void *)vma_entry->start,
+ return sys_shmat(vma_entry->fd, (void *)P(vma_entry->start),
(vma_entry->prot & PROT_WRITE) ? 0 : SHM_RDONLY);
/*
@@ -247,14 +247,14 @@ static u64 restore_mapping(const VmaEntry *vma_entry)
prot |= PROT_WRITE;
pr_debug("\tmmap(%lx -> %lx, %x %x %d\n",
- vma_entry->start, vma_entry->end,
+ P(vma_entry->start), P(vma_entry->end),
prot, flags, (int)vma_entry->fd);
/*
* Should map memory here. Note we map them as
* writable since we're going to restore page
* contents.
*/
- addr = sys_mmap((void *)vma_entry->start,
+ addr = sys_mmap((void *)P(vma_entry->start),
vma_entry_len(vma_entry),
prot, flags,
vma_entry->fd,
@@ -391,7 +391,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 %lx-%lx\n", P(vma_entry->start), P(vma_entry->end));
if (addr < args->premmapped_addr) {
if (vma_entry->end >= args->premmapped_addr)
@@ -476,7 +476,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 %lx mapping with %lx\n", P(vma_entry->start), P(va));
goto core_restore_end;
}
}
@@ -502,7 +502,7 @@ long __export_restore_task(struct task_restore_core_args *args)
if (vma_entry->prot & PROT_WRITE)
continue;
- sys_mprotect((void *)vma_entry->start,
+ sys_mprotect((void *)P(vma_entry->start),
vma_entry_len(vma_entry),
vma_entry->prot);
}
@@ -523,8 +523,8 @@ long __export_restore_task(struct task_restore_core_args *args)
if (ret) {
pr_err("madvise(%lx, %ld, %ld) "
"failed with %ld\n",
- vma_entry->start,
- vma_entry_len(vma_entry),
+ P(vma_entry->start),
+ P(vma_entry_len(vma_entry)),
i, ret);
goto core_restore_end;
}
diff --git a/pipes.c b/pipes.c
index 6542ec6..1c56816 100644
--- a/pipes.c
+++ b/pipes.c
@@ -178,7 +178,7 @@ int restore_pipe_data(int img_type, int pfd, u32 id, struct pipe_data_rst **hash
if (ret == 0 || ret > iov.iov_len /* sanity */) {
pr_err("%#x: Wanted to restore %lu bytes, but got %d\n", id,
- iov.iov_len, ret);
+ P(iov.iov_len), ret);
ret = -1;
goto err;
}
diff --git a/proc_parse.c b/proc_parse.c
index 81bf11c..ee115f0 100644
--- a/proc_parse.c
+++ b/proc_parse.c
@@ -161,7 +161,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 %lx\n", P(shmem_dev));
}
return shmem_dev == dev;
@@ -170,7 +170,7 @@ static int is_anon_shmem_map(dev_t dev)
int parse_smaps(pid_t pid, struct list_head *vma_area_list, bool use_map_files)
{
struct vma_area *vma_area = NULL;
- u64 start, end, pgoff;
+ unsigned long start, end, pgoff;
unsigned long ino;
char r, w, x, s;
int dev_maj, dev_min;
@@ -197,7 +197,7 @@ int parse_smaps(pid_t pid, struct list_head *vma_area_list, bool use_map_files)
if (!strncmp(buf, "Nonlinear", 9)) {
BUG_ON(!vma_area);
pr_err("Nonlinear mapping found %016lx-%016lx\n",
- vma_area->vma.start, vma_area->vma.end);
+ P(vma_area->vma.start), P(vma_area->vma.end));
/*
* VMA is already on list and will be
* freed later as list get destroyed.
@@ -248,7 +248,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 %lu mapping @%lx\n", P(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:
err_bogus_mapping:
pr_err("Bogus mapping 0x%lx-0x%lx (flags: %#x vm_file_fd: %d)\n",
- vma_area->vma.start, vma_area->vma.end,
+ P(vma_area->vma.start), P(vma_area->vma.end),
vma_area->vma.flags, vma_area->vm_file_fd);
goto err;
@@ -879,7 +879,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;
@@ -895,7 +895,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;
@@ -932,7 +932,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..f716c95 100644
--- a/shmem.c
+++ b/shmem.c
@@ -59,7 +59,7 @@ static int collect_shmem(int pid, VmaEntry *vi)
}
pr_info("Add new shmem 0x%lx (0x0160x%lx-0x0160x%lx)",
- vi->shmid, vi->start, vi->end);
+ P(vi->shmid), P(vi->start), P(vi->end));
si = &rst_shmems->entries[nr_shmems];
rst_shmems->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%lx 0x%lx\n", P(vi->start), P(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%016lx shmem 0x%lx %p/%d\n", P(vi->start), P(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%016lx\n", P(vi->start));
return -1;
}
@@ -191,7 +191,7 @@ int get_shmem_fd(int pid, VmaEntry *vi)
MAP_SHARED | MAP_ANONYMOUS, -1, 0);
if (addr == MAP_FAILED) {
pr_err("Can't mmap shmid=0x%lx size=%ld\n",
- vi->shmid, si->size);
+ P(vi->shmid), si->size);
return -1;
}
diff --git a/sk-inet.c b/sk-inet.c
index 25581ba..68f4447 100644
--- a/sk-inet.c
+++ b/sk-inet.c
@@ -426,8 +426,8 @@ static int inet_validate_address(InetSkEntry *ie)
return 0;
pr_err("Addr len mismatch f %d ss %lu ds %lu\n", ie->family,
- pb_repeated_size(ie, src_addr),
- pb_repeated_size(ie, dst_addr));
+ P(pb_repeated_size(ie, src_addr)),
+ P(pb_repeated_size(ie, dst_addr)));
return -1;
}
diff --git a/sk-packet.c b/sk-packet.c
index 0e85d36..c7b0de3 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 -> %lx\n", sd->file_id, P(vma->vma.start));
vma->vma.shmid = sd->file_id;
return 0;
}
@@ -344,7 +344,7 @@ static int restore_mreqs(int sk, PacketSockEntry *pse)
pr_info("Restoring mreq type %d\n", ml->type);
if (ml->addr.len > sizeof(mreq.mr_address)) {
- pr_err("To big mcaddr %lu\n", ml->addr.len);
+ pr_err("To big mcaddr %lu\n", P(ml->addr.len));
return -1;
}
diff --git a/sysctl.c b/sysctl.c
index 92fc153..1521619 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 90c82f7..d1dfda7 100644
--- a/util.c
+++ b/util.c
@@ -87,6 +87,7 @@ 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;
@@ -94,12 +95,12 @@ void pr_vma(unsigned int loglevel, const struct vma_area *vma_area)
vma_opt_str(vma_area, opt);
print_on_level(loglevel, "%#lx-%#lx (%liK) prot %#x flags %#x off %#lx "
"%s shmid: %#lx\n",
- vma_area->vma.start, vma_area->vma.end,
- KBYTES(vma_area_len(vma_area)),
+ P(vma_area->vma.start), P(vma_area->vma.end),
+ P(KBYTES(vma_area_len(vma_area))),
vma_area->vma.prot,
vma_area->vma.flags,
- vma_area->vma.pgoff,
- opt, vma_area->vma.shmid);
+ P(vma_area->vma.pgoff),
+ opt, P(vma_area->vma.shmid));
}
int close_safe(int *fd)
@@ -340,7 +341,7 @@ int copy_file(int fd_in, int fd_out, size_t bytes)
if (ret == 0) {
if (bytes && (written != bytes)) {
pr_err("Ghost file size mismatch %lu/%lu\n",
- written, bytes);
+ P(written), P(bytes));
return -1;
}
break;
@@ -387,7 +388,7 @@ void *shmalloc(size_t bytes)
void *ret;
if (bytes > SH_BUF_CHUNK) {
- pr_err("Too big shared buffer requested %lu\n", bytes);
+ pr_err("Too big shared buffer requested %lu\n", P(bytes));
return NULL;
}
--
1.7.10.4
More information about the CRIU
mailing list