]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Include/Library/NetLib.h
MdeModulePkg: Refine type cast for pointer subtraction
[mirror_edk2.git] / MdeModulePkg / Include / Library / NetLib.h
index 26709af091d1a77214fa1aa3a2e7ed635f4da04a..4cd42270f6c03d386497890e18afed71fd6f4ef5 100644 (file)
@@ -2,7 +2,7 @@
   This library is only intended to be used by UEFI network stack modules.\r
   It provides basic functions for the UEFI network stack.\r
 \r
-Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2005 - 2017, 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<BR>\r
@@ -523,6 +523,7 @@ extern IP4_ADDR gIp4AllMasks[IP4_MASK_NUM];
 extern EFI_IPv4_ADDRESS  mZeroIp4Addr;\r
 \r
 #define NET_IS_DIGIT(Ch)            (('0' <= (Ch)) && ((Ch) <= '9'))\r
+#define NET_IS_HEX(Ch)              ((('0' <= (Ch)) && ((Ch) <= '9')) || (('A' <= (Ch)) && ((Ch) <= 'F')) || (('a' <= (Ch)) && ((Ch) <= 'f')))\r
 #define NET_ROUNDUP(size, unit)     (((size) + (unit) - 1) & (~((unit) - 1)))\r
 #define NET_IS_LOWER_CASE_CHAR(Ch)  (('a' <= (Ch)) && ((Ch) <= 'z'))\r
 #define NET_IS_UPPER_CASE_CHAR(Ch)  (('A' <= (Ch)) && ((Ch) <= 'Z'))\r
@@ -1390,7 +1391,6 @@ NetLibAsciiStrToIp6 (
 \r
   @retval EFI_SUCCESS            Converted to an IPv4 address successfully.\r
   @retval EFI_INVALID_PARAMETER  The string is mal-formatted or Ip4Address is NULL.\r
-  @retval EFI_OUT_OF_RESOURCES   Failed to perform the operation due to lack of resources.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -1409,7 +1409,6 @@ NetLibStrToIp4 (
 \r
   @retval EFI_SUCCESS            Converted to an IPv6 address successfully.\r
   @retval EFI_INVALID_PARAMETER  The string is malformatted or Ip6Address is NULL.\r
-  @retval EFI_OUT_OF_RESOURCES   Failed to perform the operation due to a lack of resources.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -1430,7 +1429,6 @@ NetLibStrToIp6 (
 \r
   @retval EFI_SUCCESS            Converted to an  IPv6 address successfully.\r
   @retval EFI_INVALID_PARAMETER  The string is malformatted, or Ip6Address is NULL.\r
-  @retval EFI_OUT_OF_RESOURCES   Failed to perform the operation due to a lack of resources.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -1609,10 +1607,10 @@ typedef struct {
   (sizeof (NET_BUF) + ((BlockOpNum) - 1) * sizeof (NET_BLOCK_OP))\r
 \r
 #define NET_HEADSPACE(BlockOp)  \\r
-  (UINTN)((BlockOp)->Head - (BlockOp)->BlockHead)\r
+  ((UINTN)((BlockOp)->Head) - (UINTN)((BlockOp)->BlockHead))\r
 \r
 #define NET_TAILSPACE(BlockOp)  \\r
-  (UINTN)((BlockOp)->BlockTail - (BlockOp)->Tail)\r
+  ((UINTN)((BlockOp)->BlockTail) - (UINTN)((BlockOp)->Tail))\r
 \r
 /**\r
   Allocate a single block NET_BUF. Upon allocation, all the\r