public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v3 1/3] Define uintptr_t as long int to simplify printf() format strings
@ 2011-11-04 16:42 Simon Glass
  2011-11-04 16:42 ` [U-Boot] [PATCH v3 2/3] Fix warnings in cmd_nvedit.c Simon Glass
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Simon Glass @ 2011-11-04 16:42 UTC (permalink / raw)
  To: u-boot

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>
---
Changes in v3:
- Remove the #if logic since it doesn't really do anything

 include/compiler.h |   12 +++---------
 1 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/include/compiler.h b/include/compiler.h
index 54999a7..0734ed4 100644
--- a/include/compiler.h
+++ b/include/compiler.h
@@ -123,16 +123,10 @@ typedef unsigned int uint;
 #define __WORDSIZE	32
 #endif
 
-/* Types for `void *' pointers. */
-#if __WORDSIZE == 64
-typedef unsigned long int       uintptr_t;
-#elif __WORDSIZE == 32
-typedef unsigned int            uintptr_t;
-#else
-#error "__WORDSIZE has unexpected value"
-#endif
+/* Type for `void *' pointers. */
+typedef unsigned long int uintptr_t;
 
-#endif
+#endif /* USE_HOSTCC */
 
 /* compiler options */
 #define uninitialized_var(x)		x = x
-- 
1.7.3.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH v3 2/3] Fix warnings in cmd_nvedit.c
  2011-11-04 16:42 [U-Boot] [PATCH v3 1/3] Define uintptr_t as long int to simplify printf() format strings Simon Glass
@ 2011-11-04 16:42 ` Simon Glass
  2011-11-22  8:50   ` Stefano Babic
  2011-11-04 16:42 ` [U-Boot] [PATCH v3 3/3] sandbox: Fix warnings in hashtable.c Simon Glass
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: Simon Glass @ 2011-11-04 16:42 UTC (permalink / raw)
  To: u-boot

This printf() string should be %ld now that uintptr_t is defined
as long. Also fix a size_t error.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Mike Frysinger <vapier@gentoo.org>
---

 common/cmd_nvedit.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index 396a171..8895335 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -405,7 +405,7 @@ int setenv_addr(const char *varname, const void *addr)
 {
 	char str[17];
 
-	sprintf(str, "%x", (uintptr_t)addr);
+	sprintf(str, "%lx", (uintptr_t)addr);
 	return setenv(varname, str);
 }
 
@@ -862,7 +862,7 @@ static int do_env_import(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv
 				" - truncated\n", MAX_ENV_SIZE);
 		}
 		++size;
-		printf("## Info: input data size = %zd = 0x%zX\n", size, size);
+		printf("## Info: input data size = %zu = 0x%zX\n", size, size);
 	}
 
 	if (chk) {
-- 
1.7.3.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH v3 3/3] sandbox: Fix warnings in hashtable.c
  2011-11-04 16:42 [U-Boot] [PATCH v3 1/3] Define uintptr_t as long int to simplify printf() format strings Simon Glass
  2011-11-04 16:42 ` [U-Boot] [PATCH v3 2/3] Fix warnings in cmd_nvedit.c Simon Glass
