fix warnings from printf target addresses
PATCH 1/1 fix warnings from printf target addresses
Current code triggers:memory.c: In function 'invalid_read':
memory.c:1001: warning: format '%#x' expects type 'unsigned int',
but argument 4 has type 'target_phys_addr_t'memory.c: In function 'invalid_write':
memory.c:1013: warning: format '%#x' expects type 'unsigned int',
but argument 4 has type 'target_phys_addr_t'
--- memory.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
memory.c +4 -2
@@ -998,7 +998,8 @@ static uint64_t invalid_read(void *opaque, target_phys_addr_t addr,MemoryRegion *mr = opaque;if (!mr->warning_printed) { -fprintf (stderr,"Invalid read from memory region %s at offset %#x\n" , mr->name, addr); +fprintf (stderr,"Invalid read from memory region %s at offset %#llx\n" , + mr->name, (unsigned long long )addr); mr->warning_printed = true; }return -1U ;
@@ -1010,7 +1011,8 @@ static void invalid_write(void *opaque, target_phys_addr_t addr, uint64_t data,MemoryRegion *mr = opaque;if (!mr->warning_printed) { -fprintf (stderr,"Invalid write to memory region %s at offset %#x\n" , mr->name, addr); +fprintf (stderr,"Invalid write to memory region %s at offset %#llx\n" , + mr->name, (unsigned long long )addr); mr->warning_printed = true; } }
Signature · 1 line
1.7.9.7
Quoted 18 lines · Mike Frysinger
Current code triggers:
memory.c: In function 'invalid_read':
memory.c:1001: warning: format '%#x' expects type 'unsigned int',
but argument 4 has type 'target_phys_addr_t'memory.c: In function 'invalid_write':
memory.c:1013: warning: format '%#x' expects type 'unsigned int',
but argument 4 has type 'target_phys_addr_t'Signed-off-by Mike Frysinger <[email protected]>--- memory.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)memory.c +0
-0
memory.c static uint64_t invalid_read(void *opaque, target_phys_addr_t addr, · line 1002
Quoted 6 lines
memory.c +2
-1@@ -998,7 +998,8 @@ static uint64_t invalid_read(void *opaque, target_phys_addr_t addr,MemoryRegion *mr = opaque;if (!mr->warning_printed) { -fprintf (stderr,"Invalid read from memory region %s at offset %#x\n" , mr->name, addr); +fprintf (stderr,"Invalid read from memory region %s at offset %#llx\n" , + mr->name, (unsigned long long )addr);
The right way is not adding potentially dangerous casts but using TARGET_PRIxPHYS or TARGET_FMT_plx.
Quoted 17 lines
memory.c +2
-2mr->warning_printed = true; }return -1U ;@@ -1010,7 +1011,8 @@ static void invalid_write(void *opaque, target_phys_addr_t addr, uint64_t data,MemoryRegion *mr = opaque;if (!mr->warning_printed) { -fprintf (stderr,"Invalid write to memory region %s at offset %#x\n" , mr->name, addr); +fprintf (stderr,"Invalid write to memory region %s at offset %#llx\n" , + mr->name, (unsigned long long )addr); mr->warning_printed = true; } } --1.7.9.7
Quoted 9 lines · On Sunday 16 September 2012 03:24:22 Blue Swirl wrote:
Quoted 8 lines · Mike Frysinger
Current code triggers:
memory.c: In function 'invalid_read':
memory.c:1001: warning: format '%#x' expects type 'unsigned int',
but argument 4 has type 'target_phys_addr_t'memory.c: In function 'invalid_write':
memory.c:1013: warning: format '%#x' expects type 'unsigned int',
but argument 4 has type 'target_phys_addr_t'
Quoted 6 lines
Quoted 4 lines
- fprintf(stderr, "Invalid read from memory region %s at offset
%#x\n",mr->name, addr); + fprintf(stderr, "Invalid read from
memory region %s at offset %#llx\n", +mr->name,
(unsigned long long)addr);The right way is not adding potentially dangerous casts
they're not dangerous here at all
Quoted 1 line
but using
TARGET_PRIxPHYSorTARGET_FMT_plx.
np. i just copied what was already in memory.c, but i guess that's broken too.
-mike
Quoted 7 lines · Mike Frysinger
Current code triggers:
memory.c: In function 'invalid_read':
memory.c:1001: warning: format '%#x' expects type 'unsigned int',
but argument 4 has type 'target_phys_addr_t'memory.c: In function 'invalid_write':
memory.c:1013: warning: format '%#x' expects type 'unsigned int',
but argument 4 has type 'target_phys_addr_t'
This version was never in git. Which QEMU are you patching, a local one?
Jan
Quoted 31 lines
Signed-off-by Mike Frysinger <[email protected]>--- memory.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)memory.c +4
-2@@ -998,7 +998,8 @@ static uint64_t invalid_read(void *opaque, target_phys_addr_t addr,MemoryRegion *mr = opaque;if (!mr->warning_printed) { -fprintf (stderr,"Invalid read from memory region %s at offset %#x\n" , mr->name, addr); +fprintf (stderr,"Invalid read from memory region %s at offset %#llx\n" , + mr->name, (unsigned long long )addr); mr->warning_printed = true; }return -1U ;@@ -1010,7 +1011,8 @@ static void invalid_write(void *opaque, target_phys_addr_t addr, uint64_t data,MemoryRegion *mr = opaque;if (!mr->warning_printed) { -fprintf (stderr,"Invalid write to memory region %s at offset %#x\n" , mr->name, addr); +fprintf (stderr,"Invalid write to memory region %s at offset %#llx\n" , + mr->name, (unsigned long long )addr); mr->warning_printed = true; } }
PATCH 1/1 include address in invalid memory region accesses
The current code to display invalid memory accesses isn't terribly useful as it doesn't tell you what address is actually being accessed. Include it in the error message.
--- memory.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
memory.c +6 -2
@@ -998,7 +998,9 @@ static uint64_t invalid_read(void *opaque, target_phys_addr_t addr,MemoryRegion *mr = opaque;if (!mr->warning_printed) { -fprintf (stderr,"Invalid read from memory region %s\n" , mr->name); +fprintf (stderr, +"Invalid read from memory region %s at %#" TARGET_PRIxPHYS"\n" , + mr->name, addr); mr->warning_printed = true; }return -1U ;
@@ -1010,7 +1012,9 @@ static void invalid_write(void *opaque, target_phys_addr_t addr, uint64_t data,MemoryRegion *mr = opaque;if (!mr->warning_printed) { -fprintf (stderr,"Invalid write to memory region %s\n" , mr->name); +fprintf (stderr, +"Invalid write to memory region %s at %#" TARGET_PRIxPHYS"\n" , + mr->name, addr); mr->warning_printed = true; } }
Signature · 1 line
1.7.9.7