From 9b660eb7479cf4371808b98b771c1f7d9258a413 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Sat, 17 Sep 2022 15:54:10 +0200 Subject: [PATCH] Drop one time used macro Drop unnecessary OOM check. --- src/check_hooks.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/check_hooks.c b/src/check_hooks.c index 9f308008..80510522 100644 --- a/src/check_hooks.c +++ b/src/check_hooks.c @@ -28,18 +28,6 @@ int found_issue = 0; int suppress_output = 0; int full_path = 0; -#define ALLOC_NODE(nl) if (ck->check_nodes[nl]) { \ - loc = ck->check_nodes[nl]; \ - while (loc->next) { loc = loc->next; } \ - loc->next = xmalloc(sizeof(struct check_node)); \ - if (!loc->next) { return SELINT_OUT_OF_MEM; } \ - loc = loc->next; \ -} else { \ - ck->check_nodes[nl] = xmalloc(sizeof(struct check_node)); \ - if (!ck->check_nodes[nl]) { return SELINT_OUT_OF_MEM; } \ - loc = ck->check_nodes[nl]; \ -} - enum selint_error add_check(enum node_flavor check_flavor, struct checks *ck, const char *check_id, struct check_result *(*check_function)(const struct check_data *check_data, @@ -47,7 +35,17 @@ enum selint_error add_check(enum node_flavor check_flavor, struct checks *ck, { struct check_node *loc; - ALLOC_NODE(check_flavor); + if (ck->check_nodes[check_flavor]) { + loc = ck->check_nodes[check_flavor]; + while (loc->next) { + loc = loc->next; + } + loc->next = xmalloc(sizeof(struct check_node)); + loc = loc->next; + } else { + ck->check_nodes[check_flavor] = xmalloc(sizeof(struct check_node)); + loc = ck->check_nodes[check_flavor]; + } loc->check_function = check_function; loc->check_id = xstrdup(check_id);