]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c
UefiCpuPkg/CpuMpPei: Fix wrong CpuData pointer
[mirror_edk2.git] / ShellPkg / Library / UefiShellTftpCommandLib / Tftp.c
index d2f7046de037cdcaacce7a7265f4cbd2ca4e3e0d..2dc9287020d7d7d9b43496d25b57188c70b57e78 100644 (file)
@@ -2,6 +2,8 @@
   The implementation for the 'tftp' Shell command.\r
 \r
   Copyright (c) 2015, ARM Ltd. All rights reserved.<BR>\r
+  Copyright (c) 2015, Intel Corporation. All rights reserved. <BR>\r
+  (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -14,6 +16,8 @@
 \r
 #include "UefiShellTftpCommandLib.h"\r
 \r
+#define IP4_CONFIG2_INTERFACE_INFO_NAME_LENGTH 32\r
+\r
 /*\r
    Constant strings and definitions related to the message indicating the amount of\r
    progress in the dowloading of a TFTP file.\r
@@ -59,7 +63,8 @@ StringToUint16 (
   @param[in]   NicNumber         The network physical device number.\r
   @param[out]  NicName           Address where to store the NIC name.\r
                                  The memory area has to be at least\r
-                                 IP4_NIC_NAME_LENGTH bytes wide.\r
+                                 IP4_CONFIG2_INTERFACE_INFO_NAME_LENGTH \r
+                                 double byte wide.\r
 \r
   @return  EFI_SUCCESS  The name of the NIC was returned.\r
   @return  Others       The creation of the child for the Managed\r
@@ -258,7 +263,7 @@ ShellCommandRunTftp (
   EFI_HANDLE              *Handles;\r
   UINTN                   HandleCount;\r
   UINTN                   NicNumber;\r
-  CHAR16                  NicName[IP4_NIC_NAME_LENGTH];\r
+  CHAR16                  NicName[IP4_CONFIG2_INTERFACE_INFO_NAME_LENGTH];\r
   EFI_HANDLE              ControllerHandle;\r
   EFI_HANDLE              Mtftp4ChildHandle;\r
   EFI_MTFTP4_PROTOCOL     *Mtftp4;\r
@@ -271,6 +276,7 @@ ShellCommandRunTftp (
   NicFound            = FALSE;\r
   AsciiRemoteFilePath = NULL;\r
   Handles             = NULL;\r
+  FileSize            = 0;\r
 \r
   //\r
   // Initialize the Shell library (we must be in non-auto-init...)\r
@@ -571,7 +577,7 @@ StringToUint16 (
     return FALSE;\r
   }\r
 \r
-  *Value = Val;\r
+  *Value = (UINT16)Val;\r
   return TRUE;\r
 }\r
 \r
@@ -582,7 +588,8 @@ StringToUint16 (
   @param[in]   NicNumber         The network physical device number.\r
   @param[out]  NicName           Address where to store the NIC name.\r
                                  The memory area has to be at least\r
-                                 IP4_NIC_NAME_LENGTH bytes wide.\r
+                                 IP4_CONFIG2_INTERFACE_INFO_NAME_LENGTH \r
+                                 double byte wide.\r
 \r
   @return  EFI_SUCCESS  The name of the NIC was returned.\r
   @return  Others       The creation of the child for the Managed\r
@@ -623,7 +630,7 @@ GetNicName (
 \r
   UnicodeSPrint (\r
     NicName,\r
-    IP4_NIC_NAME_LENGTH,\r
+    IP4_CONFIG2_INTERFACE_INFO_NAME_LENGTH,\r
     SnpMode.IfType == NET_IFTYPE_ETHERNET ?\r
     L"eth%d" :\r
     L"unk%d" ,\r
@@ -942,7 +949,7 @@ CheckPacket (
 {\r
   DOWNLOAD_CONTEXT  *Context;\r
   CHAR16            Progress[TFTP_PROGRESS_MESSAGE_SIZE];\r
-  UINT64            NbOfKb;\r
+  UINT            NbOfKb;\r
   UINTN             Index;\r
   UINTN             LastStep;\r
   UINTN             Step;\r
@@ -966,10 +973,9 @@ CheckPacket (
   NbOfKb = Context->DownloadedNbOfBytes / 1024;\r
 \r
   Progress[0] = L'\0';\r
-  LastStep  = (Context->LastReportedNbOfBytes * TFTP_PROGRESS_SLIDER_STEPS) /\r
-              Context->FileSize;\r
-  Step      = (Context->DownloadedNbOfBytes   * TFTP_PROGRESS_SLIDER_STEPS) /\r
-              Context->FileSize;\r
+  LastStep  = (Context->LastReportedNbOfBytes * TFTP_PROGRESS_SLIDER_STEPS) / Context->FileSize;\r
+  Step      = (Context->DownloadedNbOfBytes * TFTP_PROGRESS_SLIDER_STEPS) / Context->FileSize;\r
+\r
   if (Step <= LastStep) {\r
     return EFI_SUCCESS;\r
   }\r