obmc-console: Fix readability-braces-around-statements
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I88d2bdcb15106298d83a1cf7176e069092820f1d
diff --git a/ringbuffer.c b/ringbuffer.c
index efa5204..856e077 100644
--- a/ringbuffer.c
+++ b/ringbuffer.c
@@ -46,8 +46,9 @@
struct ringbuffer *rb;
rb = malloc(sizeof(*rb) + size);
- if (!rb)
+ if (!rb) {
return NULL;
+ }
memset(rb, 0, sizeof(*rb));
rb->size = size;
@@ -58,8 +59,9 @@
void ringbuffer_fini(struct ringbuffer *rb)
{
- while (rb->n_consumers)
+ while (rb->n_consumers) {
ringbuffer_consumer_unregister(rb->consumers[0]);
+ }
free(rb);
}
@@ -95,9 +97,11 @@
struct ringbuffer *rb = rbc->rb;
int i;
- for (i = 0; i < rb->n_consumers; i++)
- if (rb->consumers[i] == rbc)
+ for (i = 0; i < rb->n_consumers; i++) {
+ if (rb->consumers[i] == rbc) {
break;
+ }
+ }
assert(i < rb->n_consumers);
@@ -120,10 +124,11 @@
size_t ringbuffer_len(struct ringbuffer_consumer *rbc)
{
- if (rbc->pos <= rbc->rb->tail)
+ if (rbc->pos <= rbc->rb->tail) {
return rbc->rb->tail - rbc->pos;
- else
+ } else {
return rbc->rb->tail + rbc->rb->size - rbc->pos;
+ }
}
static size_t ringbuffer_space(struct ringbuffer_consumer *rbc)
@@ -137,14 +142,16 @@
enum ringbuffer_poll_ret prc;
size_t force_len;
- if (ringbuffer_space(rbc) >= len)
+ if (ringbuffer_space(rbc) >= len) {
return 0;
+ }
force_len = len - ringbuffer_space(rbc);
prc = rbc->poll_fn(rbc->poll_data, force_len);
- if (prc != RINGBUFFER_POLL_OK)
+ if (prc != RINGBUFFER_POLL_OK) {
return -1;
+ }
return 0;
}
@@ -155,11 +162,13 @@
size_t wlen;
int i, rc;
- if (len >= rb->size)
+ if (len >= rb->size) {
return -1;
+ }
- if (len == 0)
+ if (len == 0) {
return 0;
+ }
/* Ensure there is at least len bytes of space available.
*
@@ -212,14 +221,16 @@
size_t pos;
size_t len;
- if (offset >= ringbuffer_len(rbc))
+ if (offset >= ringbuffer_len(rbc)) {
return 0;
+ }
pos = (rbc->pos + offset) % rb->size;
- if (pos <= rb->tail)
+ if (pos <= rb->tail) {
len = rb->tail - pos;
- else
+ } else {
len = rb->size - pos;
+ }
*data = rb->buf + pos;
return len;