Fix code health issues in the CDM identified by Coverity

Bug: 323331064
Change-Id: Ic87b32c1f7996bd5bb31e99a5fc117c59e94a42c
This commit is contained in:
Ian Benz
2024-01-30 21:12:56 +00:00
committed by Robert Shih
parent 93c19cd8de
commit 2fabef5bc9
5 changed files with 12 additions and 9 deletions

View File

@@ -34,9 +34,10 @@ void DumpHeader(std::ofstream* out, const std::string& type) {
void DumpHex(std::ofstream* out, const std::string& name,
const std::string& value) {
const auto out_flags = out->flags();
*out << "const uint8_t " << name << "_raw[] = {\n";
*out << " ";
for (unsigned int i = 0; i < value.length(); i++) {
for (size_t i = 0; i < value.length(); i++) {
if ((i > 0) && (i % 10 == 0)) *out << "\n ";
uint8_t c = value[i];
*out << "0x" << std::hex << std::setw(2) << std::setfill('0') << int(c)
@@ -46,7 +47,7 @@ void DumpHex(std::ofstream* out, const std::string& name,
*out << name << "_ = std::string (\n"
<< " reinterpret_cast<const char *>(" << name << "_raw), \n"
<< " sizeof(" << name << "_raw));\n";
*out << std::dec; // Turn off hex when we're done.
out->flags(out_flags); // Restore flags when we're done.
}
void LogTimer(const char* field, bool set, int64_t time) {