Here is a small fix to prevent a segmentation fault in lbtdump.
the format specifier in the printf statements have been changed from %08lx to %08llx or similar where uint64_t are being displayed.
Signed-off-by: Ben Hewson ben@hewson-venieri.com
-----------------------------------------------------------------------------------------------------------------------------------
I am not sure if this is a problem on GCC v4.x however on my V3.3.6 the compiler warns about the printf statements and lbtdump seg faults when run. This patch seem to fix the problem.
Index: util/lbtdump/lbtdump.c =================================================================== --- util/lbtdump/lbtdump.c (revision 2638) +++ util/lbtdump/lbtdump.c (working copy) @@ -110,30 +110,30 @@ { if (value > 1024ULL*1024*1024*1024*1024*1024) { value /= 1024ULL*1024*1024*1024*1024*1024; - fprintf(stream, "%ldEB", value); + fprintf(stream, "%lldEB", value); } else if (value > 1024ULL*1024*1024*1024*1024) { value /= 1024ULL*1024*1024*1024*1024; - fprintf(stream, "%ldPB", value); + fprintf(stream, "%lldPB", value); } else if (value > 1024ULL*1024*1024*1024) { value /= 1024ULL*1024*1024*1024; - fprintf(stream, "%ldTB", value); + fprintf(stream, "%lldTB", value); } else if (value > 1024ULL*1024*1024) { value /= 1024ULL*1024*1024; - fprintf(stream, "%ldGB", value); + fprintf(stream, "%lldGB", value); } else if (value > 1024ULL*1024) { value /= 1024ULL*1024; - fprintf(stream, "%ldMB", value); + fprintf(stream, "%lldMB", value); } else if (value > 1024ULL) { value /= 1024ULL; - fprintf(stream, "%ldKB", value); + fprintf(stream, "%lldKB", value); } else { - fprintf(stream, "%ldB", value); + fprintf(stream, "%lldB", value); } }
@@ -156,7 +156,7 @@ default: case 2: mem_type = "reserved"; break; } - printf("0x%08lx - 0x%08lx %s (", + printf("0x%08llx - 0x%08llx %s (", start, end, mem_type); pretty_print_number(stdout, start); printf(" - ");
On Thu, May 10, 2007 at 07:53:36PM +0100, Ben Hewson wrote:
Here is a small fix to prevent a segmentation fault in lbtdump.
the format specifier in the printf statements have been changed from %08lx to %08llx or similar where uint64_t are being displayed.
Signed-off-by: Ben Hewson ben@hewson-venieri.com
Thanks, committed in r2679. I can confirm that it fixes the warnings for me (gcc 4.1.3).
Uwe.