From: Baptiste Daroussin Date: Wed, 5 Jul 2023 13:26:37 +0000 (+0200) Subject: subscription: avoid useless goto X-Git-Tag: RELEASE_1_4_0rc1~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f4b825ba7b7e684a79e570276676345f034e01f2;p=thirdparty%2Fmlmmj.git subscription: avoid useless goto --- diff --git a/src/subscriberfuncs.c b/src/subscriberfuncs.c index 69a6ffc8..b8592c80 100644 --- a/src/subscriberfuncs.c +++ b/src/subscriberfuncs.c @@ -406,6 +406,7 @@ mod_get_addr_and_type(struct ml *ml, const char *modstr, char **addrptr, enum su int fd; char *readtype, *modfilename; char *buf, *walk; + size_t i; if (strncmp(modstr, "subscribe", 9) == 0) modstr += 9; @@ -425,20 +426,21 @@ mod_get_addr_and_type(struct ml *ml, const char *modstr, char **addrptr, enum su *addrptr = xstrdup(strsep(&walk, "\n")); readtype = strsep(&walk, "\n"); - for (size_t i = 0; i < NELEM(subtypes); i++) { + for (i = 0; i < NELEM(subtypes); i++) { if (subtypes[i] == NULL) continue; if (strcmp(subtypes[i], readtype) == 0) { *subtypeptr = i; - goto freedone; + break; } } - log_error(LOG_ARGS, "Type %s not valid in %s/%s", readtype, - ml->dir, modfilename); - exit(EXIT_FAILURE); + if (i == NELEM(subtypes)) { + log_error(LOG_ARGS, "Type %s not valid in %s/%s", readtype, + ml->dir, modfilename); + exit(EXIT_FAILURE); + } -freedone: free(buf); unlinkat(ml->fd, modfilename, 0); free(modfilename);