]> xenbits.xensource.com Git - pvdrivers/win/xenvbd.git/commitdiff
Don't use C runtime version of toupper()
authorPaul Durrant <paul.durrant@citrix.com>
Thu, 10 Dec 2015 11:39:37 +0000 (11:39 +0000)
committerPaul Durrant <paul.durrant@citrix.com>
Thu, 10 Dec 2015 11:39:37 +0000 (11:39 +0000)
It seems that, despite its trivial functionality, the runtime implementation
insists on converting to Unicode! This means the function is actually only
safe at PASSIVE_LEVEL.
This patch implements __toupper() as a replacement with no such hidden
nastiness and modifies callers to use that.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
src/xenvbd/fdo.c
src/xenvbd/util.h

index eac0584ed0ffd80bb8bc943e23535f9976e2f16f..aa92fe43e4fcdba90f6d37e019ac8460c1c0e4aa 100644 (file)
@@ -1015,7 +1015,7 @@ __FdoMultiSzToUpcaseAnsi(
             if (Buffer[Index] == '\0')
                 break;
         } else {
-            Buffer[Index] = (CHAR)toupper(Buffer[Index]);
+            Buffer[Index] = __toupper(Buffer[Index]);
             Index++;
         }
     }
index eb02e3435eb4db151614149a8dee7f5ed17c0a3a..f55fb78dd6d23742a8ecae0dfb254346a0e3d4c7 100644 (file)
@@ -266,4 +266,15 @@ __strtok_r(
     return Token;
 }
 
+static FORCEINLINE CHAR
+__toupper(
+    IN  CHAR    Character
+    )
+{
+    if (Character < 'a' || Character > 'z')
+        return Character;
+
+    return 'A' + Character - 'a';
+}
+
 #endif  // _UTIL_H