]> xenbits.xensource.com Git - pvdrivers/win/xenvif.git/commitdiff
Infer REG_SZ or REG_MULTI_SZ type in RegistryUpdateSzValue()
authorPaul Durrant <paul.durrant@citrix.com>
Tue, 7 Jul 2015 14:03:12 +0000 (15:03 +0100)
committerPaul Durrant <paul.durrant@citrix.com>
Wed, 8 Jul 2015 12:20:46 +0000 (13:20 +0100)
The argument is a pointer to an array of ANSI_STRINGs in both cases so the
type can easily be inferred from the length of the array.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
src/xenvif/registry.c
src/xenvif/registry.h

index 32755f336041620c160e0c64d89651b7329c52b5..85c924c700d8cd362fdd6ad0d5db7be0ee7de50e 100644 (file)
@@ -1258,13 +1258,12 @@ NTSTATUS
 RegistryUpdateSzValue(
     IN  HANDLE                      Key,
     IN  PCHAR                       Name,
-    IN  ULONG                       Type,
-    ...
+    IN  PANSI_STRING                Array
     )
 {
     ANSI_STRING                     Ansi;
     UNICODE_STRING                  Unicode;
-    va_list                         Arguments;
+    ULONG                           Type;
     PKEY_VALUE_PARTIAL_INFORMATION  Partial;
     NTSTATUS                        status;
 
@@ -1273,33 +1272,25 @@ RegistryUpdateSzValue(
     status = RtlAnsiStringToUnicodeString(&Unicode, &Ansi, TRUE);
     if (!NT_SUCCESS(status))
         goto fail1;
-        
-    va_start(Arguments, Type);
-    switch (Type) {
-    case REG_SZ: {
-        PANSI_STRING    Argument;
 
-        Argument = va_arg(Arguments, PANSI_STRING);
+    Type = (Array[1].Buffer != NULL) ? REG_MULTI_SZ : REG_SZ;
 
+    switch (Type) {
+    case REG_SZ:
         status = STATUS_NO_MEMORY;
-        Partial = RegistryAnsiToSz(Argument);        
+        Partial = RegistryAnsiToSz(Array);
         break;
-    }
-    case REG_MULTI_SZ: {
-        PANSI_STRING    Argument;
-
-        Argument = va_arg(Arguments, PANSI_STRING);
 
+    case REG_MULTI_SZ:
         status = STATUS_NO_MEMORY;
-        Partial = RegistryAnsiToMultiSz(Argument);        
+        Partial = RegistryAnsiToMultiSz(Array);
         break;
-    }
+
     default:
         status = STATUS_INVALID_PARAMETER;
         Partial = NULL;
         break;
     }
-    va_end(Arguments);
 
     if (Partial == NULL)
         goto fail2;
index 1d3c885b59620bb46ede9579d6c8d4d91822aeb0..71ce18ba9b029779cf6a9d41604006602b8ebc82 100644 (file)
@@ -177,8 +177,7 @@ extern NTSTATUS
 RegistryUpdateSzValue(
     IN  HANDLE          Key,
     IN  PCHAR           Name,
-    IN  ULONG           Type,
-    ...
+    IN  PANSI_STRING    Array
     );
 
 extern VOID