summaryrefslogtreecommitdiffstats
path: root/writefrudata.cpp
diff options
context:
space:
mode:
authorPatrick Venture <venture@google.com>2018-10-20 09:37:09 -0700
committerPatrick Venture <venture@google.com>2018-10-20 09:39:50 -0700
commit234b735df51ab47eecb6ff3a33a63923059816bc (patch)
tree60bf22a3628cd6334ecf453a73a48badb70731f0 /writefrudata.cpp
parent98072dcfe74a64f8ac5ae694de03d17ef974276e (diff)
downloadipmi-fru-parser-234b735df51ab47eecb6ff3a33a63923059816bc.tar.gz
ipmi-fru-parser-234b735df51ab47eecb6ff3a33a63923059816bc.zip
style: rename cleanup_error, move into anonymous
Move cleanup_error into an anonymous namespace and rename per the openbmc style naming conventions. Change-Id: Ib307ce2e89ecaff241c7b2d2403b75dbce794dbb Signed-off-by: Patrick Venture <venture@google.com>
Diffstat (limited to 'writefrudata.cpp')
-rw-r--r--writefrudata.cpp53
1 files changed, 29 insertions, 24 deletions
diff --git a/writefrudata.cpp b/writefrudata.cpp
index 84d7527..b89e019 100644
--- a/writefrudata.cpp
+++ b/writefrudata.cpp
@@ -26,6 +26,30 @@ using namespace phosphor::logging;
extern const FruMap frus;
extern const std::map<Path, InterfaceMap> extras;
+namespace
+{
+
+//------------------------------------------------------------
+// Cleanup routine
+// Must always be called as last reference to fru_fp.
+//------------------------------------------------------------
+int cleanupError(FILE* fru_fp, fru_area_vec_t& fru_area_vec)
+{
+ if (fru_fp != NULL)
+ {
+ std::fclose(fru_fp);
+ }
+
+ if (!(fru_area_vec.empty()))
+ {
+ fru_area_vec.clear();
+ }
+
+ return -1;
+}
+
+} // namespace
+
//----------------------------------------------------------------
// Constructor
//----------------------------------------------------------------
@@ -559,25 +583,6 @@ int ipmi_validate_common_hdr(const uint8_t* fru_data, const size_t data_len)
return EXIT_SUCCESS;
}
-//------------------------------------------------------------
-// Cleanup routine
-// Must always be called as last reference to fru_fp.
-//------------------------------------------------------------
-int cleanup_error(FILE* fru_fp, fru_area_vec_t& fru_area_vec)
-{
- if (fru_fp != NULL)
- {
- std::fclose(fru_fp);
- }
-
- if (!(fru_area_vec.empty()))
- {
- fru_area_vec.clear();
- }
-
- return -1;
-}
-
///-----------------------------------------------------
// Accepts the filename and validates per IPMI FRU spec
//----------------------------------------------------
@@ -612,7 +617,7 @@ int validateFRUArea(const uint8_t fruid, const char* fru_file_name,
log<level::ERR>("Unable to open fru file",
entry("FILE=%s", fru_file_name),
entry("ERRNO=%s", std::strerror(errno)));
- return cleanup_error(fru_fp, fru_area_vec);
+ return cleanupError(fru_fp, fru_area_vec);
}
// Get the size of the file to see if it meets minimum requirement
@@ -621,7 +626,7 @@ int validateFRUArea(const uint8_t fruid, const char* fru_file_name,
log<level::ERR>("Unable to seek fru file",
entry("FILE=%s", fru_file_name),
entry("ERRNO=%s", std::strerror(errno)));
- return cleanup_error(fru_fp, fru_area_vec);
+ return cleanupError(fru_fp, fru_area_vec);
}
// Allocate a buffer to hold entire file content
@@ -635,7 +640,7 @@ int validateFRUArea(const uint8_t fruid, const char* fru_file_name,
log<level::ERR>("Failed reading fru data.",
entry("BYTESREAD=%d", bytes_read),
entry("ERRNO=%s", std::strerror(errno)));
- return cleanup_error(fru_fp, fru_area_vec);
+ return cleanupError(fru_fp, fru_area_vec);
}
// We are done reading.
@@ -645,7 +650,7 @@ int validateFRUArea(const uint8_t fruid, const char* fru_file_name,
rc = ipmi_validate_common_hdr(fru_data, data_len);
if (rc < 0)
{
- return cleanup_error(fru_fp, fru_area_vec);
+ return cleanupError(fru_fp, fru_area_vec);
}
// Now that we validated the common header, populate various fru sections if
@@ -654,7 +659,7 @@ int validateFRUArea(const uint8_t fruid, const char* fru_file_name,
if (rc < 0)
{
log<level::ERR>("Populating FRU areas failed", entry("FRU=%d", fruid));
- return cleanup_error(fru_fp, fru_area_vec);
+ return cleanupError(fru_fp, fru_area_vec);
}
else
{
OpenPOWER on IntegriCloud