]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkModulePkg/Universal/Network/PxeBc/Dxe/pxe_loadfile.c
Partially make EdkModulePkg pass intel IPF compiler with /W4 /WX switched on.
[mirror_edk2.git] / EdkModulePkg / Universal / Network / PxeBc / Dxe / pxe_loadfile.c
index 8897bc726e40be438370b739cd204bb629882829..6659bc4022cb08d880179d6191e125ea0e88a464 100644 (file)
@@ -18,7 +18,7 @@ Abstract:
 --*/\r
 \r
 \r
-#include "bc.h"\r
+#include "Bc.h"\r
 \r
 #define DO_MENU     (EFI_SUCCESS)\r
 #define NO_MENU     (DO_MENU + 1)\r
@@ -393,24 +393,23 @@ Returns:
     if (gST->ConIn->ReadKeyStroke (gST->ConIn, &Key) == EFI_NOT_READY) {\r
       UINT8       Buffer[512];\r
       UINTN       BufferSize;\r
-      EFI_STATUS  Status;\r
 \r
       BufferSize = sizeof Buffer;\r
 \r
-      Status = Private->EfiBc.UdpRead (\r
-                                &Private->EfiBc,\r
-                                EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_IP |\r
-                                EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_PORT |\r
-                                EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_PORT,\r
-                                NULL, /* dest ip */\r
-                                NULL, /* dest port */\r
-                                NULL, /* src ip */\r
-                                NULL, /* src port */\r
-                                NULL, /* hdr size */\r
-                                NULL, /* hdr ptr */\r
-                                &BufferSize,\r
-                                Buffer\r
-                                );\r
+      Private->EfiBc.UdpRead (\r
+                       &Private->EfiBc,\r
+                       EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_IP |\r
+                       EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_PORT |\r
+                       EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_PORT,\r
+                       NULL, /* dest ip */\r
+                       NULL, /* dest port */\r
+                       NULL, /* src ip */\r
+                       NULL, /* src port */\r
+                       NULL, /* hdr size */\r
+                       NULL, /* hdr ptr */\r
+                       &BufferSize,\r
+                       Buffer\r
+                       );\r
 \r
       continue;\r
     }\r
@@ -870,6 +869,7 @@ Returns:
   return NULL;\r
 }\r
 \r
+STATIC\r
 UINT8 *\r
 PxeBcFindDhcpOpt (\r
   EFI_PXE_BASE_CODE_PACKET  *PacketPtr,\r
@@ -1088,7 +1088,6 @@ Returns:
 \r
   if (Private->EfiBc.Mode->BisSupported && Private->EfiBc.Mode->BisDetected && Private->EfiBc.Mode->PxeBisReplyReceived) {\r
     UINT64  CredentialLen;\r
-    UINTN   BlockSize;\r
     UINT8   CredentialFilename[256];\r
     UINT8   *op;\r
     VOID    *CredentialBuffer;\r
@@ -1398,11 +1397,6 @@ Returns:
 \r
   AsciiPrint ("Running LoadFile()\n");\r
 \r
-  //\r
-  // Resolve Warning 4 unreferenced parameter problem\r
-  //\r
-  FilePath = NULL;\r
-\r
   //\r
   // If either if these parameters are NULL, we cannot continue.\r
   //\r
@@ -1456,15 +1450,12 @@ Returns:
                   (VOID *) &LoadfilePtr->Private->CallbackProtocolPtr\r
                   );\r
 \r
-  switch (Status) {\r
-  case EFI_SUCCESS:\r
+  if (Status == EFI_SUCCESS) {\r
     //\r
     // There is already a callback routine.  Do nothing.\r
     //\r
     DEBUG ((EFI_D_WARN, "\nLoadFile()  BC callback exists."));\r
-    break;\r
-\r
-  case EFI_UNSUPPORTED:\r
+  } else if (Status == EFI_UNSUPPORTED) {\r
     //\r
     // No BaseCode Callback protocol found.  Add our own.\r
     //\r
@@ -1490,10 +1481,7 @@ Returns:
                                     &NewMakeCallback\r
                                     );\r
     }\r
-\r
-    break;\r
-\r
-  default:\r
+  } else {\r
     DEBUG ((EFI_D_WARN, "\nLoadFile()  Callback check status == %xh", Status));\r
   }\r
   //\r
