aboutsummaryrefslogtreecommitdiff
path: root/src/backup.c
diff options
context:
space:
mode:
authorJan Sucan <jan@jansucan.com>2023-11-12 15:15:31 +0100
committerJan Sucan <jan@jansucan.com>2023-11-12 15:15:38 +0100
commitbdcce656c964c6d94d85639e3f064fc8aef0c124 (patch)
tree226ee7572421645d6308eb405ccbb254ad9a5837 /src/backup.c
parent28ec9477c63342f05c6d7b0d39581c6611f76ab4 (diff)
Refactor the file size and tell operations
This was done in order to avoid C++ compiler warnings about comparing types with different signedness.
Diffstat (limited to 'src/backup.c')
-rw-r--r--src/backup.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/backup.c b/src/backup.c
index 4c9dfbd..0b558b6 100644
--- a/src/backup.c
+++ b/src/backup.c
@@ -43,16 +43,18 @@ static int
check_files(const options_backup_t *const opts,
const resources_backup_t *const res)
{
- const long in_size = file_size(res->in_file);
+ bool in_size_ok = false;
+ const size_t in_size = file_size(res->in_file, &in_size_ok);
- if (in_size < 0) {
+ if (!in_size_ok) {
print_error("cannot get size of input file: %s", strerror(errno));
return 1;
}
- const long ref_size = file_size(res->ref_file);
+ bool ref_size_ok = false;
+ const size_t ref_size = file_size(res->ref_file, &ref_size_ok);
- if (ref_size < 0) {
+ if (!ref_size_ok) {
print_error("cannot get size of reference file: %s", strerror(errno));
return 1;
}