[edk2,edk2-staging,19/19] IntelUndiPkg/GigUndiDxe: remove or reorganize unused variables

Message ID 20181106175833.26964-20-ard.biesheuvel@linaro.org
State New
Headers show
Series
  • IntelUndiPkg/GigUndiDxe: build fixes for AARCH64/ARM/GCC
Related show

Commit Message

Ard Biesheuvel Nov. 6, 2018, 5:58 p.m.
Drop variables that are assigned but never used, or move them into
a conditional preprocessor block if the only references occur from
such code.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

---
 IntelUndiPkg/GigUndiDxe/DriverDiagnostics.c |  2 --
 IntelUndiPkg/GigUndiDxe/HiiInternalLib.c    |  2 --
 IntelUndiPkg/GigUndiDxe/e1000.c             | 16 +++++++---------
 3 files changed, 7 insertions(+), 13 deletions(-)

-- 
2.19.1

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

Comments

Philippe Mathieu-Daudé Nov. 7, 2018, 9:08 a.m. | #1
On 6/11/18 18:58, Ard Biesheuvel wrote:
> Drop variables that are assigned but never used, or move them into
> a conditional preprocessor block if the only references occur from
> such code.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
>   IntelUndiPkg/GigUndiDxe/DriverDiagnostics.c |  2 --
>   IntelUndiPkg/GigUndiDxe/HiiInternalLib.c    |  2 --
>   IntelUndiPkg/GigUndiDxe/e1000.c             | 16 +++++++---------
>   3 files changed, 7 insertions(+), 13 deletions(-)
> 
> diff --git a/IntelUndiPkg/GigUndiDxe/DriverDiagnostics.c b/IntelUndiPkg/GigUndiDxe/DriverDiagnostics.c
> index f6152cd24c59..af8aaa797e68 100644
> --- a/IntelUndiPkg/GigUndiDxe/DriverDiagnostics.c
> +++ b/IntelUndiPkg/GigUndiDxe/DriverDiagnostics.c
> @@ -1123,11 +1123,9 @@ GigUndiRunPhyLoopback (
>     UINT64           FreeTxBuffer[DEFAULT_TX_DESCRIPTORS];
>     UINT32           j;
>     UINT32           i;
> -  struct e1000_hw *Hw;
>   
>     Status  = EFI_SUCCESS;
>     j       = 0;
> -  Hw = &GigAdapterInfo->Hw;
>   
>     while (j < PHY_LOOPBACK_ITERATIONS) {
>       Status = E1000Transmit (
> diff --git a/IntelUndiPkg/GigUndiDxe/HiiInternalLib.c b/IntelUndiPkg/GigUndiDxe/HiiInternalLib.c
> index 2aacb63ca158..690d8314be74 100644
> --- a/IntelUndiPkg/GigUndiDxe/HiiInternalLib.c
> +++ b/IntelUndiPkg/GigUndiDxe/HiiInternalLib.c
> @@ -197,7 +197,6 @@ GetNextRequestElement (
>     )
>   {
>     EFI_STRING StringPtr;
> -  EFI_STRING TmpPtr;
>     EFI_STATUS Status;
>     UINTN      Length;
>     UINT8 *    TmpBuffer;
> @@ -227,7 +226,6 @@ GetNextRequestElement (
>     }
>   
>     // Back up the header of one <BlockName>
> -  TmpPtr = StringPtr;
>   
>     StringPtr += StrLen (L"OFFSET=");
>   
> diff --git a/IntelUndiPkg/GigUndiDxe/e1000.c b/IntelUndiPkg/GigUndiDxe/e1000.c
> index 28c900e3ad63..3d4a21c62d77 100644
> --- a/IntelUndiPkg/GigUndiDxe/e1000.c
> +++ b/IntelUndiPkg/GigUndiDxe/e1000.c
> @@ -412,7 +412,6 @@ E1000Transmit (
>     E1000_TRANSMIT_DESCRIPTOR  *TransmitDescriptor;
>     UINT32                      i;
>     INT16                       WaitMsec;
> -  EFI_STATUS                  Status;
>     UNDI_DMA_MAPPING            *TxBufMapping;
>   
>     TxBufMapping = &GigAdapter->TxBufferMappings[GigAdapter->CurTxInd];
> @@ -483,7 +482,7 @@ E1000Transmit (
>       TxBufMapping->Size = TxBuffer->DataLen + TxBuffer->MediaheaderLen;
>   
>       // Make the Tx buffer accessible for adapter over DMA
> -    Status = UndiDmaMapMemoryRead (
> +    UndiDmaMapMemoryRead (
>                  GigAdapter->PciIo,
>                  TxBufMapping
>                  );
> @@ -594,20 +593,21 @@ E1000Receive (
>     E1000_RECEIVE_DESCRIPTOR *ReceiveDescriptor;
>     ETHER_HEADER *            EtherHeader;
>     PXE_STATCODE              StatCode;
> -  UINT16                    i;
>     UINT16                    TempLen;
> +#if (DBG_LVL & RX)
> +  UINT16                    i;
>     UINT8 *                   PacketPtr;
>   #if (DBG_LVL & CRITICAL)
> -#if (DBG_LVL & RX)
>     UINT32 Rdh;
>     UINT32 Rdt;
> -#endif /* (DBG_LVL & RX) */
> +
>   #endif /* (DBG_LVL & CRITICAL) */
> +  i           = 0;
> +#endif /* (DBG_LVL & RX) */

This context is easier to understand when looking at the whole function.
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

>   
>   
>     PacketType  = PXE_FRAME_TYPE_NONE;
>     StatCode    = PXE_STATCODE_NO_DATA;
> -  i           = 0;
>   
>     // acknowledge the interrupts
>     E1000_READ_REG (&GigAdapter->Hw, E1000_ICR);
> @@ -679,9 +679,9 @@ E1000Receive (
>           TempLen
>         );
>   
> +#if (DBG_LVL & RX)
>         PacketPtr = (UINT8 *) (UINTN) CpbReceive->BufferAddr;
>   
> -#if (DBG_LVL & RX)
>         DEBUGPRINT (RX, ("Packet Data \n"));
>         for (i = 0; i < TempLen; i++) {
>           DEBUGPRINT (RX, ("%x ", PacketPtr[i]));
> @@ -1569,13 +1569,11 @@ E1000Inititialize (
>     GIG_DRIVER_DATA *GigAdapter
>     )
>   {
> -  UINT32 *     TempBar;
>     PXE_STATCODE PxeStatcode;
>   
>     DEBUGPRINT (E1000, ("E1000Inititialize\n"));
>   
>     PxeStatcode = PXE_STATCODE_SUCCESS;
> -  TempBar = NULL;
>   
>     ZeroMem (
>       (VOID *)(UINTN)GigAdapter->RxRing.UnmappedAddress,
>
Ryszard Knop Jan. 30, 2019, 2:32 p.m. | #2
Just one thing - in E1000Receive, the removed Status is actually
needed, we've missed the error handling block in 1G while backporting
DMA changes from 40G drivers.

Reviewed-by: Ryszard Knop <ryszard.knop@linux.intel.com>


On Tue, 2018-11-06 at 18:58 +0100, ard.biesheuvela wrote:
> Drop variables that are assigned but never used, or move them into

> a conditional preprocessor block if the only references occur from

> such code.

> 

> Contributed-under: TianoCore Contribution Agreement 1.1

> Signed-off-by: Ard Biesheuvel <ard.biesheuvel at linaro.org>

> ---

>  IntelUndiPkg/GigUndiDxe/DriverDiagnostics.c |  2 --

>  IntelUndiPkg/GigUndiDxe/HiiInternalLib.c    |  2 --

>  IntelUndiPkg/GigUndiDxe/e1000.c             | 16 +++++++---------

>  3 files changed, 7 insertions(+), 13 deletions(-)

> 

> diff --git a/IntelUndiPkg/GigUndiDxe/DriverDiagnostics.c

> b/IntelUndiPkg/GigUndiDxe/DriverDiagnostics.c

> index f6152cd24c59..af8aaa797e68 100644

> --- a/IntelUndiPkg/GigUndiDxe/DriverDiagnostics.c

> +++ b/IntelUndiPkg/GigUndiDxe/DriverDiagnostics.c

> @@ -1123,11 +1123,9 @@ GigUndiRunPhyLoopback (

>    UINT64           FreeTxBuffer[DEFAULT_TX_DESCRIPTORS];

>    UINT32           j;

>    UINT32           i;

> -  struct e1000_hw *Hw;

>  

>    Status  = EFI_SUCCESS;

>    j       = 0;

> -  Hw = &GigAdapterInfo->Hw;

>  

>    while (j < PHY_LOOPBACK_ITERATIONS) {

>      Status = E1000Transmit (

> diff --git a/IntelUndiPkg/GigUndiDxe/HiiInternalLib.c

> b/IntelUndiPkg/GigUndiDxe/HiiInternalLib.c

> index 2aacb63ca158..690d8314be74 100644

> --- a/IntelUndiPkg/GigUndiDxe/HiiInternalLib.c

> +++ b/IntelUndiPkg/GigUndiDxe/HiiInternalLib.c

> @@ -197,7 +197,6 @@ GetNextRequestElement (

>    )

>  {

>    EFI_STRING StringPtr;

> -  EFI_STRING TmpPtr;

>    EFI_STATUS Status;

>    UINTN      Length;

>    UINT8 *    TmpBuffer;

> @@ -227,7 +226,6 @@ GetNextRequestElement (

>    }

>  

>    // Back up the header of one <BlockName>

> -  TmpPtr = StringPtr;

>  

>    StringPtr += StrLen (L"OFFSET=");

>  

> diff --git a/IntelUndiPkg/GigUndiDxe/e1000.c

> b/IntelUndiPkg/GigUndiDxe/e1000.c

> index 28c900e3ad63..3d4a21c62d77 100644

> --- a/IntelUndiPkg/GigUndiDxe/e1000.c

> +++ b/IntelUndiPkg/GigUndiDxe/e1000.c

> @@ -412,7 +412,6 @@ E1000Transmit (

>    E1000_TRANSMIT_DESCRIPTOR  *TransmitDescriptor;

>    UINT32                      i;

>    INT16                       WaitMsec;

> -  EFI_STATUS                  Status;

>    UNDI_DMA_MAPPING            *TxBufMapping;

>  

>    TxBufMapping = &GigAdapter->TxBufferMappings[GigAdapter-

> >CurTxInd];

> @@ -483,7 +482,7 @@ E1000Transmit (

>      TxBufMapping->Size = TxBuffer->DataLen + TxBuffer-

> >MediaheaderLen;

>  

>      // Make the Tx buffer accessible for adapter over DMA

> -    Status = UndiDmaMapMemoryRead (

> +    UndiDmaMapMemoryRead (

>                 GigAdapter->PciIo,

>                 TxBufMapping

>                 );

> @@ -594,20 +593,21 @@ E1000Receive (

>    E1000_RECEIVE_DESCRIPTOR *ReceiveDescriptor;

>    ETHER_HEADER *            EtherHeader;

>    PXE_STATCODE              StatCode;

> -  UINT16                    i;

>    UINT16                    TempLen;

> +#if (DBG_LVL & RX)

> +  UINT16                    i;

>    UINT8 *                   PacketPtr;

>  #if (DBG_LVL & CRITICAL)

> -#if (DBG_LVL & RX)

>    UINT32 Rdh;

>    UINT32 Rdt;

> -#endif /* (DBG_LVL & RX) */

> +

>  #endif /* (DBG_LVL & CRITICAL) */

> +  i           = 0;

> +#endif /* (DBG_LVL & RX) */

>  

>  

>    PacketType  = PXE_FRAME_TYPE_NONE;

>    StatCode    = PXE_STATCODE_NO_DATA;

> -  i           = 0;

>  

>    // acknowledge the interrupts

>    E1000_READ_REG (&GigAdapter->Hw, E1000_ICR);

> @@ -679,9 +679,9 @@ E1000Receive (

>          TempLen

>        );

>  

> +#if (DBG_LVL & RX)

>        PacketPtr = (UINT8 *) (UINTN) CpbReceive->BufferAddr;

>  

> -#if (DBG_LVL & RX)

>        DEBUGPRINT (RX, ("Packet Data \n"));

>        for (i = 0; i < TempLen; i++) {

>          DEBUGPRINT (RX, ("%x ", PacketPtr[i]));

> @@ -1569,13 +1569,11 @@ E1000Inititialize (

>    GIG_DRIVER_DATA *GigAdapter

>    )

>  {

> -  UINT32 *     TempBar;

>    PXE_STATCODE PxeStatcode;

>  

>    DEBUGPRINT (E1000, ("E1000Inititialize\n"));

>  

>    PxeStatcode = PXE_STATCODE_SUCCESS;

> -  TempBar = NULL;

>  

>    ZeroMem (

>      (VOID *)(UINTN)GigAdapter->RxRing.UnmappedAddress,


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

Patch

diff --git a/IntelUndiPkg/GigUndiDxe/DriverDiagnostics.c b/IntelUndiPkg/GigUndiDxe/DriverDiagnostics.c
index f6152cd24c59..af8aaa797e68 100644
--- a/IntelUndiPkg/GigUndiDxe/DriverDiagnostics.c
+++ b/IntelUndiPkg/GigUndiDxe/DriverDiagnostics.c
@@ -1123,11 +1123,9 @@  GigUndiRunPhyLoopback (
   UINT64           FreeTxBuffer[DEFAULT_TX_DESCRIPTORS];
   UINT32           j;
   UINT32           i;
-  struct e1000_hw *Hw;
 
   Status  = EFI_SUCCESS;
   j       = 0;
-  Hw = &GigAdapterInfo->Hw;
 
   while (j < PHY_LOOPBACK_ITERATIONS) {
     Status = E1000Transmit (
diff --git a/IntelUndiPkg/GigUndiDxe/HiiInternalLib.c b/IntelUndiPkg/GigUndiDxe/HiiInternalLib.c
index 2aacb63ca158..690d8314be74 100644
--- a/IntelUndiPkg/GigUndiDxe/HiiInternalLib.c
+++ b/IntelUndiPkg/GigUndiDxe/HiiInternalLib.c
@@ -197,7 +197,6 @@  GetNextRequestElement (
   )
 {
   EFI_STRING StringPtr;
-  EFI_STRING TmpPtr;
   EFI_STATUS Status;
   UINTN      Length;
   UINT8 *    TmpBuffer;
@@ -227,7 +226,6 @@  GetNextRequestElement (
   }
 
   // Back up the header of one <BlockName>
-  TmpPtr = StringPtr;
 
   StringPtr += StrLen (L"OFFSET=");
 
diff --git a/IntelUndiPkg/GigUndiDxe/e1000.c b/IntelUndiPkg/GigUndiDxe/e1000.c
index 28c900e3ad63..3d4a21c62d77 100644
--- a/IntelUndiPkg/GigUndiDxe/e1000.c
+++ b/IntelUndiPkg/GigUndiDxe/e1000.c
@@ -412,7 +412,6 @@  E1000Transmit (
   E1000_TRANSMIT_DESCRIPTOR  *TransmitDescriptor;
   UINT32                      i;
   INT16                       WaitMsec;
-  EFI_STATUS                  Status;
   UNDI_DMA_MAPPING            *TxBufMapping;
 
   TxBufMapping = &GigAdapter->TxBufferMappings[GigAdapter->CurTxInd];
@@ -483,7 +482,7 @@  E1000Transmit (
     TxBufMapping->Size = TxBuffer->DataLen + TxBuffer->MediaheaderLen;
 
     // Make the Tx buffer accessible for adapter over DMA
-    Status = UndiDmaMapMemoryRead (
+    UndiDmaMapMemoryRead (
                GigAdapter->PciIo,
                TxBufMapping
                );
@@ -594,20 +593,21 @@  E1000Receive (
   E1000_RECEIVE_DESCRIPTOR *ReceiveDescriptor;
   ETHER_HEADER *            EtherHeader;
   PXE_STATCODE              StatCode;
-  UINT16                    i;
   UINT16                    TempLen;
+#if (DBG_LVL & RX)
+  UINT16                    i;
   UINT8 *                   PacketPtr;
 #if (DBG_LVL & CRITICAL)
-#if (DBG_LVL & RX)
   UINT32 Rdh;
   UINT32 Rdt;
-#endif /* (DBG_LVL & RX) */
+
 #endif /* (DBG_LVL & CRITICAL) */
+  i           = 0;
+#endif /* (DBG_LVL & RX) */
 
 
   PacketType  = PXE_FRAME_TYPE_NONE;
   StatCode    = PXE_STATCODE_NO_DATA;
-  i           = 0;
 
   // acknowledge the interrupts
   E1000_READ_REG (&GigAdapter->Hw, E1000_ICR);
@@ -679,9 +679,9 @@  E1000Receive (
         TempLen
       );
 
+#if (DBG_LVL & RX)
       PacketPtr = (UINT8 *) (UINTN) CpbReceive->BufferAddr;
 
-#if (DBG_LVL & RX)
       DEBUGPRINT (RX, ("Packet Data \n"));
       for (i = 0; i < TempLen; i++) {
         DEBUGPRINT (RX, ("%x ", PacketPtr[i]));
@@ -1569,13 +1569,11 @@  E1000Inititialize (
   GIG_DRIVER_DATA *GigAdapter
   )
 {
-  UINT32 *     TempBar;
   PXE_STATCODE PxeStatcode;
 
   DEBUGPRINT (E1000, ("E1000Inititialize\n"));
 
   PxeStatcode = PXE_STATCODE_SUCCESS;
-  TempBar = NULL;
 
   ZeroMem (
     (VOID *)(UINTN)GigAdapter->RxRing.UnmappedAddress,