From 1055b68d0448744fa350238748b779472ad9af69 Mon Sep 17 00:00:00 2001 From: ywu21 Date: Wed, 10 Dec 2008 03:58:26 +0000 Subject: [PATCH] 1 update function header 2 update file header 3 correct some expression: Non-Boolean comparisons must use a compare operator 4 corrent some variable naming git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6960 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Universal/Network/IScsiDxe/IScsiMisc.c | 181 +++++++----------- 1 file changed, 65 insertions(+), 116 deletions(-) diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c index 7cbf362275..b967714d1b 100644 --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c +++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c @@ -1,7 +1,7 @@ /** @file Miscellaneous routines for IScsi driver. -Copyright (c) 2004 - 2008, Intel Corporation +Copyright (c) 2004 - 2008, Intel Corporation.
All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -10,14 +10,6 @@ http://opensource.org/licenses/bsd-license.php THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -Module Name: - - IScsiMisc.c - -Abstract: - - Miscellaneous routines for IScsi driver. - **/ #include "IScsiImpl.h" @@ -27,65 +19,62 @@ GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 IScsiHexString[] = "0123456789ABCDEFa /** Removes (trims) specified leading and trailing characters from a string. - @param str[in][out] Pointer to the null-terminated string to be trimmed. On return, - str will hold the trimmed string. - - @param CharC[in] Character will be trimmed from str. - - @retval NONE. + @param[in, out] Str Pointer to the null-terminated string to be trimmed. On return, + str will hold the trimmed string. + @param[in] CharC Character will be trimmed from str. **/ VOID StrTrim ( - IN OUT CHAR16 *str, + IN OUT CHAR16 *Str, IN CHAR16 CharC ) { - CHAR16 *p1; - CHAR16 *p2; + CHAR16 *Pointer1; + CHAR16 *Pointer2; - if (*str == 0) { + if (*Str == 0) { return; } // // Trim off the leading and trailing characters c // - for (p1 = str; *p1 && *p1 == CharC; p1++) { + for (Pointer1 = Str; (*Pointer1 != 0) && (*Pointer1 == CharC); Pointer1++) { ; } - p2 = str; - if (p2 == p1) { - while (*p1) { - p2++; - p1++; + Pointer2 = Str; + if (Pointer2 == Pointer1) { + while (*Pointer1 != 0) { + Pointer2++; + Pointer1++; } } else { - while (*p1) { - *p2 = *p1; - p1++; - p2++; + while (*Pointer1 != 0) { + *Pointer2 = *Pointer1; + Pointer1++; + Pointer2++; } - *p2 = 0; + *Pointer2 = 0; } - for (p1 = str + StrLen(str) - 1; p1 >= str && *p1 == CharC; p1--) { + for (Pointer1 = Str + StrLen(Str) - 1; Pointer1 >= Str && *Pointer1 == CharC; Pointer1--) { ; } - if (p1 != str + StrLen(str) - 1) { - *(p1 + 1) = 0; + if (Pointer1 != Str + StrLen(Str) - 1) { + *(Pointer1 + 1) = 0; } } /** Calculate the prefix length of the IPv4 subnet mask. - @param SubnetMask[in] The IPv4 subnet mask. - - @retval The prefix length of the subnet mask. + @param[in] SubnetMask The IPv4 subnet mask. + @return The prefix length of the subnet mask. + @return 0 Some unexpected error happened. **/ UINT8 IScsiGetSubnetMaskPrefixLength ( @@ -105,7 +94,7 @@ IScsiGetSubnetMaskPrefixLength ( // ReverseMask = ~ReverseMask; - if (ReverseMask & (ReverseMask + 1)) { + if ((ReverseMask != 0) & ((ReverseMask + 1) != 0)) { return 0; } @@ -122,14 +111,11 @@ IScsiGetSubnetMaskPrefixLength ( /** Convert the hexadecimal encoded LUN string into the 64-bit LUN. - @param Str[in] The hexadecimal encoded LUN string. - - @param Lun[out] Storage to return the 64-bit LUN. + @param[in] Str The hexadecimal encoded LUN string. + @param[out] Lun Storage to return the 64-bit LUN. @retval EFI_SUCCESS The 64-bit LUN is stored in Lun. - @retval EFI_INVALID_PARAMETER The string is malformatted. - **/ EFI_STATUS IScsiAsciiStrToLun ( @@ -192,12 +178,8 @@ IScsiAsciiStrToLun ( /** Convert the 64-bit LUN into the hexadecimal encoded LUN string. - @param Lun[in] The 64-bit LUN. - - @param Str[out] The storage to return the hexadecimal encoded LUN string. - - @retval None. - + @param[in] Lun The 64-bit LUN. + @param[out] Str The storage to return the hexadecimal encoded LUN string. **/ VOID IScsiLunToUnicodeStr ( @@ -242,12 +224,10 @@ IScsiLunToUnicodeStr ( /** Convert the ASCII string into a UNICODE string. - @param Source[out] The ASCII string. - - @param Destination[out] The storage to return the UNICODE string. - - @retval CHAR16 * Pointer to the UNICODE string. + @param[in] Source The ASCII string. + @param[out] Destination The storage to return the UNICODE string. + @return CHAR16 * Pointer to the UNICODE string. **/ CHAR16 * IScsiAsciiStrToUnicodeStr ( @@ -270,12 +250,11 @@ IScsiAsciiStrToUnicodeStr ( /** Convert the UNICODE string into an ASCII string. - @param Source[in] The UNICODE string. - - @param Destination[out] The storage to return the ASCII string. - - @retval CHAR8 * Pointer to the ASCII string. + @param[in] Source The UNICODE string. + @param[out] Destination The storage to return the ASCII string. + @return CHAR8 * Pointer to the ASCII string. +**/ **/ CHAR8 * IScsiUnicodeStrToAsciiStr ( @@ -303,14 +282,11 @@ IScsiUnicodeStrToAsciiStr ( /** Convert the decimal dotted IPv4 address into the binary IPv4 address. - @param Str[in] The UNICODE string. - - @param Ip[out] The storage to return the ASCII string. + @param[in] Str The UNICODE string. + @param[out] Ip The storage to return the ASCII string. @retval EFI_SUCCESS The binary IP address is returned in Ip. - @retval EFI_INVALID_PARAMETER The IP string is malformatted. - **/ EFI_STATUS IScsiAsciiStrToIp ( @@ -369,14 +345,9 @@ IScsiAsciiStrToIp ( /** Convert the mac address into a hexadecimal encoded "-" seperated string. - @param Mac[in] The mac address. - - @param Len[in] Length in bytes of the mac address. - - @param Str[out] The storage to return the mac string. - - @retval None. - + @param[in] Mac The mac address. + @param[in] Len Length in bytes of the mac address. + @param[out] Str The storage to return the mac string. **/ VOID IScsiMacAddrToStr ( @@ -399,19 +370,15 @@ IScsiMacAddrToStr ( /** Convert the binary encoded buffer into a hexadecimal encoded string. - @param BinBuffer[in] The buffer containing the binary data. - - @param BinLength[in] Length of the binary buffer. - - @param HexStr[in][out] Pointer to the string. - - @param HexLength[in][out] The length of the string. + @param[in] BinBuffer The buffer containing the binary data. + @param[in] BinLength Length of the binary buffer. + @param[in, out] HexStr Pointer to the string. + @param[in, out] HexLength The length of the string. @retval EFI_SUCCESS The binary data is converted to the hexadecimal string and the length of the string is updated. - @retval EFI_BUFFER_TOO_SMALL The string is too small. - + @retval EFI_INVALID_PARAMETER The IP string is malformatted. **/ EFI_STATUS IScsiBinToHex ( @@ -452,17 +419,13 @@ IScsiBinToHex ( /** Convert the hexadecimal string into a binary encoded buffer. - @param BinBuffer[in][out] The binary buffer. - - @param BinLength[in][out] Length of the binary buffer. - - @param HexStr[in] The hexadecimal string. + @param[in, out] BinBuffer The binary buffer. + @param[in, out] BinLength Length of the binary buffer. + @param[in] HexStr The hexadecimal string. @retval EFI_SUCCESS The hexadecimal string is converted into a binary encoded buffer. - @retval EFI_BUFFER_TOO_SMALL The binary buffer is too small to hold the converted data.s - **/ EFI_STATUS IScsiHexToBin ( @@ -525,12 +488,8 @@ IScsiHexToBin ( /** Generate random numbers. - @param Rand[in][out] The buffer to contain random numbers. - - @param RandLength[in] The length of the Rand buffer. - - @retval None. - + @param[in, out] Rand The buffer to contain random numbers. + @param[in] RandLength The length of the Rand buffer. **/ VOID IScsiGenRandom ( @@ -550,12 +509,11 @@ IScsiGenRandom ( /** Create the iSCSI driver data.. - @param Image[in] The handle of the driver image. - - @param Controller[in] The handle of the controller. - - @retval The iSCSI driver data created. + @param[in] Image The handle of the driver image. + @param[in] Controller The handle of the controller. + @return The iSCSI driver data created. + @return NULL Some unexpected error happened. **/ ISCSI_DRIVER_DATA * IScsiCreateDriverData ( @@ -625,10 +583,7 @@ IScsiCreateDriverData ( /** Clean the iSCSI driver data. - @param Private[in] The iSCSI driver data. - - @retval None. - + @param[in] Private The iSCSI driver data. **/ VOID IScsiCleanDriverData ( @@ -659,15 +614,13 @@ IScsiCleanDriverData ( } /** - Get the various configuration data of this iSCSI instance. - @param Private[in] The iSCSI driver data. + @param[in] Private The iSCSI driver data. @retval EFI_SUCCESS The configuration of this instance is got. - - @retval EFI_NOT_FOUND This iSCSI instance is not configured yet. - + @retval EFI_ABORTED The operation was aborted. + @retval Others Some unexpected error happened. **/ EFI_STATUS IScsiGetConfigData ( @@ -754,10 +707,10 @@ IScsiGetConfigData ( /** Get the device path of the iSCSI tcp connection and update it. - @param Private[in] The iSCSI driver data. - - @retval The updated device path. + @param[in] Private The iSCSI driver data. + @return The updated device path. + @return NULL Some unexpected error happened. **/ EFI_DEVICE_PATH_PROTOCOL * IScsiGetTcpConnDevicePath ( @@ -818,12 +771,8 @@ IScsiGetTcpConnDevicePath ( /** Abort the session when the transition from BS to RT is initiated. - @param Event[in] The event signaled. - - @param Context[in] The iSCSI driver data. - - @retval None. - + @param[in] Event The event signaled. + @param[in] Context The iSCSI driver data. **/ VOID EFIAPI