Redfish : Return after InternalError instead of Continue

"After setting response to internal error you should stop adding more content to response. Try to return instead of continuing a loop"

https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/39970/9/redfish-core/lib/pcie_slots.hpp#169

Signed-off-by: Chicago Duan <duanzhijia01@inspur.com>
Change-Id: Iadd3062ba7fef31ba61eea1e79eb3a903716b9e9
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp
index c41c73e..67f8d99 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -1973,7 +1973,7 @@
                                             // illegal property
                                             messages::internalError(
                                                 asyncResp->res);
-                                            continue;
+                                            return;
                                         }
                                         asyncResp->res.jsonValue[propertyName] =
                                             *value;
diff --git a/redfish-core/lib/memory.hpp b/redfish-core/lib/memory.hpp
index af619e0..62d8bf9 100644
--- a/redfish-core/lib/memory.hpp
+++ b/redfish-core/lib/memory.hpp
@@ -184,7 +184,7 @@
                 messages::internalError(aResp->res);
                 BMCWEB_LOG_DEBUG << "Invalid property type for "
                                     "VolatileRegionSizeLimitKiB";
-                continue;
+                return;
             }
             aResp->res.jsonValue["VolatileRegionSizeLimitMiB"] = (*value) >> 10;
         }
@@ -197,7 +197,7 @@
                 messages::internalError(aResp->res);
                 BMCWEB_LOG_DEBUG
                     << "Invalid property type for PmRegioSizeLimitKiB";
-                continue;
+                return;
             }
             aResp->res.jsonValue["PersistentRegionSizeLimitMiB"] =
                 (*value) >> 10;
@@ -211,7 +211,7 @@
                 messages::internalError(aResp->res);
                 BMCWEB_LOG_DEBUG
                     << "Invalid property type for VolatileSizeInKiB";
-                continue;
+                return;
             }
             aResp->res.jsonValue["VolatileSizeMiB"] = (*value) >> 10;
         }
@@ -222,7 +222,7 @@
             {
                 messages::internalError(aResp->res);
                 BMCWEB_LOG_DEBUG << "Invalid property type for PmSizeInKiB";
-                continue;
+                return;
             }
             aResp->res.jsonValue["NonVolatileSizeMiB"] = (*value) >> 10;
         }
@@ -233,7 +233,7 @@
             {
                 messages::internalError(aResp->res);
                 BMCWEB_LOG_DEBUG << "Invalid property type for CacheSizeInKB";
-                continue;
+                return;
             }
             aResp->res.jsonValue["CacheSizeMiB"] = (*value >> 10);
         }
@@ -247,7 +247,7 @@
                 messages::internalError(aResp->res);
                 BMCWEB_LOG_DEBUG << "Invalid property type for "
                                     "VolatileRegionMaxSizeInKib";
-                continue;
+                return;
             }
             aResp->res.jsonValue["VolatileRegionSizeMaxMiB"] = (*value) >> 10;
         }
@@ -260,7 +260,7 @@
                 messages::internalError(aResp->res);
                 BMCWEB_LOG_DEBUG
                     << "Invalid property type for PmRegionMaxSizeInKiB";
-                continue;
+                return;
             }
             aResp->res.jsonValue["PersistentRegionSizeMaxMiB"] = (*value) >> 10;
         }
@@ -273,7 +273,7 @@
                 messages::internalError(aResp->res);
                 BMCWEB_LOG_DEBUG << "Invalid property type for "
                                     "AllocationIncrementInKiB";
-                continue;
+                return;
             }
             aResp->res.jsonValue["AllocationIncrementMiB"] = (*value) >> 10;
         }
@@ -286,7 +286,7 @@
                 messages::internalError(aResp->res);
                 BMCWEB_LOG_DEBUG << "Invalid property type for "
                                     "AllocationAlignmentInKiB";
-                continue;
+                return;
             }
             aResp->res.jsonValue["AllocationAlignmentMiB"] = (*value) >> 10;
         }
