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

Thomas Huth posted 1 patch 2 weeks, 2 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260910115125.383713-1-thuth@redhat.com
Maintainers: Alexey Kardashevskiy <aik@ozlabs.ru>
hw/ppc/vof.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH] hw/ppc/vof: Use qemu_tolower() instead of tolower()
Posted by Thomas Huth 2 weeks, 2 days ago
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.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 hw/ppc/vof.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/ppc/vof.c b/hw/ppc/vof.c
index fa7b73159a0..873e967f1e4 100644
--- a/hw/ppc/vof.c
+++ b/hw/ppc/vof.c
@@ -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;
             }
     }
-- 
2.55.0
Re: [PATCH] hw/ppc/vof: Use qemu_tolower() instead of tolower()
Posted by Daniel P. Berrangé 2 weeks, 2 days ago
On Thu, Sep 10, 2026 at 01:51:25PM +0200, Thomas Huth wrote:
> 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.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  hw/ppc/vof.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|