aboutsummaryrefslogtreecommitdiffstats
path: root/src/byte_source.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-12-31 12:37:57 +0100
committerDavid Robillard <d@drobilla.net>2020-12-31 12:37:57 +0100
commit8a93d0b3be5b6d80a1bef85bc73b2661f5ab4376 (patch)
treec65c3327fde67505a8f989e57cb245ee0f286cb9 /src/byte_source.c
parent19d8a055ff1e58a699e3679b701a1a60a2927243 (diff)
downloadserd-8a93d0b3be5b6d80a1bef85bc73b2661f5ab4376.tar.gz
serd-8a93d0b3be5b6d80a1bef85bc73b2661f5ab4376.tar.bz2
serd-8a93d0b3be5b6d80a1bef85bc73b2661f5ab4376.zip
Avoid "else" after "break" and "return"
Diffstat (limited to 'src/byte_source.c')
-rw-r--r--src/byte_source.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/byte_source.c b/src/byte_source.c
index 5c0404a7..a62f7a47 100644
--- a/src/byte_source.c
+++ b/src/byte_source.c
@@ -30,15 +30,19 @@ serd_byte_source_page(SerdByteSource* source)
source->read_head = 0;
const size_t n_read = source->read_func(
source->file_buf, 1, source->page_size, source->stream);
+
if (n_read == 0) {
source->file_buf[0] = '\0';
source->eof = true;
return (source->error_func(source->stream)
? SERD_ERR_UNKNOWN : SERD_FAILURE);
- } else if (n_read < source->page_size) {
+ }
+
+ if (n_read < source->page_size) {
source->file_buf[n_read] = '\0';
source->buf_size = n_read;
}
+
return SERD_SUCCESS;
}
@@ -76,13 +80,12 @@ SerdStatus
serd_byte_source_prepare(SerdByteSource* source)
{
source->prepared = true;
+
if (source->from_stream) {
- if (source->page_size > 1) {
- return serd_byte_source_page(source);
- } else if (source->from_stream) {
- return serd_byte_source_advance(source);
- }
+ return (source->page_size > 1 ? serd_byte_source_page(source)
+ : serd_byte_source_advance(source));
}
+
return SERD_SUCCESS;
}