hw/timer/hpet: Trivial format string fix
v2 cover hw/timer/hpet: Trivial format string fix
Fix a format string and remove dead code.
Since v1:
- Addressed Dov comments (fix format string + style):
https://www.mail-archive.com/[email protected]/msg739239.html
Philippe Mathieu-Daudé (2):
hw/timer/hpet: Remove dead code
hw/timer/hpet: Fix DPRINTF format string
hw/timer/hpet.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-)
Signature · 1 line
2.26.2
PATCH v2 1/2 hw/timer/hpet: Remove dead code
This code was never compiled/used, remove it.
--- hw/timer/hpet.c | 14 -------------- 1 file changed, 14 deletions(-)
hw/timer/hpet.c +0 -14
@@ -416,20 +416,6 @@ static void hpet_del_timer(HPETTimer *t)update_irq (t,0 ); } -#ifdef HPET_DEBUG -static uint32_t hpet_ram_readb (void *opaque,hwaddr addr) -{ -printf ("qemu: hpet_read b at %" PRIx64"\n" , addr); -return 0 ; -} - -static uint32_t hpet_ram_readw (void *opaque,hwaddr addr) -{ -printf ("qemu: hpet_read w at %" PRIx64"\n" , addr); -return 0 ; -} -#endif -static uint64_t hpet_ram_read (void *opaque,hwaddr addr,unsigned size) {
Signature · 1 line
2.26.2
Re: [PATCH v2 1/2] hw/timer/hpet: Remove dead code
hw/timer/hpet.c
Quoted 14 lines · Philippe Mathieu-Daudé <[email protected]> 于2020年9月10日周四 下午10:01写道:
This code was never compiled/used, remove it.
Reviewed-by Thomas Huth <[email protected]>Signed-off-by Dov Murik <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/timer/hpet.c | 14 -------------- 1 file changed, 14 deletions(-)hw/timer/hpet.c +0
-0
Maybe we also remove the
"//#define HPET_DEBUG"
in the head of this file?
Thanks,
Li Qiang
Quoted 25 lines
hw/timer/hpet.c +0
-15@@ -416,20 +416,6 @@ static void hpet_del_timer(HPETTimer *t)update_irq (t,0 ); } -#ifdef HPET_DEBUG -static uint32_t hpet_ram_readb (void *opaque,hwaddr addr) -{ -printf ("qemu: hpet_read b at %" PRIx64"\n" , addr); -return 0 ; -} - -static uint32_t hpet_ram_readw (void *opaque,hwaddr addr) -{ -printf ("qemu: hpet_read w at %" PRIx64"\n" , addr); -return 0 ; -} -#endif -static uint64_t hpet_ram_read (void *opaque,hwaddr addr,unsigned size) { --2.26.2
Re: [PATCH v2 1/2] hw/timer/hpet: Remove dead code
Quoted 11 lines · Li Qiang
Quoted 10 lines · Philippe Mathieu-Daudé <[email protected]> 于2020年9月10日周四 下午10:01写道:
This code was never compiled/used, remove it.
Reviewed-by Thomas Huth <[email protected]>Signed-off-by Dov Murik <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/timer/hpet.c | 14 -------------- 1 file changed, 14 deletions(-)
Quoted 8 lines
hw/timer/hpet.c
Quoted 4 lines
hw/timer/hpet.c +0
-0Maybe we also remove the
"//#defineHPET_DEBUG"
in the head of this file?
We need to convert the debug calls to trace events first.
Quoted 30 lines
Thanks,
Li QiangQuoted 25 lines
hw/timer/hpet.c +0
-15@@ -416,20 +416,6 @@ static void hpet_del_timer(HPETTimer *t)update_irq (t,0 ); } -#ifdef HPET_DEBUG -static uint32_t hpet_ram_readb (void *opaque,hwaddr addr) -{ -printf ("qemu: hpet_read b at %" PRIx64"\n" , addr); -return 0 ; -} - -static uint32_t hpet_ram_readw (void *opaque,hwaddr addr) -{ -printf ("qemu: hpet_read w at %" PRIx64"\n" , addr); -return 0 ; -} -#endif -static uint64_t hpet_ram_read (void *opaque,hwaddr addr,unsigned size) { --2.26.2
PATCH v2 2/2 hw/timer/hpet: Fix DPRINTF format string
In reply to Philippe Mathieu-DaudéFix building with HPET_DEBUG enabled:
hw/timer/hpet.c:512:73: error: format specifies type 'unsigned int' but the argument has type 'uint64_t' (aka 'unsigned long') [-Werror,-Wformat]
DPRINTF("qemu: Enter hpet_ram_writel at %" PRIx64 " = %#x\n", addr, value);
~~~ ^~~~~
%#lx
hw/timer/hpet.c:655:21: error: format specifies type 'unsigned int' but the argument has type 'uint64_t' (aka 'unsigned long') [-Werror,-Wformat]
value, s->hpet_counter);
^~~~~--- hw/timer/hpet.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
hw/timer/hpet.c +6 -3
@@ -495,7 +495,8 @@ static void hpet_ram_write(void *opaque, hwaddr addr,HPETState *s = opaque;uint64_t old_val, new_val, val, index; -DPRINTF ("qemu: Enter hpet_ram_writel at %" PRIx64" = %#x\n" , addr, value); +DPRINTF ("qemu: Enter hpet_ram_writel at %#" HWADDR_PRIx" = %#" PRIx64"\n" , + addr, value); index = addr; old_val =hpet_ram_read (opaque, addr,4 ); new_val = value;
@@ -637,7 +638,8 @@ static void hpet_ram_write(void *opaque, hwaddr addr, } s->hpet_counter = (s->hpet_counter &0xffffffff00000000ULL ) | value; -DPRINTF ("qemu: HPET counter written. ctr = %#x -> %" PRIx64"\n" , +DPRINTF ("qemu: HPET counter written. ctr = %#" + PRIx64" -> %#" PRIx64"\n" , value, s->hpet_counter);break ;case HPET_COUNTER +4 :
@@ -646,7 +648,8 @@ static void hpet_ram_write(void *opaque, hwaddr addr, } s->hpet_counter = (s->hpet_counter &0xffffffffULL ) | (((uint64_t )value) <<32 ); -DPRINTF ("qemu: HPET counter + 4 written. ctr = %#x -> %" PRIx64"\n" , +DPRINTF ("qemu: HPET counter + 4 written. ctr = %#" + PRIx64" -> %#" PRIx64"\n" , value, s->hpet_counter);break ;default :
Signature · 1 line
2.26.2
Re: [PATCH v2 2/2] hw/timer/hpet: Fix DPRINTF format string
Hi Phil,
Quoted 22 lines · Philippe Mathieu-Daudé
Fix building with
HPET_DEBUGenabled:hw/timer/hpet.c:512:73: error: format specifies type 'unsigned int' but the argument has type 'uint64_t' (aka 'unsigned long') [-Werror,-Wformat] DPRINTF("qemu: Enter hpet_ram_writel at %" PRIx64 " = %#x\n", addr, value); ~~~ ^~~~~ %#lx hw/timer/hpet.c:655:21: error: format specifies type 'unsigned int' but the argument has type 'uint64_t' (aka 'unsigned long') [-Werror,-Wformat] value, s->hpet_counter); ^~~~~Reviewed-by Thomas Huth <[email protected]>Signed-off-by Dov Murik <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/timer/hpet.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)hw/timer/hpet.c +0
-0
hw/timer/hpet.c static void hpet_ram_write(void *opaque, hwaddr addr, · line 499
Quoted 6 lines
hw/timer/hpet.c +2
-1@@ -495,7 +495,8 @@ static void hpet_ram_write(void *opaque, hwaddr addr,HPETState *s = opaque;uint64_t old_val, new_val, val, index; -DPRINTF ("qemu: Enter hpet_ram_writel at %" PRIx64" = %#x\n" , addr, value); +DPRINTF ("qemu: Enter hpet_ram_writel at %#" HWADDR_PRIx" = %#" PRIx64"\n" , + addr, value);
You still use "#" in the format string; but qemu's CODING_STYLE.rst says:
//////////////
'#' printf flag
---------------
Do not use printf flag '#', like '%#x'.
Rationale: there are two ways to add a '0x' prefix to printed number: '0x%...' and '%#...'. For consistency the only one way should be used. Arguments for '0x%' are:
* it is more popular
* '%#' omits the 0x for the value 0 which makes output inconsistent
//////////////
According to that, I think the better solution would be:
DPRINTF("qemu: Enter hpet_ram_writel at 0x%" HWADDR_PRIx
" = 0x%" PRIx64 "\n", addr, value);
hw/timer/hpet.c static void hpet_ram_write(void *opaque, hwaddr addr, · line 642
Quoted 10 lines
hw/timer/hpet.c +2
-1index = addr; old_val =hpet_ram_read (opaque, addr,4 ); new_val = value;@@ -637,7 +638,8 @@ static void hpet_ram_write(void *opaque, hwaddr addr, } s->hpet_counter = (s->hpet_counter &0xffffffff00000000ULL ) | value; - DPRINTF("qemu: HPET counter written. ctr = %#x -> %" PRIx64 "\n", + DPRINTF("qemu: HPET counter written. ctr = %#" + PRIx64 " -> %#" PRIx64 "\n",
ditto.
hw/timer/hpet.c static void hpet_ram_write(void *opaque, hwaddr addr, · line 652
Quoted 10 lines
hw/timer/hpet.c +2
-1value, s->hpet_counter);break ;case HPET_COUNTER +4 :@@ -646,7 +648,8 @@ static void hpet_ram_write(void *opaque, hwaddr addr, } s->hpet_counter = (s->hpet_counter &0xffffffffULL ) | (((uint64_t )value) <<32 ); - DPRINTF("qemu: HPET counter + 4 written. ctr = %#x -> %" PRIx64 "\n", + DPRINTF("qemu: HPET counter + 4 written. ctr = %#" + PRIx64 " -> %#" PRIx64 "\n",
ditto.
hw/timer/hpet.c static void hpet_ram_write(void *opaque, hwaddr addr, · line 655
Quoted 4 lines
hw/timer/hpet.c +0
-0value, s->hpet_counter);break ;default :
-Dov
Re: [PATCH v2 2/2] hw/timer/hpet: Fix DPRINTF format string
Quoted 49 lines · Dov Murik
Hi Phil,
Quoted 28 lines · Philippe Mathieu-Daudé
Fix building with
HPET_DEBUGenabled:
hw/timer/hpet.c:512:73: error: format specifies type 'unsigned int' but the argument has type 'uint64_t' (aka 'unsigned long') [-Werror,-Wformat]
DPRINTF("qemu: Enter hpet_ram_writel at %" PRIx64 " = %#x\n", addr, value);
~~~ ^~~~~
%#lxhw/timer/hpet.c:655:21: error: format specifies type 'unsigned int' but the argument has type 'uint64_t' (aka 'unsigned long') [-Werror,-Wformat]
value,s->hpet_counter);
^~~~~Reviewed-by Thomas Huth <[email protected]>Signed-off-by Dov Murik <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
hw/timer/hpet.c| 9 ++++++---1 file changed, 6 insertions(+), 3 deletions(-)hw/timer/hpet.c +0
-0hw/timer/hpet.c static void hpet_ram_write(void *opaque, hwaddr addr, · line 501
Quoted 8 lines
hw/timer/hpet.c +2
-1@@ -495,7 +495,8 @@ static void hpet_ram_write(void *opaque, hwaddr addr, HPETState *s = opaque; uint64_t old_val, new_val, val, index; - DPRINTF("qemu: Enter hpet_ram_writel at %" PRIx64 " = %#x\n", addr, value); + DPRINTF("qemu: Enter hpet_ram_writel at %#" HWADDR_PRIx " = %#"PRIx64"\n", + addr, value);You still use "#" in the format string; but qemu's
CODING_STYLE.rstsays://////////////
'#' printf flag
---------------Do not use printf flag '#', like '%#x'.
Quoted 7 lines
Rationale: there are two ways to add a '0x' prefix to printed number:
'0x%...'
and '%#...'. For consistency the only one way should be used. Arguments for '0x%' are:* it is more popular
* '%#' omits the 0x for the value 0 which makes output inconsistent
Yes you are right, I missed that.
Do you mind adding that check to ./checkpatch?
Quoted 49 lines
//////////////
According to that, I think the better solution would be:
DPRINTF("qemu: Enter hpet_ram_writel at 0x%" HWADDR_PRIx " = 0x%" PRIx64 "\n", addr, value);Quoted 11 lines
hw/timer/hpet.c +0
-0index = addr;
old_val=hpet_ram_read(opaque, addr, 4);
new_val= value;hw/timer/hpet.c +0
-0@@ -637,7 +638,8 @@ static void hpet_ram_write(void *opaque, hwaddr addr, }
s->hpet_counter=
(s->hpet_counter&0xffffffff00000000ULL) | value; - DPRINTF("qemu: HPET counter written. ctr = %#x -> %" PRIx64 "\n",
+ DPRINTF("qemu: HPET counter written. ctr = %#" + PRIx64 " -> %#" PRIx64 "\n",ditto.
Quoted 5 lines
value,
s->hpet_counter);
break;
caseHPET_COUNTER+ 4:hw/timer/hpet.c +0
-0@@ -646,7 +648,8 @@ static void hpet_ram_write(void *opaque, hwaddr addr, }Quoted 7 lines
s->hpet_counter=
(s->hpet_counter&0xffffffffULL) | (((uint64_t)value) << 32);
- DPRINTF("qemu: HPET counter + 4 written. ctr = %#x -> %" PRIx64 "\n",
+ DPRINTF("qemu: HPET counter + 4 written. ctr = %#" + PRIx64 " -> %#" PRIx64 "\n",ditto.
Quoted 4 lines
value,
s->hpet_counter);
break;
default:-Dov
Re: [PATCH v2 2/2] hw/timer/hpet: Fix DPRINTF format string
Quoted 55 lines · Philippe Mathieu-Daudé
Quoted 54 lines · Dov Murik
Hi Phil,
Quoted 28 lines · Philippe Mathieu-Daudé
Fix building with
HPET_DEBUGenabled:
hw/timer/hpet.c:512:73: error: format specifies type 'unsigned int'
but the argument has type 'uint64_t' (aka 'unsigned long') [-Werror,-Wformat]
DPRINTF("qemu: Enterhpet_ram_writelat %" PRIx64 " = %#x\n",
addr, value);~~~ ^~~~~
%#lxhw/timer/hpet.c:655:21: error: format specifies type 'unsigned int'
but the argument has type 'uint64_t' (aka 'unsigned long') [-Werror,-Wformat]
value,s->hpet_counter);
^~~~~Reviewed-by Thomas Huth <[email protected]>Signed-off-by Dov Murik <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/timer/hpet.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)hw/timer/hpet.c +0
-0hw/timer/hpet.c static void hpet_ram_write(void *opaque, hwaddr addr, · line 501
Quoted 8 lines
hw/timer/hpet.c +2
-1@@ -495,7 +495,8 @@ static void hpet_ram_write(void *opaque, hwaddr addr, HPETState *s = opaque; uint64_t old_val, new_val, val, index; - DPRINTF("qemu: Enter hpet_ram_writel at %" PRIx64 " = %#x\n", addr, value); + DPRINTF("qemu: Enter hpet_ram_writel at %#" HWADDR_PRIx " = %#"PRIx64"\n", + addr, value);You still use "#" in the format string; but qemu's
CODING_STYLE.rstsays://////////////
'#' printf flag
---------------Do not use printf flag '#', like '%#x'.
Rationale: there are two ways to add a '0x' prefix to printed number:
'0x%...'
and '%#...'. For consistency the only one way should be used. Arguments for '0x%' are:
Quoted 6 lines
Quoted 2 lines
* it is more popular
* '%#' omits the 0x for the value 0 which makes output inconsistentYes you are right, I missed that.
Do you mind adding that check to ./checkpatch?
Fix to checkpatch sent in another patch:
https://www.mail-archive.com/[email protected]/msg740065.html
-Dov
Quoted 5 lines · Philippe Mathieu-Daudé
Fix a format string and remove dead code.
Since v1:
- Addressed Dov comments (fix format string + style):
https://www.mail-archive.com/[email protected]/msg739239.html
Dov, since you sent the same patches/code and sign them with your S-o-b, I added them here too, is that OK with you?
Quoted 8 lines
Philippe Mathieu-Daudé (2):
hw/timer/hpet: Remove dead code
hw/timer/hpet: Fix DPRINTF format stringhw/timer/hpet.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-)
Quoted 9 lines · Philippe Mathieu-Daudé
Quoted 5 lines · Philippe Mathieu-Daudé
Fix a format string and remove dead code.
Since v1:
- Addressed Dov comments (fix format string + style):https://www.mail-archive.com/[email protected]/msg739239.htmlDov, since you sent the same patches/code and sign them with your S-o-b, I added them here too, is that OK with you?
Yes, thank you for that.
Quoted 9 lines
Quoted 9 lines
Philippe Mathieu-Daudé (2):
hw/timer/hpet: Remove dead code
hw/timer/hpet: Fix DPRINTF format stringhw/timer/hpet.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-)
Laurent Vivier
AppliedLe 12/09/2020 à 19:34, Dov Murik a écrit :
Quoted 25 lines · Philippe Mathieu-Daudé
Quoted 9 lines · Philippe Mathieu-Daudé
Quoted 5 lines
Fix a format string and remove dead code.
Since v1:
- Addressed Dov comments (fix format string + style):
https://www.mail-archive.com/[email protected]/msg739239.htmlDov, since you sent the same patches/code and sign them with your S-o-b, I added them here too, is that OK with you?
Yes, thank you for that.
Quoted 9 lines
Quoted 9 lines
Philippe Mathieu-Daudé (2):
hw/timer/hpet: Remove dead code
hw/timer/hpet: Fix DPRINTF format string
hw/timer/hpet.c| 23 ++++++-----------------1 file changed, 6 insertions(+), 17 deletions(-)
Applied to my trivial-patches branch.
Thanks,
Laurent
Le 12/09/2020 à 21:02, Laurent Vivier a écrit :
Quoted 22 lines
Le 12/09/2020 à 19:34, Dov Murik a écrit :
Quoted 21 lines · Philippe Mathieu-Daudé
Quoted 9 lines · Philippe Mathieu-Daudé
Quoted 5 lines
Fix a format string and remove dead code.
Since v1:
- Addressed Dov comments (fix format string + style):
https://www.mail-archive.com/[email protected]/msg739239.htmlDov, since you sent the same patches/code and sign them with your S-o-b, I added them here too, is that OK with you?
Yes, thank you for that.
Quoted 6 lines
Quoted 6 lines
Philippe Mathieu-Daudé (2):
hw/timer/hpet: Remove dead code
hw/timer/hpet: Fix DPRINTF format string
Quoted 6 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
hw/timer/hpet.c| 23 ++++++-----------------1 file changed, 6 insertions(+), 17 deletions(-)Applied to my trivial-patches branch.
As Dov makes more comments on a patch, I've removed them from my branch.
Thanks,
Laurent
Quoted 23 lines · Laurent Vivier
Le 12/09/2020 à 21:02, Laurent Vivier a écrit :
Quoted 22 lines
Le 12/09/2020 à 19:34, Dov Murik a écrit :
Quoted 21 lines · Philippe Mathieu-Daudé
Quoted 9 lines · Philippe Mathieu-Daudé
Quoted 5 lines
Fix a format string and remove dead code.
Since v1:
- Addressed Dov comments (fix format string + style):
https://www.mail-archive.com/[email protected]/msg739239.htmlDov, since you sent the same patches/code and sign them with your S-o-b, I added them here too, is that OK with you?
Yes, thank you for that.
Quoted 6 lines
Quoted 6 lines
Philippe Mathieu-Daudé (2):
hw/timer/hpet: Remove dead code
hw/timer/hpet: Fix DPRINTF format string
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
hw/timer/hpet.c| 23 ++++++-----------------1 file changed, 6 insertions(+), 17 deletions(-)Applied to my trivial-patches branch.
As Dov makes more comments on a patch, I've removed them from my branch.
Thanks. Let's follow up with Dov patches.
Quoted 4 lines
Thanks,
Laurent