summaryrefslogtreecommitdiffstats
path: root/test/external_common.c
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2020-10-01 14:04:36 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2020-10-01 14:04:36 (GMT)
commitf1ba03cea5b82699a984c80bd2deac14fdc8df18 (patch)
treeebe777c3e0b83f4c4cec9212731da9ebe0a0cfd3 /test/external_common.c
parent10343c197906415388f2a4c8d292e21d25cf7381 (diff)
downloadhdf5-f1ba03cea5b82699a984c80bd2deac14fdc8df18.zip
hdf5-f1ba03cea5b82699a984c80bd2deac14fdc8df18.tar.gz
hdf5-f1ba03cea5b82699a984c80bd2deac14fdc8df18.tar.bz2
Source formatted
Diffstat (limited to 'test/external_common.c')
-rw-r--r--test/external_common.c49
1 files changed, 24 insertions, 25 deletions
diff --git a/test/external_common.c b/test/external_common.c
index a9e600b..f4dbb4e 100644
--- a/test/external_common.c
+++ b/test/external_common.c
@@ -20,7 +20,6 @@
#include "external_common.h"
-
/*-------------------------------------------------------------------------
* Function: reset_raw_data_files
*
@@ -37,51 +36,51 @@
herr_t
reset_raw_data_files(hbool_t is_env)
{
- int fd = 0; /* external file descriptor */
- size_t i, j; /* iterators */
- hssize_t n; /* bytes of I/O */
- char filename[1024]; /* file name */
- int data[PART_SIZE]; /* raw data buffer */
- uint8_t *garbage = NULL; /* buffer of garbage data */
- size_t garbage_count; /* size of garbage buffer */
- size_t garbage_bytes; /* # of garbage bytes written to file */
+ int fd = 0; /* external file descriptor */
+ size_t i, j; /* iterators */
+ hssize_t n; /* bytes of I/O */
+ char filename[1024]; /* file name */
+ int data[PART_SIZE]; /* raw data buffer */
+ uint8_t *garbage = NULL; /* buffer of garbage data */
+ size_t garbage_count; /* size of garbage buffer */
+ size_t garbage_bytes; /* # of garbage bytes written to file */
/* Set up garbage buffer */
garbage_count = N_EXT_FILES * GARBAGE_PER_FILE;
- if(NULL == (garbage = (uint8_t *)HDcalloc(garbage_count, sizeof(uint8_t))))
+ if (NULL == (garbage = (uint8_t *)HDcalloc(garbage_count, sizeof(uint8_t))))
goto error;
- for(i = 0; i < garbage_count; i++)
+ for (i = 0; i < garbage_count; i++)
garbage[i] = 0xFF;
/* The *r files are pre-filled with data and are used to
* verify that read operations work correctly.
*/
- for(i = 0; i < N_EXT_FILES; i++) {
+ for (i = 0; i < N_EXT_FILES; i++) {
/* Open file */
- if(is_env)
+ if (is_env)
HDsprintf(filename, "extern_env_%lur.raw", (unsigned long)i + 1);
else
HDsprintf(filename, "extern_%lur.raw", (unsigned long)i + 1);
- if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0)
+ if ((fd = HDopen(filename, O_RDWR | O_CREAT | O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0)
goto error;
/* Write garbage data to the file. This allows us to test the
* the ability to set an offset in the raw data file.
*/
garbage_bytes = i * 10;
- n = HDwrite(fd, garbage, garbage_bytes);
- if(n < 0 || (size_t)n != garbage_bytes)
+ n = HDwrite(fd, garbage, garbage_bytes);
+ if (n < 0 || (size_t)n != garbage_bytes)
goto error;
/* Fill array with data */
- for(j = 0; j < PART_SIZE; j++) {
+ for (j = 0; j < PART_SIZE; j++) {
data[j] = (int)(i * 25 + j);
} /* end for */
/* Write raw data to the file. */
n = HDwrite(fd, data, sizeof(data));
- if(n != sizeof(data))
+ if (n != sizeof(data))
goto error;
/* Close this file */
@@ -93,22 +92,22 @@ reset_raw_data_files(hbool_t is_env)
* used to verify that write operations work correctly. The individual
* tests fill in the actual data.
*/
- for(i = 0; i < N_EXT_FILES; i++) {
+ for (i = 0; i < N_EXT_FILES; i++) {
/* Open file */
- if(is_env)
+ if (is_env)
HDsprintf(filename, "extern_env_%luw.raw", (unsigned long)i + 1);
else
HDsprintf(filename, "extern_%luw.raw", (unsigned long)i + 1);
- if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0)
+ if ((fd = HDopen(filename, O_RDWR | O_CREAT | O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0)
goto error;
/* Write garbage data to the file. This allows us to test the
* the ability to set an offset in the raw data file.
*/
garbage_bytes = i * 10;
- n = HDwrite(fd, garbage, garbage_bytes);
- if(n < 0 || (size_t)n != garbage_bytes)
+ n = HDwrite(fd, garbage, garbage_bytes);
+ if (n < 0 || (size_t)n != garbage_bytes)
goto error;
/* Close this file */
@@ -119,9 +118,9 @@ reset_raw_data_files(hbool_t is_env)
return SUCCEED;
error:
- if(fd)
+ if (fd)
HDclose(fd);
- if(garbage)
+ if (garbage)
HDfree(garbage);
return FAIL;
}