[edk2-devel] [PATCH v2] IpmiFeaturePkg: Refine code to avoid warning report

Huang, Yanbo posted 1 patch 9 months, 2 weeks ago
Failed in applying to current master (apply log)
.../IpmiFeaturePkg/GenericIpmi/Dxe/IpmiInit.c | 36 ++++++++----------
.../GenericIpmi/Pei/PeiGenericIpmi.c          | 36 ++++++++----------
.../GenericIpmi/Smm/SmmGenericIpmi.c          | 38 +++++++++----------
3 files changed, 49 insertions(+), 61 deletions(-)
[edk2-devel] [PATCH v2] IpmiFeaturePkg: Refine code to avoid warning report
Posted by Huang, Yanbo 9 months, 2 weeks ago
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=4522

"if (FixedPcdGet8 (PcdKcsInterfaceSupport) == 1) {" will not be executed in current code,
put it within "case SysInterfaceKcs:" to avoid this issue.

Cc: Isaac Oram <isaac.w.oram@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>

Signed-off-by: Yanbo Huang <yanbo.huang@intel.com>
---
 .../IpmiFeaturePkg/GenericIpmi/Dxe/IpmiInit.c | 36 ++++++++----------
 .../GenericIpmi/Pei/PeiGenericIpmi.c          | 36 ++++++++----------
 .../GenericIpmi/Smm/SmmGenericIpmi.c          | 38 +++++++++----------
 3 files changed, 49 insertions(+), 61 deletions(-)

diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/IpmiInit.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/IpmiInit.c
index 7113556df8..82f6d2a661 100644
--- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/IpmiInit.c
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/IpmiInit.c
@@ -630,8 +630,8 @@ InitializeIpmiKcsPhysicalLayer (
     // Check interface data initialized successfully else register notify protocol.
     for (Index = SysInterfaceKcs; Index < SysInterfaceMax; Index++) {
       switch (Index) {
-      if (FixedPcdGet8 (PcdKcsInterfaceSupport) == 1) {
-          case SysInterfaceKcs:
+        case SysInterfaceKcs:
+          if (FixedPcdGet8 (PcdKcsInterfaceSupport) == 1) {
             if ((mIpmiInstance->BmcStatus != BMC_HARDFAIL) && (mIpmiInstance->BmcStatus != BMC_UPDATE_IN_PROGRESS)) {
               BMC_INTERFACE_STATUS  BmcStatus;
               mIpmiInstance->IpmiTransport2.Interface.KcsInterfaceState = IpmiInterfaceInitialized;
@@ -646,21 +646,19 @@ InitializeIpmiKcsPhysicalLayer (
                 mIpmiInstance->IpmiTransport2.Interface.KcsInterfaceState = IpmiInterfaceInitError;
               }
             }
+          }
+          break;
 
-            break;
-      }
-
-      if (FixedPcdGet8 (PcdBtInterfaceSupport) == 1) {
-          case SysInterfaceBt:
+        case SysInterfaceBt:
+          if (FixedPcdGet8 (PcdBtInterfaceSupport) == 1) {
             if (mIpmiInstance->IpmiTransport2.Interface.Bt.InterfaceState == IpmiInterfaceInitialized) {
               InterfaceState = IpmiInterfaceInitialized;
             }
+          }
+          break;
 
-            break;
-      }
-
-      if (FixedPcdGet8 (PcdSsifInterfaceSupport) == 1) {
-          case SysInterfaceSsif:
+        case SysInterfaceSsif:
+          if (FixedPcdGet8 (PcdSsifInterfaceSupport) == 1) {
             if (mIpmiInstance->IpmiTransport2.Interface.Ssif.InterfaceState == IpmiInterfaceInitialized) {
               InterfaceState = IpmiInterfaceInitialized;
             } else if (mIpmiInstance->IpmiTransport2.Interface.Ssif.InterfaceState == IpmiInterfaceInitError) {
@@ -669,12 +667,11 @@ InitializeIpmiKcsPhysicalLayer (
                                                     &mIpmiInstance->IpmiTransport2.Interface.Ssif.SsifInterfaceApiGuid
                                                     );
             }
+          }
+          break;
 
-            break;
-      }
-
-      if (FixedPcdGet8 (PcdIpmbInterfaceSupport) == 1) {
-          case SysInterfaceIpmb:
+        case SysInterfaceIpmb:
+          if (FixedPcdGet8 (PcdIpmbInterfaceSupport) == 1) {
             if (mIpmiInstance->IpmiTransport2.Interface.Ipmb.InterfaceState == IpmiInterfaceInitialized) {
               InterfaceState = IpmiInterfaceInitialized;
             } else if (mIpmiInstance->IpmiTransport2.Interface.Ipmb.InterfaceState == IpmiInterfaceInitError) {
@@ -683,9 +680,8 @@ InitializeIpmiKcsPhysicalLayer (
                                                     &mIpmiInstance->IpmiTransport2.Interface.Ipmb.IpmbInterfaceApiGuid
                                                     );
             }
-
-            break;
-      }
+          }
+          break;
 
         default:
           break;
diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.c
index 1d8266a0b1..ebc9e7085d 100644
--- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.c
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.c
@@ -343,8 +343,8 @@ PeiInitializeIpmiKcsPhysicalLayer (
   // Check interface data initialized successfully else register notify protocol.
   for (Index = SysInterfaceKcs; Index < SysInterfaceMax; Index++) {
     switch (Index) {
-    if (FixedPcdGet8 (PcdKcsInterfaceSupport) == 1) {
-        case SysInterfaceKcs:
+      case SysInterfaceKcs:
+        if (FixedPcdGet8 (PcdKcsInterfaceSupport) == 1) {
           if ((mIpmiInstance->BmcStatus != BMC_HARDFAIL) && (mIpmiInstance->BmcStatus != BMC_UPDATE_IN_PROGRESS)) {
             BMC_INTERFACE_STATUS  BmcStatus;
             mIpmiInstance->IpmiTransport2Ppi.Interface.KcsInterfaceState = IpmiInterfaceInitialized;
@@ -359,42 +359,38 @@ PeiInitializeIpmiKcsPhysicalLayer (
               mIpmiInstance->IpmiTransport2Ppi.Interface.KcsInterfaceState = IpmiInterfaceInitError;
             }
           }
+        }
+        break;
 
-          break;
-    }
-
-    if (FixedPcdGet8 (PcdBtInterfaceSupport) == 1) {
-        case SysInterfaceBt:
+      case SysInterfaceBt:
+        if (FixedPcdGet8 (PcdBtInterfaceSupport) == 1) {
           if (mIpmiInstance->IpmiTransport2Ppi.Interface.Bt.InterfaceState == IpmiInterfaceInitialized) {
             InterfaceState = IpmiInterfaceInitialized;
           }
+        }
+        break;
 
-          break;
-    }
-
-    if (FixedPcdGet8 (PcdSsifInterfaceSupport) == 1) {
-        case SysInterfaceSsif:
+      case SysInterfaceSsif:
+        if (FixedPcdGet8 (PcdSsifInterfaceSupport) == 1) {
           if (mIpmiInstance->IpmiTransport2Ppi.Interface.Ssif.InterfaceState == IpmiInterfaceInitialized) {
             InterfaceState = IpmiInterfaceInitialized;
           } else if (mIpmiInstance->IpmiTransport2Ppi.Interface.Ssif.InterfaceState == IpmiInterfaceInitError) {
             // Register protocol notify for SMBUS Protocol.
             Status = RegisterPpiCallback (PeiServices, &mIpmiInstance->IpmiTransport2Ppi.Interface.Ssif.SsifInterfaceApiGuid);
           }
+        }
+        break;
 
-          break;
-    }
-
-    if (FixedPcdGet8 (PcdIpmbInterfaceSupport) == 1) {
-        case SysInterfaceIpmb:
+      case SysInterfaceIpmb:
+        if (FixedPcdGet8 (PcdIpmbInterfaceSupport) == 1) {
           if (mIpmiInstance->IpmiTransport2Ppi.Interface.Ipmb.InterfaceState == IpmiInterfaceInitialized) {
             InterfaceState = IpmiInterfaceInitialized;
           } else if (mIpmiInstance->IpmiTransport2Ppi.Interface.Ipmb.InterfaceState == IpmiInterfaceInitError) {
             // Register protocol notify for SMBUS Protocol.
             Status = RegisterPpiCallback (PeiServices, &mIpmiInstance->IpmiTransport2Ppi.Interface.Ipmb.IpmbInterfaceApiGuid);
           }
-
-          break;
-    }
+        }
+        break;
 
       default:
         break;
diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Smm/SmmGenericIpmi.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Smm/SmmGenericIpmi.c
index 350d6afef5..2349373317 100644
--- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Smm/SmmGenericIpmi.c
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Smm/SmmGenericIpmi.c
@@ -210,7 +210,7 @@ SmmNotifyCallback (
                                                  &mIpmiInstance->IpmiTransport2
                                                  );
   }
-
+  ASSERT_EFI_ERROR (Status);
   return EFI_SUCCESS;
 }
 
@@ -335,8 +335,8 @@ Returns:
     // Check interface data initialized successfully else register notify protocol.
     for (Index = SysInterfaceKcs; Index < SysInterfaceMax; Index++) {
       switch (Index) {
-      if (FixedPcdGet8 (PcdKcsInterfaceSupport) == 1) {
-          case SysInterfaceKcs:
+        case SysInterfaceKcs:
+          if (FixedPcdGet8 (PcdKcsInterfaceSupport) == 1) {
             if ((mIpmiInstance->BmcStatus != BMC_HARDFAIL) && (mIpmiInstance->BmcStatus != BMC_UPDATE_IN_PROGRESS)) {
               BMC_INTERFACE_STATUS  BmcStatus;
               mIpmiInstance->IpmiTransport2.Interface.KcsInterfaceState = IpmiInterfaceInitialized;
@@ -351,42 +351,38 @@ Returns:
                 mIpmiInstance->IpmiTransport2.Interface.KcsInterfaceState = IpmiInterfaceInitError;
               }
             }
+          }
+          break;
 
-            break;
-      }
-
-      if (FixedPcdGet8 (PcdBtInterfaceSupport) == 1) {
-          case SysInterfaceBt:
+        case SysInterfaceBt:
+          if (FixedPcdGet8 (PcdBtInterfaceSupport) == 1) {
             if (mIpmiInstance->IpmiTransport2.Interface.Bt.InterfaceState == IpmiInterfaceInitialized) {
               InterfaceState = IpmiInterfaceInitialized;
             }
+          }
+          break;
 
-            break;
-      }
-
-      if (FixedPcdGet8 (PcdSsifInterfaceSupport) == 1) {
-          case SysInterfaceSsif:
+        case SysInterfaceSsif:
+          if (FixedPcdGet8 (PcdSsifInterfaceSupport) == 1) {
             if (mIpmiInstance->IpmiTransport2.Interface.Ssif.InterfaceState == IpmiInterfaceInitialized) {
               InterfaceState = IpmiInterfaceInitialized;
             } else if (mIpmiInstance->IpmiTransport2.Interface.Ssif.InterfaceState == IpmiInterfaceInitError) {
               // Register protocol notify for SMBUS Protocol.
               Status = SmmRegisterProtocolCallback (&mIpmiInstance->IpmiTransport2.Interface.Ssif.SsifInterfaceApiGuid);
             }
+          }
+          break;
 
-            break;
-      }
-
-      if (FixedPcdGet8 (PcdIpmbInterfaceSupport) == 1) {
-          case SysInterfaceIpmb:
+        case SysInterfaceIpmb:
+          if (FixedPcdGet8 (PcdIpmbInterfaceSupport) == 1) {
             if (mIpmiInstance->IpmiTransport2.Interface.Ipmb.InterfaceState == IpmiInterfaceInitialized) {
               InterfaceState = IpmiInterfaceInitialized;
             } else if (mIpmiInstance->IpmiTransport2.Interface.Ipmb.InterfaceState == IpmiInterfaceInitError) {
               // Register protocol notify for SMBUS Protocol.
               Status = SmmRegisterProtocolCallback (&mIpmiInstance->IpmiTransport2.Interface.Ipmb.IpmbInterfaceApiGuid);
             }
-
-            break;
-      }
+          }
+          break;
 
         default:
           break;
-- 
2.31.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#108296): https://edk2.groups.io/g/devel/message/108296
Mute This Topic: https://groups.io/mt/101185487/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH v2] IpmiFeaturePkg: Refine code to avoid warning report
Posted by Nate DeSimone 9 months ago
Pushed: https://github.com/tianocore/edk2-platforms/commit/cf8a716

-----Original Message-----
From: Huang, Yanbo <yanbo.huang@intel.com> 
Sent: Tuesday, September 5, 2023 7:19 PM
To: devel@edk2.groups.io
Cc: Huang, Yanbo <yanbo.huang@intel.com>; Isaac Oram <isaac.w.oram@intel.com>; Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>
Subject: [PATCH v2] IpmiFeaturePkg: Refine code to avoid warning report

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=4522

"if (FixedPcdGet8 (PcdKcsInterfaceSupport) == 1) {" will not be executed in current code, put it within "case SysInterfaceKcs:" to avoid this issue.

Cc: Isaac Oram <isaac.w.oram@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>

Signed-off-by: Yanbo Huang <yanbo.huang@intel.com>
---
 .../IpmiFeaturePkg/GenericIpmi/Dxe/IpmiInit.c | 36 ++++++++----------
 .../GenericIpmi/Pei/PeiGenericIpmi.c          | 36 ++++++++----------
 .../GenericIpmi/Smm/SmmGenericIpmi.c          | 38 +++++++++----------
 3 files changed, 49 insertions(+), 61 deletions(-)

diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/IpmiInit.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/IpmiInit.c
index 7113556df8..82f6d2a661 100644
--- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/IpmiInit.c
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/
+++ IpmiInit.c
@@ -630,8 +630,8 @@ InitializeIpmiKcsPhysicalLayer (
     // Check interface data initialized successfully else register notify protocol.
     for (Index = SysInterfaceKcs; Index < SysInterfaceMax; Index++) {
       switch (Index) {
-      if (FixedPcdGet8 (PcdKcsInterfaceSupport) == 1) {
-          case SysInterfaceKcs:
+        case SysInterfaceKcs:
+          if (FixedPcdGet8 (PcdKcsInterfaceSupport) == 1) {
             if ((mIpmiInstance->BmcStatus != BMC_HARDFAIL) && (mIpmiInstance->BmcStatus != BMC_UPDATE_IN_PROGRESS)) {
               BMC_INTERFACE_STATUS  BmcStatus;
               mIpmiInstance->IpmiTransport2.Interface.KcsInterfaceState = IpmiInterfaceInitialized; @@ -646,21 +646,19 @@ InitializeIpmiKcsPhysicalLayer (
                 mIpmiInstance->IpmiTransport2.Interface.KcsInterfaceState = IpmiInterfaceInitError;
               }
             }
+          }
+          break;
 
-            break;
-      }
-
-      if (FixedPcdGet8 (PcdBtInterfaceSupport) == 1) {
-          case SysInterfaceBt:
+        case SysInterfaceBt:
+          if (FixedPcdGet8 (PcdBtInterfaceSupport) == 1) {
             if (mIpmiInstance->IpmiTransport2.Interface.Bt.InterfaceState == IpmiInterfaceInitialized) {
               InterfaceState = IpmiInterfaceInitialized;
             }
+          }
+          break;
 
-            break;
-      }
-
-      if (FixedPcdGet8 (PcdSsifInterfaceSupport) == 1) {
-          case SysInterfaceSsif:
+        case SysInterfaceSsif:
+          if (FixedPcdGet8 (PcdSsifInterfaceSupport) == 1) {
             if (mIpmiInstance->IpmiTransport2.Interface.Ssif.InterfaceState == IpmiInterfaceInitialized) {
               InterfaceState = IpmiInterfaceInitialized;
             } else if (mIpmiInstance->IpmiTransport2.Interface.Ssif.InterfaceState == IpmiInterfaceInitError) { @@ -669,12 +667,11 @@ InitializeIpmiKcsPhysicalLayer (
                                                     &mIpmiInstance->IpmiTransport2.Interface.Ssif.SsifInterfaceApiGuid
                                                     );
             }
+          }
+          break;
 
-            break;
-      }
-
-      if (FixedPcdGet8 (PcdIpmbInterfaceSupport) == 1) {
-          case SysInterfaceIpmb:
+        case SysInterfaceIpmb:
+          if (FixedPcdGet8 (PcdIpmbInterfaceSupport) == 1) {
             if (mIpmiInstance->IpmiTransport2.Interface.Ipmb.InterfaceState == IpmiInterfaceInitialized) {
               InterfaceState = IpmiInterfaceInitialized;
             } else if (mIpmiInstance->IpmiTransport2.Interface.Ipmb.InterfaceState == IpmiInterfaceInitError) { @@ -683,9 +680,8 @@ InitializeIpmiKcsPhysicalLayer (
                                                     &mIpmiInstance->IpmiTransport2.Interface.Ipmb.IpmbInterfaceApiGuid
                                                     );
             }
-
-            break;
-      }
+          }
+          break;
 
         default:
           break;
diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.c
index 1d8266a0b1..ebc9e7085d 100644
--- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.c
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/
+++ PeiGenericIpmi.c
@@ -343,8 +343,8 @@ PeiInitializeIpmiKcsPhysicalLayer (
   // Check interface data initialized successfully else register notify protocol.
   for (Index = SysInterfaceKcs; Index < SysInterfaceMax; Index++) {
     switch (Index) {
-    if (FixedPcdGet8 (PcdKcsInterfaceSupport) == 1) {
-        case SysInterfaceKcs:
+      case SysInterfaceKcs:
+        if (FixedPcdGet8 (PcdKcsInterfaceSupport) == 1) {
           if ((mIpmiInstance->BmcStatus != BMC_HARDFAIL) && (mIpmiInstance->BmcStatus != BMC_UPDATE_IN_PROGRESS)) {
             BMC_INTERFACE_STATUS  BmcStatus;
             mIpmiInstance->IpmiTransport2Ppi.Interface.KcsInterfaceState = IpmiInterfaceInitialized; @@ -359,42 +359,38 @@ PeiInitializeIpmiKcsPhysicalLayer (
               mIpmiInstance->IpmiTransport2Ppi.Interface.KcsInterfaceState = IpmiInterfaceInitError;
             }
           }
+        }
+        break;
 
-          break;
-    }
-
-    if (FixedPcdGet8 (PcdBtInterfaceSupport) == 1) {
-        case SysInterfaceBt:
+      case SysInterfaceBt:
+        if (FixedPcdGet8 (PcdBtInterfaceSupport) == 1) {
           if (mIpmiInstance->IpmiTransport2Ppi.Interface.Bt.InterfaceState == IpmiInterfaceInitialized) {
             InterfaceState = IpmiInterfaceInitialized;
           }
+        }
+        break;
 
-          break;
-    }
-
-    if (FixedPcdGet8 (PcdSsifInterfaceSupport) == 1) {
-        case SysInterfaceSsif:
+      case SysInterfaceSsif:
+        if (FixedPcdGet8 (PcdSsifInterfaceSupport) == 1) {
           if (mIpmiInstance->IpmiTransport2Ppi.Interface.Ssif.InterfaceState == IpmiInterfaceInitialized) {
             InterfaceState = IpmiInterfaceInitialized;
           } else if (mIpmiInstance->IpmiTransport2Ppi.Interface.Ssif.InterfaceState == IpmiInterfaceInitError) {
             // Register protocol notify for SMBUS Protocol.
             Status = RegisterPpiCallback (PeiServices, &mIpmiInstance->IpmiTransport2Ppi.Interface.Ssif.SsifInterfaceApiGuid);
           }
+        }
+        break;
 
-          break;
-    }
-
-    if (FixedPcdGet8 (PcdIpmbInterfaceSupport) == 1) {
-        case SysInterfaceIpmb:
+      case SysInterfaceIpmb:
+        if (FixedPcdGet8 (PcdIpmbInterfaceSupport) == 1) {
           if (mIpmiInstance->IpmiTransport2Ppi.Interface.Ipmb.InterfaceState == IpmiInterfaceInitialized) {
             InterfaceState = IpmiInterfaceInitialized;
           } else if (mIpmiInstance->IpmiTransport2Ppi.Interface.Ipmb.InterfaceState == IpmiInterfaceInitError) {
             // Register protocol notify for SMBUS Protocol.
             Status = RegisterPpiCallback (PeiServices, &mIpmiInstance->IpmiTransport2Ppi.Interface.Ipmb.IpmbInterfaceApiGuid);
           }
-
-          break;
-    }
+        }
+        break;
 
       default:
         break;
diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Smm/SmmGenericIpmi.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Smm/SmmGenericIpmi.c
index 350d6afef5..2349373317 100644
--- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Smm/SmmGenericIpmi.c
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Smm/
+++ SmmGenericIpmi.c
@@ -210,7 +210,7 @@ SmmNotifyCallback (
                                                  &mIpmiInstance->IpmiTransport2
                                                  );
   }
-
+  ASSERT_EFI_ERROR (Status);
   return EFI_SUCCESS;
 }
 
@@ -335,8 +335,8 @@ Returns:
     // Check interface data initialized successfully else register notify protocol.
     for (Index = SysInterfaceKcs; Index < SysInterfaceMax; Index++) {
       switch (Index) {
-      if (FixedPcdGet8 (PcdKcsInterfaceSupport) == 1) {
-          case SysInterfaceKcs:
+        case SysInterfaceKcs:
+          if (FixedPcdGet8 (PcdKcsInterfaceSupport) == 1) {
             if ((mIpmiInstance->BmcStatus != BMC_HARDFAIL) && (mIpmiInstance->BmcStatus != BMC_UPDATE_IN_PROGRESS)) {
               BMC_INTERFACE_STATUS  BmcStatus;
               mIpmiInstance->IpmiTransport2.Interface.KcsInterfaceState = IpmiInterfaceInitialized; @@ -351,42 +351,38 @@ Returns:
                 mIpmiInstance->IpmiTransport2.Interface.KcsInterfaceState = IpmiInterfaceInitError;
               }
             }
+          }
+          break;
 
-            break;
-      }
-
-      if (FixedPcdGet8 (PcdBtInterfaceSupport) == 1) {
-          case SysInterfaceBt:
+        case SysInterfaceBt:
+          if (FixedPcdGet8 (PcdBtInterfaceSupport) == 1) {
             if (mIpmiInstance->IpmiTransport2.Interface.Bt.InterfaceState == IpmiInterfaceInitialized) {
               InterfaceState = IpmiInterfaceInitialized;
             }
+          }
+          break;
 
-            break;
-      }
-
-      if (FixedPcdGet8 (PcdSsifInterfaceSupport) == 1) {
-          case SysInterfaceSsif:
+        case SysInterfaceSsif:
+          if (FixedPcdGet8 (PcdSsifInterfaceSupport) == 1) {
             if (mIpmiInstance->IpmiTransport2.Interface.Ssif.InterfaceState == IpmiInterfaceInitialized) {
               InterfaceState = IpmiInterfaceInitialized;
             } else if (mIpmiInstance->IpmiTransport2.Interface.Ssif.InterfaceState == IpmiInterfaceInitError) {
               // Register protocol notify for SMBUS Protocol.
               Status = SmmRegisterProtocolCallback (&mIpmiInstance->IpmiTransport2.Interface.Ssif.SsifInterfaceApiGuid);
             }
+          }
+          break;
 
-            break;
-      }
-
-      if (FixedPcdGet8 (PcdIpmbInterfaceSupport) == 1) {
-          case SysInterfaceIpmb:
+        case SysInterfaceIpmb:
+          if (FixedPcdGet8 (PcdIpmbInterfaceSupport) == 1) {
             if (mIpmiInstance->IpmiTransport2.Interface.Ipmb.InterfaceState == IpmiInterfaceInitialized) {
               InterfaceState = IpmiInterfaceInitialized;
             } else if (mIpmiInstance->IpmiTransport2.Interface.Ipmb.InterfaceState == IpmiInterfaceInitError) {
               // Register protocol notify for SMBUS Protocol.
               Status = SmmRegisterProtocolCallback (&mIpmiInstance->IpmiTransport2.Interface.Ipmb.IpmbInterfaceApiGuid);
             }
-
-            break;
-      }
+          }
+          break;
 
         default:
           break;
--
2.31.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#108858): https://edk2.groups.io/g/devel/message/108858
Mute This Topic: https://groups.io/mt/101185487/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH v2] IpmiFeaturePkg: Refine code to avoid warning report
Posted by Nate DeSimone 9 months ago
Reviewed-by: Nate DeSimone <nathaniel.l.desimone@intel.com>

-----Original Message-----
From: Huang, Yanbo <yanbo.huang@intel.com> 
Sent: Tuesday, September 5, 2023 7:19 PM
To: devel@edk2.groups.io
Cc: Huang, Yanbo <yanbo.huang@intel.com>; Isaac Oram <isaac.w.oram@intel.com>; Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>
Subject: [PATCH v2] IpmiFeaturePkg: Refine code to avoid warning report

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=4522

"if (FixedPcdGet8 (PcdKcsInterfaceSupport) == 1) {" will not be executed in current code, put it within "case SysInterfaceKcs:" to avoid this issue.

Cc: Isaac Oram <isaac.w.oram@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>

Signed-off-by: Yanbo Huang <yanbo.huang@intel.com>
---
 .../IpmiFeaturePkg/GenericIpmi/Dxe/IpmiInit.c | 36 ++++++++----------
 .../GenericIpmi/Pei/PeiGenericIpmi.c          | 36 ++++++++----------
 .../GenericIpmi/Smm/SmmGenericIpmi.c          | 38 +++++++++----------
 3 files changed, 49 insertions(+), 61 deletions(-)

diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/IpmiInit.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/IpmiInit.c
index 7113556df8..82f6d2a661 100644
--- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/IpmiInit.c
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/
+++ IpmiInit.c
@@ -630,8 +630,8 @@ InitializeIpmiKcsPhysicalLayer (
     // Check interface data initialized successfully else register notify protocol.
     for (Index = SysInterfaceKcs; Index < SysInterfaceMax; Index++) {
       switch (Index) {
-      if (FixedPcdGet8 (PcdKcsInterfaceSupport) == 1) {
-          case SysInterfaceKcs:
+        case SysInterfaceKcs:
+          if (FixedPcdGet8 (PcdKcsInterfaceSupport) == 1) {
             if ((mIpmiInstance->BmcStatus != BMC_HARDFAIL) && (mIpmiInstance->BmcStatus != BMC_UPDATE_IN_PROGRESS)) {
               BMC_INTERFACE_STATUS  BmcStatus;
               mIpmiInstance->IpmiTransport2.Interface.KcsInterfaceState = IpmiInterfaceInitialized; @@ -646,21 +646,19 @@ InitializeIpmiKcsPhysicalLayer (
                 mIpmiInstance->IpmiTransport2.Interface.KcsInterfaceState = IpmiInterfaceInitError;
               }
             }
+          }
+          break;
 
-            break;
-      }
-
-      if (FixedPcdGet8 (PcdBtInterfaceSupport) == 1) {
-          case SysInterfaceBt:
+        case SysInterfaceBt:
+          if (FixedPcdGet8 (PcdBtInterfaceSupport) == 1) {
             if (mIpmiInstance->IpmiTransport2.Interface.Bt.InterfaceState == IpmiInterfaceInitialized) {
               InterfaceState = IpmiInterfaceInitialized;
             }
+          }
+          break;
 
-            break;
-      }
-
-      if (FixedPcdGet8 (PcdSsifInterfaceSupport) == 1) {
-          case SysInterfaceSsif:
+        case SysInterfaceSsif:
+          if (FixedPcdGet8 (PcdSsifInterfaceSupport) == 1) {
             if (mIpmiInstance->IpmiTransport2.Interface.Ssif.InterfaceState == IpmiInterfaceInitialized) {
               InterfaceState = IpmiInterfaceInitialized;
             } else if (mIpmiInstance->IpmiTransport2.Interface.Ssif.InterfaceState == IpmiInterfaceInitError) { @@ -669,12 +667,11 @@ InitializeIpmiKcsPhysicalLayer (
                                                     &mIpmiInstance->IpmiTransport2.Interface.Ssif.SsifInterfaceApiGuid
                                                     );
             }
+          }
+          break;
 
-            break;
-      }
-
-      if (FixedPcdGet8 (PcdIpmbInterfaceSupport) == 1) {
-          case SysInterfaceIpmb:
+        case SysInterfaceIpmb:
+          if (FixedPcdGet8 (PcdIpmbInterfaceSupport) == 1) {
             if (mIpmiInstance->IpmiTransport2.Interface.Ipmb.InterfaceState == IpmiInterfaceInitialized) {
               InterfaceState = IpmiInterfaceInitialized;
             } else if (mIpmiInstance->IpmiTransport2.Interface.Ipmb.InterfaceState == IpmiInterfaceInitError) { @@ -683,9 +680,8 @@ InitializeIpmiKcsPhysicalLayer (
                                                     &mIpmiInstance->IpmiTransport2.Interface.Ipmb.IpmbInterfaceApiGuid
                                                     );
             }
-
-            break;
-      }
+          }
+          break;
 
         default:
           break;
diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.c
index 1d8266a0b1..ebc9e7085d 100644
--- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.c
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/
+++ PeiGenericIpmi.c
@@ -343,8 +343,8 @@ PeiInitializeIpmiKcsPhysicalLayer (
   // Check interface data initialized successfully else register notify protocol.
   for (Index = SysInterfaceKcs; Index < SysInterfaceMax; Index++) {
     switch (Index) {
-    if (FixedPcdGet8 (PcdKcsInterfaceSupport) == 1) {
-        case SysInterfaceKcs:
+      case SysInterfaceKcs:
+        if (FixedPcdGet8 (PcdKcsInterfaceSupport) == 1) {
           if ((mIpmiInstance->BmcStatus != BMC_HARDFAIL) && (mIpmiInstance->BmcStatus != BMC_UPDATE_IN_PROGRESS)) {
             BMC_INTERFACE_STATUS  BmcStatus;
             mIpmiInstance->IpmiTransport2Ppi.Interface.KcsInterfaceState = IpmiInterfaceInitialized; @@ -359,42 +359,38 @@ PeiInitializeIpmiKcsPhysicalLayer (
               mIpmiInstance->IpmiTransport2Ppi.Interface.KcsInterfaceState = IpmiInterfaceInitError;
             }
           }
+        }
+        break;
 
-          break;
-    }
-
-    if (FixedPcdGet8 (PcdBtInterfaceSupport) == 1) {
-        case SysInterfaceBt:
+      case SysInterfaceBt:
+        if (FixedPcdGet8 (PcdBtInterfaceSupport) == 1) {
           if (mIpmiInstance->IpmiTransport2Ppi.Interface.Bt.InterfaceState == IpmiInterfaceInitialized) {
             InterfaceState = IpmiInterfaceInitialized;
           }
+        }
+        break;
 
-          break;
-    }
-
-    if (FixedPcdGet8 (PcdSsifInterfaceSupport) == 1) {
-        case SysInterfaceSsif:
+      case SysInterfaceSsif:
+        if (FixedPcdGet8 (PcdSsifInterfaceSupport) == 1) {
           if (mIpmiInstance->IpmiTransport2Ppi.Interface.Ssif.InterfaceState == IpmiInterfaceInitialized) {
             InterfaceState = IpmiInterfaceInitialized;
           } else if (mIpmiInstance->IpmiTransport2Ppi.Interface.Ssif.InterfaceState == IpmiInterfaceInitError) {
             // Register protocol notify for SMBUS Protocol.
             Status = RegisterPpiCallback (PeiServices, &mIpmiInstance->IpmiTransport2Ppi.Interface.Ssif.SsifInterfaceApiGuid);
           }
+        }
+        break;
 
-          break;
-    }
-
-    if (FixedPcdGet8 (PcdIpmbInterfaceSupport) == 1) {
-        case SysInterfaceIpmb:
+      case SysInterfaceIpmb:
+        if (FixedPcdGet8 (PcdIpmbInterfaceSupport) == 1) {
           if (mIpmiInstance->IpmiTransport2Ppi.Interface.Ipmb.InterfaceState == IpmiInterfaceInitialized) {
             InterfaceState = IpmiInterfaceInitialized;
           } else if (mIpmiInstance->IpmiTransport2Ppi.Interface.Ipmb.InterfaceState == IpmiInterfaceInitError) {
             // Register protocol notify for SMBUS Protocol.
             Status = RegisterPpiCallback (PeiServices, &mIpmiInstance->IpmiTransport2Ppi.Interface.Ipmb.IpmbInterfaceApiGuid);
           }
-
-          break;
-    }
+        }
+        break;
 
       default:
         break;
diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Smm/SmmGenericIpmi.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Smm/SmmGenericIpmi.c
index 350d6afef5..2349373317 100644
--- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Smm/SmmGenericIpmi.c
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Smm/
+++ SmmGenericIpmi.c
@@ -210,7 +210,7 @@ SmmNotifyCallback (
                                                  &mIpmiInstance->IpmiTransport2
                                                  );
   }
-
+  ASSERT_EFI_ERROR (Status);
   return EFI_SUCCESS;
 }
 
@@ -335,8 +335,8 @@ Returns:
     // Check interface data initialized successfully else register notify protocol.
     for (Index = SysInterfaceKcs; Index < SysInterfaceMax; Index++) {
       switch (Index) {
-      if (FixedPcdGet8 (PcdKcsInterfaceSupport) == 1) {
-          case SysInterfaceKcs:
+        case SysInterfaceKcs:
+          if (FixedPcdGet8 (PcdKcsInterfaceSupport) == 1) {
             if ((mIpmiInstance->BmcStatus != BMC_HARDFAIL) && (mIpmiInstance->BmcStatus != BMC_UPDATE_IN_PROGRESS)) {
               BMC_INTERFACE_STATUS  BmcStatus;
               mIpmiInstance->IpmiTransport2.Interface.KcsInterfaceState = IpmiInterfaceInitialized; @@ -351,42 +351,38 @@ Returns:
                 mIpmiInstance->IpmiTransport2.Interface.KcsInterfaceState = IpmiInterfaceInitError;
               }
             }
+          }
+          break;
 
-            break;
-      }
-
-      if (FixedPcdGet8 (PcdBtInterfaceSupport) == 1) {
-          case SysInterfaceBt:
+        case SysInterfaceBt:
+          if (FixedPcdGet8 (PcdBtInterfaceSupport) == 1) {
             if (mIpmiInstance->IpmiTransport2.Interface.Bt.InterfaceState == IpmiInterfaceInitialized) {
               InterfaceState = IpmiInterfaceInitialized;
             }
+          }
+          break;
 
-            break;
-      }
-
-      if (FixedPcdGet8 (PcdSsifInterfaceSupport) == 1) {
-          case SysInterfaceSsif:
+        case SysInterfaceSsif:
+          if (FixedPcdGet8 (PcdSsifInterfaceSupport) == 1) {
             if (mIpmiInstance->IpmiTransport2.Interface.Ssif.InterfaceState == IpmiInterfaceInitialized) {
               InterfaceState = IpmiInterfaceInitialized;
             } else if (mIpmiInstance->IpmiTransport2.Interface.Ssif.InterfaceState == IpmiInterfaceInitError) {
               // Register protocol notify for SMBUS Protocol.
               Status = SmmRegisterProtocolCallback (&mIpmiInstance->IpmiTransport2.Interface.Ssif.SsifInterfaceApiGuid);
             }
+          }
+          break;
 
-            break;
-      }
-
-      if (FixedPcdGet8 (PcdIpmbInterfaceSupport) == 1) {
-          case SysInterfaceIpmb:
+        case SysInterfaceIpmb:
+          if (FixedPcdGet8 (PcdIpmbInterfaceSupport) == 1) {
             if (mIpmiInstance->IpmiTransport2.Interface.Ipmb.InterfaceState == IpmiInterfaceInitialized) {
               InterfaceState = IpmiInterfaceInitialized;
             } else if (mIpmiInstance->IpmiTransport2.Interface.Ipmb.InterfaceState == IpmiInterfaceInitError) {
               // Register protocol notify for SMBUS Protocol.
               Status = SmmRegisterProtocolCallback (&mIpmiInstance->IpmiTransport2.Interface.Ipmb.IpmbInterfaceApiGuid);
             }
-
-            break;
-      }
+          }
+          break;
 
         default:
           break;
--
2.31.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#108857): https://edk2.groups.io/g/devel/message/108857
Mute This Topic: https://groups.io/mt/101185487/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-