Skip to content

Commit

Permalink
Merge pull request #643 from JagMod/master
Browse files Browse the repository at this point in the history
cppcheck warnings fixed
  • Loading branch information
tschak909 authored Jul 27, 2023
2 parents 4ff7437 + cd7bc13 commit 0af5aa7
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 16 deletions.
10 changes: 5 additions & 5 deletions lib/device/rs232/network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,11 @@ void rs232Network::rs232_set_prefix()
prefixSpec_str = prefixSpec_str.substr(prefixSpec_str.find_first_of(":") + 1);
Debug_printf("rs232Network::rs232_set_prefix(%s)\n", prefixSpec_str.c_str());

if (prefixSpec_str == "..") // Devance path N:..
if (prefixSpec_str.empty())
{
prefix.clear();
}
else if (prefixSpec_str == "..") // Devance path N:..
{
vector<int> pathLocations;
for (int i = 0; i < prefix.size(); i++)
Expand All @@ -489,10 +493,6 @@ void rs232Network::rs232_set_prefix()
{
prefix = prefixSpec_str;
}
else if (prefixSpec_str.empty())
{
prefix.clear();
}
else if (prefixSpec_str.find_first_of(":") != string::npos)
{
prefix = prefixSpec_str;
Expand Down
10 changes: 5 additions & 5 deletions lib/device/sio/network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,11 @@ void sioNetwork::sio_set_prefix()
prefixSpec_str = prefixSpec_str.substr(prefixSpec_str.find_first_of(":") + 1);
Debug_printf("sioNetwork::sio_set_prefix(%s)\n", prefixSpec_str.c_str());

if (prefixSpec_str == "..") // Devance path N:..
if (prefixSpec_str.empty())
{
prefix.clear();
}
else if (prefixSpec_str == "..") // Devance path N:..
{
vector<int> pathLocations;
for (int i = 0; i < prefix.size(); i++)
Expand Down Expand Up @@ -537,10 +541,6 @@ void sioNetwork::sio_set_prefix()
{
prefix = prefixSpec_str;
}
else if (prefixSpec_str.empty())
{
prefix.clear();
}
else if (prefixSpec_str.find_first_of(":") != string::npos)
{
prefix = prefixSpec_str;
Expand Down
7 changes: 7 additions & 0 deletions lib/ftp/fnFTP.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ class fnFTP
*/
virtual ~fnFTP();

/**
* Class 'fnFTP' does not have a copy constructor which is recommended since it has dynamic memory/resource allocation(s).
* Unless these two functions are implemented, they are being deleted so they cannot be used
*/
fnFTP (const fnFTP&) = delete;
fnFTP& operator= (const fnFTP&) = delete;

/**
* Log into FTP server.
* @param username username for login
Expand Down
1 change: 1 addition & 0 deletions lib/http/httpService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ void fnHttpService::parse_query(httpd_req_t *req, queryparts *results)
return;
}

/// @todo Error if path_end == 0, the index to substr becomes -1
results->path += results->full_uri.substr(0, path_end - 1);
results->query += results->full_uri.substr(path_end + 1);

Expand Down
2 changes: 1 addition & 1 deletion lib/meatloaf/device/flash.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ friend class FlashIStream;
if (mstr::contains(name, "?") || mstr::contains(name, "*"))
seekEntry( name );

if (!pathValid(path.c_str()))
if (!pathValid(path))
m_isNull = true;
else
m_isNull = false;
Expand Down
3 changes: 2 additions & 1 deletion lib/meatloaf/network/tnfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,10 @@ void TNFSHandle::obtain(std::string m_path, std::string mode) {
// it will be caught by the real file open later on

char *pathStr = new char[m_path.length()];
strncpy(pathStr, m_path.data(), m_path.length());

if (pathStr) {
strncpy(pathStr, m_path.data(), m_path.length());

// Make dirs up to the final fnamepart
char *ptr = strchr(pathStr, '/');
while (ptr) {
Expand Down
7 changes: 7 additions & 0 deletions lib/network-protocol/FTP.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ class NetworkProtocolFTP : public NetworkProtocolFS
*/
virtual ~NetworkProtocolFTP();

/**
* Class 'NetworkProtocolFTP' does not have a copy constructor which is recommended since it has dynamic memory/resource allocation(s).
* Unless these two functions are implemented, they are being deleted so they cannot be used
*/
NetworkProtocolFTP (const NetworkProtocolFTP&) = delete;
NetworkProtocolFTP& operator= (const NetworkProtocolFTP&) = delete;

/**
* @brief Return a DSTATS byte for a requested COMMAND byte.
* @param cmd The Command (0x00-0xFF) for which DSTATS is requested.
Expand Down
2 changes: 1 addition & 1 deletion lib/printer-emulator/atari_1029.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void atari1029::print_8bit_gfx(uint8_t c)
// lead with '0' to enter a space
// then shift back with 133 and print each pin
fprintf(_file, "0");
for (int i = 0; i < 7; i++)
for (unsigned i = 0; i < 7; i++)
{
if ((c >> i) & 0x01)
fprintf(_file, ")100(%u", i + 1);
Expand Down
2 changes: 1 addition & 1 deletion lib/printer-emulator/commodoremps803.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void commodoremps803::mps_print_bitmap(uint8_t c)
// lead with '0' to enter a space
// then shift back with 100 and print each pin
fprintf(_file, " ");
for (int i = 0; i < 8; i++)
for (unsigned i = 0; i < 8; i++)
{
if ((c >> i) & 0x01)
fprintf(_file, ")100(%u", i + 1);
Expand Down
2 changes: 1 addition & 1 deletion lib/printer-emulator/epson_80.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void epson80::print_8bit_gfx(uint8_t c)
// lead with '0' to enter a space
// then shift back with 133 and print each pin
fprintf(_file, "0");
for (int i = 0; i < 8; i++)
for (unsigned i = 0; i < 8; i++)
{
if ((c >> i) & 0x01)
fprintf(_file, ")133(%u", i + 1);
Expand Down
2 changes: 1 addition & 1 deletion lib/printer-emulator/okimate_10.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ void okimate10::print_7bit_gfx(uint8_t c)
// lead with '0' to enter a space
// then shift back with 100 and print each pin
fprintf(_file, "0");
for (int i = 0; i < 7; i++)
for (unsigned i = 0; i < 7; i++)
{
if ((c >> (6 - i)) & 0x01) // have the gfx font points backwards or Okimate dot-graphics are upside down
fprintf(_file, ")99(%u", i + 1);
Expand Down
1 change: 1 addition & 0 deletions lib/sam/sam.c
Original file line number Diff line number Diff line change
Expand Up @@ -1275,6 +1275,7 @@ void AdjustLengths()
mem56 = flags[index];

// not a consonant
/// @todo code above check if index == 255, if it is, then flags[index] is out of bounds
if ((flags[index] & 64) == 0)
{
// RX or LX?
Expand Down
5 changes: 5 additions & 0 deletions lib/utils/cbuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ class cbuf
cbuf(size_t size);
~cbuf();

// Class 'cbuf' does not have a copy constructor which is recommended since it has dynamic memory/resource allocation(s).
// Unless these two functions are implemented, they are being deleted so they cannot be used
cbuf (const cbuf&) = delete;
cbuf& operator= (const cbuf&) = delete;

size_t resizeAdd(size_t addSize);
size_t resize(size_t newSize);
size_t available() const;
Expand Down

0 comments on commit 0af5aa7

Please sign in to comment.