Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update attr tests
[simgrid.git] / teshsuite / smpi / mpich3-test / attr / attrend2.c
index 4454531..d71592b 100644 (file)
@@ -1,7 +1,7 @@
 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
 /*
  *
- *  (C) 2008 by Argonne National Laboratory.
+ *  (C) 2009 by Argonne National Laboratory.
  *      See COPYRIGHT in top-level directory.
  */
 /*
  * assuming a decent hash function is used. */
 #define NUM_TEST_ATTRS (20)
 
-static __attribute__((unused)) int exit_keys[NUM_TEST_ATTRS]; /* init to MPI_KEYVAL_INVALID */
-static __attribute__((unused)) int was_called[NUM_TEST_ATTRS];
+static int exit_keys[NUM_TEST_ATTRS];   /* init to MPI_KEYVAL_INVALID */
+static int was_called[NUM_TEST_ATTRS];
 int foundError = 0;
-int delete_fn (MPI_Comm, int, void *, void *);
+int delete_fn(MPI_Comm, int, void *, void *);
 
 int main(int argc, char **argv)
 {
-    int wrank;
+    int errs = 0, wrank;
+    int i;
 
     MTest_Init(&argc, &argv);
 
     MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
 
 #if MTEST_HAVE_MIN_MPI_VERSION(2,2)
-    int errs = 0;
-    int i;
     for (i = 0; i < NUM_TEST_ATTRS; ++i) {
         exit_keys[i] = MPI_KEYVAL_INVALID;
         was_called[i] = 0;
@@ -45,7 +44,7 @@ int main(int argc, char **argv)
         /* create the keyval for the exit handler */
         MPI_Comm_create_keyval(MPI_COMM_NULL_COPY_FN, delete_fn, &exit_keys[i], NULL);
         /* attach to comm_self */
-        MPI_Comm_set_attr(MPI_COMM_SELF, exit_keys[i], (void*)(long)i);
+        MPI_Comm_set_attr(MPI_COMM_SELF, exit_keys[i], (void *) (long) i);
     }
 
     /* we can free the keys now */
@@ -66,12 +65,15 @@ int main(int argc, char **argv)
             }
             else if (was_called[i] > 1) {
                 errs++;
-                printf("Attribute delete function on MPI_COMM_SELF was called multiple times for idx=%d\n", i);
+                printf
+                    ("Attribute delete function on MPI_COMM_SELF was called multiple times for idx=%d\n",
+                     i);
             }
         }
         if (foundError != 0) {
             errs++;
-            printf("Found %d errors while executing delete function in MPI_COMM_SELF\n", foundError);
+            printf("Found %d errors while executing delete function in MPI_COMM_SELF\n",
+                   foundError);
         }
         if (errs == 0) {
             printf(" No Errors\n");
@@ -94,7 +96,7 @@ int delete_fn(MPI_Comm comm, int keyval, void *attribute_val, void *extra_state)
 {
     int flag;
     int i;
-    int my_idx = (int)(long)attribute_val;
+    int my_idx = (int) (long) attribute_val;
 
     if (my_idx < 0 || my_idx > NUM_TEST_ATTRS) {
         printf("internal error, my_idx=%d is invalid!\n", my_idx);
@@ -126,4 +128,3 @@ int delete_fn(MPI_Comm comm, int keyval, void *attribute_val, void *extra_state)
 
     return MPI_SUCCESS;
 }
-