diff options
author | dzwdz | 2022-12-27 17:04:15 +0100 |
---|---|---|
committer | dzwdz | 2022-12-27 19:13:44 +0100 |
commit | 021fcb5f9734c4980b9f4793e756641b6e8477b3 (patch) | |
tree | 7934fa1c8c724301e67b3b0666116f7b850f1e50 /src | |
parent | 7ea0ddc733285cfa25d6535954de4784b054902a (diff) |
fsutil: don't set the offset to 0 when length == 0
Diffstat (limited to 'src')
-rw-r--r-- | src/shared/fsutil.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/shared/fsutil.c b/src/shared/fsutil.c index ffdcc43..05ca44a 100644 --- a/src/shared/fsutil.c +++ b/src/shared/fsutil.c @@ -16,7 +16,8 @@ void fs_normslice(long *restrict offset, size_t *restrict length, size_t max, bo *offset += max + 1; if (*offset < 0) { /* cursor went before the file, EOF */ - *length = *offset = 0; + *length = 0; + *offset = max; goto end; } } @@ -37,14 +38,13 @@ void fs_normslice(long *restrict offset, size_t *restrict length, size_t max, bo *length = maxlen; } else { /* regular EOF */ - *length = *offset = 0; + *length = 0; + *offset = max; goto end; } } end: - if (*length == 0) *offset = 0; - assert(0 <= *offset); if (!expand) assert(*offset + *length <= max); |