diff --git a/opal/util/show_help.c b/opal/util/show_help.c index 2622484385..b37ac7bbd4 100644 --- a/opal/util/show_help.c +++ b/opal/util/show_help.c @@ -10,6 +10,8 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2008 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2015 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -244,18 +246,17 @@ static int find_topic(const char *base, const char *topic) */ static int read_topic(char ***array) { - char *tmp; - int token; + int token, rc; while (1) { token = opal_show_help_yylex(); switch (token) { case OPAL_SHOW_HELP_PARSE_MESSAGE: - tmp = strdup(opal_show_help_yytext); - if (NULL == tmp) { - return OPAL_ERR_OUT_OF_RESOURCE; + /* opal_argv_append_nosize does strdup(opal_show_help_yytext) */ + rc = opal_argv_append_nosize(array, opal_show_help_yytext); + if (rc != OPAL_SUCCESS) { + return rc; } - opal_argv_append_nosize(array, tmp); break; default: diff --git a/opal/util/sys_limits.c b/opal/util/sys_limits.c index 3be720d507..a6d8f1dfdc 100644 --- a/opal/util/sys_limits.c +++ b/opal/util/sys_limits.c @@ -13,6 +13,8 @@ * Copyright (c) 2013 Los Alamos National Security, LLC. * All rights reserved. * Copyright (c) 2014 Intel, Inc. All rights reserved. + * Copyright (c) 2015 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -107,7 +109,7 @@ static int opal_setlimit(int resource, char *value, rlim_t *out) int opal_util_init_sys_limits(char **errmsg) { char **lims, **lim=NULL, *setlim; - int i; + int i, rc = OPAL_ERROR; rlim_t value; /* if limits were not given, then nothing to do */ @@ -136,14 +138,14 @@ int opal_util_init_sys_limits(char **errmsg) if (OPAL_SUCCESS != opal_setlimit(RLIMIT_NOFILE, "max", &value)) { *errmsg = opal_show_help_string("help-opal-util.txt", "sys-limit-failed", true, "openfiles", "max"); - return OPAL_ERROR; + goto out; } opal_sys_limits.num_files = value; #endif #if HAVE_DECL_RLIMIT_NPROC if (OPAL_SUCCESS != opal_setlimit(RLIMIT_NPROC, "max", &value)) { *errmsg = opal_show_help_string("help-opal-util.txt", "sys-limit-failed", true, "maxchildren", "max"); - return OPAL_ERROR; + goto out; } opal_sys_limits.num_procs = value; #endif @@ -151,7 +153,7 @@ int opal_util_init_sys_limits(char **errmsg) if (OPAL_SUCCESS != opal_setlimit(RLIMIT_FSIZE, "max", &value)) { *errmsg = opal_show_help_string("help-opal-util.txt", "sys-limit-failed", true, "filesize", "max"); - return OPAL_ERROR; + goto out; } opal_sys_limits.file_size = value; #endif @@ -166,14 +168,14 @@ int opal_util_init_sys_limits(char **errmsg) #if HAVE_DECL_RLIMIT_CORE if (OPAL_SUCCESS != opal_setlimit(RLIMIT_CORE, setlim, &value)) { *errmsg = opal_show_help_string("help-opal-util.txt", "sys-limit-failed", true, "openfiles", setlim); - return OPAL_ERROR; + goto out; } #endif } else if (0 == strcmp(lim[0], "filesize")) { #if HAVE_DECL_RLIMIT_FSIZE if (OPAL_SUCCESS != opal_setlimit(RLIMIT_FSIZE, setlim, &value)) { *errmsg = opal_show_help_string("help-opal-util.txt", "sys-limit-failed", true, "filesize", setlim); - return OPAL_ERROR; + goto out; } opal_sys_limits.file_size = value; #endif @@ -181,14 +183,14 @@ int opal_util_init_sys_limits(char **errmsg) #if HAVE_DECL_RLIMIT_AS if (OPAL_SUCCESS != opal_setlimit(RLIMIT_AS, setlim, &value)) { *errmsg = opal_show_help_string("help-opal-util.txt", "sys-limit-failed", true, "maxmem", setlim); - return OPAL_ERROR; + goto out; } #endif } else if (0 == strcmp(lim[0], "openfiles")) { #if HAVE_DECL_RLIMIT_NOFILE if (OPAL_SUCCESS != opal_setlimit(RLIMIT_NOFILE, setlim, &value)) { *errmsg = opal_show_help_string("help-opal-util.txt", "sys-limit-failed", true, "openfiles", setlim); - return OPAL_ERROR; + goto out; } opal_sys_limits.num_files = value; #endif @@ -196,23 +198,29 @@ int opal_util_init_sys_limits(char **errmsg) #if HAVE_DECL_RLIMIT_STACK if (OPAL_SUCCESS != opal_setlimit(RLIMIT_STACK, setlim, &value)) { *errmsg = opal_show_help_string("help-opal-util.txt", "sys-limit-failed", true, "stacksize", setlim); - return OPAL_ERROR; + goto out; } #endif } else if (0 == strcmp(lim[0], "maxchildren")) { #if HAVE_DECL_RLIMIT_NPROC if (OPAL_SUCCESS != opal_setlimit(RLIMIT_NPROC, setlim, &value)) { *errmsg = opal_show_help_string("help-opal-util.txt", "sys-limit-failed", true, "maxchildren", setlim); - return OPAL_ERROR; + goto out; } opal_sys_limits.num_procs = value; #endif } else { *errmsg = opal_show_help_string("help-opal-util.txt", "sys-limit-unrecognized", true, lim[0], setlim); - return OPAL_ERROR; + goto out; } } + /* indicate we initialized the limits structure */ + opal_sys_limits.initialized = true; + + rc = OPAL_SUCCESS; + +out: if (NULL != lim) { opal_argv_free(lim); } @@ -220,10 +228,7 @@ int opal_util_init_sys_limits(char **errmsg) opal_argv_free(lims); } - /* indicate we initialized the limits structure */ - opal_sys_limits.initialized = true; - - return OPAL_SUCCESS; + return rc; } int opal_getpagesize(void) diff --git a/opal/util/uri.c b/opal/util/uri.c index 4641bd4dd7..b01f30fa70 100644 --- a/opal/util/uri.c +++ b/opal/util/uri.c @@ -1,6 +1,8 @@ /* * Copyright (c) 2012 Los Alamos National Security, LLC. * All rights reserved. + * Copyright (c) 2015 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -33,6 +35,7 @@ char *opal_uri_get_scheme(const char *uri) if (NULL == (ptr = strchr(turi, ':'))) { opal_show_help("help-opal-util.txt", "malformed-uri", true, uri); + free(turi); return NULL; } *ptr = '\0'; @@ -117,6 +120,7 @@ char *opal_filename_from_uri(const char *uri, if (NULL == (ptr = strchr(turi, ':'))) { opal_show_help("help-opal-util.txt", "malformed-uri", true, uri); + free(turi); return NULL; } *ptr = '\0';