All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] util/cutils: Use qemu_isdigit() instead of isdigit()
@ 2026-09-10 11:21 Thomas Huth
  2026-09-10 12:01 ` Daniel P. Berrangé
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Huth @ 2026-09-10 11:21 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Reinoud Zandijk

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/util/cutils.c:25:
  ../src/util/cutils.c: In function 'do_strtosz':
  ../src/util/cutils.c:245:61: warning: array subscript has type 'char' [-Wchar-subscripts]
  245 |         if (retval == 0 && *endptr == '.' && !isdigit(endptr[1])) {

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

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 util/cutils.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/util/cutils.c b/util/cutils.c
index 96c80d4d429..91ddadfd15a 100644
--- a/util/cutils.c
+++ b/util/cutils.c
@@ -242,7 +242,7 @@ static int do_strtosz(const char *nptr, const char **end,
          */
         double fraction = 0.0;
 
-        if (retval == 0 && *endptr == '.' && !isdigit(endptr[1])) {
+        if (retval == 0 && *endptr == '.' && !qemu_isdigit(endptr[1])) {
             /* If we got here, we parsed at least one digit already. */
             endptr++;
         } else {
-- 
2.55.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] util/cutils: Use qemu_isdigit() instead of isdigit()
  2026-09-10 11:21 [PATCH] util/cutils: Use qemu_isdigit() instead of isdigit() Thomas Huth
@ 2026-09-10 12:01 ` Daniel P. Berrangé
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel P. Berrangé @ 2026-09-10 12:01 UTC (permalink / raw)
  To: Thomas Huth; +Cc: qemu-devel, qemu-trivial, Reinoud Zandijk

On Thu, Sep 10, 2026 at 01:21:00PM +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/util/cutils.c:25:
>   ../src/util/cutils.c: In function 'do_strtosz':
>   ../src/util/cutils.c:245:61: warning: array subscript has type 'char' [-Wchar-subscripts]
>   245 |         if (retval == 0 && *endptr == '.' && !isdigit(endptr[1])) {
> 
> isdigit() should not be used with plain "char" variables since these
> can be signed and isdigit() could be implemented as a macro that uses
> its parameter to index into an array. Use our wrapper qemu_isdigit()
> to fix this problem.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  util/cutils.c | 2 +-
>  1 file changed, 1 insertion(+), 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 :|



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-10 12:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-10 11:21 [PATCH] util/cutils: Use qemu_isdigit() instead of isdigit() Thomas Huth
2026-09-10 12:01 ` Daniel P. Berrangé

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.