[edk2] [Patch 3/4] NetworkPkg: Fix some coding style issues in UDP6 driver

fanwang2 posted 4 patches 6 years, 11 months ago
[edk2] [Patch 3/4] NetworkPkg: Fix some coding style issues in UDP6 driver
Posted by fanwang2 6 years, 11 months ago
From: Wang Fan <fan.wang@intel.com>

In UDP6Dxe, there are some coding style issues, this patch
is to fix these issues.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
---
 NetworkPkg/Udp6Dxe/Udp6Driver.c | 20 ++++++++++----------
 NetworkPkg/Udp6Dxe/Udp6Impl.c   | 10 ++++++----
 NetworkPkg/Udp6Dxe/Udp6Main.c   |  2 +-
 3 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/NetworkPkg/Udp6Dxe/Udp6Driver.c b/NetworkPkg/Udp6Dxe/Udp6Driver.c
index a4b1104..6dde1fc 100644
--- a/NetworkPkg/Udp6Dxe/Udp6Driver.c
+++ b/NetworkPkg/Udp6Dxe/Udp6Driver.c
@@ -1,9 +1,9 @@
 /** @file
   Driver Binding functions and Service Binding functions for the Network driver module.
 
-  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
 
   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
   http://opensource.org/licenses/bsd-license.php.
@@ -162,11 +162,10 @@ Udp6DriverBindingStart (
                   &Udp6Service->ServiceBinding,
                   NULL
                   );
   if (EFI_ERROR (Status)) {
     Udp6CleanService (Udp6Service);
-    goto EXIT;
   }
 
 EXIT:
   if (EFI_ERROR (Status)) {
     if (Udp6Service != NULL) {
@@ -180,12 +179,13 @@ EXIT:
   Callback function which provided by user to remove one node in NetDestroyLinkList process.
   
   @param[in]    Entry           The entry to be removed.
   @param[in]    Context         Pointer to the callback context corresponds to the Context in NetDestroyLinkList.
 
-  @retval EFI_SUCCESS           The entry has been removed successfully.
-  @retval Others                Fail to remove the entry.
+  @retval EFI_INVALID_PARAMETER  Entry is NULL or Context is NULL.
+  @retval EFI_SUCCESS            The entry has been removed successfully.
+  @retval Others                 Fail to remove the entry.
 
 **/
 EFI_STATUS
 EFIAPI
 Udp6DestroyChildEntryInHandleBuffer (
@@ -241,16 +241,16 @@ Udp6DriverBindingStop (
   IN  EFI_HANDLE                   ControllerHandle,
   IN  UINTN                        NumberOfChildren,
   IN  EFI_HANDLE                   *ChildHandleBuffer OPTIONAL
   )
 {
-  EFI_STATUS                    Status;
-  EFI_HANDLE                    NicHandle;
-  EFI_SERVICE_BINDING_PROTOCOL  *ServiceBinding;
-  UDP6_SERVICE_DATA             *Udp6Service;
-  LIST_ENTRY                    *List;
-  UDP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT Context;
+  EFI_STATUS                                Status;
+  EFI_HANDLE                                NicHandle;
+  EFI_SERVICE_BINDING_PROTOCOL              *ServiceBinding;
+  UDP6_SERVICE_DATA                         *Udp6Service;
+  LIST_ENTRY                                *List;
+  UDP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT  Context;
 
   //
   // Find the NicHandle where UDP6 ServiceBinding Protocol is installed.
   //
   NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiIp6ProtocolGuid);
diff --git a/NetworkPkg/Udp6Dxe/Udp6Impl.c b/NetworkPkg/Udp6Dxe/Udp6Impl.c
index 25d4e6a..458470c 100644
--- a/NetworkPkg/Udp6Dxe/Udp6Impl.c
+++ b/NetworkPkg/Udp6Dxe/Udp6Impl.c
@@ -156,11 +156,12 @@ Udp6RecycleRxDataWrap (
   @param[in]  Packet             Pointer to the buffer containing the received
                                  datagram.
   @param[in]  RxData             Pointer to the EFI_UDP6_RECEIVE_DATA of this
                                  datagram.
 
-  @return Pointer to the structure wrapping the RxData and the Packet.
+  @return Pointer to the structure wrapping the RxData and the Packet. NULL will
+          be returned if any error occurs.
 
 **/
 UDP6_RXDATA_WRAP *
 Udp6WrapRxData (
   IN UDP6_INSTANCE_DATA     *Instance,
@@ -1372,11 +1373,12 @@ Udp6RecycleRxDataWrap (
   @param[in]  Packet             Pointer to the buffer containing the received
                                  datagram.
   @param[in]  RxData             Pointer to the EFI_UDP6_RECEIVE_DATA of this
                                  datagram.
 
-  @return Pointer to the structure wrapping the RxData and the Packet.
+  @return Pointer to the structure wrapping the RxData and the Packet. NULL will
+          be returned if any error occurs.
 
 **/
 UDP6_RXDATA_WRAP *
 Udp6WrapRxData (
   IN UDP6_INSTANCE_DATA     *Instance,
@@ -1596,11 +1598,11 @@ Udp6Demultiplex (
   UINT16                 HeadSum;
   EFI_UDP6_RECEIVE_DATA  RxData;
   EFI_UDP6_SESSION_DATA  *Udp6Session;
   UINTN                  Enqueued;
 
-  if (Packet->TotalSize < sizeof (EFI_UDP_HEADER)) {
+  if (Packet->TotalSize < UDP6_HEADER_SIZE) {
     NetbufFree (Packet);
     return;
   }
   
   //
@@ -1848,11 +1850,11 @@ Udp6IcmpHandler (
   EFI_UDP_HEADER         *Udp6Header;
   EFI_UDP6_SESSION_DATA  Udp6Session;
   LIST_ENTRY             *Entry;
   UDP6_INSTANCE_DATA     *Instance;
 
-  if (Packet->TotalSize < sizeof (EFI_UDP_HEADER)) {
+  if (Packet->TotalSize < UDP6_HEADER_SIZE) {
     NetbufFree (Packet);
     return;
   }
   
   Udp6Header = (EFI_UDP_HEADER *) NetbufGetByte (Packet, 0, NULL);
diff --git a/NetworkPkg/Udp6Dxe/Udp6Main.c b/NetworkPkg/Udp6Dxe/Udp6Main.c
index 8495bc3..53145c3 100644
--- a/NetworkPkg/Udp6Dxe/Udp6Main.c
+++ b/NetworkPkg/Udp6Dxe/Udp6Main.c
@@ -583,11 +583,11 @@ Udp6Transmit (
       Udp6Header->Checksum = Udp6Checksum (Packet, HeadSum);
       if (Udp6Header->Checksum == 0) {
         //
         // If the calculated checksum is 0, fill the Checksum field with all ones.
         //
-        Udp6Header->Checksum = 0XFFFF;
+        Udp6Header->Checksum = 0xffff;
       }
     } else {
       //
       // Set the checksum is zero if the ConfigData->StationAddress is unspcified
       // and the Ipv6 will fill the correct value of this checksum.
-- 
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel