From d1d2cf776d4f7b809e3cc1bda1a001ea147dfa89 Mon Sep 17 00:00:00 2001
From: Vailin Choi <vchoi@jam.ad.hdfgroup.org>
Date: Tue, 30 Oct 2018 16:53:09 -0500
Subject: Fix for HDFFV-10554 use_append_chunks in swmr use case test failure
 Fix the timing issue of the test by moving the open/close of the test file
 for the writer to use_append_chunk.c and use_append_mchunks.c.

---
 test/use.h                |  2 +-
 test/use_append_chunk.c   | 67 ++++++++++++++++++++++++++++++++++------------
 test/use_append_mchunks.c | 68 +++++++++++++++++++++++++++++++++++------------
 test/use_common.c         | 32 +++++-----------------
 4 files changed, 109 insertions(+), 60 deletions(-)

diff --git a/test/use.h b/test/use.h
index 0885cc5..54d9b26 100644
--- a/test/use.h
+++ b/test/use.h
@@ -58,6 +58,6 @@ int setup_parameters(int argc, char * const argv[]);
 void show_parameters(void);
 void usage(const char *prog);
 int create_uc_file(void);
-int write_uc_file(hbool_t tosend);
+int write_uc_file(hbool_t tosend, hid_t fid);
 int read_uc_file(hbool_t towait);
 
diff --git a/test/use_append_chunk.c b/test/use_append_chunk.c
index 005eb51..7dda732 100644
--- a/test/use_append_chunk.c
+++ b/test/use_append_chunk.c
@@ -124,6 +124,9 @@ main(int argc, char *argv[])
     int ret_value = 0;
     int child_ret_value;
     hbool_t send_wait = FALSE;
