From 021fcb5f9734c4980b9f4793e756641b6e8477b3 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Tue, 27 Dec 2022 17:04:15 +0100 Subject: fsutil: don't set the offset to 0 when length == 0 --- src/shared/fsutil.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') 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); -- cgit v1.2.3