* [Qemu-devel] [PATCH] fix warnings from printf target addresses
@ 2012-09-16 0:05 Mike Frysinger
2012-09-16 7:24 ` Blue Swirl
2012-09-16 7:31 ` Jan Kiszka
0 siblings, 2 replies; 5+ messages in thread
From: Mike Frysinger @ 2012-09-16 0:05 UTC (permalink / raw)
To: qemu-devel
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 <vapier@gentoo.org>
---
memory.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/memory.c b/memory.c
index 58a242d..7d5f4a3 100644
--- a/memory.c
+++ b/memory.c
@@ -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;
}
}
--
1.7.9.7
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] fix warnings from printf target addresses
2012-09-16 0:05 [Qemu-devel] [PATCH] fix warnings from printf target addresses Mike Frysinger
@ 2012-09-16 7:24 ` Blue Swirl
2012-09-16 19:38 ` Mike Frysinger
2012-09-16 7:31 ` Jan Kiszka
1 sibling, 1 reply; 5+ messages in thread
From: Blue Swirl @ 2012-09-16 7:24 UTC (permalink / raw)
To: Mike Frysinger; +Cc: qemu-devel
On Sun, Sep 16, 2012 at 12:05 AM, Mike Frysinger <vapier@gentoo.org> wrote:
> 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 <vapier@gentoo.org>
> ---
> memory.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/memory.c b/memory.c
> index 58a242d..7d5f4a3 100644
> --- a/memory.c
> +++ b/memory.c
> @@ -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.
> 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;
> }
> }
> --
> 1.7.9.7
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] fix warnings from printf target addresses
2012-09-16 7:24 ` Blue Swirl
@ 2012-09-16 19:38 ` Mike Frysinger
0 siblings, 0 replies; 5+ messages in thread
From: Mike Frysinger @ 2012-09-16 19:38 UTC (permalink / raw)
To: Blue Swirl; +Cc: qemu-devel
[-- Attachment #1: Type: Text/Plain, Size: 987 bytes --]
On Sunday 16 September 2012 03:24:22 Blue Swirl wrote:
> On Sun, Sep 16, 2012 at 12:05 AM, Mike Frysinger wrote:
> > 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'
> >
> > - 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
> but using TARGET_PRIxPHYS or TARGET_FMT_plx.
np. i just copied what was already in memory.c, but i guess that's broken
too.
-mike
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] fix warnings from printf target addresses
2012-09-16 0:05 [Qemu-devel] [PATCH] fix warnings from printf target addresses Mike Frysinger
2012-09-16 7:24 ` Blue Swirl
@ 2012-09-16 7:31 ` Jan Kiszka
2012-09-16 19:46 ` [Qemu-devel] [PATCH] include address in invalid memory region accesses Mike Frysinger
1 sibling, 1 reply; 5+ messages in thread
From: Jan Kiszka @ 2012-09-16 7:31 UTC (permalink / raw)
To: Mike Frysinger; +Cc: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 1686 bytes --]
On 2012-09-16 02:05, Mike Frysinger wrote:
> 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
>
> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
> ---
> memory.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/memory.c b/memory.c
> index 58a242d..7d5f4a3 100644
> --- a/memory.c
> +++ b/memory.c
> @@ -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;
> }
> }
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH] include address in invalid memory region accesses
2012-09-16 7:31 ` Jan Kiszka
@ 2012-09-16 19:46 ` Mike Frysinger
0 siblings, 0 replies; 5+ messages in thread
From: Mike Frysinger @ 2012-09-16 19:46 UTC (permalink / raw)
To: qemu-devel
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.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
memory.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/memory.c b/memory.c
index d528d1f..0ea0320 100644
--- a/memory.c
+++ b/memory.c
@@ -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;
}
}
--
1.7.9.7
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-09-16 19:46 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-16 0:05 [Qemu-devel] [PATCH] fix warnings from printf target addresses Mike Frysinger
2012-09-16 7:24 ` Blue Swirl
2012-09-16 19:38 ` Mike Frysinger
2012-09-16 7:31 ` Jan Kiszka
2012-09-16 19:46 ` [Qemu-devel] [PATCH] include address in invalid memory region accesses Mike Frysinger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).