]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/XenBusDxe/XenStore.c
OvmfPkg/PlatformPei: SEV: allocate pages of initial SMRAM save state map
[mirror_edk2.git] / OvmfPkg / XenBusDxe / XenStore.c
index 61976f91f11b7f7b4024a93dd81f7c3405081eb1..6812e1078cd88d2a7eda1c0a5da7392548160064 100644 (file)
@@ -10,7 +10,7 @@
 \r
   The XenStore is ASCII string based, and has a structure and semantics\r
   similar to a filesystem.  There are files and directories, the directories\r
-  able to contain files or other directories.  The depth of the hierachy\r
+  able to contain files or other directories.  The depth of the hierarchy\r
   is only limited by the XenStore's maximum path length.\r
 \r
   The communication channel between the XenStore service and other\r
@@ -303,14 +303,17 @@ XenStoreJoin (
   )\r
 {\r
   CHAR8 *Buf;\r
+  UINTN BufSize;\r
 \r
   /* +1 for '/' and +1 for '\0' */\r
-  Buf = AllocateZeroPool (\r
-          AsciiStrLen (DirectoryPath) + AsciiStrLen (Node) + 2);\r
-  AsciiStrCat (Buf, DirectoryPath);\r
-  if (Node[0] != '\0') {\r
-    AsciiStrCat (Buf, "/");\r
-    AsciiStrCat (Buf, Node);\r
+  BufSize = AsciiStrLen (DirectoryPath) + AsciiStrLen (Node) + 2;\r
+  Buf = AllocatePool (BufSize);\r
+  ASSERT (Buf != NULL);\r
+\r
+  if (Node[0] == '\0') {\r
+    AsciiSPrint (Buf, BufSize, "%a", DirectoryPath);\r
+  } else {\r
+    AsciiSPrint (Buf, BufSize, "%a/%a", DirectoryPath, Node);\r
   }\r
 \r
   return Buf;\r
@@ -710,7 +713,6 @@ static XenStoreErrors gXenStoreErrors[] = {
   { XENSTORE_STATUS_EISCONN, "EISCONN" },\r
   { XENSTORE_STATUS_E2BIG, "E2BIG" }\r
 };\r
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))\r
 \r
 STATIC\r
 XENSTORE_STATUS\r
@@ -1073,9 +1075,6 @@ XenStoreInit (
 \r
   /* Initialize the shared memory rings to talk to xenstored */\r
   Status = XenStoreInitComms (&xs);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
 \r
   return Status;\r
 }\r
@@ -1298,16 +1297,14 @@ XenStoreTransactionEnd (
 {\r
   CHAR8 AbortStr[2];\r
 \r
-  if (Abort) {\r
-    AsciiStrCpy (AbortStr, "F");\r
-  } else {\r
-    AsciiStrCpy (AbortStr, "T");\r
-  }\r
+  AbortStr[0] = Abort ? 'F' : 'T';\r
+  AbortStr[1] = '\0';\r
 \r
   return XenStoreSingle (Transaction, XS_TRANSACTION_END, AbortStr, NULL, NULL);\r
 }\r
 \r
 XENSTORE_STATUS\r
+EFIAPI\r
 XenStoreVSPrint (\r
   IN CONST XENSTORE_TRANSACTION *Transaction,\r
   IN CONST CHAR8           *DirectoryPath,\r
@@ -1319,8 +1316,11 @@ XenStoreVSPrint (
   CHAR8 *Buf;\r
   XENSTORE_STATUS Status;\r
   UINTN BufSize;\r
+  VA_LIST Marker2;\r
 \r
-  BufSize = SPrintLengthAsciiFormat (FormatString, Marker) + 1;\r
+  VA_COPY (Marker2, Marker);\r
+  BufSize = SPrintLengthAsciiFormat (FormatString, Marker2) + 1;\r
+  VA_END (Marker2);\r
   Buf = AllocateZeroPool (BufSize);\r
   AsciiVSPrint (Buf, BufSize, FormatString, Marker);\r
   Status = XenStoreWrite (Transaction, DirectoryPath, Node, Buf);\r