aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Sucan <jan@jansucan.com>2021-05-30 18:06:18 +0200
committerJan Sucan <jan@jansucan.com>2021-05-30 18:06:24 +0200
commite19731f6d38aa0931f59bba95565c8f40f1dc3b0 (patch)
tree1fe851b862adcf26824ce854002ad2a803382f8f
parent2ec55caeeafe4cc381386b8f708f6f1f76bffc3f (diff)
Fix cppcheck warnings
-rw-r--r--src/backup.c2
-rw-r--r--src/restore.c7
2 files changed, 4 insertions, 5 deletions
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);