[mpich-commits] r10637 - in mpich2/trunk/src/mpi/romio: adio/include mpi-io

goodell at mcs.anl.gov goodell at mcs.anl.gov
Tue Nov 20 16:20:56 CST 2012


Author: goodell
Date: 2012-11-20 16:20:56 -0600 (Tue, 20 Nov 2012)
New Revision: 10637

Modified:
   mpich2/trunk/src/mpi/romio/adio/include/adioi_error.h
   mpich2/trunk/src/mpi/romio/mpi-io/fsync.c
   mpich2/trunk/src/mpi/romio/mpi-io/open.c
   mpich2/trunk/src/mpi/romio/mpi-io/set_info.c
   mpich2/trunk/src/mpi/romio/mpi-io/set_size.c
Log:
add missing checks on parameters of IO routines

Contributed by IBM.  Based on patch 0009 from code discussions.

Modified: mpich2/trunk/src/mpi/romio/adio/include/adioi_error.h
===================================================================
--- mpich2/trunk/src/mpi/romio/adio/include/adioi_error.h	2012-11-20 22:20:55 UTC (rev 10636)
+++ mpich2/trunk/src/mpi/romio/adio/include/adioi_error.h	2012-11-20 22:20:56 UTC (rev 10637)
@@ -21,6 +21,21 @@
     goto fn_exit;                                               \
 }
 
+/* TODO could add more glue code to help check for handle validity, or perhaps
+ * do some sort of always-safe attribute/info call to check for handle validity */
+#define MPIO_CHECK_COMM(comm_, myname_, error_code_)                          \
+    do {                                                                      \
+        if ((comm_) == MPI_COMM_NULL) {                                       \
+            error_code = MPIO_Err_create_code(MPI_SUCCESS,                    \
+                                              MPIR_ERR_RECOVERABLE,           \
+                                              (myname_), __LINE__,            \
+                                              MPI_ERR_COMM,                   \
+                                              "**commnull", 0);               \
+            error_code_ = MPIO_Err_return_file(MPI_FILE_NULL, (error_code_)); \
+            goto fn_exit;                                                     \
+        }                                                                     \
+    } while (0)
+
 #define MPIO_CHECK_COUNT(fh, count, myname, error_code)         \
 if (count < 0) {						\
     error_code = MPIO_Err_create_code(MPI_SUCCESS,		\

Modified: mpich2/trunk/src/mpi/romio/mpi-io/fsync.c
===================================================================
--- mpich2/trunk/src/mpi/romio/mpi-io/fsync.c	2012-11-20 22:20:55 UTC (rev 10636)
+++ mpich2/trunk/src/mpi/romio/mpi-io/fsync.c	2012-11-20 22:20:56 UTC (rev 10637)
@@ -55,6 +55,7 @@
 	error_code = MPIO_Err_return_file(MPI_FILE_NULL, error_code);
 	goto fn_exit;
     }
+    MPIO_CHECK_WRITABLE(fh, myname, error_code);
     /* --END ERROR HANDLING-- */
 
     ADIOI_TEST_DEFERRED(adio_fh, "MPI_File_sync", &error_code);

Modified: mpich2/trunk/src/mpi/romio/mpi-io/open.c
===================================================================
--- mpich2/trunk/src/mpi/romio/mpi-io/open.c	2012-11-20 22:20:55 UTC (rev 10636)
+++ mpich2/trunk/src/mpi/romio/mpi-io/open.c	2012-11-20 22:20:56 UTC (rev 10637)
@@ -60,13 +60,7 @@
     MPIU_THREAD_CS_ENTER(ALLFUNC,);
 
     /* --BEGIN ERROR HANDLING-- */
-    if (comm == MPI_COMM_NULL)
-    {
-	error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
-					  myname, __LINE__, MPI_ERR_COMM,
-					  "**comm", 0);
-	goto fn_fail;
-    }
+    MPIO_CHECK_COMM(comm, myname, error_code);
     /* --END ERROR HANDLING-- */
 
     MPI_Comm_test_inter(comm, &flag);

Modified: mpich2/trunk/src/mpi/romio/mpi-io/set_info.c
===================================================================
--- mpich2/trunk/src/mpi/romio/mpi-io/set_info.c	2012-11-20 22:20:55 UTC (rev 10636)
+++ mpich2/trunk/src/mpi/romio/mpi-io/set_info.c	2012-11-20 22:20:56 UTC (rev 10637)
@@ -48,14 +48,13 @@
 
     /* set new info */
     ADIO_SetInfo(adio_fh, info, &error_code);
-    /* TODO: what to do with error code? */
 
+fn_exit:
     /* --BEGIN ERROR HANDLING-- */
     if (error_code != MPI_SUCCESS)
 	error_code = MPIO_Err_return_file(adio_fh, error_code);
     /* --END ERROR HANDLING-- */
 
-fn_exit:
     MPIU_THREAD_CS_EXIT(ALLFUNC,);
 
     return error_code;

Modified: mpich2/trunk/src/mpi/romio/mpi-io/set_size.c
===================================================================
--- mpich2/trunk/src/mpi/romio/mpi-io/set_size.c	2012-11-20 22:20:55 UTC (rev 10636)
+++ mpich2/trunk/src/mpi/romio/mpi-io/set_size.c	2012-11-20 22:20:56 UTC (rev 10637)
@@ -61,6 +61,7 @@
 	error_code = MPIO_Err_return_file(adio_fh, error_code);
 	goto fn_exit;
     }
+    MPIO_CHECK_WRITABLE(fh, myname, error_code);
     /* --END ERROR HANDLING-- */
 
     tmp_sz = size;



More information about the commits mailing list