+    hid_t fapl = -1;    /* File access property list */
+    hid_t fid = -1;     /* File ID */
+    char *name;         /* Test file name */
 
     /* initialization */
     if (setup_parameters(argc, argv) < 0){
@@ -182,29 +185,59 @@ main(int argc, char *argv[])
     /* ============= */
     /* this process continues to launch the writer */
     printf("%d: continue as the writer process\n", mypid);
-    if (write_uc_file(send_wait) < 0){
-	fprintf(stderr, "write_uc_file encountered error\n");
-	Hgoto_error(1);
+
+    name = UC_opts.filename;
+
+    /* Set file access proeprty list */
+    if((fapl = h5_fileaccess()) < 0)
+        Hgoto_error(1);
+
+    if(UC_opts.use_swmr)
+        if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+            Hgoto_error(1);
+
+    /* Open the file */
+    if((fid = H5Fopen(name, H5F_ACC_RDWR | (UC_opts.use_swmr ? H5F_ACC_SWMR_WRITE : 0), fapl)) < 0) {
+        fprintf(stderr, "H5Fopen failed\n");
+        Hgoto_error(1);
+    }
+
+    if(write_uc_file(send_wait, fid) < 0) {
+        fprintf(stderr, "write_uc_file encountered error\n");
+        Hgoto_error(1);
     }
 
     /* ================================================ */
     /* If readwrite, collect exit code of child process */
     /* ================================================ */
     if (UC_opts.launch == UC_READWRITE){
-	if ((tmppid = HDwaitpid(childpid, &child_status, child_wait_option)) < 0){
-	    HDperror("waitpid");
-	    Hgoto_error(1);
-	}
-	if (WIFEXITED(child_status)){
-	    if ((child_ret_value=WEXITSTATUS(child_status)) != 0){
-		printf("%d: child process exited with non-zero code (%d)\n",
-		    mypid, child_ret_value);
-		Hgoto_error(2);
-	    }
-	} else {
-	    printf("%d: child process terminated abnormally\n", mypid);
-	    Hgoto_error(2);
-	}
+        if ((tmppid = HDwaitpid(childpid, &child_status, child_wait_option)) < 0){
+            HDperror("waitpid");
+            Hgoto_error(1);
+        }
+
+        /* Close the file */
+        if(H5Fclose(fid) < 0) {
+            fprintf(stderr, "Failed to close file id\n");
+            Hgoto_error(1);
+        }
+
+        /* Close the property list */
+        if(H5Pclose(fapl) < 0) {
+            fprintf(stderr, "Failed to property list\n");
+            Hgoto_error(1);
+        }
+
+        if (WIFEXITED(child_status)){
+            if ((child_ret_value=WEXITSTATUS(child_status)) != 0){
+                printf("%d: child process exited with non-zero code (%d)\n",
+                        mypid, child_ret_value);
+                Hgoto_error(2);
+            }
+         } else {
+                printf("%d: child process terminated abnormally\n", mypid);
+                Hgoto_error(2);
+         }
     }
     
 done:
diff --git a/test/use_append_mchunks.c b/test/use_append_mchunks.c
index 9ee37cb..2dc7bdb 100644
--- a/test/use_append_mchunks.c
+++ b/test/use_append_mchunks.c
@@ -117,6 +117,9 @@ main(int argc, char *argv[])
     int ret_value = 0;
     int child_ret_value;
     hbool_t send_wait = 0;
+    hid_t fapl = -1;        /* File access property list */
+    hid_t fid = -1;         /* File ID */
+    char *name;             /* Test file name */
 
     /* initialization */
     if (setup_parameters(argc, argv) < 0){
@@ -175,29 +178,60 @@ main(int argc, char *argv[])
     /* ============= */
     /* this process continues to launch the writer */
     printf("%d: continue as the writer process\n", mypid);
-    if (write_uc_file(send_wait) < 0){
-	fprintf(stderr, "write_uc_file encountered error\n");
-	Hgoto_error(1);
+
+    name = UC_opts.filename;
+
+    /* Set the file access property list */
+    if((fapl = h5_fileaccess()) < 0)
+        Hgoto_error(1);
+
+    if(UC_opts.use_swmr)
+        if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+            Hgoto_error(1);
+
+    /* Open the file */
+    if((fid = H5Fopen(name, H5F_ACC_RDWR | (UC_opts.use_swmr ? H5F_ACC_SWMR_WRITE : 0), fapl)) < 0) {
+        fprintf(stderr, "H5Fopen failed\n");
+        Hgoto_error(1);
+    }
+
+    if(write_uc_file(send_wait, fid) < 0) {
+        fprintf(stderr, "write_uc_file encountered error\n");
+        Hgoto_error(1);
     }
 
+
     /* ================================================ */
     /* If readwrite, collect exit code of child process */
     /* ================================================ */
     if (UC_opts.launch == UC_READWRITE){
-	if ((tmppid = waitpid(childpid, &child_status, child_wait_option)) < 0){
-	    perror("waitpid");
-	    Hgoto_error(1);
-	}
-	if (WIFEXITED(child_status)){
-	    if ((child_ret_value=WEXITSTATUS(child_status)) != 0){
-		printf("%d: child process exited with non-zero code (%d)\n",
-		    mypid, child_ret_value);
-		Hgoto_error(2);
-	    }
-	} else {
-	    printf("%d: child process terminated abnormally\n", mypid);
-	    Hgoto_error(2);
-	}
+        if ((tmppid = waitpid(childpid, &child_status, child_wait_option)) < 0){
+            perror("waitpid");
+            Hgoto_error(1);
+        }
+
+        /* Close the file  */
+        if(H5Fclose(fid) < 0) {
+            fprintf(stderr, "Failed to close file id\n");
+            Hgoto_error(1);
+        }
+
+        /* Close the property list */
+        if(H5Pclose(fapl) < 0) {
+            fprintf(stderr, "Failed to property list\n");
+            Hgoto_error(1);
+        }
+
+        if (WIFEXITED(child_status)){
+            if ((child_ret_value=WEXITSTATUS(child_status)) != 0){
+                printf("%d: child process exited with non-zero code (%d)\n",
+                    mypid, child_ret_value);
+                Hgoto_error(1);
+            }
+        } else {
+            printf("%d: child process terminated abnormally\n", mypid);
+            Hgoto_error(2);
+        }
     }
     
 done:
diff --git a/test/use_common.c b/test/use_common.c
index 5aa6692..164480f 100644
--- a/test/use_common.c
+++ b/test/use_common.c
@@ -252,13 +252,10 @@ int create_uc_file(void)
  *
  * Return: 0 succeed; -1 fail.
  */
-int write_uc_file(hbool_t tosend)
+int write_uc_file(hbool_t tosend, hid_t fid)
 {
-    hid_t	fid;          /* File ID for new HDF5 file */
     hid_t	dsid;         /* dataset ID */
-    hid_t       fapl;         /* File access property list */
     hid_t	dcpl;         /* Dataset creation property list */
-    char	*name;
     UC_CTYPE	*buffer, *bufptr;	/* data buffer */
     hsize_t	cz=UC_opts.chunksize;		/* Chunk size */
     hid_t	f_sid;	    /* dataset file space id */
@@ -270,19 +267,6 @@ int write_uc_file(hbool_t tosend)
     hsize_t	start[3] = {0,0,0}, count[3];    /* Hyperslab selection values */
     hsize_t     i, j, k;
 
-    name = UC_opts.filename;
-
-    /* Open the file */
-    if((fapl = h5_fileaccess()) < 0)
-        return -1;
-    if(UC_opts.use_swmr)
-        if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
-            return -1;
-    if((fid = H5Fopen(name, H5F_ACC_RDWR | (UC_opts.use_swmr ? H5F_ACC_SWMR_WRITE : 0), fapl)) < 0){
-	fprintf(stderr, "H5Fopen failed\n");
-        return -1;
-    }
-
     if(tosend)
         /* Send a message that H5Fopen is complete--releasing the file lock */
         h5_send_message(WRITER_MESSAGE, NULL, NULL);
@@ -427,14 +411,6 @@ int write_uc_file(hbool_t tosend)
 	fprintf(stderr, "Failed to close file space\n");
 	return -1;
     }
-    if (H5Pclose(fapl) < 0){
-	fprintf(stderr, "Failed to property list\n");
-	return -1;
-    }
-    if (H5Fclose(fid) < 0){
-	fprintf(stderr, "Failed to close file id\n");
-	return -1;
-    }
 
     return 0;
 }
@@ -645,6 +621,12 @@ int read_uc_file(hbool_t towait)
 	}
     }
 
+    /* Close the file */
+    if(H5Fclose(fid) < 0) {
+        fprintf(stderr, "H5Fclose failed\n");
+        return -1;
+    }
+
     if (nreadererr)
 	return -1;
     else
-- 
cgit v0.12


From 4f62c084f1b0502bc984edd8ce380bea22518bd3 Mon Sep 17 00:00:00 2001
From: Vailin Choi <vchoi@jam.ad.hdfgroup.org>
Date: Thu, 1 Nov 2018 12:03:34 -0500
Subject: Fixed fprintf to HDfprintf in the following routines: 1)
 read_uc_file() in use_common.c 2) main() of use_append_chunk.c and
 use_append_mchunks.c

---
 test/use_append_chunk.c   |  60 ++++++++++++-------------
 test/use_append_mchunks.c |  54 +++++++++++-----------
 test/use_common.c         | 112 +++++++++++++++++++++++-----------------------
 3 files changed, 113 insertions(+), 113 deletions(-)

diff --git a/test/use_append_chunk.c b/test/use_append_chunk.c
index 7dda732..fb906b6 100644
--- a/test/use_append_chunk.c
+++ b/test/use_append_chunk.c
@@ -130,7 +130,7 @@ main(int argc, char *argv[])
 
     /* initialization */
     if (setup_parameters(argc, argv) < 0){
-	Hgoto_error(1);
+        Hgoto_error(1);
     }
 
     /* Determine the need to send/wait message file*/
@@ -148,20 +148,20 @@ main(int argc, char *argv[])
     /* Create file */
     /* ============*/
     if (UC_opts.launch != UC_READER){
-	printf("Creating skeleton data file for test...\n");
-	if (create_uc_file() < 0){
-	    fprintf(stderr, "***encounter error\n");
-	    Hgoto_error(1);
-	}else
-	    printf("File created.\n");
+        HDprintf("Creating skeleton data file for test...\n");
+        if (create_uc_file() < 0){
+            HDfprintf(stderr, "***encounter error\n");
+            Hgoto_error(1);
+        }else
+            HDprintf("File created.\n");
     }
 
     if (UC_opts.launch==UC_READWRITE){
-	/* fork process */
-	if((childpid = HDfork()) < 0) {
-	    HDperror("fork");
-	    Hgoto_error(1);
-	};
+        /* fork process */
+        if((childpid = HDfork()) < 0) {
+            HDperror("fork");
+            Hgoto_error(1);
+        };
     };
     mypid = HDgetpid();
 
