obmc-console: Address bugprone-sizeof-expression
Disable the lint where we know the implementation is valid, but do not
disable it globally.
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: Ie1640d82138fe91a401188cf966250103a25dde6
diff --git a/ringbuffer.c b/ringbuffer.c
index 48c163a..efa5204 100644
--- a/ringbuffer.c
+++ b/ringbuffer.c
@@ -77,8 +77,14 @@
rbc->pos = rb->tail;
n = rb->n_consumers++;
- rb->consumers = realloc(rb->consumers,
- sizeof(*rb->consumers) * rb->n_consumers);
+ /*
+ * We're managing an array of pointers to aggregates, so don't warn about sizeof() on a
+ * pointer type.
+ */
+ /* NOLINTBEGIN(bugprone-sizeof-expression) */
+ rb->consumers = reallocarray(rb->consumers, rb->n_consumers,
+ sizeof(*rb->consumers));
+ /* NOLINTEND(bugprone-sizeof-expression) */
rb->consumers[n] = rbc;
return rbc;
@@ -97,11 +103,17 @@
rb->n_consumers--;
+ /*
+ * We're managing an array of pointers to aggregates, so don't warn about sizeof() on a
+ * pointer type.
+ */
+ /* NOLINTBEGIN(bugprone-sizeof-expression) */
memmove(&rb->consumers[i], &rb->consumers[i + 1],
sizeof(*rb->consumers) * (rb->n_consumers - i));
- rb->consumers = realloc(rb->consumers,
- sizeof(*rb->consumers) * rb->n_consumers);
+ rb->consumers = reallocarray(rb->consumers, rb->n_consumers,
+ sizeof(*rb->consumers));
+ /* NOLINTEND(bugprone-sizeof-expression) */
free(rbc);
}