diff options
author | tb <> | 2024-03-20 21:41:09 +0000 |
---|---|---|
committer | tb <> | 2024-03-20 21:41:09 +0000 |
commit | 0de7995140535d5315629d4c1bb9008cd635b390 (patch) | |
tree | 69d33f70b7d3f8477c2a9204867ebe95c4fd5311 /src | |
parent | f1380ec05ac6100b94e238dc0bc83cc4946033f7 (diff) | |
download | openbsd-0de7995140535d5315629d4c1bb9008cd635b390.tar.gz openbsd-0de7995140535d5315629d4c1bb9008cd635b390.tar.bz2 openbsd-0de7995140535d5315629d4c1bb9008cd635b390.zip |
Change return type of module_add()
There is one caller of this function which returns module_add() != NULL.
Make the function return an int instead.
suggested by and ok jsing
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/conf/conf_mod.c | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/src/lib/libcrypto/conf/conf_mod.c b/src/lib/libcrypto/conf/conf_mod.c index f1522b9518..a919a54f20 100644 --- a/src/lib/libcrypto/conf/conf_mod.c +++ b/src/lib/libcrypto/conf/conf_mod.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: conf_mod.c,v 1.30 2024/03/20 21:31:31 tb Exp $ */ | 1 | /* $OpenBSD: conf_mod.c,v 1.31 2024/03/20 21:41:09 tb Exp $ */ |
2 | /* Written by Stephen Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Stephen Henson (steve@openssl.org) for the OpenSSL |
3 | * project 2001. | 3 | * project 2001. |
4 | */ | 4 | */ |
@@ -101,7 +101,7 @@ static void imodule_free(CONF_IMODULE *imod); | |||
101 | static void module_finish(CONF_IMODULE *imod); | 101 | static void module_finish(CONF_IMODULE *imod); |
102 | static int module_run(const CONF *cnf, char *name, char *value, | 102 | static int module_run(const CONF *cnf, char *name, char *value, |
103 | unsigned long flags); | 103 | unsigned long flags); |
104 | static CONF_MODULE *module_add(const char *name, conf_init_func *ifunc, | 104 | static int module_add(const char *name, conf_init_func *ifunc, |
105 | conf_finish_func *ffunc); | 105 | conf_finish_func *ffunc); |
106 | static CONF_MODULE *module_find(char *name); | 106 | static CONF_MODULE *module_find(char *name); |
107 | static int module_init(CONF_MODULE *pmod, char *name, char *value, | 107 | static int module_init(CONF_MODULE *pmod, char *name, char *value, |
@@ -214,33 +214,37 @@ module_run(const CONF *cnf, char *name, char *value, unsigned long flags) | |||
214 | return ret; | 214 | return ret; |
215 | } | 215 | } |
216 | 216 | ||
217 | /* add module to list */ | 217 | static int |
218 | static CONF_MODULE * | ||
219 | module_add(const char *name, conf_init_func *ifunc, conf_finish_func *ffunc) | 218 | module_add(const char *name, conf_init_func *ifunc, conf_finish_func *ffunc) |
220 | { | 219 | { |
221 | CONF_MODULE *tmod = NULL; | 220 | CONF_MODULE *tmod = NULL; |
221 | int ret = 0; | ||
222 | 222 | ||
223 | if (name == NULL) | 223 | if (name == NULL) |
224 | return NULL; | 224 | goto err; |
225 | |||
225 | if (supported_modules == NULL) | 226 | if (supported_modules == NULL) |
226 | supported_modules = sk_CONF_MODULE_new_null(); | 227 | supported_modules = sk_CONF_MODULE_new_null(); |
227 | if (supported_modules == NULL) | 228 | if (supported_modules == NULL) |
228 | return NULL; | 229 | goto err; |
229 | tmod = malloc(sizeof(CONF_MODULE)); | ||
230 | if (tmod == NULL) | ||
231 | return NULL; | ||
232 | 230 | ||
233 | tmod->name = strdup(name); | 231 | if ((tmod = calloc(1, sizeof(*tmod))) == NULL) |
232 | goto err; | ||
233 | if ((tmod->name = strdup(name)) == NULL) | ||
234 | goto err; | ||
234 | tmod->init = ifunc; | 235 | tmod->init = ifunc; |
235 | tmod->finish = ffunc; | 236 | tmod->finish = ffunc; |
236 | tmod->links = 0; | ||
237 | 237 | ||
238 | if (!sk_CONF_MODULE_push(supported_modules, tmod)) { | 238 | if (!sk_CONF_MODULE_push(supported_modules, tmod)) |
239 | free(tmod); | 239 | goto err; |
240 | return NULL; | 240 | tmod = NULL; |
241 | } | ||
242 | 241 | ||
243 | return tmod; | 242 | ret = 1; |
243 | |||
244 | err: | ||
245 | module_free(tmod); | ||
246 | |||
247 | return ret; | ||
244 | } | 248 | } |
245 | 249 | ||
246 | /* Find a module from the list. We allow module names of the | 250 | /* Find a module from the list. We allow module names of the |
@@ -415,7 +419,7 @@ module_finish(CONF_IMODULE *imod) | |||
415 | int | 419 | int |
416 | CONF_module_add(const char *name, conf_init_func *ifunc, conf_finish_func *ffunc) | 420 | CONF_module_add(const char *name, conf_init_func *ifunc, conf_finish_func *ffunc) |
417 | { | 421 | { |
418 | return module_add(name, ifunc, ffunc) != NULL; | 422 | return module_add(name, ifunc, ffunc); |
419 | } | 423 | } |
420 | 424 | ||
421 | void | 425 | void |