qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] fix warnings on NetBSD
@ 2008-11-10  9:55 Christoph Egger
  2008-11-10 16:03 ` [Qemu-devel] " Blue Swirl
  0 siblings, 1 reply; 8+ messages in thread
From: Christoph Egger @ 2008-11-10  9:55 UTC (permalink / raw)
  To: qemu-devel; +Cc: blauwirbel

[-- Attachment #1: Type: text/plain, Size: 627 bytes --]


Hi!

Attached patch fixes a series of this warning
when compiling on NetBSD:

warning: array subscript has type 'char'

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>

Christoph


-- 
AMD Saxony, Dresden, Germany
Operating System Research Center

Legal Information:
AMD Saxony Limited Liability Company & Co. KG
Sitz (Geschäftsanschrift):
   Wilschdorfer Landstr. 101, 01109 Dresden, Deutschland
Registergericht Dresden: HRA 4896
vertretungsberechtigter Komplementär:
   AMD Saxony LLC (Sitz Wilmington, Delaware, USA)
Geschäftsführer der AMD Saxony LLC:
   Dr. Hans-R. Deppe, Thomas McCoy

[-- Attachment #2: qemu.diff --]
[-- Type: text/x-diff, Size: 7813 bytes --]

Index: readline.c
===================================================================
--- readline.c	(revision 5666)
+++ readline.c	(working copy)
@@ -169,7 +169,7 @@
 
     /* find first word (backwards) */
     while (start > 0) {
-        if (!isspace(term_cmd_buf[start])) {
+        if (!isspace((uint8_t)term_cmd_buf[start])) {
             break;
         }
 
@@ -178,7 +178,7 @@
 
     /* find first space (backwards) */
     while (start > 0) {
-        if (isspace(term_cmd_buf[start])) {
+        if (isspace((uint8_t)term_cmd_buf[start])) {
             ++start;
             break;
         }
Index: block-vvfat.c
===================================================================
--- block-vvfat.c	(revision 5666)
+++ block-vvfat.c	(working copy)
@@ -1056,7 +1056,7 @@
 
     i = strrchr(dirname, ':') - dirname;
     assert(i >= 3);
-    if (dirname[i-2] == ':' && isalpha(dirname[i-1]))
+    if (dirname[i-2] == ':' && isalpha((uint8_t)dirname[i-1]))
 	/* workaround for DOS drive names */
 	dirname += i-1;
     else
Index: target-ppc/translate_init.c
===================================================================
--- target-ppc/translate_init.c	(revision 5666)
+++ target-ppc/translate_init.c	(working copy)
@@ -9458,7 +9458,7 @@
         p = name;
     check_pvr:
         for (i = 0; i < 8; i++) {
-            if (!isxdigit(*p++))
+            if (!isxdigit((uint8_t)*p++))
                 break;
         }
         if (i == 8)
Index: net.c
===================================================================
--- net.c	(revision 5666)
+++ net.c	(working copy)
@@ -279,7 +279,7 @@
     if (buf[0] == '\0') {
         saddr->sin_addr.s_addr = 0;
     } else {
-        if (isdigit(buf[0])) {
+        if (isdigit((uint8_t)buf[0])) {
             if (!inet_aton(buf, &saddr->sin_addr))
                 return -1;
         } else {
Index: cutils.c
===================================================================
--- cutils.c	(revision 5666)
+++ cutils.c	(working copy)
@@ -72,7 +72,7 @@
     p = str;
     q = val;
     while (*q != '\0') {
-        if (toupper(*p) != toupper(*q))
+        if (toupper((uint8_t)*p) != toupper((uint8_t)*q))
             return 0;
         p++;
         q++;
Index: audio/audio.c
===================================================================
--- audio/audio.c	(revision 5666)
+++ audio/audio.c	(working copy)
@@ -215,7 +215,7 @@
         pstrcat (r, len + sizeof (qemu_prefix), s);
 
         for (i = 0; i < len; ++i) {
-            u[i] = toupper (u[i]);
+            u[i] = toupper ((uint8_t)u[i]);
         }
     }
     return r;
@@ -470,7 +470,7 @@
 
         /* copy while upper-casing, including trailing zero */
         for (i = 0; i <= preflen; ++i) {
-            optname[i + sizeof (qemu_prefix) - 1] = toupper (prefix[i]);
+            optname[i + sizeof (qemu_prefix) - 1] = toupper ((uint8_t)prefix[i]);
         }
         pstrcat (optname, optlen, "_");
         pstrcat (optname, optlen, opt->name);
Index: monitor.c
===================================================================
--- monitor.c	(revision 5666)
+++ monitor.c	(working copy)
@@ -1933,7 +1933,7 @@
 {
     if (pch != '\0') {
         pch++;
-        while (isspace(*pch))
+        while (isspace((uint8_t)*pch))
             pch++;
     }
 }
@@ -1992,7 +1992,7 @@
                     *q++ = *pch;
                 pch++;
             }
-            while (isspace(*pch))
+            while (isspace((uint8_t)*pch))
                 pch++;
             *q = 0;
             ret = get_monitor_def(&reg, buf);
@@ -2017,7 +2017,7 @@
             expr_error("invalid char in expression");
         }
         pch = p;
-        while (isspace(*pch))
+        while (isspace((uint8_t)*pch))
             pch++;
         break;
     }
@@ -2111,7 +2111,7 @@
         *pp = pch;
         return -1;
     }
-    while (isspace(*pch))
+    while (isspace((uint8_t)*pch))
         pch++;
     *pval = expr_sum();
     *pp = pch;
@@ -2126,7 +2126,7 @@
 
     q = buf;
     p = *pp;
-    while (isspace(*p))
+    while (isspace((uint8_t)*p))
         p++;
     if (*p == '\0') {
     fail:
@@ -2171,7 +2171,7 @@
         }
         p++;
     } else {
-        while (*p != '\0' && !isspace(*p)) {
+        while (*p != '\0' && !isspace((uint8_t)*p)) {
             if ((q - buf) < buf_size - 1) {
                 *q++ = *p;
             }
@@ -2217,12 +2217,12 @@
     /* extract the command name */
     p = cmdline;
     q = cmdname;
-    while (isspace(*p))
+    while (isspace((uint8_t)*p))
         p++;
     if (*p == '\0')
         return;
     pstart = p;
-    while (*p != '\0' && *p != '/' && !isspace(*p))
+    while (*p != '\0' && *p != '/' && !isspace((uint8_t)*p))
         p++;
     len = p - pstart;
     if (len > sizeof(cmdname) - 1)
@@ -2258,7 +2258,7 @@
                 int ret;
                 char *str;
 
-                while (isspace(*p))
+                while (isspace((uint8_t)*p))
                     p++;
                 if (*typestr == '?') {
                     typestr++;
@@ -2299,15 +2299,15 @@
             {
                 int count, format, size;
 
-                while (isspace(*p))
+                while (isspace((uint8_t)*p))
                     p++;
                 if (*p == '/') {
                     /* format found */
                     p++;
                     count = 1;
-                    if (isdigit(*p)) {
+                    if (isdigit((uint8_t)*p)) {
                         count = 0;
-                        while (isdigit(*p)) {
+                        while (isdigit((uint8_t)*p)) {
                             count = count * 10 + (*p - '0');
                             p++;
                         }
@@ -2346,7 +2346,7 @@
                         }
                     }
                 next:
-                    if (*p != '\0' && !isspace(*p)) {
+                    if (*p != '\0' && !isspace((uint8_t)*p)) {
                         term_printf("invalid char in format: '%c'\n", *p);
                         goto fail;
                     }
@@ -2380,7 +2380,7 @@
             {
                 int64_t val;
 
-                while (isspace(*p))
+                while (isspace((uint8_t)*p))
                     p++;
                 if (*typestr == '?' || *typestr == '.') {
                     if (*typestr == '?') {
@@ -2391,7 +2391,7 @@
                     } else {
                         if (*p == '.') {
                             p++;
-                            while (isspace(*p))
+                            while (isspace((uint8_t)*p))
                                 p++;
                             has_arg = 1;
                         } else {
@@ -2436,7 +2436,7 @@
                 c = *typestr++;
                 if (c == '\0')
                     goto bad_type;
-                while (isspace(*p))
+                while (isspace((uint8_t)*p))
                     p++;
                 has_option = 0;
                 if (*p == '-') {
@@ -2461,7 +2461,7 @@
         }
     }
     /* check that all arguments were parsed */
-    while (isspace(*p))
+    while (isspace((uint8_t)*p))
         p++;
     if (*p != '\0') {
         term_printf("%s: extraneous characters at the end of line\n",
@@ -2609,7 +2609,7 @@
     p = cmdline;
     nb_args = 0;
     for(;;) {
-        while (isspace(*p))
+        while (isspace((uint8_t)*p))
             p++;
         if (*p == '\0')
             break;
@@ -2643,7 +2643,7 @@
     /* if the line ends with a space, it means we want to complete the
        next arg */
     len = strlen(cmdline);
-    if (len > 0 && isspace(cmdline[len - 1])) {
+    if (len > 0 && isspace((uint8_t)cmdline[len - 1])) {
         if (nb_args >= MAX_ARGS)
             return;
         args[nb_args++] = qemu_strdup("");

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

* [Qemu-devel] Re: [PATCH] fix warnings on NetBSD
  2008-11-10  9:55 [Qemu-devel] [PATCH] fix warnings on NetBSD Christoph Egger
@ 2008-11-10 16:03 ` Blue Swirl
  2008-11-10 16:35   ` Christoph Egger
  0 siblings, 1 reply; 8+ messages in thread
From: Blue Swirl @ 2008-11-10 16:03 UTC (permalink / raw)
  To: Christoph Egger; +Cc: qemu-devel

On 11/10/08, Christoph Egger <Christoph.Egger@amd.com> wrote:
>
>  Hi!
>
>  Attached patch fixes a series of this warning
>  when compiling on NetBSD:
>
>  warning: array subscript has type 'char'

There has been some discussion on ctype.h macro problems, please see:
http://lists.gnu.org/archive/html/qemu-devel/2008-08/msg01239.html

I'd vote for introducing qemu_isfoobar and qemu_towombat instead of casts.

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

* [Qemu-devel] Re: [PATCH] fix warnings on NetBSD
  2008-11-10 16:03 ` [Qemu-devel] " Blue Swirl
