Patchwork [16/18] lib: fwts_memorymap: print format using inttypes

login
register
mail settings
Submitter Colin King
Date Sept. 23, 2012, 7:03 p.m.
Message ID <1348427041-4913-17-git-send-email-colin.king@canonical.com>
Download mbox | patch
Permalink /patch/186265/
State Accepted
Headers show

Comments

Colin King - Sept. 23, 2012, 7:03 p.m.
From: Colin Ian King <colin.king@canonical.com>

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/lib/src/fwts_memorymap.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
Keng-Yu Lin - Sept. 27, 2012, 9:34 a.m.
On Mon, Sep 24, 2012 at 3:03 AM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/lib/src/fwts_memorymap.c |   10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/src/lib/src/fwts_memorymap.c b/src/lib/src/fwts_memorymap.c
> index 8b29315..46fe455 100644
> --- a/src/lib/src/fwts_memorymap.c
> +++ b/src/lib/src/fwts_memorymap.c
> @@ -25,6 +25,7 @@
>  #include <string.h>
>  #include <unistd.h>
>  #include <stdint.h>
> +#include <inttypes.h>
>
>  #include "fwts.h"
>
> @@ -201,9 +202,8 @@ static void fwts_memory_map_dump_info(void *data, void *private)
>         fwts_memory_map_entry *entry = (fwts_memory_map_entry *)data;
>         fwts_framework *fw = (fwts_framework *)private;
>
> -       fwts_log_info_verbatum(fw, "%016llx - %016llx  %s",
> -                       (unsigned long long)entry->start_address,
> -                       (unsigned long long)entry->end_address,
> +       fwts_log_info_verbatum(fw, "0x%16.16" PRIx64 " - 0x%16.16" PRIx64 " %s",
> +                       entry->start_address, entry->end_address,
>                         fwts_memory_map_type_to_str(entry->type));
>  }
>
> @@ -258,7 +258,7 @@ static fwts_memory_map_entry *fwts_memory_map_table_read_entry(const char *which
>                 free(entry);
>                 return NULL;
>         }
> -       sscanf(data, "0x%llx", (unsigned long long*)&entry->start_address);
> +       sscanf(data, "0x%" SCNx64, &entry->start_address);
>         free(data);
>
>         snprintf(path, sizeof(path), "/sys/firmware/memmap/%s/end", which);
> @@ -266,7 +266,7 @@ static fwts_memory_map_entry *fwts_memory_map_table_read_entry(const char *which
>                 free(entry);
>                 return NULL;
>         }
> -       sscanf(data, "0x%llx", (unsigned long long*)&entry->end_address);
> +       sscanf(data, "0x%" SCNx64, &entry->end_address);
>         free(data);
>
>         snprintf(path, sizeof(path), "/sys/firmware/memmap/%s/type", which);
> --
> 1.7.10.4
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>
Ivan Hu - Oct. 2, 2012, 2:41 a.m.
On 09/24/2012 03:03 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/lib/src/fwts_memorymap.c |   10 +++++-----
>   1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/src/lib/src/fwts_memorymap.c b/src/lib/src/fwts_memorymap.c
> index 8b29315..46fe455 100644
> --- a/src/lib/src/fwts_memorymap.c
> +++ b/src/lib/src/fwts_memorymap.c
> @@ -25,6 +25,7 @@
>   #include <string.h>
>   #include <unistd.h>
>   #include <stdint.h>
> +#include <inttypes.h>
>
>   #include "fwts.h"
>
> @@ -201,9 +202,8 @@ static void fwts_memory_map_dump_info(void *data, void *private)
>   	fwts_memory_map_entry *entry = (fwts_memory_map_entry *)data;
>   	fwts_framework *fw = (fwts_framework *)private;
>
> -	fwts_log_info_verbatum(fw, "%016llx - %016llx  %s",
> -			(unsigned long long)entry->start_address,
> -			(unsigned long long)entry->end_address,
> +	fwts_log_info_verbatum(fw, "0x%16.16" PRIx64 " - 0x%16.16" PRIx64 " %s",
> +			entry->start_address, entry->end_address,
>   			fwts_memory_map_type_to_str(entry->type));
>   }
>
> @@ -258,7 +258,7 @@ static fwts_memory_map_entry *fwts_memory_map_table_read_entry(const char *which
>   		free(entry);
>   		return NULL;
>   	}
> -	sscanf(data, "0x%llx", (unsigned long long*)&entry->start_address);
> +	sscanf(data, "0x%" SCNx64, &entry->start_address);
>   	free(data);
>
>   	snprintf(path, sizeof(path), "/sys/firmware/memmap/%s/end", which);
> @@ -266,7 +266,7 @@ static fwts_memory_map_entry *fwts_memory_map_table_read_entry(const char *which
>   		free(entry);
>   		return NULL;
>   	}
> -	sscanf(data, "0x%llx", (unsigned long long*)&entry->end_address);
> +	sscanf(data, "0x%" SCNx64, &entry->end_address);
>   	free(data);
>
>   	snprintf(path, sizeof(path), "/sys/firmware/memmap/%s/type", which);
>

Acked-by: Ivan Hu <ivan.hu@canonical.com>

Patch

diff --git a/src/lib/src/fwts_memorymap.c b/src/lib/src/fwts_memorymap.c
index 8b29315..46fe455 100644
--- a/src/lib/src/fwts_memorymap.c
+++ b/src/lib/src/fwts_memorymap.c
@@ -25,6 +25,7 @@ 
 #include <string.h>
 #include <unistd.h>
 #include <stdint.h>
+#include <inttypes.h>
 
 #include "fwts.h"
 
@@ -201,9 +202,8 @@  static void fwts_memory_map_dump_info(void *data, void *private)
 	fwts_memory_map_entry *entry = (fwts_memory_map_entry *)data;
 	fwts_framework *fw = (fwts_framework *)private;
 
-	fwts_log_info_verbatum(fw, "%016llx - %016llx  %s",
-			(unsigned long long)entry->start_address,
-			(unsigned long long)entry->end_address,
+	fwts_log_info_verbatum(fw, "0x%16.16" PRIx64 " - 0x%16.16" PRIx64 " %s",
+			entry->start_address, entry->end_address,
 			fwts_memory_map_type_to_str(entry->type));
 }
 
@@ -258,7 +258,7 @@  static fwts_memory_map_entry *fwts_memory_map_table_read_entry(const char *which
 		free(entry);
 		return NULL;
 	}
-	sscanf(data, "0x%llx", (unsigned long long*)&entry->start_address);
+	sscanf(data, "0x%" SCNx64, &entry->start_address);
 	free(data);
 
 	snprintf(path, sizeof(path), "/sys/firmware/memmap/%s/end", which);
@@ -266,7 +266,7 @@  static fwts_memory_map_entry *fwts_memory_map_table_read_entry(const char *which
 		free(entry);
 		return NULL;
 	}
-	sscanf(data, "0x%llx", (unsigned long long*)&entry->end_address);
+	sscanf(data, "0x%" SCNx64, &entry->end_address);
 	free(data);
 
 	snprintf(path, sizeof(path), "/sys/firmware/memmap/%s/type", which);