]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/DxeNetLib/NetBuffer.c
MdeModulePkg/DxeNetLib: Rewrite NetblockChecksum function logic
[mirror_edk2.git] / MdeModulePkg / Library / DxeNetLib / NetBuffer.c
index bbbdbc048aedc45acacc1b462f57e20d1beb69e1..95cb71714b5bbb3afdd748db3415e6f065809ee5 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Network library functions providing net buffer operation support.\r
 \r
-Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -1661,19 +1661,19 @@ NetblockChecksum (
 \r
   Sum = 0;\r
 \r
+  //\r
+  // Add left-over byte, if any\r
+  //\r
+  if (Len % 2 != 0) {\r
+    Sum += *(Bulk + Len - 1);\r
+  }\r
+\r
   while (Len > 1) {\r
     Sum += *(UINT16 *) Bulk;\r
     Bulk += 2;\r
     Len -= 2;\r
   }\r
 \r
-  //\r
-  // Add left-over byte, if any\r
-  //\r
-  if (Len > 0) {\r
-    Sum += *(UINT8 *) Bulk;\r
-  }\r
-\r
   //\r
   // Fold 32-bit sum to 16 bits\r
   //\r