summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordzwdz2022-07-29 19:30:26 +0200
committerdzwdz2022-07-29 19:30:26 +0200
commitdf7e4aeeed27c35994bc12614d5ffcb82ec6497b (patch)
tree3e6581bb5b7882651b1c6e23c04cddb3dd9afc8b /src
parent2cdc815322af6c7c22b9ceb371d9c7b2a4853c0e (diff)
fsutil/fs_normslice: define *offset == 0 when *length == 0
Diffstat (limited to 'src')
-rw-r--r--src/shared/fsutil.c12
-rw-r--r--src/shared/include/camellia/fsutil.h1
2 files changed, 5 insertions, 8 deletions
diff --git a/src/shared/fsutil.c b/src/shared/fsutil.c
index a1dabfd..45a64f6 100644
--- a/src/shared/fsutil.c
+++ b/src/shared/fsutil.c
@@ -45,11 +45,9 @@ void fs_normslice(long *restrict offset, size_t *restrict length, size_t max, bo
}
end:
- if (*length > 0) {
- assert(0 <= *offset);
- if (!expand)
- assert(*offset + *length <= max);
- } else {
- /* EOF, *offset is undefined. */
- }
+ if (*length == 0) *offset = 0;
+
+ assert(0 <= *offset);
+ if (!expand)
+ assert(*offset + *length <= max);
}
diff --git a/src/shared/include/camellia/fsutil.h b/src/shared/include/camellia/fsutil.h
index eb2b23e..8b8c4fc 100644
--- a/src/shared/include/camellia/fsutil.h
+++ b/src/shared/include/camellia/fsutil.h
@@ -3,7 +3,6 @@
#include <stddef.h>
/** Normalizes the offset and length passed to a fs into safe values.
- * If returns *length == 0, *offset is meaningless.
*
* @param expand Can this operation expand the target file?
* true if writing to a file with an adjustable size