@@ -296,7 +296,7 @@
             if (value == nullptr)
             {
                 messages::internalError(aResp->res);
-                continue;
+                return;
             }
             aResp->res.jsonValue["VolatileRegionNumberLimit"] = *value;
         }
@@ -306,7 +306,7 @@
             if (value == nullptr)
             {
                 messages::internalError(aResp->res);
-                continue;
+                return;
             }
             aResp->res.jsonValue["PersistentRegionNumberLimit"] = *value;
         }
@@ -316,7 +316,7 @@
             if (value == nullptr)
             {
                 messages::internalError(aResp->res);
-                continue;
+                return;
             }
             aResp->res.jsonValue["SpareDeviceCount"] = *value;
         }
@@ -326,7 +326,7 @@
             if (value == nullptr)
             {
                 messages::internalError(aResp->res);
-                continue;
+                return;
             }
             aResp->res.jsonValue["IsSpareDeviceEnabled"] = *value;
         }
@@ -336,7 +336,7 @@
             if (value == nullptr)
             {
                 messages::internalError(aResp->res);
-                continue;
+                return;
             }
             aResp->res.jsonValue["IsRankSpareEnabled"] = *value;
         }
@@ -349,7 +349,7 @@
                 messages::internalError(aResp->res);
                 BMCWEB_LOG_DEBUG << "Invalid property type for "
                                     "MaxAveragePowerLimitmW";
-                continue;
+                return;
             }
             aResp->res.jsonValue["MaxTDPMilliWatts"] = *value;
         }
@@ -359,7 +359,7 @@
             if (value == nullptr)
             {
                 messages::internalError(aResp->res);
-                continue;
+                return;
             }
             aResp->res.jsonValue["ConfigurationLocked"] = *value;
         }
@@ -371,7 +371,7 @@
             {
                 messages::internalError(aResp->res);
                 BMCWEB_LOG_DEBUG << "Invalid property type for FormFactor";
-                continue;
+                return;
             }
             constexpr const std::array<const char*, 3> values{"Volatile",
                                                               "PMEM", "Block"};
@@ -393,7 +393,7 @@
             {
                 messages::internalError(aResp->res);
                 BMCWEB_LOG_DEBUG << "Invalid property type for MemoryMedia";
-                continue;
+                return;
             }
             constexpr const std::array<const char*, 3> values{"DRAM", "NAND",
                                                               "Intel3DXPoint"};
@@ -416,7 +416,7 @@
             if (value == nullptr)
             {
                 messages::internalError(aResp->res);
-                continue;
+                return;
             }
             aResp->res.jsonValue["SecurityCapabilities"][property.first] =
                 *value;
@@ -428,7 +428,7 @@
             if (value == nullptr)
             {
                 messages::internalError(aResp->res);
-                continue;
+                return;
             }
             aResp->res.jsonValue["SecurityCapabilities"][property.first] =
                 *value;
@@ -527,7 +527,7 @@
                         messages::internalError(aResp->res);
                         BMCWEB_LOG_DEBUG
                             << "Invalid property type for RevisionCode";
-                        continue;
+                        return;
                     }
                     aResp->res.jsonValue["FirmwareRevision"] =
                         std::to_string(*value);
@@ -550,7 +550,7 @@
                     {
                         messages::internalError(aResp->res);
                         BMCWEB_LOG_DEBUG << "Invalid property type for ECC";
-                        continue;
+                        return;
                     }
                     constexpr const std::array<const char*, 4> values{
                         "NoECC", "SingleBitECC", "MultiBitECC",
@@ -574,7 +574,7 @@
                         messages::internalError(aResp->res);
                         BMCWEB_LOG_DEBUG
                             << "Invalid property type for FormFactor";
-                        continue;
+                        return;
                     }
                     constexpr const std::array<const char*, 11> values{
                         "RDIMM",        "UDIMM",        "SO_DIMM",
@@ -617,7 +617,7 @@
                         messages::internalError(aResp->res);
                         BMCWEB_LOG_DEBUG
                             << "Invalid property type for MemoryAttributes";
-                        continue;
+                        return;
                     }
                     aResp->res.jsonValue["RankCount"] =
                         static_cast<uint64_t>(*value);