@ 2011-11-04 16:42 ` Simon Glass
  2011-11-04 20:07 ` [U-Boot] [PATCH v3 1/3] Define uintptr_t as long int to simplify printf() format strings Mike Frysinger
  2011-11-22  8:49 ` Stefano Babic
  3 siblings, 0 replies; 6+ messages in thread
From: Simon Glass @ 2011-11-04 16:42 UTC (permalink / raw)
  To: u-boot

This fixes a few printf() strings for size_t which are missing the 'z'
modifier.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Mike Frysinger <vapier@gentoo.org>
---
Changes in v2:
- Fix another warning in the same file

 lib/hashtable.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/hashtable.c b/lib/hashtable.c
index 6895550..fca9d6e 100644
--- a/lib/hashtable.c
+++ b/lib/hashtable.c
@@ -491,8 +491,8 @@ ssize_t hexport_r(struct hsearch_data *htab, const char sep,
 		return (-1);
 	}
 
-	debug("EXPORT  table = %p, htab.size = %d, htab.filled = %d, size = %d\n",
-		htab, htab->size, htab->filled, size);
+	debug("EXPORT  table = %p, htab.size = %d, htab.filled = %d, "
+		"size = %zu\n", htab, htab->size, htab->filled, size);
 	/*
 	 * Pass 1:
 	 * search used entries,
@@ -539,7 +539,7 @@ ssize_t hexport_r(struct hsearch_data *htab, const char sep,
 	/* Check if the user supplied buffer size is sufficient */
 	if (size) {
 		if (size < totlen + 1) {	/* provided buffer too small */
-			debug("### buffer too small: %d, but need %d\n",
+			debug("### buffer too small: %zu, but need %zu\n",
 				size, totlen + 1);
 			__set_errno(ENOMEM);
 			return (-1);
@@ -640,7 +640,7 @@ int himport_r(struct hsearch_data *htab,
 
 	/* we allocate new space to make sure we can write to the array */
 	if ((data = malloc(size)) == NULL) {
-		debug("himport_r: can't malloc %d bytes\n", size);
+		debug("himport_r: can't malloc %zu bytes\n", size);
 		__set_errno(ENOMEM);
 		return 0;
 	}
-- 
1.7.3.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH v3 1/3] Define uintptr_t as long int to simplify printf() format strings
  2011-11-04 16:42 [U-Boot] [PATCH v3 1/3] Define uintptr_t as long int to simplify printf() format strings Simon Glass
  2011-11-04 16:42 ` [U-Boot] [PATCH v3 2/3] Fix warnings in cmd_nvedit.c Simon Glass
  2011-11-04 16:42 ` [U-Boot] [PATCH v3 3/3] sandbox: Fix warnings in hashtable.c Simon Glass
@ 2011-11-04 20:07 ` Mike Frysinger
  2011-11-22  8:49 ` Stefano Babic
  3 siblings, 0 replies; 6+ messages in thread
From: Mike Frysinger @ 2011-11-04 20:07 UTC (permalink / raw)
  To: u-boot

Acked-by: Mike Frysinger <vapier@gentoo.org>
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20111104/bcbc19a0/attachment.pgp 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH v3 1/3] Define uintptr_t as long int to simplify printf() format strings
  2011-11-04 16:42 [U-Boot] [PATCH v3 1/3] Define uintptr_t as long int to simplify printf() format strings Simon Glass
                   ` (2 preceding siblings ...)
  2011-11-04 20:07 ` [U-Boot] [PATCH v3 1/3] Define uintptr_t as long int to simplify printf() format strings Mike Frysinger
@ 2011-11-22  8:49 ` Stefano Babic
  3 siblings, 0 replies; 6+ messages in thread
From: Stefano Babic @ 2011-11-22  8:49 UTC (permalink / raw)
  To: u-boot

On 04/11/2011 17:42, Simon Glass wrote:
> 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>
> ---

Applied to u-boot-staging, sbabic at denx.de, thanks.

Best regards,
Stefano Babic


-- 
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH v3 2/3] Fix warnings in cmd_nvedit.c
  2011-11-04 16:42 ` [U-Boot] [PATCH v3 2/3] Fix warnings in cmd_nvedit.c Simon Glass
@ 2011-11-22  8:50   ` Stefano Babic
  0 siblings, 0 replies; 6+ messages in thread
From: Stefano Babic @ 2011-11-22  8:50 UTC (permalink / raw)
  To: u-boot

On 04/11/2011 17:42, Simon Glass wrote:
> This printf() string should be %ld now that uintptr_t is defined
> as long. Also fix a size_t error.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Acked-by: Mike Frysinger <vapier@gentoo.org>
> ---

Applied to u-boot-staging, sbabic at denx.de, thanks.

Best regards,
Stefano Babic


-- 
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-11-22  8:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-04 16:42 [U-Boot] [PATCH v3 1/3] Define uintptr_t as long int to simplify printf() format strings Simon Glass
2011-11-04 16:42 ` [U-Boot] [PATCH v3 2/3] Fix warnings in cmd_nvedit.c Simon Glass
2011-11-22  8:50   ` Stefano Babic
2011-11-04 16:42 ` [U-Boot] [PATCH v3 3/3] sandbox: Fix warnings in hashtable.c Simon Glass
2011-11-04 20:07 ` [U-Boot] [PATCH v3 1/3] Define uintptr_t as long int to simplify printf() format strings Mike Frysinger
2011-11-22  8:49 ` Stefano Babic

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox