1
1
openmpi/opal/mca/base/mca_base_components_close.c
Nathan Hjelm cea735b3c3 mca/base: fix coverity issues and enable project name in MCA groups
CID 1047278 Unchecked return value

Updated check for mca_base_var_generate_full_name4 to match other
checks. Logically equivalent to the old check. Not a bug.

CID 1196685 Dereference null return

Added check for NULL when looking up the original variable for a
synonym.

CID 1269705 Logically dead code

Removed code that set the project to NULL. Code was intended to be
removed with an earlier commit that added the project name into the
component structure. Added code to actually support searching for a
group with a wildcard ('*').

CID 1292739 Dereference null return
CID 1269819 Dereference null return

Removed unnecessary string duplication and strchr.

CID 1287030 Logically dead code

Refactored fixup_files code and confirmed that the code in question is
not reachable. Removed the dead code.

CID 1292740 Use of untrusted string

Use strdup to silence coverity warning.

CID 1294413 Free of address-of expression

Reset mitem to NULL after the OPAL_LIST_FOREACH loop to ensure we
never try to free the list sentinel.

CID 1294414 Unchecked return value

Use (void) to indicate we do not care about the return code in this
instance.

CID 1294415 Resource leak

On error free all the base pointer.

Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
2015-05-21 13:33:31 -06:00

94 строки
3.2 KiB
C

/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2006 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2006 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2006 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2013 Los Alamos National Security, LLC. All rights
* reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "opal_config.h"
#include "opal/class/opal_list.h"
#include "opal/util/output.h"
#include "opal/mca/mca.h"
#include "opal/mca/base/base.h"
#include "opal/mca/base/mca_base_component_repository.h"
#include "opal/constants.h"
void mca_base_component_unload (const mca_base_component_t *component, int output_id)
{
int ret;
/* Unload */
opal_output_verbose(10, output_id,
"mca: base: close: unloading component %s",
component->mca_component_name);
ret = mca_base_var_group_find (component->mca_project_name, component->mca_type_name,
component->mca_component_name);
if (0 <= ret) {
mca_base_var_group_deregister (ret);
}
mca_base_component_repository_release (component);
}
void mca_base_component_close (const mca_base_component_t *component, int output_id)
{
/* Close */
if (NULL != component->mca_close_component) {
component->mca_close_component();
opal_output_verbose(10, output_id,
"mca: base: close: component %s closed",
component->mca_component_name);
}
mca_base_component_unload (component, output_id);
}
int mca_base_framework_components_close (mca_base_framework_t *framework,
const mca_base_component_t *skip)
{
return mca_base_components_close (framework->framework_output,
&framework->framework_components,
skip);
}
int mca_base_components_close(int output_id, opal_list_t *components,
const mca_base_component_t *skip)
{
mca_base_component_list_item_t *cli, *next;
/* Close and unload all components in the available list, except the
"skip" item. This is handy to close out all non-selected
components. It's easier to simply remove the entire list and
then simply re-add the skip entry when done. */
OPAL_LIST_FOREACH_SAFE(cli, next, components, mca_base_component_list_item_t) {
if (skip == cli->cli_component) {
continue;
}
mca_base_component_close (cli->cli_component, output_id);
opal_list_remove_item (components, &cli->super);
OBJ_RELEASE(cli);
}
/* All done */
return OPAL_SUCCESS;
}