Skip to content

Commit

Permalink
Fix cppcheck warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
uweseimet committed Dec 30, 2024
1 parent d5d11d7 commit f324038
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 18 deletions.
2 changes: 1 addition & 1 deletion cpp/base/device_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class DeviceFactory
shared_ptr<PrimaryDevice> CreateDevice(PbDeviceType, int, const string&) const;
PbDeviceType GetTypeForFile(const string&) const;

auto GetExtensionMapping() const
const auto& GetExtensionMapping() const
{
return mapping;
}
Expand Down
2 changes: 1 addition & 1 deletion cpp/base/property_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ property_map PropertyHandler::GetProperties(const string &filter) const
return filtered_properties;
}

property_map PropertyHandler::GetUnknownProperties() const
const property_map& PropertyHandler::GetUnknownProperties() const
{
return unknown_properties;
}
Expand Down
2 changes: 1 addition & 1 deletion cpp/base/property_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class PropertyHandler
void Init(const string&, const property_map&, bool);

property_map GetProperties(const string& = "") const;
property_map GetUnknownProperties() const;
const property_map& GetUnknownProperties() const;
const string& RemoveProperty(const string&, const string& = "");
void AddProperty(const string&, string_view);
void RemoveProperties(const string&);
Expand Down
2 changes: 1 addition & 1 deletion cpp/command/command_image_support.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class CommandImageSupport
{
return depth;
}
string GetDefaultFolder() const
const string& GetDefaultFolder() const
{
return default_folder;
}
Expand Down
2 changes: 1 addition & 1 deletion cpp/devices/scsi_generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ScsiGeneric : public PrimaryDevice
return device + " (" + GetPaddedName() + ")";
}

string GetDevice() const
const string& GetDevice() const
{
return device;
}
Expand Down
4 changes: 2 additions & 2 deletions cpp/devices/storage_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class StorageDevice : public PrimaryDevice
{
filename = filesystem::path(file);
}
string GetLastFilename() const
const string& GetLastFilename() const
{
return last_filename;
}
Expand Down Expand Up @@ -93,7 +93,7 @@ class StorageDevice : public PrimaryDevice
medium_changed = b;
}

static auto GetReservedFiles()
static const auto& GetReservedFiles()
{
return reserved_files;
}
Expand Down
2 changes: 1 addition & 1 deletion cpp/devices/tap_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ pair<string, string> TapDriver::ExtractAddressAndMask(logger &logger) const
address = components[0];

const int m = ParseAsUnsignedInt(components[1]);
if (m == -1 || m < 8 || m > 32) {
if (m < 8 || m > 32) {
logger.error("Invalid CIDR netmask notation '{}'", components[1]);
return {"", ""};
}
Expand Down
2 changes: 1 addition & 1 deletion cpp/devices/tape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ bool Tape::Locate(bool locate_16)
throw ScsiException(SenseKey::ILLEGAL_REQUEST, Asc::INVALID_FIELD_IN_CDB);
}

auto identifier = static_cast<uint32_t>(locate_16 ? GetCdbInt64(4) : GetCdbInt32(3));
auto identifier = locate_16 ? GetCdbInt64(4) : GetCdbInt32(3);
const bool bt = GetCdbByte(1) & 0x04;

if (tar_file) {
Expand Down
4 changes: 1 addition & 3 deletions cpp/s2pexec/s2pexec_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,7 @@ bool S2pExec::ParseArguments(span<char*> args, bool in_process)
if (buffer_size = ParseAsUnsignedInt(buf); buffer_size <= 0) {
throw ParserException("Invalid receive buffer size: '" + buf + "'");
}
else {
buffer.resize(buffer_size);
}
buffer.resize(buffer_size);
}

return true;
Expand Down
10 changes: 4 additions & 6 deletions cpp/shared/s2p_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,10 @@ string s2p_util::ParseIdAndLun(const string &id_spec, int &id, int &lun)
}

if (const auto &components = Split(id_spec, COMPONENT_SEPARATOR, 2); !components.empty()) {
if (components.size() >= 1) {
id = ParseAsUnsignedInt(components[0]);
if (id == -1 || id > 7) {
id = -1;
return "Invalid device ID: '" + components[0] + "' (0-7)";
}
id = ParseAsUnsignedInt(components[0]);
if (id == -1 || id > 7) {
id = -1;
return "Invalid device ID: '" + components[0] + "' (0-7)";
}

if (components.size() >= 2) {
Expand Down

0 comments on commit f324038

Please sign in to comment.