@@ -169,22 +169,22 @@ main(int argc, char *argv[])
     /* launch reader */
     /* ============= */
     if (UC_opts.launch != UC_WRITER){
-	/* child process launch the reader */
-	if(0 == childpid) {
-	    printf("%d: launch reader process\n", mypid);
-	    if (read_uc_file(send_wait) < 0){
-		fprintf(stderr, "read_uc_file encountered error\n");
-		exit(1);
-	    }
-	    exit(0);
-	}
+        /* child process launch the reader */
+        if(0 == childpid) {
+            HDprintf("%d: launch reader process\n", mypid);
+            if (read_uc_file(send_wait) < 0){
+                HDfprintf(stderr, "read_uc_file encountered error\n");
+                exit(1);
+            }
+            exit(0);
+        }
     }
 
     /* ============= */
     /* launch writer */
     /* ============= */
     /* this process continues to launch the writer */
-    printf("%d: continue as the writer process\n", mypid);
+    HDprintf("%d: continue as the writer process\n", mypid);
 
     name = UC_opts.filename;
 
@@ -198,12 +198,12 @@ main(int argc, char *argv[])
 
     /* Open the file */
     if((fid = H5Fopen(name, H5F_ACC_RDWR | (UC_opts.use_swmr ? H5F_ACC_SWMR_WRITE : 0), fapl)) < 0) {
-        fprintf(stderr, "H5Fopen failed\n");
+        HDfprintf(stderr, "H5Fopen failed\n");
         Hgoto_error(1);
     }
 
     if(write_uc_file(send_wait, fid) < 0) {
-        fprintf(stderr, "write_uc_file encountered error\n");
+        HDfprintf(stderr, "write_uc_file encountered error\n");
         Hgoto_error(1);
     }
 
@@ -218,24 +218,24 @@ main(int argc, char *argv[])
 
         /* Close the file */
         if(H5Fclose(fid) < 0) {
-            fprintf(stderr, "Failed to close file id\n");
+            HDfprintf(stderr, "Failed to close file id\n");
             Hgoto_error(1);
         }
 
         /* Close the property list */
         if(H5Pclose(fapl) < 0) {
-            fprintf(stderr, "Failed to property list\n");
+            HDfprintf(stderr, "Failed to close the property list\n");
             Hgoto_error(1);
         }
 
         if (WIFEXITED(child_status)){
             if ((child_ret_value=WEXITSTATUS(child_status)) != 0){
-                printf("%d: child process exited with non-zero code (%d)\n",
+                HDprintf("%d: child process exited with non-zero code (%d)\n",
                         mypid, child_ret_value);
                 Hgoto_error(2);
             }
          } else {
-                printf("%d: child process terminated abnormally\n", mypid);
+                HDprintf("%d: child process terminated abnormally\n", mypid);
                 Hgoto_error(2);
          }
     }
@@ -243,9 +243,9 @@ main(int argc, char *argv[])
 done:
     /* Print result and exit */
     if (ret_value != 0){
-	printf("Error(s) encountered\n");
+        HDprintf("Error(s) encountered\n");
     }else{
-	printf("All passed\n");
+        HDprintf("All passed\n");
     }
 
     return(ret_value);
diff --git a/test/use_append_mchunks.c b/test/use_append_mchunks.c
index 2dc7bdb..da7e2b3 100644
--- a/test/use_append_mchunks.c
+++ b/test/use_append_mchunks.c
@@ -123,7 +123,7 @@ main(int argc, char *argv[])
 
     /* initialization */
     if (setup_parameters(argc, argv) < 0){
-	Hgoto_error(1);
+        Hgoto_error(1);
     }
 
     /* Determine the need to send/wait message file*/
