Patchwork [for-1.4,v2,1/5] qtest: Use strtoull() for uint64_t

login
register
mail settings
Submitter Andreas Färber
Date Feb. 6, 2013, 6:33 p.m.
Message ID <1360175610-8992-2-git-send-email-afaerber@suse.de>
Download mbox | patch
Permalink /patch/218717/
State New
Headers show

Comments

Andreas Färber - Feb. 6, 2013, 6:33 p.m.
On 32-bit hosts, unsigned long may be uint32_t and uint64_t may be
unsigned long long. Account for this by always using strtoull().
We were already using strtoll() for int64_t.

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 qtest.c |    8 ++++----
 1 Datei geändert, 4 Zeilen hinzugefügt(+), 4 Zeilen entfernt(-)
Anthony Liguori - Feb. 8, 2013, 9:35 p.m.
Andreas Färber <afaerber@suse.de> writes:

> On 32-bit hosts, unsigned long may be uint32_t and uint64_t may be
> unsigned long long. Account for this by always using strtoull().
> We were already using strtoll() for int64_t.
>
> Signed-off-by: Andreas Färber <afaerber@suse.de>

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>

Regards,

Anthony Liguori

> ---
>  qtest.c |    8 ++++----
>  1 Datei geändert, 4 Zeilen hinzugefügt(+), 4 Zeilen entfernt(-)
>
> diff --git a/qtest.c b/qtest.c
> index b7a3821..4663a38 100644
> --- a/qtest.c
> +++ b/qtest.c
> @@ -282,8 +282,8 @@ static void qtest_process_command(CharDriverState *chr, gchar **words)
>          uint8_t *data;
>  
>          g_assert(words[1] && words[2]);
> -        addr = strtoul(words[1], NULL, 0);
> -        len = strtoul(words[2], NULL, 0);
> +        addr = strtoull(words[1], NULL, 0);
> +        len = strtoull(words[2], NULL, 0);
>  
>          data = g_malloc(len);
>          cpu_physical_memory_read(addr, data, len);
> @@ -302,8 +302,8 @@ static void qtest_process_command(CharDriverState *chr, gchar **words)
>          size_t data_len;
>  
>          g_assert(words[1] && words[2] && words[3]);
> -        addr = strtoul(words[1], NULL, 0);
> -        len = strtoul(words[2], NULL, 0);
> +        addr = strtoull(words[1], NULL, 0);
> +        len = strtoull(words[2], NULL, 0);
>  
>          data_len = strlen(words[3]);
>          if (data_len < 3) {
> -- 
> 1.7.10.4

Patch

diff --git a/qtest.c b/qtest.c
index b7a3821..4663a38 100644
--- a/qtest.c
+++ b/qtest.c
@@ -282,8 +282,8 @@  static void qtest_process_command(CharDriverState *chr, gchar **words)
         uint8_t *data;
 
         g_assert(words[1] && words[2]);
-        addr = strtoul(words[1], NULL, 0);
-        len = strtoul(words[2], NULL, 0);
+        addr = strtoull(words[1], NULL, 0);
+        len = strtoull(words[2], NULL, 0);
 
         data = g_malloc(len);
         cpu_physical_memory_read(addr, data, len);
@@ -302,8 +302,8 @@  static void qtest_process_command(CharDriverState *chr, gchar **words)
         size_t data_len;
 
         g_assert(words[1] && words[2] && words[3]);
-        addr = strtoul(words[1], NULL, 0);
-        len = strtoul(words[2], NULL, 0);
+        addr = strtoull(words[1], NULL, 0);
+        len = strtoull(words[2], NULL, 0);
 
         data_len = strlen(words[3]);
         if (data_len < 3) {