Skip to content

Commit

Permalink
Drop one time used macro
Browse files Browse the repository at this point in the history
Drop unnecessary OOM check.
  • Loading branch information
cgzones committed Dec 29, 2023
1 parent fb346a2 commit 4e84151
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/check_hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,24 @@ 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,
const struct policy_node *node))
{
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);
Expand Down

0 comments on commit 4e84151

Please sign in to comment.