@@ -141,20 +141,20 @@ main(int argc, char *argv[])
     /* Create file */
     /* ============*/
     if (UC_opts.launch != UC_READER){
-	printf("Creating skeleton data file for test...\n");
+        HDprintf("Creating skeleton data file for test...\n");
 	if (create_uc_file() < 0){
-	    fprintf(stderr, "***encounter error\n");
+	    HDfprintf(stderr, "***encounter error\n");
 	    Hgoto_error(1);
 	}else
-	    printf("File created.\n");
+	    HDprintf("File created.\n");
     }
 
     if (UC_opts.launch==UC_READWRITE){
-	/* fork process */
-	if((childpid = fork()) < 0) {
-	    perror("fork");
-	    Hgoto_error(1);
-	};
+        /* fork process */
+        if((childpid = fork()) < 0) {
+            perror("fork");
+            Hgoto_error(1);
+        };
     };
     mypid = getpid();
 
@@ -162,22 +162,22 @@ main(int argc, char *argv[])
     /* launch reader */
     /* ============= */
     if (UC_opts.launch != UC_WRITER){
-	/* child process launch the reader */
-	if(0 == childpid) {
-	    printf("%d: launch reader process\n", mypid);
-	    if (read_uc_file(send_wait) < 0){
-		fprintf(stderr, "read_uc_file encountered error\n");
-		exit(1);
-	    }
-	    exit(0);
-	}
+        /* child process launch the reader */
+        if(0 == childpid) {
+            HDprintf("%d: launch reader process\n", mypid);
+            if (read_uc_file(send_wait) < 0){
+                HDfprintf(stderr, "read_uc_file encountered error\n");
+                exit(1);
+            }
+            exit(0);
+        }
     }
 
     /* ============= */
     /* launch writer */
     /* ============= */
     /* this process continues to launch the writer */
-    printf("%d: continue as the writer process\n", mypid);
+    HDprintf("%d: continue as the writer process\n", mypid);
 
     name = UC_opts.filename;
 
@@ -191,12 +191,12 @@ main(int argc, char *argv[])
 
     /* Open the file */
     if((fid = H5Fopen(name, H5F_ACC_RDWR | (UC_opts.use_swmr ? H5F_ACC_SWMR_WRITE : 0), fapl)) < 0) {
-        fprintf(stderr, "H5Fopen failed\n");
+        HDfprintf(stderr, "H5Fopen failed\n");
         Hgoto_error(1);
     }
 
     if(write_uc_file(send_wait, fid) < 0) {
-        fprintf(stderr, "write_uc_file encountered error\n");
+        HDfprintf(stderr, "write_uc_file encountered error\n");
         Hgoto_error(1);
     }
 
@@ -212,24 +212,24 @@ main(int argc, char *argv[])
 
         /* Close the file  */
         if(H5Fclose(fid) < 0) {
-            fprintf(stderr, "Failed to close file id\n");
+            HDfprintf(stderr, "Failed to close file id\n");
             Hgoto_error(1);
         }
 
         /* Close the property list */
         if(H5Pclose(fapl) < 0) {
-            fprintf(stderr, "Failed to property list\n");
+            HDfprintf(stderr, "Failed to close the property list\n");
             Hgoto_error(1);
         }
 
         if (WIFEXITED(child_status)){
             if ((child_ret_value=WEXITSTATUS(child_status)) != 0){
-                printf("%d: child process exited with non-zero code (%d)\n",
+                HDprintf("%d: child process exited with non-zero code (%d)\n",
                     mypid, child_ret_value);
                 Hgoto_error(1);
             }
         } else {
-            printf("%d: child process terminated abnormally\n", mypid);
+            HDprintf("%d: child process terminated abnormally\n", mypid);
             Hgoto_error(2);
         }
     }
@@ -237,9 +237,9 @@ main(int argc, char *argv[])
 done:
     /* Print result and exit */
     if (ret_value != 0){
-	printf("Error(s) encountered\n");
+        HDprintf("Error(s) encountered\n");
     }else{
-	printf("All passed\n");
+        HDprintf("All passed\n");
     }
 
     return(ret_value);
