]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/XenBusDxe/XenStore.c
IntelFsp2Pkg/SplitFspBin.py: Support rebasing 1.x binary.
[mirror_edk2.git] / OvmfPkg / XenBusDxe / XenStore.c
index fb00e7393bb10d82585e851a14e7c6c8e7e0f195..34890ae40bb2d48f5fc0eaee497a4c20861e34ba 100644 (file)
   This file may be distributed separately from the Linux kernel, or\r
   incorporated into other software packages, subject to the following license:\r
 \r
-  Permission is hereby granted, free of charge, to any person obtaining a copy\r
-  of this source file (the "Software"), to deal in the Software without\r
-  restriction, including without limitation the rights to use, copy, modify,\r
-  merge, publish, distribute, sublicense, and/or sell copies of the Software,\r
-  and to permit persons to whom the Software is furnished to do so, subject to\r
-  the following conditions:\r
-\r
-  The above copyright notice and this permission notice shall be included in\r
-  all copies or substantial portions of the Software.\r
-\r
-  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
-  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
-  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
-  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
-  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\r
-  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\r
-  IN THE SOFTWARE.\r
+  SPDX-License-Identifier: MIT\r
 **/\r
 \r
 #include "XenStore.h"\r
@@ -303,14 +287,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 +697,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 +1059,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 +1281,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