Patchwork [U-Boot,1/3] Define uintptr_t as long int to simplify printf() format strings

login
register
mail settings
Submitter Simon Glass
Date Nov. 4, 2011, 1:08 a.m.
Message ID <1320368936-28096-1-git-send-email-sjg@chromium.org>
Download mbox | patch
Permalink /patch/123541/
State New, archived
Headers show

Comments

Simon Glass - Nov. 4, 2011, 1:08 a.m.
If uintptr_t can be either an unsigned int or an unsigned long int, it is
tricky to use it in a printf() format string. This changes it to
unsigned long int consistently. This should do the right thing on both
32-bit and 64-bit architectures.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
 include/compiler.h |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
Mike Frysinger - Nov. 4, 2011, 2:01 a.m.
On Thursday 03 November 2011 21:08:54 Simon Glass wrote:
> --- a/include/compiler.h
> +++ b/include/compiler.h
> 
>  /* Types for `void *' pointers. */
> -#if __WORDSIZE == 64
> +#if __WORDSIZE == 64 || __WORDSIZE == 32
>  typedef unsigned long int       uintptr_t;
> -#elif __WORDSIZE == 32
> -typedef unsigned int            uintptr_t;
>  #else
>  #error "__WORDSIZE has unexpected value"
>  #endif

i'd just delete the #if logic altogether considering we set up the values a 
few lines above
-mike
Simon Glass - Nov. 4, 2011, 4:39 p.m.
On Thu, Nov 3, 2011 at 7:01 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Thursday 03 November 2011 21:08:54 Simon Glass wrote:
>> --- a/include/compiler.h
>> +++ b/include/compiler.h
>>
>>  /* Types for `void *' pointers. */
>> -#if __WORDSIZE == 64
>> +#if __WORDSIZE == 64 || __WORDSIZE == 32
>>  typedef unsigned long int       uintptr_t;
>> -#elif __WORDSIZE == 32
>> -typedef unsigned int            uintptr_t;
>>  #else
>>  #error "__WORDSIZE has unexpected value"
>>  #endif
>
> i'd just delete the #if logic altogether considering we set up the values a
> few lines above
> -mike
>

OK will do in v3 - Simon

Patch

diff --git a/include/compiler.h b/include/compiler.h
index 54999a7..17f4e93 100644
--- a/include/compiler.h
+++ b/include/compiler.h
@@ -124,10 +124,8 @@  typedef unsigned int uint;
 #endif
 
 /* Types for `void *' pointers. */
-#if __WORDSIZE == 64
+#if __WORDSIZE == 64 || __WORDSIZE == 32
 typedef unsigned long int       uintptr_t;
-#elif __WORDSIZE == 32
-typedef unsigned int            uintptr_t;
 #else
 #error "__WORDSIZE has unexpected value"
 #endif