diff --git a/test/use_common.c b/test/use_common.c
index 164480f..3ecb2e1 100644
--- a/test/use_common.c
+++ b/test/use_common.c
@@ -447,7 +447,7 @@ int read_uc_file(hbool_t towait)
 
     /* Before reading, wait for the message that H5Fopen is complete--file lock is released */
     if(towait && h5_wait_message(WRITER_MESSAGE) < 0) {
-        fprintf(stderr, "Cannot find writer message file...failed\n");
+        HDfprintf(stderr, "Cannot find writer message file...failed\n");
         return -1;
     }
 
@@ -457,19 +457,19 @@ int read_uc_file(hbool_t towait)
     if((fapl = h5_fileaccess()) < 0)
         return -1;
     if((fid = H5Fopen(name, H5F_ACC_RDONLY | (UC_opts.use_swmr ? H5F_ACC_SWMR_READ : 0), fapl)) < 0){
-	fprintf(stderr, "H5Fopen failed\n");
+        HDfprintf(stderr, "H5Fopen failed\n");
         return -1;
     }
     if (H5Pclose(fapl) < 0){
-	    fprintf(stderr, "Failed to property list\n");
+	    HDfprintf(stderr, "Failed to property list\n");
 	    return -1;
     }
 
 
     /* Open the dataset of the program name */
     if((dsid = H5Dopen2(fid, progname_g, H5P_DEFAULT)) < 0){
-	fprintf(stderr, "H5Dopen2 failed\n");
-	return -1;
+        HDfprintf(stderr, "H5Dopen2 failed\n");
+        return -1;
     }
 
     /* allocate space for data buffer 1 X dims[1] X dims[2] of UC_CTYPE */
@@ -477,8 +477,8 @@ int read_uc_file(hbool_t towait)
     memdims[1] = UC_opts.dims[1];
     memdims[2] = UC_opts.dims[2];
     if ((buffer=(UC_CTYPE*)HDmalloc((size_t)memdims[1]*(size_t)memdims[2]*sizeof(UC_CTYPE)))==NULL) {
-	fprintf(stderr, "malloc: failed\n");
-	return -1;
+        HDfprintf(stderr, "malloc: failed\n");
+        return -1;
     };
 
     /*
@@ -488,31 +488,31 @@ int read_uc_file(hbool_t towait)
     f_sid = H5Dget_space(dsid);    /* Get filespace handle first. */
     rank  = H5Sget_simple_extent_ndims(f_sid);
     if (rank != UC_RANK){
-	fprintf(stderr, "rank(%d) of dataset does not match\n", rank);
-	return -1;
+        HDfprintf(stderr, "rank(%d) of dataset does not match\n", rank);
+        return -1;
     }
     if (H5Sget_simple_extent_dims(f_sid, dims, NULL) < 0){
-	fprintf(stderr, "H5Sget_simple_extent_dims got error\n");
-	return -1;
+        HDfprintf(stderr, "H5Sget_simple_extent_dims got error\n");
+        return -1;
     }
