[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[win-pv-devel] [PATCH] Don't use C runtime version of toupper()



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@xxxxxxxxxx>
---
 src/xenvbd/fdo.c  |  2 +-
 src/xenvbd/util.h | 11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/xenvbd/fdo.c b/src/xenvbd/fdo.c
index eac0584..aa92fe4 100644
--- a/src/xenvbd/fdo.c
+++ b/src/xenvbd/fdo.c
@@ -1015,7 +1015,7 @@ __FdoMultiSzToUpcaseAnsi(
             if (Buffer[Index] == '\0')
                 break;
         } else {
-            Buffer[Index] = (CHAR)toupper(Buffer[Index]);
+            Buffer[Index] = __toupper(Buffer[Index]);
             Index++;
         }
     }
diff --git a/src/xenvbd/util.h b/src/xenvbd/util.h
index eb02e34..f55fb78 100644
--- a/src/xenvbd/util.h
+++ b/src/xenvbd/util.h
@@ -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
-- 
2.1.1


_______________________________________________
win-pv-devel mailing list
win-pv-devel@xxxxxxxxxxxxxxxxxxxx
http://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.