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

Pavel Emelyanov xemul at parallels.com
Thu Jan 17 04:54:29 EST 2013


On 01/17/2013 10:34 AM, Alexander Kartashov wrote:
> On 01/16/2013 07:27 PM, Pavel Emelyanov wrote:
>>>   			     vma_entry_len(vma_entry),
>>>>  			     vma_entry->prot);
>>>>  	}
>>>> diff --git a/pipes.c b/pipes.c
>>>> index 16a2454..8b801b8 100644
>>>> --- a/pipes.c
>>>> +++ b/pipes.c
>>>> @@ -186,7 +186,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);
>> printf format to fix
>>
> 
> I expected this comment. Take a look at the following modelling program:
> 
> #include <stdio.h>
> 
> int main() {
> size_t v = 1;
> 
> printf("%lu\n", v);
> 
> return 0;
> }
> 
> It compiles on x86_64 successfully but the ARM compiler says:
> 
> 2.c: In function ‘main’:
> 2.c:7:2: error: format ‘%lu’ expects argument of type ‘long unsigned 
> int’, but argument 2 has type ‘size_t’ [-Werror=format]
> cc1: all warnings being treated as errors
> 
> 
> If we change the format specified to %u the ARM compiler is happy but 
> x86_64 isn't:
> 
> 2.c: In function ‘main’:
> 2.c:7:2: error: format ‘%u’ expects argument of type ‘unsigned int’, but 
> argument 2 has type ‘size_t’ [-Werror=format]
> cc1: all warnings being treated as errors
> 
> 
> Moreover we can't use explicit size specifier because the size of size_t 
> is different on x86 an ARM.

OK. So this is about "how to printf size_t-s" right? How is it solved
in other projects, e.g. kernel?




More information about the CRIU mailing list