@@ -667,7 +667,7 @@
                     if (value == nullptr)
                     {
                         messages::internalError(aResp->res);
-                        continue;
+                        return;
                     }
                     aResp->res.jsonValue["MemoryLocation"][property.first] =
                         *value;
@@ -679,7 +679,7 @@
                     if (value == nullptr)
                     {
                         messages::internalError(aResp->res);
-                        continue;
+                        return;
                     }
                     aResp->res.jsonValue["SparePartNumber"] = *value;
                 }
@@ -690,7 +690,7 @@
                     if (value == nullptr)
                     {
                         messages::internalError(aResp->res);
-                        continue;
+                        return;
                     }
                     aResp->res.jsonValue["Model"] = *value;
                 }
@@ -701,7 +701,7 @@
                     if (value == nullptr)
                     {
                         messages::internalError(aResp->res);
-                        continue;
+                        return;
                     }
                     aResp->res
                         .jsonValue["Location"]["PartLocation"]["ServiceLabel"] =
@@ -745,7 +745,7 @@
                     if (value == nullptr)
                     {
                         messages::internalError(aResp->res);
-                        continue;
+                        return;
                     }
                     partition[key] = *value;
                 }
@@ -755,7 +755,7 @@
                     if (value == nullptr)
                     {
                         messages::internalError(aResp->res);
-                        continue;
+                        return;
                     }
 
                     partition["OffsetMiB"] = (*value >> 10);
@@ -766,7 +766,7 @@
                     if (value == nullptr)
                     {
                         messages::internalError(aResp->res);
-                        continue;
+                        return;
                     }
                     partition["RegionId"] = *value;
                 }
@@ -777,7 +777,7 @@
                     if (value == nullptr)
                     {
                         messages::internalError(aResp->res);
-                        continue;
+                        return;
                     }
                     partition["PassphraseEnabled"] = *value;
                 }
@@ -789,7 +789,7 @@
                         messages::internalError(aResp->res);
                         BMCWEB_LOG_DEBUG
                             << "Invalid property type for SizeInKiB";
-                        continue;
+                        return;
                     }
                     partition["SizeMiB"] = (*value >> 10);
                 }
diff --git a/redfish-core/lib/storage.hpp b/redfish-core/lib/storage.hpp
index c2651d5..34ef39a 100644
--- a/redfish-core/lib/storage.hpp
+++ b/redfish-core/lib/storage.hpp
@@ -239,7 +239,7 @@
                                     {
                                         // illegal property
                                         messages::internalError(asyncResp->res);
-                                        continue;
+                                        return;
                                     }
                                     object[propertyName] = *value;
                                 }
@@ -385,7 +385,7 @@
                                 {
                                     // illegal property
                                     messages::internalError(asyncResp->res);
-                                    continue;
+                                    return;
                                 }
                                 asyncResp->res.jsonValue[propertyName] = *value;
                             }
diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp
index f97dba2..8d76722 100644
--- a/redfish-core/lib/systems.hpp
+++ b/redfish-core/lib/systems.hpp
@@ -1760,7 +1760,7 @@
                     if (!state)
                     {
                         messages::internalError(aResp->res);
-                        continue;
+                        return;
                     }
 
                     hostWatchdogTimer["FunctionEnabled"] = *state;
@@ -1772,14 +1772,14 @@
                     if (!s)
                     {
                         messages::internalError(aResp->res);
-                        continue;
+                        return;
                     }
 
                     std::string action = dbusToRfWatchdogAction(*s);
                     if (action.empty())
                     {
                         messages::internalError(aResp->res);
-                        continue;
+                        return;
                     }
                     hostWatchdogTimer["TimeoutAction"] = action;
                 }