Skip to contentSkip to conversation

display/vmware_vga: Fix bad printf format specifiers

PATCH Superseded Alex Chen 2 participants 3 messages Nov 19, 2020

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Alex Chen

author
#0 lore raw

PATCH 1/1 display/vmware_vga: Fix bad printf format specifiers

We should use printf format specifier "%u" instead of "%d" for argument of type "unsigned int".

---
 hw/display/vmware_vga.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/display/vmware_vga.c +1 -1
index bef0d7d69a..f93bbe15c2 100644
@@ -534,7 +534,7 @@ static inline void vmsvga_cursor_define(struct vmsvga_state_s *s,
 #endif
         break;
     default:
-        fprintf(stderr, "%s: unhandled bpp %d, using fallback cursor\n",
+        fprintf(stderr, "%s: unhandled bpp %u, using fallback cursor\n",
                 __func__, c->bpp);
         cursor_put(qc);
         qc = cursor_builtin_left_ptr();
Signature · 1 line
2.19.1
Reviewed-by on v1 1/1
#1 lore raw

Hi Alex,

Quoted 14 lines · Alex Chen

We should use printf format specifier "%u" instead of "%d" for argument of type "unsigned int".

---
 hw/display/vmware_vga.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/display/vmware_vga.c +0 -0
index bef0d7d69a..f93bbe15c2 100644

hw/display/vmware_vga.c static inline void vmsvga_cursor_define(struct vmsvga_state_s *s, · line 538

Quoted 6 lines
hw/display/vmware_vga.c +1 -1
@@ -534,7 +534,7 @@ static inline void vmsvga_cursor_define(struct vmsvga_state_s *s,
 #endif
         break;
     default:
-        fprintf(stderr, "%s: unhandled bpp %d, using fallback cursor\n",
+        fprintf(stderr, "%s: unhandled bpp %u, using fallback cursor\n",
                 __func__, c->bpp);

The format fix is correct, but since you change that line, "fprintf(stderr)" is old code, nowadays we prefer get rid of it by using warn_report() in place (see "qemu/error-report.h").

Preferably using warn_report():

Quoted 3 lines
hw/display/vmware_vga.c +0 -0
         cursor_put(qc);
         qc = cursor_builtin_left_ptr();
author
#2 lore raw

Hi Philippe,

Quoted 12 lines · Philippe Mathieu-Daudé

Hi Alex,

Quoted 9 lines · Alex Chen

We should use printf format specifier "%u" instead of "%d" for argument of type "unsigned int".

---
 hw/display/vmware_vga.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines

hw/display/vmware_vga.c static inline void vmsvga_cursor_define(struct vmsvga_state_s *s, · line 538

Quoted 11 lines
hw/display/vmware_vga.c +1 -1
index bef0d7d69a..f93bbe15c2 100644
@@ -534,7 +534,7 @@ static inline void vmsvga_cursor_define(struct vmsvga_state_s *s,
 #endif
         break;
     default:
-        fprintf(stderr, "%s: unhandled bpp %d, using fallback cursor\n",
+        fprintf(stderr, "%s: unhandled bpp %u, using fallback cursor\n",
                 __func__, c->bpp);

The format fix is correct, but since you change that line, "fprintf(stderr)" is old code, nowadays we prefer get rid of it by using warn_report() in place (see "qemu/error-report.h").

Thanks for your review, since fprintf() is used elsewhere in vmware_vga.c, I will send a new patch to replace all fprintf() with warn_report() in vmware_vga.c. In addition, is there better to use error_report() instead of warn_report() here?

Thanks,
Alex