Commit 06397126 authored by Pavan Balaji's avatar Pavan Balaji
Browse files

[svn-r10247] Get rid of duplicate jump on failure for the MPIR_ERRTEST_ macros.

In several places, after checking for a parameter (e.g., comm) we were
directly using it assuming that the parameter is valid.  Since the
previous ERRTEST macros did not jump to fn_fail on an error, this
could result in undefined behavior if the parameter was invalid.  Now,
since we jump on errors within the macros themselves, once the check
is done, we know that the parameter values are valid.

Reviewed by buntinas.
parent b376e1e6
......@@ -69,7 +69,6 @@ int MPI_Attr_delete(MPI_Comm comm, int keyval)
MPID_BEGIN_ERROR_CHECKS;
{
MPIR_ERRTEST_COMM(comm, mpi_errno);
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
}
MPID_END_ERROR_CHECKS;
}
......
......@@ -93,11 +93,9 @@ int MPI_Attr_get(MPI_Comm comm, int keyval, void *attr_value, int *flag)
should have been used. We can test for this specific
case. Note that this code assumes sizeof(MPIR_Pint) is
a power of 2. */
if ((MPIR_Pint)attr_value & (sizeof(MPIR_Pint)-1)) {
MPIU_ERR_SET(mpi_errno,MPI_ERR_ARG,"**attrnotptr");
}
MPIU_ERR_CHKANDJUMP((MPIR_Pint)attr_value & (sizeof(MPIR_Pint)-1),
mpi_errno,MPI_ERR_ARG,"**attrnotptr");
# endif
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
}
MPID_END_ERROR_CHECKS;
}
......@@ -116,7 +114,6 @@ int MPI_Attr_get(MPI_Comm comm, int keyval, void *attr_value, int *flag)
/* If comm_ptr is not valid, it will be reset to null */
MPIR_ERRTEST_ARGNULL(attr_value, "attr_value", mpi_errno);
MPIR_ERRTEST_ARGNULL(flag, "flag", mpi_errno);
if (mpi_errno) goto fn_fail;
}
MPID_END_ERROR_CHECKS;
}
......
......@@ -88,7 +88,6 @@ int MPI_Attr_put(MPI_Comm comm, int keyval, void *attr_value)
MPIR_ERRTEST_COMM(comm, mpi_errno);
MPIR_ERRTEST_KEYVAL(keyval, MPID_COMM, "communicator", mpi_errno);
MPIR_ERRTEST_KEYVAL_PERM(keyval, mpi_errno);
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
}
MPID_END_ERROR_CHECKS;
}
......
......@@ -135,7 +135,6 @@ int MPI_Comm_create_keyval(MPI_Comm_copy_attr_function *comm_copy_attr_fn,
MPID_BEGIN_ERROR_CHECKS;
{
MPIR_ERRTEST_ARGNULL(comm_keyval, "comm_keyval", mpi_errno);
if (mpi_errno) goto fn_fail;
}
MPID_END_ERROR_CHECKS;
}
......
......@@ -123,7 +123,6 @@ int MPI_Comm_delete_attr(MPI_Comm comm, int comm_keyval)
MPIR_ERRTEST_COMM(comm, mpi_errno);
MPIR_ERRTEST_KEYVAL(comm_keyval, MPID_COMM, "communicator", mpi_errno);
MPIR_ERRTEST_KEYVAL_PERM(comm_keyval, mpi_errno);
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
}
MPID_END_ERROR_CHECKS;
}
......
......@@ -86,11 +86,8 @@ int MPI_Comm_free_keyval(int *comm_keyval)
MPID_BEGIN_ERROR_CHECKS;
{
MPIR_ERRTEST_ARGNULL(comm_keyval, "comm_keyval", mpi_errno);
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
MPIR_ERRTEST_KEYVAL(*comm_keyval, MPID_COMM, "communicator",
mpi_errno);
MPIR_ERRTEST_KEYVAL(*comm_keyval, MPID_COMM, "communicator", mpi_errno);
MPIR_ERRTEST_KEYVAL_PERM(*comm_keyval, mpi_errno);
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
}
MPID_END_ERROR_CHECKS;
}
......
......@@ -62,10 +62,9 @@ int MPIR_CommGetAttr( MPI_Comm comm, int comm_keyval, void *attribute_val,
case. Note that this code assumes sizeof(MPIR_Pint) is
a power of 2. */
if ((MPIR_Pint)attribute_val & (sizeof(MPIR_Pint)-1)) {
MPIU_ERR_SET(mpi_errno,MPI_ERR_ARG,"**attrnotptr");
MPIU_ERR_SETANDSTMT(mpi_errno,MPI_ERR_ARG,goto fn_fail,"**attrnotptr");
}
# endif
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
}
MPID_END_ERROR_CHECKS;
}
......@@ -84,7 +83,6 @@ int MPIR_CommGetAttr( MPI_Comm comm, int comm_keyval, void *attribute_val,
/* If comm_ptr is not valid, it will be reset to null */
MPIR_ERRTEST_ARGNULL(attribute_val, "attr_val", mpi_errno);
MPIR_ERRTEST_ARGNULL(flag, "flag", mpi_errno);
if (mpi_errno) goto fn_fail;
}
MPID_END_ERROR_CHECKS;
}
......
......@@ -125,7 +125,6 @@ int MPIR_CommSetAttr( MPI_Comm comm, int comm_keyval, void *attribute_val,
MPIR_ERRTEST_COMM(comm, mpi_errno);
MPIR_ERRTEST_KEYVAL(comm_keyval, MPID_COMM, "communicator", mpi_errno);
MPIR_ERRTEST_KEYVAL_PERM(comm_keyval, mpi_errno);
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
}
MPID_END_ERROR_CHECKS;
}
......@@ -232,7 +231,6 @@ int MPI_Comm_set_attr(MPI_Comm comm, int comm_keyval, void *attribute_val)
MPIR_ERRTEST_COMM(comm, mpi_errno);
MPIR_ERRTEST_KEYVAL(comm_keyval, MPID_COMM, "communicator", mpi_errno);
MPIR_ERRTEST_KEYVAL_PERM(comm_keyval, mpi_errno);
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
}
MPID_END_ERROR_CHECKS;
}
......
......@@ -82,7 +82,6 @@ int MPI_Keyval_create(MPI_Copy_function *copy_fn,
MPID_BEGIN_ERROR_CHECKS;
{
MPIR_ERRTEST_ARGNULL(keyval, "keyval", mpi_errno);
if (mpi_errno) goto fn_fail;
}
MPID_END_ERROR_CHECKS;
}
......
......@@ -69,7 +69,6 @@ int MPI_Keyval_free(int *keyval)
MPID_BEGIN_ERROR_CHECKS;
{
MPIR_ERRTEST_ARGNULL(keyval, "keyval", mpi_errno);
if (mpi_errno) goto fn_fail;
}
MPID_END_ERROR_CHECKS;
}
......
......@@ -86,7 +86,6 @@ int MPI_Type_create_keyval(MPI_Type_copy_attr_function *type_copy_attr_fn,
MPID_BEGIN_ERROR_CHECKS;
{
MPIR_ERRTEST_ARGNULL(type_keyval,"type_keyval",mpi_errno);
if (mpi_errno) goto fn_fail;
}
MPID_END_ERROR_CHECKS;
}
......
......@@ -70,7 +70,6 @@ int MPI_Type_delete_attr(MPI_Datatype type, int type_keyval)
MPIR_ERRTEST_DATATYPE(type, "datatype", mpi_errno);
MPIR_ERRTEST_KEYVAL(type_keyval, MPID_DATATYPE, "datatype", mpi_errno);
MPIR_ERRTEST_KEYVAL_PERM(type_keyval, mpi_errno);
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
}
MPID_END_ERROR_CHECKS;
}
......
......@@ -65,11 +65,8 @@ int MPI_Type_free_keyval(int *type_keyval)
MPID_BEGIN_ERROR_CHECKS;
{
MPIR_ERRTEST_ARGNULL(type_keyval, "type_keyval", mpi_errno);
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
MPIR_ERRTEST_KEYVAL(*type_keyval, MPID_DATATYPE, "datatype",
mpi_errno);
MPIR_ERRTEST_KEYVAL(*type_keyval, MPID_DATATYPE, "datatype", mpi_errno);
MPIR_ERRTEST_KEYVAL_PERM(*type_keyval, mpi_errno);
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
}
MPID_END_ERROR_CHECKS;
}
......
......@@ -57,10 +57,9 @@ int MPIR_TypeGetAttr( MPI_Datatype type, int type_keyval, void *attribute_val,
case. Note that this code assumes sizeof(MPIR_Pint) is
a power of 2. */
if ((MPIR_Pint)attribute_val & (sizeof(MPIR_Pint)-1)) {
MPIU_ERR_SET(mpi_errno,MPI_ERR_ARG,"**attrnotptr");
MPIU_ERR_SETANDSTMT(mpi_errno,MPI_ERR_ARG,goto fn_fail,"**attrnotptr");
}
# endif
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
}
MPID_END_ERROR_CHECKS;
}
......
......@@ -51,7 +51,6 @@ int MPIR_TypeSetAttr(MPI_Datatype type, int type_keyval, void *attribute_val,
MPIR_ERRTEST_DATATYPE(type, "datatype", mpi_errno);
MPIR_ERRTEST_KEYVAL(type_keyval, MPID_DATATYPE, "datatype", mpi_errno);
MPIR_ERRTEST_KEYVAL_PERM(type_keyval, mpi_errno);
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
}
MPID_END_ERROR_CHECKS;
}
......
......@@ -86,7 +86,6 @@ int MPI_Win_create_keyval(MPI_Win_copy_attr_function *win_copy_attr_fn,
MPID_BEGIN_ERROR_CHECKS;
{
MPIR_ERRTEST_ARGNULL(win_keyval,"win_keyval",mpi_errno);
if (mpi_errno) goto fn_fail;
}
MPID_END_ERROR_CHECKS;
}
......
......@@ -71,7 +71,6 @@ int MPI_Win_delete_attr(MPI_Win win, int win_keyval)
MPIR_ERRTEST_WIN(win, mpi_errno);
MPIR_ERRTEST_KEYVAL(win_keyval, MPID_WIN, "window", mpi_errno);
MPIR_ERRTEST_KEYVAL_PERM(win_keyval, mpi_errno);
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
}
MPID_END_ERROR_CHECKS;
}
......
......@@ -66,10 +66,8 @@ int MPI_Win_free_keyval(int *win_keyval)
MPID_BEGIN_ERROR_CHECKS;
{
MPIR_ERRTEST_ARGNULL(*win_keyval, "win_keyval", mpi_errno);
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
MPIR_ERRTEST_KEYVAL(*win_keyval, MPID_WIN, "window", mpi_errno);
MPIR_ERRTEST_KEYVAL_PERM(*win_keyval, mpi_errno);
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
}
MPID_END_ERROR_CHECKS;
}
......
......@@ -53,10 +53,9 @@ int MPIR_WinGetAttr( MPI_Win win, int win_keyval, void *attribute_val,
case. Note that this code assumes sizeof(MPIR_Pint) is
a power of 2. */
if ((MPIR_Pint)attribute_val & (sizeof(MPIR_Pint)-1)) {
MPIU_ERR_SET(mpi_errno,MPI_ERR_ARG,"**attrnotptr");
MPIU_ERR_SETANDSTMT(mpi_errno,MPI_ERR_ARG,goto fn_fail,"**attrnotptr");
}
# endif
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
}
MPID_END_ERROR_CHECKS;
}
......@@ -75,7 +74,6 @@ int MPIR_WinGetAttr( MPI_Win win, int win_keyval, void *attribute_val,
/* If win_ptr is not valid, it will be reset to null */
MPIR_ERRTEST_ARGNULL(attribute_val, "attribute_val", mpi_errno);
MPIR_ERRTEST_ARGNULL(flag, "flag", mpi_errno);
if (mpi_errno) goto fn_fail;
}
MPID_END_ERROR_CHECKS;
}
......
......@@ -51,7 +51,6 @@ int MPIR_WinSetAttr( MPI_Win win, int win_keyval, void *attribute_val,
MPIR_ERRTEST_WIN(win, mpi_errno);
MPIR_ERRTEST_KEYVAL(win_keyval, MPID_WIN, "window", mpi_errno);
MPIR_ERRTEST_KEYVAL_PERM(win_keyval, mpi_errno);
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
}
MPID_END_ERROR_CHECKS;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment