[CRIU] [PATCH 14/23] cr: introduced the macro P() to convert an integer to unsigned long

Pavel Emelyanov xemul at parallels.com
Mon Jan 14 05:56:42 EST 2013


On 01/14/2013 11:25 AM, Alexander Kartashov wrote:
> This patch prevents a lot of format string warnings on ARM.
> 
> Signed-off-by: Alexander Kartashov <alekskartashov at parallels.com>
> ---
>  arch/x86/include/asm/types.h |    2 ++
>  cr-dump.c                    |    2 +-
>  cr-restore.c                 |   20 ++++++++++----------
>  cr-show.c                    |   18 +++++++++---------
>  eventfd.c                    |    2 +-
>  eventpoll.c                  |    2 +-
>  files-reg.c                  |    2 +-
>  inotify.c                    |    8 ++++----
>  ipc_ns.c                     |    4 ++--
>  parasite-syscall.c           |    8 ++++----
>  pie/parasite.c               |    4 ++--
>  pie/restorer.c               |   20 ++++++++++----------
>  pipes.c                      |    2 +-
>  proc_parse.c                 |    8 ++++----
>  shmem.c                      |   10 +++++-----
>  sk-inet.c                    |    4 ++--
>  sk-packet.c                  |    4 ++--
>  util.c                       |   13 +++++++------
>  18 files changed, 68 insertions(+), 65 deletions(-)
> 
> diff --git a/arch/x86/include/asm/types.h b/arch/x86/include/asm/types.h
> index 4a02a93..a3cdf3e 100644
> --- a/arch/x86/include/asm/types.h
> +++ b/arch/x86/include/asm/types.h
> @@ -274,4 +274,6 @@ typedef struct {
>  
>  #define TI_SP(core) ((core)->thread_info->gpregs->sp)
>  
> +#define P(i) i
> +
>  #endif /* __CR_ASM_TYPES_H__ */
> diff --git a/cr-dump.c b/cr-dump.c
> index 23744e4..8379c76 100644
> --- a/cr-dump.c
> +++ b/cr-dump.c
> @@ -656,7 +656,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;
> diff --git a/cr-restore.c b/cr-restore.c
> index 36d67e6..1d23d3e 100644
> --- a/cr-restore.c
> +++ b/cr-restore.c
> @@ -216,8 +216,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));

print format should be fixed instead

> +			paddr = (void *)P(vma_premmaped_start(&p->vma));

the vma_premmaped_start should do typecast itself

>  			break;
>  		}
>  
> @@ -227,7 +227,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));

same here

>  
>  		addr = mmap(tgt_addr, vma_entry_len(&vma->vma),
>  				vma->vma.prot | PROT_WRITE,
> @@ -309,8 +309,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;
> @@ -324,7 +324,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;
> @@ -473,8 +473,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);

printf format to fix

>  
>  		if (vma_entry_is(&vma->vma, VMA_AREA_SYSVIPC))
>  			ret = vma->vma.shmid;
> @@ -529,9 +529,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);
> diff --git a/cr-show.c b/cr-show.c
> index 8ad2361..975f8ba 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%16lx ", P(e.va));

print format

>  			}
>  			pr_msg("\n");
>  		}
> @@ -310,18 +310,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))

format

>  #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))

format

>  	pr_msg("\t---[ GP registers set ]---\n");
>  
> @@ -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%lx\n", P(thread_info->clear_tid_addr));

format

>  	pr_msg("\n");
>  
>  	show_core_regs(thread_info->gpregs);
> diff --git a/eventfd.c b/eventfd.c
> index 1a8fca3..23c5082 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));

format

there below too may formats to fix. Plz, check yourself.


More information about the CRIU mailing list