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/socket-handler.c b/socket-handler.c
index d7aaa67..954c326 100644
--- a/socket-handler.c
+++ b/socket-handler.c
@@ -86,10 +86,16 @@
client = NULL;
sh->n_clients--;
+ /*
+ * We're managing an array of pointers to aggregates, so don't warn about sizeof() on a
+ * pointer type.
+ */
+ /* NOLINTBEGIN(bugprone-sizeof-expression) */
memmove(&sh->clients[idx], &sh->clients[idx + 1],
sizeof(*sh->clients) * (sh->n_clients - idx));
sh->clients =
- realloc(sh->clients, sizeof(*sh->clients) * sh->n_clients);
+ reallocarray(sh->clients, sh->n_clients, sizeof(*sh->clients));
+ /* NOLINTEND(bugprone-sizeof-expression) */
}
static void client_set_blocked(struct client *client, bool blocked)
@@ -299,8 +305,14 @@
sh->console, client_ringbuffer_poll, client);
n = sh->n_clients++;
+ /*
+ * We're managing an array of pointers to aggregates, so don't warn about sizeof() on a
+ * pointer type.
+ */
+ /* NOLINTBEGIN(bugprone-sizeof-expression) */
sh->clients =
- realloc(sh->clients, sizeof(*sh->clients) * sh->n_clients);
+ reallocarray(sh->clients, sh->n_clients, sizeof(*sh->clients));
+ /* NOLINTEND(bugprone-sizeof-expression) */
sh->clients[n] = client;
return POLLER_OK;