@@ -1578,11 +1566,11 @@ Returns:
 \r
   DEBUG ((EFI_D_WARN, "\nBC.Loadfile()  Status == %xh\n", Status));\r
 \r
-  switch (Status) {\r
-  case EFI_SUCCESS:           /* 0 */\r
+  if (Status == EFI_SUCCESS) {\r
+    /* 0 */\r
     return EFI_SUCCESS;\r
-\r
-  case EFI_BUFFER_TOO_SMALL:  /* 5 */\r
+  } else if (Status == EFI_BUFFER_TOO_SMALL) {\r
+    /* 5 */\r
     //\r
     // Error is only displayed when we are actually trying to\r
     // download the boot image.\r
@@ -1590,104 +1578,81 @@ Returns:
     if (Buffer == NULL) {\r
       return EFI_BUFFER_TOO_SMALL;\r
     }\r
-\r
     AsciiPrint ("\nPXE-E05: Download buffer is smaller than requested file.\n");\r
-    break;\r
-\r
-  case EFI_DEVICE_ERROR:      /* 7 */\r
+  } else if (Status == EFI_DEVICE_ERROR) {\r
+    /* 7 */\r
     AsciiPrint ("\nPXE-E07: Network device error.  Check network connection.\n");\r
-    break;\r
-\r
-  case EFI_OUT_OF_RESOURCES:  /* 9 */\r
+  } else if (Status == EFI_OUT_OF_RESOURCES) {\r
+    /* 9 */\r
     AsciiPrint ("\nPXE-E09: Could not allocate I/O buffers.\n");\r
-    break;\r
-\r
-  case EFI_NO_MEDIA:          /* 12 */\r
+  } else if (Status == EFI_NO_MEDIA) {\r
+    /* 12 */\r
     AsciiPrint ("\nPXE-E12: Could not detect network connection.  Check cable.\n");\r
-    break;\r
-\r
-  case EFI_NO_RESPONSE:       /* 16 */\r
+  } else if (Status == EFI_NO_RESPONSE) {\r
+    /* 16 */\r
     AsciiPrint ("\nPXE-E16: Valid PXE offer not received.\n");\r
-    break;\r
-\r
-  case EFI_TIMEOUT:           /* 18 */\r
+  } else if (Status == EFI_TIMEOUT) {\r
+    /* 18 */\r
     AsciiPrint ("\nPXE-E18: Timeout.  Server did not respond.\n");\r
-    break;\r
-\r
-  case EFI_ABORTED:           /* 21 */\r
+  } else if (Status == EFI_ABORTED) {\r
+    /* 21 */\r
     AsciiPrint ("\nPXE-E21: Remote boot cancelled.\n");\r
-    break;\r
-\r
-  case EFI_ICMP_ERROR:        /* 22 */\r
+  } else if (Status == EFI_ICMP_ERROR) {\r
+    /* 22 */\r
     AsciiPrint ("\nPXE-E22: Client received ICMP error from server.\n");\r
 \r
-    if (LoadfilePtr->Private->EfiBc.Mode == NULL) {\r
-      break;\r
-    }\r
-\r
-    if (!LoadfilePtr->Private->EfiBc.Mode->IcmpErrorReceived) {\r
-      break;\r
-    }\r
+    if ((LoadfilePtr->Private->EfiBc.Mode != NULL) && LoadfilePtr->Private->EfiBc.Mode->IcmpErrorReceived) {\r
+      AsciiPrint (\r
+        "PXE-E98: Type: %xh  Code: %xh  ",\r
+        LoadfilePtr->Private->EfiBc.Mode->IcmpError.Type,\r
+        LoadfilePtr->Private->EfiBc.Mode->IcmpError.Code\r
+        );\r
 \r
-    AsciiPrint (\r
-      "PXE-E98: Type: %xh  Code: %xh  ",\r
-      LoadfilePtr->Private->EfiBc.Mode->IcmpError.Type,\r
-      LoadfilePtr->Private->EfiBc.Mode->IcmpError.Code\r
-      );\r
+      switch (LoadfilePtr->Private->EfiBc.Mode->IcmpError.Type) {\r
+      case 0x03:\r
+        switch (LoadfilePtr->Private->EfiBc.Mode->IcmpError.Code) {\r
+        case 0x00:              /* net unreachable */\r
+          AsciiPrint ("Net unreachable");\r
+          break;\r
 \r
-    switch (LoadfilePtr->Private->EfiBc.Mode->IcmpError.Type) {\r
-    case 0x03:\r
-      switch (LoadfilePtr->Private->EfiBc.Mode->IcmpError.Code) {\r
-      case 0x00:              /* net unreachable */\r
-        AsciiPrint ("Net unreachable");\r
-        break;\r
+        case 0x01:              /* host unreachable */\r
+          AsciiPrint ("Host unreachable");\r
+          break;\r
 \r
-      case 0x01:              /* host unreachable */\r
-        AsciiPrint ("Host unreachable");\r
-        break;\r
+        case 0x02:              /* protocol unreachable */\r
+          AsciiPrint ("Protocol unreachable");\r
+          break;\r
 \r
-      case 0x02:              /* protocol unreachable */\r
-        AsciiPrint ("Protocol unreachable");\r
-        break;\r
+        case 0x03:              /* port unreachable */\r
+          AsciiPrint ("Port unreachable");\r
+          break;\r
 \r
-      case 0x03:              /* port unreachable */\r
-        AsciiPrint ("Port unreachable");\r
-        break;\r
+        case 0x04:              /* Fragmentation needed */\r
+          AsciiPrint ("Fragmentation needed");\r
+          break;\r
 \r
-      case 0x04:              /* Fragmentation needed */\r
-        AsciiPrint ("Fragmentation needed");\r
-        break;\r
+        case 0x05:              /* Source route failed */\r
+          AsciiPrint ("Source route failed");\r
+          break;\r
+        }\r
 \r
-      case 0x05:              /* Source route failed */\r
-        AsciiPrint ("Source route failed");\r
         break;\r
       }\r
 \r
-      break;\r
+      AsciiPrint ("\n");\r
     }\r
-\r
-    AsciiPrint ("\n");\r
-\r
-    break;\r
-\r
-  case EFI_TFTP_ERROR:        /* 23 */\r
+  } else if (Status == EFI_TFTP_ERROR) {\r
+    /* 23 */\r
     AsciiPrint ("\nPXE-E23: Client received TFTP error from server.\n");\r
 \r
-    if (LoadfilePtr->Private->EfiBc.Mode == NULL) {\r
-      break;\r
-    }\r
-\r
-    if (LoadfilePtr->Private->EfiBc.Mode->TftpErrorReceived) {\r
+    if ((LoadfilePtr->Private->EfiBc.Mode != NULL) && (LoadfilePtr->Private->EfiBc.Mode->TftpErrorReceived)) {\r
       AsciiPrint (\r
         "PXE-E98: Code: %xh  %a\n",\r
         LoadfilePtr->Private->EfiBc.Mode->TftpError.ErrorCode,\r
         LoadfilePtr->Private->EfiBc.Mode->TftpError.ErrorString\r
         );\r
     }\r
-\r
-    break;\r
-\r
-  default:\r
+  } else {\r
     AsciiPrint ("\nPXE-E99: Unexpected network error: %xh\n", Status);\r
   }\r
 \r