coverity suggestions; nbd disk-backend garbage output fix

This commit is contained in:
folkert van heusden 2024-04-21 21:06:44 +02:00
parent bccf8c69cf
commit 1c03260f37
Signed by untrusted user who does not match committer: folkert
GPG key ID: 6B6455EDFEED3BD1
3 changed files with 7 additions and 4 deletions

View file

@ -79,7 +79,7 @@ std::pair<breakpoint_register *, std::optional<std::string> > breakpoint_registe
return { nullptr, "register: key or value missing" };
auto values_in = parts.at(1);
auto v_parts = split(values_in, ",");
auto v_parts = split(std::move(values_in), ",");
std::set<uint16_t> values;
for(auto & v: v_parts)
values.insert(std::stoi(v, nullptr, 8));

View file

@ -346,6 +346,8 @@ bool cpu::check_pending_interrupts() const
for(uint8_t i=start_level; i < 8; i++) {
auto interrupts = queued_interrupts.find(i);
assert(interrupts != queued_interrupts.end());
if (interrupts->second.empty() == false)
return true;
}
@ -2316,7 +2318,7 @@ std::map<std::string, std::vector<std::string> > cpu::disassemble(const uint16_t
// PSW
std::string psw_str = format("%d%d|%d|%d|%c%c%c%c%c", psw >> 14, (psw >> 12) & 3, (psw >> 11) & 1, (psw >> 5) & 7,
psw & 16?'t':'-', psw & 8?'n':'-', psw & 4?'z':'-', psw & 2 ? 'v':'-', psw & 1 ? 'c':'-');
out.insert({ "psw", { psw_str } });
out.insert({ "psw", { std::move(psw_str) } });
out.insert({ "psw-value", { format("%06o", psw) } });
// values worked with

View file

@ -119,13 +119,14 @@ bool disk_backend_nbd::connect(const bool retry)
}
}
if (memcmp(nbd_hello.magic1, "NBDMAGIC", 8) != 0) {
if (fd != -1 && memcmp(nbd_hello.magic1, "NBDMAGIC", 8) != 0) {
close(fd);
fd = -1;
DOLOG(warning, true, "disk_backend_nbd::connect: magic invalid");
}
DOLOG(info, false, "NBD size: %u", NTOHLL(nbd_hello.size));
if (fd != -1)
DOLOG(info, false, "NBD size: %u", NTOHLL(nbd_hello.size));
}
while(fd == -1 && retry);