Skip to content

Commit

Permalink
fix som cppcheck issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Dreik committed Jan 12, 2025
1 parent d285323 commit d543b79
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 19 deletions.
18 changes: 8 additions & 10 deletions EasyRandom.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,14 @@ class EasyRandom::GlobalRandom final

private:
std::mt19937 m_gen{};
static const int nchars = 64;
static constexpr int nchars = 64;
static char getChar(int i)
{
const char acceptable_filename_chars[] = "abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"0123456789"
"_-";
static_assert(nchars + 1 == sizeof(acceptable_filename_chars),
"mismatch in size");
const char acceptable_filename_chars[nchars + 1] =
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"0123456789"
"_-";
return acceptable_filename_chars[i];
}
std::uniform_int_distribution<int> m_dist{ 0, nchars - 1 };
Expand All @@ -69,8 +68,7 @@ std::string
EasyRandom::makeRandomFileString(std::size_t N)
{
std::string ret(N, '\0');
for (auto& c : ret) {
c = m_rand.randomFileChar();
}
std::generate(
begin(ret), end(ret), [this]() { return m_rand.randomFileChar(); });
return ret;
}
10 changes: 5 additions & 5 deletions Fileinfo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,12 @@ Fileinfo::getduptypestring(const Fileinfo& A)

// constructor
Fileinfo::Fileinfostat::Fileinfostat()
: stat_size{ 99999 }
, stat_ino{ 99999 }
, stat_dev{ 99999 }
, is_file{ false }
, is_directory{ false }
{
stat_size = 99999;
stat_ino = 99999;
stat_dev = 99999;
is_file = false;
is_directory = false;
}

int
Expand Down
4 changes: 0 additions & 4 deletions Fileinfo.hh
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ public:
void setduptype(enum duptype duptype_) { m_duptype = duptype_; }

std::int64_t getidentity() const { return m_identity; }
static std::int64_t identity(const Fileinfo& A) { return A.getidentity(); }
void setidentity(std::int64_t id) { m_identity = id; }

/**
Expand Down Expand Up @@ -109,9 +108,6 @@ public:
/// returns the file size in bytes
filesizetype size() const { return m_info.stat_size; }

// returns true if A has size zero
bool isempty() const { return size() == 0; }

/// filesize comparison
bool is_smaller_than(Fileinfo::filesizetype minsize) const
{
Expand Down
3 changes: 3 additions & 0 deletions UndoableUnlink.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ UndoableUnlink::unlink()
return 0;
}

// cppcheck thinks this can throw in undo(), but that contains a check for
// m_state so that can not happen.
// cppcheck-suppress throwInNoexceptFunction
UndoableUnlink::~UndoableUnlink()
{
if (m_state == state::MOVED_TO_TEMPORARY) {
Expand Down

0 comments on commit d543b79

Please sign in to comment.