From 234b735df51ab47eecb6ff3a33a63923059816bc Mon Sep 17 00:00:00 2001 From: Patrick Venture Date: Sat, 20 Oct 2018 09:37:09 -0700 Subject: 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 --- writefrudata.cpp | 53 +++++++++++++++++++++++++++++------------------------ 1 file 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 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("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("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("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("Populating FRU areas failed", entry("FRU=%d", fruid)); - return cleanup_error(fru_fp, fru_area_vec); + return cleanupError(fru_fp, fru_area_vec); } else { -- cgit v1.2.1