Skip to contentSkip to conversation

hw/ppc/vof: Use qemu_tolower() instead of tolower()

PATCH In review Thomas Huth 2 participants 2 messages Sep 10

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/ppc/vof: Use qemu_tolower() instead of tolower()

When building QEMU for NetBSD ("make vm-build-netbsd"), the compiler complains:

In file included from /usr/include/ctype.h:100,

                 from ../src/include/qemu/osdep.h:123,
                 from ../src/hw/ppc/vof.c:12:

../src/hw/ppc/vof.c: In function 'path_offset':
../src/hw/ppc/vof.c:150:31: warning: array subscript has type 'char' [-Wchar-subscripts]
150 | *at = tolower(*at);

tolower() should not be used with plain "char" variables since these can be signed and tolower() could be implemented as a macro that uses its parameter to index into an array. Use our wrapper qemu_tolower() to fix this problem.

---
 hw/ppc/vof.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/ppc/vof.c +2 -1
index fa7b73159a0..873e967f1e4 100644
@@ -10,6 +10,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/ctype.h"
 #include "qemu/timer.h"
 #include "qemu/range.h"
 #include "qemu/units.h"
@@ -147,7 +148,7 @@ static int path_offset(const void *fdt, const char *path)
             if (*at == '/') {
                 at = strchr(at, '@');
             } else {
-                *at = tolower(*at);
+                *at = qemu_tolower(*at);
                 ++at;
             }
     }
Signature · 1 line
2.55.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 15 lines · Thomas Huth

When building QEMU for NetBSD ("make vm-build-netbsd"), the compiler complains:

In file included from /usr/include/ctype.h:100,

                 from ../src/include/qemu/osdep.h:123,
                 from ../src/hw/ppc/vof.c:12:

../src/hw/ppc/vof.c: In function 'path_offset':
../src/hw/ppc/vof.c:150:31: warning: array subscript has type 'char' [-Wchar-subscripts]
150 | *at = tolower(*at);

tolower() should not be used with plain "char" variables since these can be signed and tolower() could be implemented as a macro that uses its parameter to index into an array. Use our wrapper qemu_tolower() to fix this problem.

Quoted 4 lines
---
 hw/ppc/vof.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|