Skip to content

Commit

Permalink
FIX: dinit-iostream: Remove useless else(s)
Browse files Browse the repository at this point in the history
According to CODE-STYLE:

>   2.2. Omit "else" if the body of the associated "if" does not fall through (i.e. if it always
>        either returns or throws an exception).

Signed-off-by: Mobin Aydinfar <[email protected]>
  • Loading branch information
mobin-2008 committed Oct 21, 2024
1 parent 878b7f1 commit 074ee79
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/dinit-iostream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ ssize_t ostream::put(const char *msg, size_t count) noexcept
if (count == 0) {
return 0; // Null/Empty message
}
else if (count > buf->get_size()) {
if (count > buf->get_size()) {
bool r = flush_nx();
if (!r) {
// io_error was set by flush_nx() call
return -1;
}
else while (count > static_cast<size_t>(buf->get_free())) {
while (count > static_cast<size_t>(buf->get_free())) {
int prev_freespace = buf->get_free();
buf->append(msg, prev_freespace);
msg += prev_freespace;
Expand All @@ -88,7 +88,7 @@ ssize_t ostream::put(const char *msg, size_t count) noexcept
buf->append(msg, count);
return output_count + count;
}
else while (count > static_cast<size_t>(buf->get_free())) {
while (count > static_cast<size_t>(buf->get_free())) {
// If we haven't enough storage for caputring the message Firstly we try to fill buffer as
// much as possible and then write the buffer.
int prev_freespace = buf->get_free();
Expand All @@ -104,7 +104,6 @@ ssize_t ostream::put(const char *msg, size_t count) noexcept
}

buf->append(msg, count);

return output_count + count;
}

Expand Down Expand Up @@ -236,7 +235,8 @@ bool ostream::flush_nx() noexcept
if (!good()) {
return -1;
}
else while (buf->get_length() > 0) {

while (buf->get_length() > 0) {
char *ptr = buf->get_ptr(0);
unsigned len = buf->get_contiguous_length(ptr);
ssize_t r = bp_sys::write(fd, ptr, len);
Expand Down Expand Up @@ -613,7 +613,7 @@ int istream::getc_nx() noexcept
eof_state = true;
return -1;
}
else if (r < 0) {
if (r < 0) {
io_error = errno;
return -1;
}
Expand Down

0 comments on commit 074ee79

Please sign in to comment.