diff options
| author | Jan Sucan <jan@jansucan.com> | 2024-04-27 15:58:59 +0200 |
|---|---|---|
| committer | Ján Sučan <jan@jansucan.com> | 2024-04-27 16:16:36 +0200 |
| commit | 4387433f3bc125ed8dd08bd974efd8f00fcb5949 (patch) | |
| tree | 6a5fe468b5a76c469d3fc0d0483f37a7ba745a97 | |
| parent | 6a4d6d3f5fb59fc6dd05a1b478a29dc5ae1344fa (diff) | |
Fix issues reported by cppcheck
| -rw-r--r-- | src/backup.cpp | 4 | ||||
| -rw-r--r-- | src/options.cpp | 4 | ||||
| -rw-r--r-- | src/options.h | 4 | ||||
| -rw-r--r-- | src/restore.cpp | 3 |
4 files changed, 8 insertions, 7 deletions
diff --git a/src/backup.cpp b/src/backup.cpp index b7f23b2..99a9141 100644 --- a/src/backup.cpp +++ b/src/backup.cpp @@ -197,8 +197,8 @@ backup(const OptionsBackup &opts) } /* Write the next backup record */ const uint64_t o = htole64(input_file_offset); - memcpy(res.out_buffer.get() + out_buffer_index, (void *)&o, - sizeof(o)); + memcpy(res.out_buffer.get() + out_buffer_index, + reinterpret_cast<const void *>(&o), sizeof(o)); out_buffer_index += sizeof(o); memcpy(res.out_buffer.get() + out_buffer_index, diff --git a/src/options.cpp b/src/options.cpp index 545d11a..9fc89cd 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -181,8 +181,8 @@ OptionParser::parse_common(int *const argc, char ***const argv, Options &opts) *argv += 1; int ch; - char *arg_sector_size = NULL; - char *arg_buffer_size = NULL; + const char *arg_sector_size = NULL; + const char *arg_buffer_size = NULL; while ((ch = getopt(*argc, *argv, ":b:s:")) != -1) { switch (ch) { diff --git a/src/options.h b/src/options.h index 3d80c67..058ad58 100644 --- a/src/options.h +++ b/src/options.h @@ -61,7 +61,7 @@ class OptionsBackup : public Options friend class OptionParser; public: - virtual ~OptionsBackup() = default; + virtual ~OptionsBackup() override = default; std::filesystem::path getInFilePath() const; std::filesystem::path getRefFilePath() const; @@ -78,7 +78,7 @@ class OptionsRestore : public Options friend class OptionParser; public: - virtual ~OptionsRestore() = default; + virtual ~OptionsRestore() override = default; std::filesystem::path getInFilePath() const; std::filesystem::path getOutFilePath() const; diff --git a/src/restore.cpp b/src/restore.cpp index 3f5f4cf..c9ace96 100644 --- a/src/restore.cpp +++ b/src/restore.cpp @@ -188,7 +188,8 @@ restore(const OptionsRestore &opts) char *in_buffer = res.in_buffer.get(); for (size_t s = 0; s < in_sectors_read; ++s) { - const uint64_t out_offset = le64toh(*((uint64_t *)in_buffer)); + const uint64_t out_offset = + le64toh(*(reinterpret_cast<uint64_t *>(in_buffer))); in_buffer += sizeof(uint64_t); if (!res.out_file.seekp(out_offset, std::ios_base::beg)) { |