-    printf("dataset rank %d, dimensions %llu x %llu x %llu\n",
-	   rank, (unsigned long long)(dims[0]), (unsigned long long)(dims[1]),
-           (unsigned long long)(dims[2]));
+    HDprintf("dataset rank %d, dimensions %llu x %llu x %llu\n",
+            rank, (unsigned long long)(dims[0]), (unsigned long long)(dims[1]),
+            (unsigned long long)(dims[2]));
     /* verify that file space dims are as expected and are consistent with memory space dims */
     if (dims[1] != memdims[1] || dims[2] != memdims[2]){
-	fprintf(stderr, "dataset dimension is not as expected. Got dims=(%llu,%llu,%llu)\n",
-	    (unsigned long long)dims[0], (unsigned long long)dims[1],
+        HDfprintf(stderr, "dataset dimension is not as expected. Got dims=(%llu,%llu,%llu)\n",
+            (unsigned long long)dims[0], (unsigned long long)dims[1],
             (unsigned long long)dims[2]);
-	fprintf(stderr, "But memdims=(%llu,%llu,%llu)\n",
-	    (unsigned long long)memdims[0], (unsigned long long)memdims[1], 
+        HDfprintf(stderr, "But memdims=(%llu,%llu,%llu)\n",
+            (unsigned long long)memdims[0], (unsigned long long)memdims[1], 
             (unsigned long long)memdims[2]);
-	return -1;
+        return -1;
     }
     
     /* setup mem-space for buffer */
     if ((m_sid=H5Screate_simple(rank, memdims, NULL))<0){
-	fprintf(stderr, "H5Screate_simple for memory failed\n");
-	return -1;
+        HDfprintf(stderr, "H5Screate_simple for memory failed\n");
+        return -1;
     };
 
     /* Read 1 plane at a time whenever the dataset grows larger
@@ -526,22 +526,22 @@ int read_uc_file(hbool_t towait)
 	/* print progress message according to if new planes are availalbe */
 	if (nplane_old < dims[0]) {
 	    if (nonewplane){
-		/* end the previous message */
-		printf("\n");
-		nonewplane=0;
+            /* end the previous message */
+            HDprintf("\n");
+            nonewplane=0;
 	    }
-	    printf("reading planes %llu to %llu\n", (unsigned long long)nplane_old, 
+	    HDprintf("reading planes %llu to %llu\n", (unsigned long long)nplane_old, 
                 (unsigned long long)dims[0]);
 	}else{
 	    if (nonewplane){
-		printf(".");
+            HDprintf(".");
 		if (nonewplane>=30){
-		    fprintf(stderr, "waited too long for new plane, quit.\n");
+		    HDfprintf(stderr, "waited too long for new plane, quit.\n");
 		    return -1;
 		}
 	    }else{
-		/* print mesg only the first time; dots still no new plane */
-		printf("no new planes to read ");
+            /* print mesg only the first time; dots still no new plane */
+            HDprintf("no new planes to read ");
 	    }
 	    nonewplane++;
 	    /* pause for a second */
@@ -551,41 +551,41 @@ int read_uc_file(hbool_t towait)
 	    /* read planes between last old nplanes and current extent */
 	    /* Get the dataset's dataspace */
 	    if((f_sid = H5Dget_space(dsid)) < 0){
-		fprintf(stderr, "H5Dget_space failed\n");
-		return -1;
+            HDfprintf(stderr, "H5Dget_space failed\n");
+            return -1;
 	    }
 
 	    start[0]=nplane;
 	    /* Choose the next plane to read */
 	    if(H5Sselect_hyperslab(f_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0){
-		fprintf(stderr, "H5Sselect_hyperslab failed\n");
-		return -1;
+            HDfprintf(stderr, "H5Sselect_hyperslab failed\n");
+            return -1;
 	    }
 
 	    /* Read the plane from the dataset */
 	    if(H5Dread(dsid, UC_DATATYPE, m_sid, f_sid, H5P_DEFAULT, buffer) < 0){
-		fprintf(stderr, "H5Dread failed\n");
-		return -1;
+            HDfprintf(stderr, "H5Dread failed\n");
+            return -1;
 	    }
 
 	    /* compare read data with expected data value which is nplane */
 	    bufptr = buffer;
 	    nerrs=0;
 	    for (j=0; j<dims[1]; j++){
-		for (k=0; k<dims[2]; k++){
-		    if ((hsize_t)*bufptr++ != nplane){
-			if (++nerrs < ErrorReportMax){
-			    fprintf(stderr,
-				"found error %llu plane(%llu,%llu), expected %llu, got %d\n",
-				(unsigned long long)nplane, (unsigned long long)j, 
-                                (unsigned long long)k, (unsigned long long)nplane, (int)*(bufptr-1));
-			}
-		    }
-		}
+            for (k=0; k<dims[2]; k++){
+                if ((hsize_t)*bufptr++ != nplane){
+                    if (++nerrs < ErrorReportMax){
+                        HDfprintf(stderr,
+                            "found error %llu plane(%llu,%llu), expected %llu, got %d\n",
+                            (unsigned long long)nplane, (unsigned long long)j, 
+                            (unsigned long long)k, (unsigned long long)nplane, (int)*(bufptr-1));
+                    }
+                }
+            }
 	    }
 	    if (nerrs){
-		nreadererr++;
-		fprintf(stderr, "found %d unexpected values in plane %llu\n", nerrs, 
+            nreadererr++;
+            HDfprintf(stderr, "found %d unexpected values in plane %llu\n", nerrs, 
                     (unsigned long long)nplane);
 	    }
 	}
@@ -596,19 +596,19 @@ int read_uc_file(hbool_t towait)
 #if 0
 	/* close dsid and file, then reopen them */
 	if (H5Dclose(dsid) < 0){
-	    fprintf(stderr, "H5Dclose failed\n");
+	    HDfprintf(stderr, "H5Dclose failed\n");
 	    return -1;
 	}
 	if (H5Fclose(fid) < 0){
-	    fprintf(stderr, "H5Fclose failed\n");
+	    HDfprintf(stderr, "H5Fclose failed\n");
 	    return -1;
 	}
 	if((fid = H5Fopen(name, H5F_ACC_RDONLY | (UC_opts.use_swmr ? H5F_ACC_SWMR_READ : 0), H5P_DEFAULT)) < 0){
-	    fprintf(stderr, "H5Fopen failed\n");
+	    HDfprintf(stderr, "H5Fopen failed\n");
 	    return -1;
 	}
 	if((dsid = H5Dopen2(fid, progname_g, H5P_DEFAULT)) < 0){
-	    fprintf(stderr, "H5Dopen2 failed\n");
+	    HDfprintf(stderr, "H5Dopen2 failed\n");
 	    return -1;
 	}
 #else
@@ -616,22 +616,22 @@ int read_uc_file(hbool_t towait)
 #endif
 	f_sid = H5Dget_space(dsid);    /* Get filespace handle first. */
 	if (H5Sget_simple_extent_dims(f_sid, dims, NULL) < 0){
-	    fprintf(stderr, "H5Sget_simple_extent_dims got error\n");
+	    HDfprintf(stderr, "H5Sget_simple_extent_dims got error\n");
 	    return -1;
 	}
     }
 
     /* Close the file */
     if(H5Fclose(fid) < 0) {
-        fprintf(stderr, "H5Fclose failed\n");
+        HDfprintf(stderr, "H5Fclose failed\n");
         return -1;
     }
 
     if (nreadererr)
-	return -1;
+        return -1;
     else
-	return 0;
-}
+        return 0;
+} /* read_uc_file() */
 
 #endif /* H5_HAVE_FORK */
 
-- 
cgit v0.12


From 51076d40617aa6f0236809c2c919cc6921b3bbc1 Mon Sep 17 00:00:00 2001
From: Vailin Choi <vchoi@jam.ad.hdfgroup.org>
Date: Thu, 1 Nov 2018 15:00:40 -0500
Subject: Fixed exit() to HDexit() in use_append_chunk.c and
 use_append_mchunks.c

---
 test/use_append_chunk.c   | 4 ++--
 test/use_append_mchunks.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/test/use_append_chunk.c b/test/use_append_chunk.c
index fb906b6..4e8c672 100644
--- a/test/use_append_chunk.c
+++ b/test/use_append_chunk.c
@@ -174,9 +174,9 @@ main(int argc, char *argv[])
             HDprintf("%d: launch reader process\n", mypid);
             if (read_uc_file(send_wait) < 0){
                 HDfprintf(stderr, "read_uc_file encountered error\n");
-                exit(1);
+                HDexit(1);
             }
-            exit(0);
+            HDexit(0);
         }
     }
 
diff --git a/test/use_append_mchunks.c b/test/use_append_mchunks.c
index da7e2b3..0414628 100644
--- a/test/use_append_mchunks.c
+++ b/test/use_append_mchunks.c
@@ -167,9 +167,9 @@ main(int argc, char *argv[])
             HDprintf("%d: launch reader process\n", mypid);
             if (read_uc_file(send_wait) < 0){
                 HDfprintf(stderr, "read_uc_file encountered error\n");
-                exit(1);
+                HDexit(1);
             }
-            exit(0);
+            HDexit(0);
         }
     }
 
-- 
cgit v0.12