Skip to content

Commit 8984c65

Browse files
committed
cond_get_agg: minor refactor
- Use stack instead of heap memory - constify Signed-off-by: Joachim Wiberg <[email protected]>
1 parent 1a7b26b commit 8984c65

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/cond.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,16 @@ enum cond_state cond_get(const char *name)
9696

9797
enum cond_state cond_get_agg(const char *names)
9898
{
99-
static char conds[MAX_COND_LEN];
10099
enum cond_state s = COND_ON;
101-
char *cond;
102100

103-
if (!names)
104-
return COND_ON;
101+
if (names) {
102+
char conds[strlen(names) + 1];
103+
const char *cond;
105104

106-
strlcpy(conds, names, sizeof(conds));
107-
for (cond = strtok(conds, ","); s && cond; cond = strtok(NULL, ","))
108-
s = min(s, cond_get(cond));
105+
strlcpy(conds, names, sizeof(conds));
106+
for (cond = strtok(conds, ","); s && cond; cond = strtok(NULL, ","))
107+
s = min(s, cond_get(cond));
108+
}
109109

110110
return s;
111111
}

0 commit comments

Comments
 (0)