@ 2008-11-10 16:35   ` Christoph Egger
  2008-11-10 16:56     ` Blue Swirl
  0 siblings, 1 reply; 8+ messages in thread
From: Christoph Egger @ 2008-11-10 16:35 UTC (permalink / raw)
  To: qemu-devel; +Cc: Blue Swirl

[-- Attachment #1: Type: text/plain, Size: 1117 bytes --]

On Monday 10 November 2008 17:03:27 Blue Swirl wrote:
> On 11/10/08, Christoph Egger <Christoph.Egger@amd.com> wrote:
> >  Hi!
> >
> >  Attached patch fixes a series of this warning
> >  when compiling on NetBSD:
> >
> >  warning: array subscript has type 'char'
>
> There has been some discussion on ctype.h macro problems, please see:
> http://lists.gnu.org/archive/html/qemu-devel/2008-08/msg01239.html
>
> I'd vote for introducing qemu_isfoobar and qemu_towombat instead of casts.

Attached patch introduces a CTYPE macro as mentioned on this mail.
The diff in qemu-common.h has been taken from xen ioemu.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>


-- 
AMD Saxony, Dresden, Germany
Operating System Research Center

Legal Information:
AMD Saxony Limited Liability Company & Co. KG
Sitz (Geschäftsanschrift):
   Wilschdorfer Landstr. 101, 01109 Dresden, Deutschland
Registergericht Dresden: HRA 4896
vertretungsberechtigter Komplementär:
   AMD Saxony LLC (Sitz Wilmington, Delaware, USA)
Geschäftsführer der AMD Saxony LLC:
   Dr. Hans-R. Deppe, Thomas McCoy

[-- Attachment #2: qemu.diff --]
[-- Type: text/x-diff, Size: 8858 bytes --]

Index: readline.c
===================================================================
--- readline.c	(revision 5666)
+++ readline.c	(working copy)
@@ -169,7 +169,7 @@
 
     /* find first word (backwards) */
     while (start > 0) {
-        if (!isspace(term_cmd_buf[start])) {
+        if (!CTYPE(isspace, term_cmd_buf[start])) {
             break;
         }
 
@@ -178,7 +178,7 @@
 
     /* find first space (backwards) */
     while (start > 0) {
-        if (isspace(term_cmd_buf[start])) {
+        if (CTYPE(isspace, term_cmd_buf[start])) {
             ++start;
             break;
         }
Index: block-vvfat.c
===================================================================
--- block-vvfat.c	(revision 5666)
+++ block-vvfat.c	(working copy)
@@ -1056,7 +1056,7 @@
 
     i = strrchr(dirname, ':') - dirname;
     assert(i >= 3);
-    if (dirname[i-2] == ':' && isalpha(dirname[i-1]))
+    if (dirname[i-2] == ':' && CTYPE(isalpha, dirname[i-1]))
 	/* workaround for DOS drive names */
 	dirname += i-1;
     else
Index: target-ppc/translate_init.c
===================================================================
--- target-ppc/translate_init.c	(revision 5666)
+++ target-ppc/translate_init.c	(working copy)
@@ -9458,7 +9458,7 @@
         p = name;
     check_pvr:
         for (i = 0; i < 8; i++) {
-            if (!isxdigit(*p++))
+            if (!CTYPE(isxdigit, *p++))
                 break;
         }
         if (i == 8)
Index: net.c
===================================================================
--- net.c	(revision 5666)
+++ net.c	(working copy)
@@ -279,7 +279,7 @@
     if (buf[0] == '\0') {
         saddr->sin_addr.s_addr = 0;
     } else {
-        if (isdigit(buf[0])) {
+        if (CTYPE(isdigit, buf[0])) {
             if (!inet_aton(buf, &saddr->sin_addr))
                 return -1;
         } else {
Index: cutils.c
===================================================================
--- cutils.c	(revision 5666)
+++ cutils.c	(working copy)
@@ -72,7 +72,7 @@
     p = str;
     q = val;
     while (*q != '\0') {
-        if (toupper(*p) != toupper(*q))
+        if (CTYPE(toupper, *p) != CTYPE(toupper, *q))
             return 0;
         p++;
         q++;
Index: audio/audio.c
===================================================================
--- audio/audio.c	(revision 5666)
+++ audio/audio.c	(working copy)
@@ -215,7 +215,7 @@
         pstrcat (r, len + sizeof (qemu_prefix), s);
 
         for (i = 0; i < len; ++i) {
-            u[i] = toupper (u[i]);
+            u[i] = CTYPE(toupper, u[i]);
         }
     }
     return r;
@@ -470,7 +470,7 @@
 
         /* copy while upper-casing, including trailing zero */
         for (i = 0; i <= preflen; ++i) {
-            optname[i + sizeof (qemu_prefix) - 1] = toupper (prefix[i]);
+            optname[i + sizeof (qemu_prefix) - 1] = CTYPE(toupper, prefix[i]);
         }
         pstrcat (optname, optlen, "_");
         pstrcat (optname, optlen, opt->name);
Index: qemu-common.h
===================================================================
--- qemu-common.h	(revision 5666)
+++ qemu-common.h	(working copy)
@@ -93,6 +93,17 @@
 int stristart(const char *str, const char *val, const char **ptr);
 time_t mktimegm(struct tm *tm);
 
+#define CTYPE(isfoobar,argumentchar) (isfoobar((unsigned char)(argumentchar)))
+  /* One must not pass a plain `char' to isupper, toupper, et al.  If
+   * it has the top bit set (ie, is negative if your chars are
+   * signed), undefined behaviour results.  The <ctype.h> functions
+   * are defined to take the value of an unsigned char, as an int.
+   * So use this macro.  You may pass toupper et al for isfoobar.
+   * Do not pass EOF as a character to this macro.  If you might have
+   * EOF then you ought to have it in an int representing an unsigned
+   * char, which is safe for the ctype macros directly.  Or test separately.
+   * Obviously don't use this for floating point things like isnan! */
+
 void *qemu_malloc(size_t size);
 void *qemu_realloc(void *ptr, size_t size);
 void *qemu_mallocz(size_t size);
Index: monitor.c
===================================================================
--- monitor.c	(revision 5666)
+++ monitor.c	(working copy)
@@ -1933,7 +1933,7 @@
 {
     if (pch != '\0') {
         pch++;
-        while (isspace(*pch))
+        while (CTYPE(isspace, *pch))
             pch++;
     }
 }
@@ -1992,7 +1992,7 @@
                     *q++ = *pch;
                 pch++;
             }
-            while (isspace(*pch))
+            while (CTYPE(isspace, *pch))
                 pch++;
             *q = 0;
             ret = get_monitor_def(&reg, buf);
@@ -2017,7 +2017,7 @@
             expr_error("invalid char in expression");
         }
         pch = p;
-        while (isspace(*pch))
+        while (CTYPE(isspace, *pch))
             pch++;
         break;
     }
@@ -2111,7 +2111,7 @@
         *pp = pch;
         return -1;
     }
-    while (isspace(*pch))
+    while (CTYPE(isspace, *pch))
         pch++;
     *pval = expr_sum();
     *pp = pch;
@@ -2126,7 +2126,7 @@
 
     q = buf;
     p = *pp;
-    while (isspace(*p))
+    while (CTYPE(isspace, *p))
         p++;
     if (*p == '\0') {
     fail:
@@ -2171,7 +2171,7 @@
         }
         p++;
     } else {
-        while (*p != '\0' && !isspace(*p)) {
+        while (*p != '\0' && !CTYPE(isspace, *p)) {
             if ((q - buf) < buf_size - 1) {
                 *q++ = *p;
             }
@@ -2217,12 +2217,12 @@
     /* extract the command name */
     p = cmdline;
     q = cmdname;
-    while (isspace(*p))
+    while (CTYPE(isspace, *p))
         p++;
     if (*p == '\0')
         return;
     pstart = p;
-    while (*p != '\0' && *p != '/' && !isspace(*p))
+    while (*p != '\0' && *p != '/' && !CTYPE(isspace, *p))
         p++;
     len = p - pstart;
     if (len > sizeof(cmdname) - 1)
@@ -2258,7 +2258,7 @@
                 int ret;
                 char *str;
 
-                while (isspace(*p))
+                while (CTYPE(isspace, *p))
                     p++;
                 if (*typestr == '?') {
                     typestr++;
@@ -2299,15 +2299,15 @@
             {
                 int count, format, size;
 
-                while (isspace(*p))
+                while (CTYPE(isspace, *p))
                     p++;
                 if (*p == '/') {
                     /* format found */
                     p++;
                     count = 1;
-                    if (isdigit(*p)) {
+                    if (CTYPE(isdigit, *p)) {
                         count = 0;
-                        while (isdigit(*p)) {
+                        while (CTYPE(isdigit, *p)) {
                             count = count * 10 + (*p - '0');
                             p++;
                         }
@@ -2346,7 +2346,7 @@
                         }
                     }
                 next:
-                    if (*p != '\0' && !isspace(*p)) {
+                    if (*p != '\0' && !CTYPE(isspace, *p)) {
                         term_printf("invalid char in format: '%c'\n", *p);
                         goto fail;
                     }
@@ -2380,7 +2380,7 @@
             {
                 int64_t val;
 
-                while (isspace(*p))
+                while (CTYPE(isspace, *p))
                     p++;
                 if (*typestr == '?' || *typestr == '.') {
                     if (*typestr == '?') {
@@ -2391,7 +2391,7 @@
                     } else {
                         if (*p == '.') {
                             p++;
-                            while (isspace(*p))
+                            while (CTYPE(isspace, *p))
                                 p++;
                             has_arg = 1;
                         } else {
@@ -2436,7 +2436,7 @@
                 c = *typestr++;
                 if (c == '\0')
                     goto bad_type;
-                while (isspace(*p))
+                while (CTYPE(isspace, *p))
                     p++;
                 has_option = 0;
                 if (*p == '-') {
@@ -2461,7 +2461,7 @@
         }
     }
     /* check that all arguments were parsed */
-    while (isspace(*p))
+    while (CTYPE(isspace, *p))
         p++;
     if (*p != '\0') {
         term_printf("%s: extraneous characters at the end of line\n",
@@ -2609,7 +2609,7 @@
     p = cmdline;
     nb_args = 0;
     for(;;) {
-        while (isspace(*p))
+        while (CTYPE(isspace, *p))
             p++;
         if (*p == '\0')
             break;
@@ -2643,7 +2643,7 @@
     /* if the line ends with a space, it means we want to complete the
        next arg */
     len = strlen(cmdline);
-    if (len > 0 && isspace(cmdline[len - 1])) {
+    if (len > 0 && CTYPE(isspace, cmdline[len - 1])) {
         if (nb_args >= MAX_ARGS)
             return;
         args[nb_args++] = qemu_strdup("");

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

* [Qemu-devel] Re: [PATCH] fix warnings on NetBSD
  2008-11-10 16:35   ` Christoph Egger
@ 2008-11-10 16:56     ` Blue Swirl
  2008-11-11  9:46       ` Christoph Egger
  0 siblings, 1 reply; 8+ messages in thread
From: Blue Swirl @ 2008-11-10 16:56 UTC (permalink / raw)
  To: Christoph Egger; +Cc: qemu-devel

On 11/10/08, Christoph Egger <Christoph.Egger@amd.com> wrote:
> On Monday 10 November 2008 17:03:27 Blue Swirl wrote:
>  > On 11/10/08, Christoph Egger <Christoph.Egger@amd.com> wrote:
>  > >  Hi!
>  > >
>  > >  Attached patch fixes a series of this warning
>  > >  when compiling on NetBSD:
>  > >
>  > >  warning: array subscript has type 'char'
>  >
>  > There has been some discussion on ctype.h macro problems, please see:
>  > http://lists.gnu.org/archive/html/qemu-devel/2008-08/msg01239.html
>  >
>  > I'd vote for introducing qemu_isfoobar and qemu_towombat instead of casts.
>
>
> Attached patch introduces a CTYPE macro as mentioned on this mail.
>  The diff in qemu-common.h has been taken from xen ioemu.

Sorry, you must have missed the two follow-up messages:
http://lists.gnu.org/archive/html/qemu-devel/2008-08/msg01252.html
http://lists.gnu.org/archive/html/qemu-devel/2008-08/msg01292.html

So instead of CTYPE macro, there should be qemu_toupper, qemu_isalpha
etc. which handle char arguments correctly even when sign extension
happens.

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

* [Qemu-devel] Re: [PATCH] fix warnings on NetBSD
  2008-11-10 16:56     ` Blue Swirl
@ 2008-11-11  9:46       ` Christoph Egger
  2008-11-11 17:45         ` Blue Swirl
  2008-11-16 14:04         ` Blue Swirl
  0 siblings, 2 replies; 8+ messages in thread
From: Christoph Egger @ 2008-11-11  9:46 UTC (permalink / raw)
  To: Blue Swirl; +Cc: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1718 bytes --]

On Monday 10 November 2008 17:56:58 Blue Swirl wrote:
> On 11/10/08, Christoph Egger <Christoph.Egger@amd.com> wrote:
> > On Monday 10 November 2008 17:03:27 Blue Swirl wrote:
> >  > On 11/10/08, Christoph Egger <Christoph.Egger@amd.com> wrote:
> >  > >  Hi!
> >  > >
> >  > >  Attached patch fixes a series of this warning
> >  > >  when compiling on NetBSD:
> >  > >
> >  > >  warning: array subscript has type 'char'
> >  >
> >  > There has been some discussion on ctype.h macro problems, please see:
> >  > http://lists.gnu.org/archive/html/qemu-devel/2008-08/msg01239.html
> >  >
> >  > I'd vote for introducing qemu_isfoobar and qemu_towombat instead of
> >  > casts.
> >
> > Attached patch introduces a CTYPE macro as mentioned on this mail.
> >  The diff in qemu-common.h has been taken from xen ioemu.
>
> Sorry, you must have missed the two follow-up messages:
> http://lists.gnu.org/archive/html/qemu-devel/2008-08/msg01252.html
> http://lists.gnu.org/archive/html/qemu-devel/2008-08/msg01292.html
>
> So instead of CTYPE macro, there should be qemu_toupper, qemu_isalpha
> etc. which handle char arguments correctly even when sign extension
> happens.

New patch attached. Better now ?

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>


-- 
AMD Saxony, Dresden, Germany
Operating System Research Center

Legal Information:
AMD Saxony Limited Liability Company & Co. KG
Sitz (Geschäftsanschrift):
   Wilschdorfer Landstr. 101, 01109 Dresden, Deutschland
Registergericht Dresden: HRA 4896
vertretungsberechtigter Komplementär:
   AMD Saxony LLC (Sitz Wilmington, Delaware, USA)
Geschäftsführer der AMD Saxony LLC:
   Dr. Hans-R. Deppe, Thomas McCoy

[-- Attachment #2: qemu.diff --]
[-- Type: text/x-diff, Size: 8902 bytes --]

Index: readline.c
===================================================================
--- readline.c	(revision 5670)
+++ readline.c	(working copy)
@@ -169,7 +169,7 @@
 
     /* find first word (backwards) */
     while (start > 0) {
-        if (!isspace(term_cmd_buf[start])) {
+        if (!qemu_isspace(term_cmd_buf[start])) {
             break;
         }
 
@@ -178,7 +178,7 @@
 
     /* find first space (backwards) */
     while (start > 0) {
-        if (isspace(term_cmd_buf[start])) {
+        if (qemu_isspace(term_cmd_buf[start])) {
             ++start;
             break;
         }
Index: block-vvfat.c
===================================================================
--- block-vvfat.c	(revision 5670)
+++ block-vvfat.c	(working copy)
@@ -1056,7 +1056,7 @@
 
     i = strrchr(dirname, ':') - dirname;
     assert(i >= 3);
-    if (dirname[i-2] == ':' && isalpha(dirname[i-1]))
+    if (dirname[i-2] == ':' && qemu_isalpha(dirname[i-1]))
 	/* workaround for DOS drive names */
 	dirname += i-1;
     else
Index: target-ppc/translate_init.c
===================================================================
--- target-ppc/translate_init.c	(revision 5670)
+++ target-ppc/translate_init.c	(working copy)
@@ -9458,7 +9458,7 @@
         p = name;
     check_pvr:
         for (i = 0; i < 8; i++) {
-            if (!isxdigit(*p++))
+            if (!qemu_isxdigit(*p++))
                 break;
         }
         if (i == 8)
Index: net.c
===================================================================
--- net.c	(revision 5670)
+++ net.c	(working copy)
@@ -279,7 +279,7 @@
     if (buf[0] == '\0') {
         saddr->sin_addr.s_addr = 0;
     } else {
-        if (isdigit(buf[0])) {
+        if (qemu_isdigit(buf[0])) {
             if (!inet_aton(buf, &saddr->sin_addr))
                 return -1;
         } else {
Index: cutils.c
===================================================================
--- cutils.c	(revision 5670)
+++ cutils.c	(working copy)
@@ -72,7 +72,7 @@
     p = str;
     q = val;
     while (*q != '\0') {
-        if (toupper(*p) != toupper(*q))
+        if (qemu_toupper(*p) != qemu_toupper(*q))
             return 0;
         p++;
         q++;
Index: audio/audio.c
===================================================================
--- audio/audio.c	(revision 5670)
+++ audio/audio.c	(working copy)
@@ -215,7 +215,7 @@
         pstrcat (r, len + sizeof (qemu_prefix), s);
 
         for (i = 0; i < len; ++i) {
-            u[i] = toupper (u[i]);
+            u[i] = qemu_toupper(u[i]);
         }
     }
     return r;
@@ -470,7 +470,7 @@
 
         /* copy while upper-casing, including trailing zero */
         for (i = 0; i <= preflen; ++i) {
-            optname[i + sizeof (qemu_prefix) - 1] = toupper (prefix[i]);
+            optname[i + sizeof (qemu_prefix) - 1] = qemu_toupper(prefix[i]);
         }
         pstrcat (optname, optlen, "_");
         pstrcat (optname, optlen, opt->name);
Index: qemu-common.h
===================================================================
--- qemu-common.h	(revision 5670)
+++ qemu-common.h	(working copy)
@@ -93,6 +93,22 @@
 int stristart(const char *str, const char *val, const char **ptr);
 time_t mktimegm(struct tm *tm);
 
+#define qemu_isalnum(c)		isalnum((unsigned char)(c))
+#define qemu_isalpha(c)		isalpha((unsigned char)(c))
+#define qemu_iscntrl(c)		iscntrl((unsigned char)(c))
+#define qemu_isdigit(c)		isdigit((unsigned char)(c))
+#define qemu_isgraph(c)		isgraph((unsigned char)(c))
+#define qemu_islower(c)		islower((unsigned char)(c))
+#define qemu_isprint(c)		isprint((unsigned char)(c))
+#define qemu_ispunct(c)		ispunct((unsigned char)(c))
+#define qemu_isspace(c)		isspace((unsigned char)(c))
+#define qemu_isupper(c)		isupper((unsigned char)(c))
+#define qemu_isxdigit(c)	isxdigit((unsigned char)(c))
+#define qemu_tolower(c)		tolower((unsigned char)(c))
+#define qemu_toupper(c)		toupper((unsigned char)(c))
+#define qemu_isascii(c)		isascii((unsigned char)(c))
+#define qemu_toascii(c)		toascii((unsigned char)(c))
+
 void *qemu_malloc(size_t size);
 void *qemu_realloc(void *ptr, size_t size);
 void *qemu_mallocz(size_t size);
Index: monitor.c
===================================================================
--- monitor.c	(revision 5670)
+++ monitor.c	(working copy)
@@ -1933,7 +1933,7 @@
 {
     if (pch != '\0') {
         pch++;
-        while (isspace(*pch))
+        while (qemu_isspace(*pch))
             pch++;
     }
 }
@@ -1992,7 +1992,7 @@
                     *q++ = *pch;
                 pch++;
             }
-            while (isspace(*pch))
+            while (qemu_isspace(*pch))
                 pch++;
             *q = 0;
             ret = get_monitor_def(&reg, buf);
@@ -2017,7 +2017,7 @@
             expr_error("invalid char in expression");
         }
         pch = p;
-        while (isspace(*pch))
+        while (qemu_isspace(*pch))
             pch++;
         break;
     }
@@ -2111,7 +2111,7 @@
         *pp = pch;
         return -1;
     }
-    while (isspace(*pch))
+    while (qemu_isspace(*pch))
         pch++;
     *pval = expr_sum();
     *pp = pch;
@@ -2126,7 +2126,7 @@
 
     q = buf;
     p = *pp;
-    while (isspace(*p))
+    while (qemu_isspace(*p))
         p++;
     if (*p == '\0') {
     fail:
@@ -2171,7 +2171,7 @@
         }
         p++;
     } else {
-        while (*p != '\0' && !isspace(*p)) {
+        while (*p != '\0' && !qemu_isspace(*p)) {
             if ((q - buf) < buf_size - 1) {
                 *q++ = *p;
             }
@@ -2217,12 +2217,12 @@
     /* extract the command name */
     p = cmdline;
     q = cmdname;
-    while (isspace(*p))
+    while (qemu_isspace(*p))
         p++;
     if (*p == '\0')
         return;
     pstart = p;
-    while (*p != '\0' && *p != '/' && !isspace(*p))
+    while (*p != '\0' && *p != '/' && !qemu_isspace(*p))
         p++;
     len = p - pstart;
     if (len > sizeof(cmdname) - 1)
@@ -2258,7 +2258,7 @@
                 int ret;
                 char *str;
 
-                while (isspace(*p))
+                while (qemu_isspace(*p))
                     p++;
                 if (*typestr == '?') {
                     typestr++;
@@ -2299,15 +2299,15 @@
             {
                 int count, format, size;
 
-                while (isspace(*p))
+                while (qemu_isspace(*p))
                     p++;
                 if (*p == '/') {
                     /* format found */
                     p++;
                     count = 1;
-                    if (isdigit(*p)) {
+                    if (qemu_isdigit(*p)) {
                         count = 0;
-                        while (isdigit(*p)) {
+                        while (qemu_isdigit(*p)) {
                             count = count * 10 + (*p - '0');
                             p++;
                         }
@@ -2346,7 +2346,7 @@
                         }
                     }
                 next:
-                    if (*p != '\0' && !isspace(*p)) {
+                    if (*p != '\0' && !qemu_isspace(*p)) {
                         term_printf("invalid char in format: '%c'\n", *p);
                         goto fail;
                     }
@@ -2380,7 +2380,7 @@
             {
                 int64_t val;
 
-                while (isspace(*p))
+                while (qemu_isspace(*p))
                     p++;
                 if (*typestr == '?' || *typestr == '.') {
                     if (*typestr == '?') {
@@ -2391,7 +2391,7 @@
                     } else {
                         if (*p == '.') {
                             p++;
-                            while (isspace(*p))
+                            while (qemu_isspace(*p))
                                 p++;
                             has_arg = 1;
                         } else {
@@ -2436,7 +2436,7 @@
                 c = *typestr++;
                 if (c == '\0')
                     goto bad_type;
-                while (isspace(*p))
+                while (qemu_isspace(*p))
                     p++;
                 has_option = 0;
                 if (*p == '-') {
@@ -2461,7 +2461,7 @@
         }
     }
     /* check that all arguments were parsed */
-    while (isspace(*p))
+    while (qemu_isspace(*p))
         p++;
     if (*p != '\0') {
         term_printf("%s: extraneous characters at the end of line\n",
@@ -2609,7 +2609,7 @@
     p = cmdline;
     nb_args = 0;
     for(;;) {
-        while (isspace(*p))
+        while (qemu_isspace(*p))
             p++;
         if (*p == '\0')
             break;
@@ -2643,7 +2643,7 @@
     /* if the line ends with a space, it means we want to complete the
        next arg */
     len = strlen(cmdline);
-    if (len > 0 && isspace(cmdline[len - 1])) {
+    if (len > 0 && qemu_isspace(cmdline[len - 1])) {
         if (nb_args >= MAX_ARGS)
             return;
         args[nb_args++] = qemu_strdup("");

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

* [Qemu-devel] Re: [PATCH] fix warnings on NetBSD
  2008-11-11  9:46       ` Christoph Egger
@ 2008-11-11 17:45         ` Blue Swirl
  2008-11-11 17:53           ` Anthony Liguori
  2008-11-16 14:04         ` Blue Swirl
  1 sibling, 1 reply; 8+ messages in thread
From: Blue Swirl @ 2008-11-11 17:45 UTC (permalink / raw)
  To: Christoph Egger, Anthony Liguori; +Cc: qemu-devel

On 11/11/08, Christoph Egger <Christoph.Egger@amd.com> wrote:
> On Monday 10 November 2008 17:56:58 Blue Swirl wrote:
>  > On 11/10/08, Christoph Egger <Christoph.Egger@amd.com> wrote:
>  > > On Monday 10 November 2008 17:03:27 Blue Swirl wrote:
>  > >  > On 11/10/08, Christoph Egger <Christoph.Egger@amd.com> wrote:
>  > >  > >  Hi!
>  > >  > >
>  > >  > >  Attached patch fixes a series of this warning
>  > >  > >  when compiling on NetBSD:
>  > >  > >
>  > >  > >  warning: array subscript has type 'char'
>  > >  >
>  > >  > There has been some discussion on ctype.h macro problems, please see:
>  > >  > http://lists.gnu.org/archive/html/qemu-devel/2008-08/msg01239.html
>  > >  >
>  > >  > I'd vote for introducing qemu_isfoobar and qemu_towombat instead of
>  > >  > casts.
>  > >
>  > > Attached patch introduces a CTYPE macro as mentioned on this mail.
>  > >  The diff in qemu-common.h has been taken from xen ioemu.
>  >
>  > Sorry, you must have missed the two follow-up messages:
>  > http://lists.gnu.org/archive/html/qemu-devel/2008-08/msg01252.html
>  > http://lists.gnu.org/archive/html/qemu-devel/2008-08/msg01292.html
>  >
>  > So instead of CTYPE macro, there should be qemu_toupper, qemu_isalpha
>  > etc. which handle char arguments correctly even when sign extension
>  > happens.
>
>
> New patch attached. Better now ?
>
>
>  Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>

Looks good to me. Anybody mind if I commit it? Anthony, happy with this version?

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

* [Qemu-devel] Re: [PATCH] fix warnings on NetBSD
  2008-11-11 17:45         ` Blue Swirl
@ 2008-11-11 17:53           ` Anthony Liguori
  0 siblings, 0 replies; 8+ messages in thread
From: Anthony Liguori @ 2008-11-11 17:53 UTC (permalink / raw)
  To: Blue Swirl; +Cc: Christoph Egger, qemu-devel

Blue Swirl wrote:
>>
>>  Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
>>     
>
> Looks good to me. Anybody mind if I commit it? Anthony, happy with this version?
>   

Looks good to me.

Regards,

Anthony Liguori

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

* [Qemu-devel] Re: [PATCH] fix warnings on NetBSD
  2008-11-11  9:46       ` Christoph Egger
  2008-11-11 17:45         ` Blue Swirl
@ 2008-11-16 14:04         ` Blue Swirl
  1 sibling, 0 replies; 8+ messages in thread
From: Blue Swirl @ 2008-11-16 14:04 UTC (permalink / raw)
  To: Christoph Egger; +Cc: qemu-devel

On 11/11/08, Christoph Egger <Christoph.Egger@amd.com> wrote:
> On Monday 10 November 2008 17:56:58 Blue Swirl wrote:
>  > On 11/10/08, Christoph Egger <Christoph.Egger@amd.com> wrote:
>  > > On Monday 10 November 2008 17:03:27 Blue Swirl wrote:
>  > >  > On 11/10/08, Christoph Egger <Christoph.Egger@amd.com> wrote:
>  > >  > >  Hi!
>  > >  > >
>  > >  > >  Attached patch fixes a series of this warning
>  > >  > >  when compiling on NetBSD:
>  > >  > >
>  > >  > >  warning: array subscript has type 'char'
>  > >  >
>  > >  > There has been some discussion on ctype.h macro problems, please see:
>  > >  > http://lists.gnu.org/archive/html/qemu-devel/2008-08/msg01239.html
>  > >  >
>  > >  > I'd vote for introducing qemu_isfoobar and qemu_towombat instead of
>  > >  > casts.
>  > >
>  > > Attached patch introduces a CTYPE macro as mentioned on this mail.
>  > >  The diff in qemu-common.h has been taken from xen ioemu.
>  >
>  > Sorry, you must have missed the two follow-up messages:
>  > http://lists.gnu.org/archive/html/qemu-devel/2008-08/msg01252.html
>  > http://lists.gnu.org/archive/html/qemu-devel/2008-08/msg01292.html
>  >
>  > So instead of CTYPE macro, there should be qemu_toupper, qemu_isalpha
>  > etc. which handle char arguments correctly even when sign extension
>  > happens.
>
>
> New patch attached. Better now ?

Thanks, applied as r5727.

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

end of thread, other threads:[~2008-11-16 14:04 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-10  9:55 [Qemu-devel] [PATCH] fix warnings on NetBSD Christoph Egger
2008-11-10 16:03 ` [Qemu-devel] " Blue Swirl
2008-11-10 16:35   ` Christoph Egger
2008-11-10 16:56     ` Blue Swirl
2008-11-11  9:46       ` Christoph Egger
2008-11-11 17:45         ` Blue Swirl
2008-11-11 17:53           ` Anthony Liguori
2008-11-16 14:04         ` Blue Swirl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).