From e19731f6d38aa0931f59bba95565c8f40f1dc3b0 Mon Sep 17 00:00:00 2001 From: Jan Sucan Date: Sun, 30 May 2021 18:06:18 +0200 Subject: Fix cppcheck warnings --- src/backup.c | 2 +- src/restore.c | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/backup.c b/src/backup.c index dcda6b5..15628b8 100644 --- a/src/backup.c +++ b/src/backup.c @@ -190,7 +190,7 @@ backup(const options_t *const opts, resources_t *const res) } /* Write out the output buffer */ - if (out_buffer_index >= 0) { + if (out_buffer_index > 0) { if (write_out_buffer(res->out_buffer, out_buffer_index, res->out_file) != 1) { return 1; diff --git a/src/restore.c b/src/restore.c index 11f10f7..1c2beae 100644 --- a/src/restore.c +++ b/src/restore.c @@ -63,7 +63,6 @@ is_reference_file_valid(resources_t *const res, uint32_t sector_size) return 1; } - uint64_t ref_offset = 0; uint64_t prev_out_offset; /* Scan the reference file and check */ @@ -79,7 +78,7 @@ is_reference_file_valid(resources_t *const res, uint32_t sector_size) } else if ((ref_read != 1U) || ferror(res->ref_file)) { print_error("cannot read from reference file: %s", strerror(errno)); return false; - } else if (((ref_offset != 0) && (out_offset <= prev_out_offset)) || + } else if (((out_offset <= prev_out_offset)) || ((out_offset + sector_size) > out_size)) { /* The offset must be higher than the previous one and it * must point into the file @@ -134,9 +133,9 @@ restore(const options_t *const opts, resources_t *const res) } /* Restore data from the differential image */ - uint64_t out_offset; - for (;;) { + uint64_t out_offset; + /* Read data of the offset and the next sector */ const size_t ref_read = fread(res->ref_buffer, ref_buffer_size, 1U, res->ref_file); -- cgit v1.2.3