summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2024-03-20 21:41:09 +0000
committertb <>2024-03-20 21:41:09 +0000
commit0de7995140535d5315629d4c1bb9008cd635b390 (patch)
tree69d33f70b7d3f8477c2a9204867ebe95c4fd5311 /src
parentf1380ec05ac6100b94e238dc0bc83cc4946033f7 (diff)
downloadopenbsd-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.c38
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);
101static void module_finish(CONF_IMODULE *imod); 101static void module_finish(CONF_IMODULE *imod);
102static int module_run(const CONF *cnf, char *name, char *value, 102static int module_run(const CONF *cnf, char *name, char *value,
103 unsigned long flags); 103 unsigned long flags);
104static CONF_MODULE *module_add(const char *name, conf_init_func *ifunc, 104static int module_add(const char *name, conf_init_func *ifunc,
105 conf_finish_func *ffunc); 105 conf_finish_func *ffunc);
106static CONF_MODULE *module_find(char *name); 106static CONF_MODULE *module_find(char *name);
107static int module_init(CONF_MODULE *pmod, char *name, char *value, 107static 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 */ 217static int
218static CONF_MODULE *
219module_add(const char *name, conf_init_func *ifunc, conf_finish_func *ffunc) 218module_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)
415int 419int
416CONF_module_add(const char *name, conf_init_func *ifunc, conf_finish_func *ffunc) 420CONF_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
421void 425void