1
1

Handle ompi error codes in java code

This commit also adds protection against negative error codes in ompi
error code functions. There is one outstanding issue. There is a
negative MPI error code defined in mpi.h. This will need to be fixed
separetely.

This commit fixes coverity IDs 1271533 and 1270156.

Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
Этот коммит содержится в:
Nathan Hjelm 2015-05-21 10:39:09 -06:00
родитель 757c021951
Коммит 403b3b20d7
2 изменённых файлов: 34 добавлений и 11 удалений
ompi
errhandler
mpi/java/c

@ -1,4 +1,4 @@
/* -*- Mode: C; c-basic-offset:4 ; -*- */
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
@ -12,6 +12,8 @@
* All rights reserved.
* Copyright (c) 2006 University of Houston. All rights reserved.
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
* reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -69,10 +71,13 @@ static inline bool ompi_mpi_errcode_is_invalid(int errcode)
*/
static inline int ompi_mpi_errcode_get_class (int errcode)
{
ompi_mpi_errcode_t *err;
ompi_mpi_errcode_t *err = NULL;
if (errcode >= 0) {
err = (ompi_mpi_errcode_t *)opal_pointer_array_get_item(&ompi_mpi_errcodes, errcode);
/* If we get a bogus errcode, return MPI_ERR_UNKNOWN */
}
err = (ompi_mpi_errcode_t *)opal_pointer_array_get_item(&ompi_mpi_errcodes, errcode);
/* If we get a bogus errcode, return MPI_ERR_UNKNOWN */
if (NULL != err) {
if ( err->code != MPI_UNDEFINED ) {
return err->cls;
@ -93,6 +98,10 @@ static inline int ompi_mpi_errnum_is_class ( int errnum )
{
ompi_mpi_errcode_t *err;
if (errno < 0) {
return false;
}
if ( errnum <= ompi_mpi_errcode_lastpredefined ) {
/* Predefined error values represent an error code and
an error class at the same time */
@ -117,11 +126,14 @@ static inline int ompi_mpi_errnum_is_class ( int errnum )
*/
static inline char* ompi_mpi_errnum_get_string (int errnum)
{
ompi_mpi_errcode_t *err;
err = (ompi_mpi_errcode_t *)opal_pointer_array_get_item(&ompi_mpi_errcodes, errnum);
/* If we get a bogus errcode, return a string indicating that this
truly should not happen */
ompi_mpi_errcode_t *err = NULL;
if (errnum >= 0) {
err = (ompi_mpi_errcode_t *)opal_pointer_array_get_item(&ompi_mpi_errcodes, errnum);
/* If we get a bogus errcode, return a string indicating that this
truly should not happen */
}
if (NULL != err) {
return err->errstring;
} else {

@ -531,8 +531,11 @@ static void* getBuffer(JNIEnv *env, ompi_java_buffer_t **item, int size)
opal_free_list_item_t *freeListItem;
freeListItem = opal_free_list_get (&ompi_java_buffers);
ompi_java_exceptionCheck(env, NULL == freeListItem ? OMPI_ERROR :
OMPI_SUCCESS);
ompi_java_exceptionCheck(env, NULL == freeListItem ? MPI_ERR_NO_MEM :
MPI_SUCCESS);
if (NULL == freeListItem) {
return NULL;
}
*item = (ompi_java_buffer_t*)freeListItem;
return (*item)->buffer;
@ -1049,6 +1052,14 @@ void ompi_java_releasePtrArray(JNIEnv *env, jlongArray array,
jboolean ompi_java_exceptionCheck(JNIEnv *env, int rc)
{
if (rc < 0) {
/* handle ompi error code */
rc = ompi_errcode_get_mpi_code (rc);
/* ompi_mpi_errcode_get_class CAN NOT handle negative error codes.
* all Open MPI MPI error codes should be > 0. */
assert (rc >= 0);
}
if(MPI_SUCCESS == rc)
{
return JNI_FALSE;