Skip to contentSkip to conversation

debug warning

U-Boot York Sun 3 participants 6 messages Jul 15, 2015 – Jul 16, 2015

lore
Share & tools
lore

York Sun

author
#0 lore raw

Simon,

Did it happen to you with this warning?

lib/fdtdec.c:108:4: warning: format ?%x? expects argument of type ?unsigned int?, but argument 3 has type ?fdt_size_t? [-Wformat=]

    debug("addr=%08lx, size=%08x\n",
    ^

I think when we have 64-bit physical address, as defined in fdtdec.h, this debug statement needs to be changed. I am thinking to change the typedef fdt_addr_t to phys_addr_t, and fdt_size_t to phys_size_t. What do you say?

York

#1 lore raw

Hello York,

Quoted 4 lines · York Sun

Simon,

Did it happen to you with this warning?

Quoted 8 lines

lib/fdtdec.c:108:4: warning: format ?%x? expects argument of type ?unsigned int?, but argument 3 has type ?fdt_size_t? [-Wformat=]

    debug("addr=%08lx, size=%08x\n",
    ^

I think when we have 64-bit physical address, as defined in fdtdec.h, this debug statement needs to be changed. I am thinking to change the typedef fdt_addr_t to phys_addr_t, and fdt_size_t to phys_size_t. What do you say?

I say there is no reason to change a type just because a printf format specifier is wrong for it when building for 64-bit.

Is there a rationale apart from the format specifier error?

If not, then What should be done is fix the specifier so that it is correct in both 32 and 64 bits.

Amicalement,

Signature · 1 line
Albert.
author
#2 lore raw
Quoted 17 lines · Albert ARIBAUD

Hello York,

Quoted 4 lines · York Sun

Simon,

Did it happen to you with this warning?

Quoted 8 lines

lib/fdtdec.c:108:4: warning: format ?%x? expects argument of type ?unsigned int?, but argument 3 has type ?fdt_size_t? [-Wformat=]

    debug("addr=%08lx, size=%08x\n",
    ^

I think when we have 64-bit physical address, as defined in fdtdec.h, this debug statement needs to be changed. I am thinking to change the typedef fdt_addr_t to phys_addr_t, and fdt_size_t to phys_size_t. What do you say?

Quoted 8 lines

I say there is no reason to change a type just because a printf format specifier is wrong for it when building for 64-bit.

Is there a rationale apart from the format specifier error?

If not, then What should be done is fix the specifier so that it is correct in both 32 and 64 bits.

Albert,

Let me send a RFC patch so you can comment on it.

York

#3 lore raw

Hi York,

Quoted 25 lines · York Sun
Quoted 22 lines · Albert ARIBAUD

Hello York,

Quoted 4 lines · York Sun

Simon,

Did it happen to you with this warning?

Quoted 8 lines

lib/fdtdec.c:108:4: warning: format ?%x? expects argument of type ?unsigned int?, but argument 3 has type ?fdt_size_t? [-Wformat=]

    debug("addr=%08lx, size=%08x\n",
    ^

I think when we have 64-bit physical address, as defined in fdtdec.h, this debug statement needs to be changed. I am thinking to change the typedef fdt_addr_t to phys_addr_t, and fdt_size_t to phys_size_t. What do you say?

I say there is no reason to change a type just because a printf format specifier is wrong for it when building for 64-bit.

Is there a rationale apart from the format specifier error?

Quoted 7 lines
Quoted 3 lines

If not, then What should be done is fix the specifier so that it is correct in both 32 and 64 bits.

Albert,

Let me send a RFC patch so you can comment on it.

I'm not sure how to do what Albert is suggesting.

Regards,
Simon

author
#4 lore raw
Quoted 32 lines · Simon Glass

Hi York,

Quoted 29 lines · York Sun
Quoted 25 lines · Albert ARIBAUD

Hello York,

Quoted 4 lines · York Sun

Simon,

Did it happen to you with this warning?

Quoted 8 lines

lib/fdtdec.c:108:4: warning: format ?%x? expects argument of type ?unsigned int?, but argument 3 has type ?fdt_size_t? [-Wformat=]

    debug("addr=%08lx, size=%08x\n",
    ^

I think when we have 64-bit physical address, as defined in fdtdec.h, this debug statement needs to be changed. I am thinking to change the typedef fdt_addr_t to phys_addr_t, and fdt_size_t to phys_size_t. What do you say?

I say there is no reason to change a type just because a printf format specifier is wrong for it when building for 64-bit.

Is there a rationale apart from the format specifier error?

If not, then What should be done is fix the specifier so that it is correct in both 32 and 64 bits.

Quoted 6 lines
Quoted 3 lines

Albert,

Let me send a RFC patch so you can comment on it.

I'm not sure how to do what Albert is suggesting.

I only thought of two ways, using #ifdef or changing the type as my RFC patch suggests.

York

#5 lore raw

Hello York,

Quoted 37 lines · York Sun
Quoted 34 lines · Simon Glass

Hi York,

Quoted 31 lines · York Sun
Quoted 17 lines · Albert ARIBAUD

Hello York,

Quoted 4 lines · York Sun

Simon,

Did it happen to you with this warning?

Quoted 8 lines

lib/fdtdec.c:108:4: warning: format ?%x? expects argument of type ?unsigned int?, but argument 3 has type ?fdt_size_t? [-Wformat=]

    debug("addr=%08lx, size=%08x\n",
    ^

I think when we have 64-bit physical address, as defined in fdtdec.h, this debug statement needs to be changed. I am thinking to change the typedef fdt_addr_t to phys_addr_t, and fdt_size_t to phys_size_t. What do you say?

Quoted 8 lines

I say there is no reason to change a type just because a printf format specifier is wrong for it when building for 64-bit.

Is there a rationale apart from the format specifier error?

If not, then What should be done is fix the specifier so that it is correct in both 32 and 64 bits.

Albert,

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Let me send a RFC patch so you can comment on it.

I'm not sure how to do what Albert is suggesting.

I only thought of two ways, using #ifdef or changing the type as my RFC patch suggests.

There's a third one: changing the form of the format specifier according to the target's definition of the variable -- you do that once somewhere in a common header file and you're all set up everywhere else.

See for instance how 'uint64_t' has such a format specifier PRIu64 #define-d in /usr/include/inttypes.h; whatever the definition of uint64_t, you can do a printf with it as follows:

	uint64_t var;
	...
	printf("Value of var is " PRIu64 ".\n", var);

(I learned this about a year ago while working on code that had to run on both a 64-bit Intel-core PC and a 32-bit ARM-core Beaglebone)

The same technique can be used here and I strongly prefer it oer changing the type of the variable, because changing the type affects the function of *all* code that uses the variable (thus potentially modifying the board behavior), whereas changing the format specifier affects *only* the printf() code (thus not changing the board behavior except for debug code which, supposedly, it only *fixes*.

Quoted 1 line

York

Amicalement,

Signature · 1 line
Albert.