Enable pro-type-static-cast-downcast checks
We only had one usage, and it was really bad and breaking const
correctness, so fix it to read the crashdump in inline.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I234946fe09d73a9fa0191a15a89d0b2c26f32337
diff --git a/.clang-tidy b/.clang-tidy
index c15af94..7f36b77 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -211,6 +211,7 @@
cppcoreguidelines-pro-type-cstyle-cast,
cppcoreguidelines-pro-type-member-init,
cppcoreguidelines-pro-type-reinterpret-cast,
+cppcoreguidelines-pro-type-static-cast-downcast,
cppcoreguidelines-pro-type-vararg,
cppcoreguidelines-special-member-functions,
misc-misplaced-const,
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index a33e061..774bb0a 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -2856,16 +2856,9 @@
return;
}
ifs.seekg(0, std::ios::beg);
-
- auto crashData = std::make_unique<char[]>(
- static_cast<unsigned int>(fileSize));
-
- ifs.read(crashData.get(), static_cast<int>(fileSize));
-
- // The cast to std::string is intentional in order to
- // use the assign() that applies move mechanics
- asyncResp->res.body().assign(
- static_cast<std::string>(crashData.get()));
+ size_t sFileSize = static_cast<size_t>(fileSize);
+ asyncResp->res.body().resize(sFileSize, '\0');
+ ifs.read(asyncResp->res.body().data(), fileSize);
// Configure this to be a file download when accessed
// from a browser