summaryrefslogtreecommitdiffstats
path: root/tools/misc
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2020-10-01 18:57:05 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2020-10-01 18:57:05 (GMT)
commit9aa0ae6778b23786480ddd2fdcd1711b84f74e78 (patch)
treeae51dfc33cf40432dad25a5088767115a98f195e /tools/misc
parent8eef7d295cc3dd134aef0a826f1de4287629996d (diff)
parent1ba1f2f3222cbe8df0bf601929a4bffd478d7e02 (diff)
downloadhdf5-9aa0ae6778b23786480ddd2fdcd1711b84f74e78.zip
hdf5-9aa0ae6778b23786480ddd2fdcd1711b84f74e78.tar.gz
hdf5-9aa0ae6778b23786480ddd2fdcd1711b84f74e78.tar.bz2
Merge pull request #2913 in HDFFV/hdf5 from ~BYRN/hdf5_clang_format:hdf5_1_8 to hdf5_1_8
* commit '1ba1f2f3222cbe8df0bf601929a4bffd478d7e02': Source formatted
Diffstat (limited to 'tools/misc')
-rw-r--r--tools/misc/h5debug.c331
-rw-r--r--tools/misc/h5mkgrp.c121
-rw-r--r--tools/misc/h5repart.c337
-rw-r--r--tools/misc/h5repart_gentest.c71
-rw-r--r--tools/misc/repart_test.c50
-rw-r--r--tools/misc/talign.c114
6 files changed, 504 insertions, 520 deletions
diff --git a/tools/misc/h5debug.c b/tools/misc/h5debug.c
index 676e050..f5fc8f4 100644
--- a/tools/misc/h5debug.c
+++ b/tools/misc/h5debug.c
@@ -21,36 +21,35 @@
*
*-------------------------------------------------------------------------
*/
-#define H5A_PACKAGE /*suppress error about including H5Apkg */
-#define H5B2_PACKAGE /*suppress error about including H5B2pkg */
-#define H5B2_TESTING /*suppress warning about H5B2 testing funcs*/
-#define H5D_PACKAGE /*suppress error about including H5Dpkg */
-#define H5F_PACKAGE /*suppress error about including H5Fpkg */
-#define H5G_PACKAGE /*suppress error about including H5Gpkg */
-#define H5HF_PACKAGE /*suppress error about including H5HFpkg */
-#define H5O_PACKAGE /*suppress error about including H5Opkg */
-#define H5SM_PACKAGE /*suppress error about including H5SMpkg */
-
-#include "H5private.h" /* Generic Functions */
-#include "H5Apkg.h" /* Attributes */
-#include "H5B2pkg.h" /* v2 B-trees */
-#include "H5Dpkg.h" /* Datasets */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5Fpkg.h" /* File access */
+#define H5A_PACKAGE /*suppress error about including H5Apkg */
+#define H5B2_PACKAGE /*suppress error about including H5B2pkg */
+#define H5B2_TESTING /*suppress warning about H5B2 testing funcs*/
+#define H5D_PACKAGE /*suppress error about including H5Dpkg */
+#define H5F_PACKAGE /*suppress error about including H5Fpkg */
+#define H5G_PACKAGE /*suppress error about including H5Gpkg */
+#define H5HF_PACKAGE /*suppress error about including H5HFpkg */
+#define H5O_PACKAGE /*suppress error about including H5Opkg */
+#define H5SM_PACKAGE /*suppress error about including H5SMpkg */
+
+#include "H5private.h" /* Generic Functions */
+#include "H5Apkg.h" /* Attributes */
+#include "H5B2pkg.h" /* v2 B-trees */
+#include "H5Dpkg.h" /* Datasets */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5Fpkg.h" /* File access */
#include "H5FSprivate.h" /* Free space manager */
-#include "H5Gpkg.h" /* Groups */
-#include "H5HFpkg.h" /* Fractal heaps */
+#include "H5Gpkg.h" /* Groups */
+#include "H5HFpkg.h" /* Fractal heaps */
#include "H5HGprivate.h" /* Global Heaps */
-#include "H5Iprivate.h" /* IDs */
-#include "H5Opkg.h" /* Object headers */
-#include "H5SMpkg.h" /* Implicitly shared messages */
+#include "H5Iprivate.h" /* IDs */
+#include "H5Opkg.h" /* Object headers */
+#include "H5SMpkg.h" /* Implicitly shared messages */
/* File drivers */
#include "H5FDfamily.h"
-#define INDENT 3
-#define VCOL 50
-
+#define INDENT 3
+#define VCOL 50
/*-------------------------------------------------------------------------
* Function: get_H5B2_class
@@ -70,59 +69,58 @@
static const H5B2_class_t *
get_H5B2_class(const uint8_t *sig)
{
- H5B2_subid_t subtype = (H5B2_subid_t)sig[H5_SIZEOF_MAGIC + 1];
+ H5B2_subid_t subtype = (H5B2_subid_t)sig[H5_SIZEOF_MAGIC + 1];
const H5B2_class_t *cls;
- switch(subtype) {
- case H5B2_TEST_ID:
- cls = H5B2_TEST;
- break;
+ switch (subtype) {
+ case H5B2_TEST_ID:
+ cls = H5B2_TEST;
+ break;
- case H5B2_FHEAP_HUGE_INDIR_ID:
- cls = H5HF_HUGE_BT2_INDIR;
- break;
+ case H5B2_FHEAP_HUGE_INDIR_ID:
+ cls = H5HF_HUGE_BT2_INDIR;
+ break;
- case H5B2_FHEAP_HUGE_FILT_INDIR_ID:
- cls = H5HF_HUGE_BT2_FILT_INDIR;
- break;
+ case H5B2_FHEAP_HUGE_FILT_INDIR_ID:
+ cls = H5HF_HUGE_BT2_FILT_INDIR;
+ break;
- case H5B2_FHEAP_HUGE_DIR_ID:
- cls = H5HF_HUGE_BT2_DIR;
- break;
+ case H5B2_FHEAP_HUGE_DIR_ID:
+ cls = H5HF_HUGE_BT2_DIR;
+ break;
- case H5B2_FHEAP_HUGE_FILT_DIR_ID:
- cls = H5HF_HUGE_BT2_FILT_DIR;
- break;
+ case H5B2_FHEAP_HUGE_FILT_DIR_ID:
+ cls = H5HF_HUGE_BT2_FILT_DIR;
+ break;
- case H5B2_GRP_DENSE_NAME_ID:
- cls = H5G_BT2_NAME;
- break;
+ case H5B2_GRP_DENSE_NAME_ID:
+ cls = H5G_BT2_NAME;
+ break;
- case H5B2_GRP_DENSE_CORDER_ID:
- cls = H5G_BT2_CORDER;
- break;
+ case H5B2_GRP_DENSE_CORDER_ID:
+ cls = H5G_BT2_CORDER;
+ break;
- case H5B2_SOHM_INDEX_ID:
- cls = H5SM_INDEX;
- break;
+ case H5B2_SOHM_INDEX_ID:
+ cls = H5SM_INDEX;
+ break;
- case H5B2_ATTR_DENSE_NAME_ID:
- cls = H5A_BT2_NAME;
- break;
+ case H5B2_ATTR_DENSE_NAME_ID:
+ cls = H5A_BT2_NAME;
+ break;
- case H5B2_ATTR_DENSE_CORDER_ID:
- cls = H5A_BT2_CORDER;
- break;
+ case H5B2_ATTR_DENSE_CORDER_ID:
+ cls = H5A_BT2_CORDER;
+ break;
default:
HDfprintf(stderr, "Unknown B-tree subtype %u\n", (unsigned)(subtype));
HDexit(4);
} /* end switch */
- return(cls);
+ return (cls);
} /* end get_H5B2_class() */
-
/*-------------------------------------------------------------------------
* Function: main
*
@@ -141,22 +139,22 @@ get_H5B2_class(const uint8_t *sig)
int
main(int argc, char *argv[])
{
- hid_t fid, fapl, dxpl;
- H5F_t *f;
+ hid_t fid, fapl, dxpl;
+ H5F_t * f;
haddr_t addr = 0, extra = 0, extra2 = 0, extra3 = 0, extra4 = 0;
uint8_t sig[H5F_SIGNATURE_LEN];
size_t u;
H5E_auto2_t func;
- void *edata;
+ void * edata;
herr_t status = SUCCEED;
- if(argc == 1) {
+ if (argc == 1) {
HDfprintf(stderr, "Usage: %s filename [signature-addr [extra]]\n", argv[0]);
HDexit(1);
} /* end if */
/* Initialize the library */
- if(H5open() < 0) {
+ if (H5open() < 0) {
HDfprintf(stderr, "cannot initialize the library\n");
HDexit(1);
} /* end if */
@@ -168,24 +166,24 @@ main(int argc, char *argv[])
/*
* Open the file and get the file descriptor.
*/
- if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) {
+ if ((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) {
HDfprintf(stderr, "cannot create dataset transfer property list\n");
HDexit(1);
} /* end if */
- if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) {
+ if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) {
HDfprintf(stderr, "cannot create file access property list\n");
HDexit(1);
} /* end if */
- if(HDstrchr(argv[1], '%'))
- if(H5Pset_fapl_family (fapl, (hsize_t)0, H5P_DEFAULT) < 0) {
+ if (HDstrchr(argv[1], '%'))
+ if (H5Pset_fapl_family(fapl, (hsize_t)0, H5P_DEFAULT) < 0) {
HDfprintf(stderr, "cannot set file access property list\n");
HDexit(1);
}
- if((fid = H5Fopen(argv[1], H5F_ACC_RDONLY, fapl)) < 0) {
+ if ((fid = H5Fopen(argv[1], H5F_ACC_RDONLY, fapl)) < 0) {
HDfprintf(stderr, "cannot open file\n");
HDexit(1);
} /* end if */
- if(NULL == (f = (H5F_t *)H5I_object(fid))) {
+ if (NULL == (f = (H5F_t *)H5I_object(fid))) {
HDfprintf(stderr, "cannot obtain H5F_t pointer\n");
HDexit(2);
} /* end if */
@@ -193,61 +191,59 @@ main(int argc, char *argv[])
/*
* Parse command arguments.
*/
- if(argc > 2)
+ if (argc > 2)
addr = (haddr_t)HDstrtoll(argv[2], NULL, 0);
- if(argc > 3)
+ if (argc > 3)
extra = (haddr_t)HDstrtoll(argv[3], NULL, 0);
- if(argc > 4)
+ if (argc > 4)
extra2 = (haddr_t)HDstrtoll(argv[4], NULL, 0);
- if(argc > 5)
+ if (argc > 5)
extra3 = (haddr_t)HDstrtoll(argv[5], NULL, 0);
- if(argc > 6)
+ if (argc > 6)
extra4 = (haddr_t)HDstrtoll(argv[6], NULL, 0);
/*
* Read the signature at the specified file position.
*/
HDfprintf(stdout, "Reading signature at address %a (rel)\n", addr);
- if(H5F_block_read(f, H5FD_MEM_SUPER, addr, sizeof(sig), dxpl, sig) < 0) {
+ if (H5F_block_read(f, H5FD_MEM_SUPER, addr, sizeof(sig), dxpl, sig) < 0) {
HDfprintf(stderr, "cannot read signature\n");
HDexit(3);
}
- if(!HDmemcmp(sig, H5F_SIGNATURE, (size_t)H5F_SIGNATURE_LEN)) {
+ if (!HDmemcmp(sig, H5F_SIGNATURE, (size_t)H5F_SIGNATURE_LEN)) {
/*
* Debug the file's super block.
*/
status = H5F_debug(f, stdout, 0, VCOL);
-
- } else if(!HDmemcmp(sig, H5HL_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
+ }
+ else if (!HDmemcmp(sig, H5HL_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
* Debug a local heap.
*/
status = H5HL_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL);
-
}
- else if(!HDmemcmp (sig, H5HG_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
+ else if (!HDmemcmp(sig, H5HG_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
* Debug a global heap collection.
*/
status = H5HG_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL);
-
}
- else if(!HDmemcmp(sig, H5G_NODE_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
+ else if (!HDmemcmp(sig, H5G_NODE_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
* Debug a symbol table node.
*/
/* Check for extra parameters */
- if(extra == 0) {
- HDfprintf(stderr, "\nWarning: Providing the group's local heap address will give more information\n");
+ if (extra == 0) {
+ HDfprintf(stderr,
+ "\nWarning: Providing the group's local heap address will give more information\n");
HDfprintf(stderr, "Symbol table node usage:\n");
HDfprintf(stderr, "\th5debug <filename> <Symbol table node address> <address of local heap>\n\n");
} /* end if */
status = H5G_node_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, extra);
-
}
- else if(!HDmemcmp(sig, H5B_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
+ else if (!HDmemcmp(sig, H5B_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
* Debug a B-tree. B-trees are debugged through the B-tree
* subclass. The subclass identifier is the byte immediately
@@ -256,30 +252,36 @@ main(int argc, char *argv[])
H5B_subid_t subtype = (H5B_subid_t)sig[H5_SIZEOF_MAGIC];
unsigned ndims;
- switch(subtype) {
- case H5B_SNODE_ID:
- /* Check for extra parameters */
- if(extra == 0) {
- HDfprintf(stderr, "\nWarning: Providing the group's local heap address will give more information\n");
- HDfprintf(stderr, "B-tree symbol table node usage:\n");
- HDfprintf(stderr, "\th5debug <filename> <B-tree node address> <address of local heap>\n\n");
- HDexit(4);
- } /* end if */
-
- status = H5G_node_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, extra);
- break;
-
- case H5B_CHUNK_ID:
- /* Check for extra parameters */
- if(extra == 0) {
- HDfprintf(stderr, "ERROR: Need number of dimensions of chunk in order to dump chunk B-tree node\n");
- HDfprintf(stderr, "B-tree chunked storage node usage:\n");
- HDfprintf(stderr, "\th5debug <filename> <B-tree node address> <# of dimensions> <slowest chunk dim>...<fastest chunk dim>\n");
- HDexit(4);
- } /* end if */
+ switch (subtype) {
+ case H5B_SNODE_ID:
+ /* Check for extra parameters */
+ if (extra == 0) {
+ HDfprintf(
+ stderr,
+ "\nWarning: Providing the group's local heap address will give more information\n");
+ HDfprintf(stderr, "B-tree symbol table node usage:\n");
+ HDfprintf(stderr,
+ "\th5debug <filename> <B-tree node address> <address of local heap>\n\n");
+ HDexit(4);
+ } /* end if */
+
+ status = H5G_node_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, extra);
+ break;
- /* Build array of chunk dimensions */
- ndims = (unsigned)extra;
+ case H5B_CHUNK_ID:
+ /* Check for extra parameters */
+ if (extra == 0) {
+ HDfprintf(
+ stderr,
+ "ERROR: Need number of dimensions of chunk in order to dump chunk B-tree node\n");
+ HDfprintf(stderr, "B-tree chunked storage node usage:\n");
+ HDfprintf(stderr, "\th5debug <filename> <B-tree node address> <# of dimensions> <slowest "
+ "chunk dim>...<fastest chunk dim>\n");
+ HDexit(4);
+ } /* end if */
+
+ /* Build array of chunk dimensions */
+ ndims = (unsigned)extra;
status = H5D_btree_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, ndims);
break;
@@ -287,9 +289,8 @@ main(int argc, char *argv[])
HDfprintf(stderr, "Unknown B-tree subtype %u\n", (unsigned)(subtype));
HDexit(4);
}
-
}
- else if(!HDmemcmp(sig, H5B2_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
+ else if (!HDmemcmp(sig, H5B2_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
* Debug a v2 B-tree header.
*/
@@ -297,9 +298,8 @@ main(int argc, char *argv[])
HDassert(cls);
status = H5B2_hdr_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, cls, (haddr_t)extra);
-
}
- else if(!HDmemcmp(sig, H5B2_INT_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
+ else if (!HDmemcmp(sig, H5B2_INT_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
* Debug a v2 B-tree internal node.
*/
@@ -307,18 +307,21 @@ main(int argc, char *argv[])
HDassert(cls);
/* Check for enough valid parameters */
- if(extra == 0 || extra2 == 0 || extra3 == 0) {
- HDfprintf(stderr, "ERROR: Need v2 B-tree header address and the node's number of records and depth in order to dump internal node\n");
- HDfprintf(stderr, "NOTE: Leaf nodes are depth 0, the internal nodes above them are depth 1, etc.\n");
+ if (extra == 0 || extra2 == 0 || extra3 == 0) {
+ HDfprintf(stderr, "ERROR: Need v2 B-tree header address and the node's number of records and "
+ "depth in order to dump internal node\n");
+ HDfprintf(stderr,
+ "NOTE: Leaf nodes are depth 0, the internal nodes above them are depth 1, etc.\n");
HDfprintf(stderr, "v2 B-tree internal node usage:\n");
- HDfprintf(stderr, "\th5debug <filename> <internal node address> <v2 B-tree header address> <number of records> <depth>\n");
+ HDfprintf(stderr, "\th5debug <filename> <internal node address> <v2 B-tree header address> "
+ "<number of records> <depth>\n");
HDexit(4);
} /* end if */
- status = H5B2_int_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, cls, extra, (unsigned)extra2, (unsigned)extra3, (haddr_t)extra4);
-
+ status = H5B2_int_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, cls, extra,
+ (unsigned)extra2, (unsigned)extra3, (haddr_t)extra4);
}
- else if(!HDmemcmp(sig, H5B2_LEAF_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
+ else if (!HDmemcmp(sig, H5B2_LEAF_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
* Debug a v2 B-tree leaf node.
*/
@@ -326,118 +329,127 @@ main(int argc, char *argv[])
HDassert(cls);
/* Check for enough valid parameters */
- if(extra == 0 || extra2 == 0) {
- HDfprintf(stderr, "ERROR: Need v2 B-tree header address and number of records in order to dump leaf node\n");
+ if (extra == 0 || extra2 == 0) {
+ HDfprintf(
+ stderr,
+ "ERROR: Need v2 B-tree header address and number of records in order to dump leaf node\n");
HDfprintf(stderr, "v2 B-tree leaf node usage:\n");
- HDfprintf(stderr, "\th5debug <filename> <leaf node address> <v2 B-tree header address> <number of records>\n");
+ HDfprintf(
+ stderr,
+ "\th5debug <filename> <leaf node address> <v2 B-tree header address> <number of records>\n");
HDexit(4);
} /* end if */
- status = H5B2_leaf_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, cls, extra, (unsigned)extra2, (haddr_t)extra3);
-
+ status = H5B2_leaf_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, cls, extra,
+ (unsigned)extra2, (haddr_t)extra3);
}
- else if(!HDmemcmp(sig, H5HF_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
+ else if (!HDmemcmp(sig, H5HF_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
* Debug a fractal heap header.
*/
status = H5HF_hdr_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL);
-
}
- else if(!HDmemcmp(sig, H5HF_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
+ else if (!HDmemcmp(sig, H5HF_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
* Debug a fractal heap direct block.
*/
/* Check for enough valid parameters */
- if(extra == 0 || extra2 == 0) {
- HDfprintf(stderr, "ERROR: Need fractal heap header address and size of direct block in order to dump direct block\n");
+ if (extra == 0 || extra2 == 0) {
+ HDfprintf(stderr, "ERROR: Need fractal heap header address and size of direct block in order to "
+ "dump direct block\n");
HDfprintf(stderr, "Fractal heap direct block usage:\n");
- HDfprintf(stderr, "\th5debug <filename> <direct block address> <heap header address> <size of direct block>\n");
+ HDfprintf(
+ stderr,
+ "\th5debug <filename> <direct block address> <heap header address> <size of direct block>\n");
HDexit(4);
} /* end if */
status = H5HF_dblock_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, extra, (size_t)extra2);
-
}
- else if(!HDmemcmp(sig, H5HF_IBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
+ else if (!HDmemcmp(sig, H5HF_IBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
* Debug a fractal heap indirect block.
*/
/* Check for enough valid parameters */
- if(extra == 0 || extra2 == 0) {
- HDfprintf(stderr, "ERROR: Need fractal heap header address and number of rows in order to dump indirect block\n");
+ if (extra == 0 || extra2 == 0) {
+ HDfprintf(stderr, "ERROR: Need fractal heap header address and number of rows in order to dump "
+ "indirect block\n");
HDfprintf(stderr, "Fractal heap indirect block usage:\n");
- HDfprintf(stderr, "\th5debug <filename> <indirect block address> <heap header address> <number of rows>\n");
+ HDfprintf(
+ stderr,
+ "\th5debug <filename> <indirect block address> <heap header address> <number of rows>\n");
HDexit(4);
} /* end if */
- status = H5HF_iblock_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, extra, (unsigned)extra2);
-
+ status =
+ H5HF_iblock_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, extra, (unsigned)extra2);
}
- else if(!HDmemcmp(sig, H5FS_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
+ else if (!HDmemcmp(sig, H5FS_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
* Debug a free space header.
*/
status = H5FS_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL);
-
}
- else if(!HDmemcmp(sig, H5FS_SINFO_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
+ else if (!HDmemcmp(sig, H5FS_SINFO_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
* Debug free space serialized sections.
*/
/* Check for enough valid parameters */
- if(extra == 0 || extra2 == 0) {
- HDfprintf(stderr, "ERROR: Need free space header address and client address in order to dump serialized sections\n");
+ if (extra == 0 || extra2 == 0) {
+ HDfprintf(stderr, "ERROR: Need free space header address and client address in order to dump "
+ "serialized sections\n");
HDfprintf(stderr, "Free space serialized sections usage:\n");
- HDfprintf(stderr, "\th5debug <filename> <serialized sections address> <free space header address> <client address>\n");
+ HDfprintf(stderr, "\th5debug <filename> <serialized sections address> <free space header "
+ "address> <client address>\n");
HDexit(4);
} /* end if */
status = H5FS_sects_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, extra, extra2);
-
}
- else if(!HDmemcmp(sig, H5SM_TABLE_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
+ else if (!HDmemcmp(sig, H5SM_TABLE_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
* Debug shared message master table.
*/
- status = H5SM_table_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, (unsigned) UFAIL, (unsigned) UFAIL);
-
+ status = H5SM_table_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, (unsigned)UFAIL,
+ (unsigned)UFAIL);
}
- else if(!HDmemcmp(sig, H5SM_LIST_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
+ else if (!HDmemcmp(sig, H5SM_LIST_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
* Debug shared message list index.
*/
/* Check for enough valid parameters */
- if(extra2 == 0) {
- HDfprintf(stderr, "ERROR: Need list format version and number of messages in order to shared message list\n");
+ if (extra2 == 0) {
+ HDfprintf(
+ stderr,
+ "ERROR: Need list format version and number of messages in order to shared message list\n");
HDfprintf(stderr, "Shared message list usage:\n");
- HDfprintf(stderr, "\th5debug <filename> <shared message list address> <list format version> <number of mesages in list>\n");
+ HDfprintf(stderr, "\th5debug <filename> <shared message list address> <list format version> "
+ "<number of mesages in list>\n");
HDexit(4);
} /* end if */
- status = H5SM_list_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, (unsigned) extra, (size_t) extra2);
-
+ status = H5SM_list_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, (unsigned)extra,
+ (size_t)extra2);
}
- else if(!HDmemcmp(sig, H5EA_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
+ else if (!HDmemcmp(sig, H5EA_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
* Debug v2 object header (which have signatures).
*/
status = H5O_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL);
-
}
- else if(sig[0] == H5O_VERSION_1) {
+ else if (sig[0] == H5O_VERSION_1) {
/*
* This could be a v1 object header. Since they don't have a signature
* it's a somewhat "ify" detection.
*/
status = H5O_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL);
-
}
else {
/*
@@ -461,7 +473,7 @@ main(int argc, char *argv[])
} /* end else */
/* Check for an error when dumping information */
- if(status < 0) {
+ if (status < 0) {
HDfprintf(stderr, "An error occurred!\n");
H5Eprint2(H5E_DEFAULT, stderr);
HDexit(5);
@@ -475,4 +487,3 @@ main(int argc, char *argv[])
return 0;
} /* main() */
-
diff --git a/tools/misc/h5mkgrp.c b/tools/misc/h5mkgrp.c
index feb60d4..671b8ae 100644
--- a/tools/misc/h5mkgrp.c
+++ b/tools/misc/h5mkgrp.c
@@ -11,7 +11,6 @@
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
#include "H5private.h"
#include "h5tools.h"
#include "h5tools_utils.h"
@@ -23,28 +22,22 @@
int d_status = EXIT_SUCCESS;
/* command-line options: short and long-named parameters */
-static const char *s_opts = "hlpvV";
-static struct long_options l_opts[] = {
- { "help", no_arg, 'h' },
- { "latest", no_arg, 'l' },
- { "parents", no_arg, 'p' },
- { "verbose", no_arg, 'v' },
- { "version", no_arg, 'V' },
- { NULL, 0, '\0' }
-};
+static const char * s_opts = "hlpvV";
+static struct long_options l_opts[] = {{"help", no_arg, 'h'}, {"latest", no_arg, 'l'},
+ {"parents", no_arg, 'p'}, {"verbose", no_arg, 'v'},
+ {"version", no_arg, 'V'}, {NULL, 0, '\0'}};
/* Command line parameter settings */
typedef struct {
- char *fname; /* File name to operate on */
- hbool_t latest; /* Whether file should use latest format versions */
- hbool_t verbose; /* Whether output should be verbose */
- hbool_t parents; /* Whether to create intermediate groups */
- size_t ngroups; /* Number of groups to create */
- char **groups; /* Pointer to array of group names */
+ char * fname; /* File name to operate on */
+ hbool_t latest; /* Whether file should use latest format versions */
+ hbool_t verbose; /* Whether output should be verbose */
+ hbool_t parents; /* Whether to create intermediate groups */
+ size_t ngroups; /* Number of groups to create */
+ char ** groups; /* Pointer to array of group names */
} param_t;
-param_t params; /* Command line parameter settings */
+param_t params; /* Command line parameter settings */
-
/*-------------------------------------------------------------------------
* Function: leave
*
@@ -62,17 +55,16 @@ leave(int ret)
size_t curr_group;
if (params.fname)
- HDfree (params.fname);
+ HDfree(params.fname);
if (params.ngroups) {
- for(curr_group = 0; curr_group < params.ngroups; curr_group++)
- HDfree (params.groups[curr_group]);
- HDfree (params.groups);
+ for (curr_group = 0; curr_group < params.ngroups; curr_group++)
+ HDfree(params.groups[curr_group]);
+ HDfree(params.groups);
}
h5tools_close();
HDexit(ret);
} /* end leave() */
-
/*-------------------------------------------------------------------------
* Function: usage
*
@@ -97,7 +89,6 @@ usage: h5mkgrp [OPTIONS] FILE GROUP...\n\
-V, --version Print version number and exit\n");
} /* end usage() */
-
/*-------------------------------------------------------------------------
* Function: parse_command_line
*
@@ -113,18 +104,18 @@ usage: h5mkgrp [OPTIONS] FILE GROUP...\n\
static int
parse_command_line(int argc, const char *argv[], param_t *parms)
{
- int opt; /* Option from command line */
- size_t curr_group; /* Current group name to copy */
+ int opt; /* Option from command line */
+ size_t curr_group; /* Current group name to copy */
/* Check for empty command line */
- if(argc == 1) {
+ if (argc == 1) {
usage();
leave(EXIT_SUCCESS);
} /* end if */
/* Parse command line options */
- while((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) {
- switch((char)opt) {
+ while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) {
+ switch ((char)opt) {
/* Display 'help' */
case 'h':
usage();
@@ -157,10 +148,10 @@ parse_command_line(int argc, const char *argv[], param_t *parms)
usage();
leave(EXIT_FAILURE);
} /* end switch */
- } /* end while */
+ } /* end while */
/* Check for file name to be processed */
- if(argc <= opt_ind) {
+ if (argc <= opt_ind) {
error_msg("missing file name\n");
usage();
leave(EXIT_FAILURE);
@@ -171,7 +162,7 @@ parse_command_line(int argc, const char *argv[], param_t *parms)
opt_ind++;
/* Check for group(s) to be created */
- if(argc <= opt_ind) {
+ if (argc <= opt_ind) {
error_msg("missing group name(s)\n");
usage();
leave(EXIT_FAILURE);
@@ -179,29 +170,28 @@ parse_command_line(int argc, const char *argv[], param_t *parms)
/* Allocate space for the group name pointers */
parms->ngroups = (size_t)(argc - opt_ind);
- parms->groups = (char **)HDmalloc(parms->ngroups * sizeof(char *));
+ parms->groups = (char **)HDmalloc(parms->ngroups * sizeof(char *));
/* Retrieve the group names */
curr_group = 0;
- while(opt_ind < argc) {
+ while (opt_ind < argc) {
parms->groups[curr_group] = HDstrdup(argv[opt_ind]);
curr_group++;
opt_ind++;
} /* end while */
#ifdef QAK
-HDfprintf(stderr, "parms->parents = %t\n", parms->parents);
-HDfprintf(stderr, "parms->verbose = %t\n", parms->verbose);
-HDfprintf(stderr, "parms->fname = '%s'\n", parms->fname);
-HDfprintf(stderr, "parms->ngroups = %Zu\n", parms->ngroups);
-for(curr_group = 0; curr_group < parms->ngroups; curr_group++)
- HDfprintf(stderr, "parms->group[%Zu] = '%s'\n", curr_group, parms->groups[curr_group]);
+ HDfprintf(stderr, "parms->parents = %t\n", parms->parents);
+ HDfprintf(stderr, "parms->verbose = %t\n", parms->verbose);
+ HDfprintf(stderr, "parms->fname = '%s'\n", parms->fname);
+ HDfprintf(stderr, "parms->ngroups = %Zu\n", parms->ngroups);
+ for (curr_group = 0; curr_group < parms->ngroups; curr_group++)
+ HDfprintf(stderr, "parms->group[%Zu] = '%s'\n", curr_group, parms->groups[curr_group]);
#endif /* QAK */
- return(0);
+ return (0);
} /* parse_command_line() */
-
/*-------------------------------------------------------------------------
* Function: main
*
@@ -214,10 +204,10 @@ for(curr_group = 0; curr_group < parms->ngroups; curr_group++)
int
main(int argc, const char *argv[])
{
- hid_t fid; /* HDF5 file ID */
- hid_t fapl_id; /* File access property list ID */
- hid_t lcpl_id; /* Link creation property list ID */
- size_t curr_group; /* Current group to create */
+ hid_t fid; /* HDF5 file ID */
+ hid_t fapl_id; /* File access property list ID */
+ hid_t lcpl_id; /* Link creation property list ID */
+ size_t curr_group; /* Current group to create */
h5tools_setprogname(PROGRAMNAME);
h5tools_setstatus(EXIT_SUCCESS);
@@ -230,27 +220,27 @@ main(int argc, const char *argv[])
/* Parse command line */
HDmemset(&params, 0, sizeof(params));
- if(parse_command_line(argc, argv, &params) < 0) {
+ if (parse_command_line(argc, argv, &params) < 0) {
error_msg("unable to parse command line arguments\n");
leave(EXIT_FAILURE);
} /* end if */
/* Create file access property list */
- if((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) {
+ if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) {
error_msg("Could not create file access property list\n");
leave(EXIT_FAILURE);
} /* end if */
/* Check for creating groups with new format version */
- if(params.latest) {
+ if (params.latest) {
/* Set the "use the latest version of the format" bounds */
- if(H5Pset_libver_bounds(fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) {
+ if (H5Pset_libver_bounds(fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) {
error_msg("Could not set property for using latest version of the format\n");
leave(EXIT_FAILURE);
} /* end if */
/* Display some output if requested */
- if(params.verbose)
+ if (params.verbose)
HDprintf("%s: Creating groups with latest version of the format\n", h5tools_getprogname());
} /* end if */
@@ -259,73 +249,72 @@ main(int argc, const char *argv[])
/* If we couldn't open an existing file, try creating file */
/* (use "EXCL" instead of "TRUNC", so we don't blow away existing non-HDF5 file) */
- if(fid < 0)
+ if (fid < 0)
fid = H5Fcreate(params.fname, H5F_ACC_EXCL, H5P_DEFAULT, fapl_id);
/* Test for error in opening file */
- if(fid < 0) {
+ if (fid < 0) {
error_msg("Could not open output file '%s'\n", params.fname);
leave(EXIT_FAILURE);
} /* end if */
/* Create link creation property list */
- if((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) {
+ if ((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) {
error_msg("Could not create link creation property list\n");
leave(EXIT_FAILURE);
} /* end if */
/* Check for creating intermediate groups */
- if(params.parents) {
+ if (params.parents) {
/* Set the intermediate group creation property */
- if(H5Pset_create_intermediate_group(lcpl_id, TRUE) < 0) {
+ if (H5Pset_create_intermediate_group(lcpl_id, TRUE) < 0) {
error_msg("Could not set property for creating parent groups\n");
leave(EXIT_FAILURE);
} /* end if */
/* Display some output if requested */
- if(params.verbose)
+ if (params.verbose)
HDprintf("%s: Creating parent groups\n", h5tools_getprogname());
} /* end if */
/* Loop over creating requested groups */
- for(curr_group = 0; curr_group < params.ngroups; curr_group++) {
- hid_t gid; /* Group ID */
+ for (curr_group = 0; curr_group < params.ngroups; curr_group++) {
+ hid_t gid; /* Group ID */
/* Attempt to create a group */
- if((gid = H5Gcreate2(fid, params.groups[curr_group], lcpl_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
+ if ((gid = H5Gcreate2(fid, params.groups[curr_group], lcpl_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
error_msg("Could not create group '%s'\n", params.groups[curr_group]);
leave(EXIT_FAILURE);
} /* end if */
/* Close the group */
- if(H5Gclose(gid) < 0) {
+ if (H5Gclose(gid) < 0) {
error_msg("Could not close group '%s'??\n", params.groups[curr_group]);
leave(EXIT_FAILURE);
} /* end if */
/* Display some output if requested */
- if(params.verbose)
+ if (params.verbose)
HDprintf("%s: created group '%s'\n", h5tools_getprogname(), params.groups[curr_group]);
} /* end for */
/* Close link creation property list */
- if(H5Pclose(lcpl_id) < 0) {
+ if (H5Pclose(lcpl_id) < 0) {
error_msg("Could not close link creation property list\n");
leave(EXIT_FAILURE);
} /* end if */
/* Close file */
- if(H5Fclose(fid) < 0) {
+ if (H5Fclose(fid) < 0) {
error_msg("Could not close output file '%s'??\n", params.fname);
leave(EXIT_FAILURE);
} /* end if */
/* Close file access property list */
- if(H5Pclose(fapl_id) < 0) {
+ if (H5Pclose(fapl_id) < 0) {
error_msg("Could not close file access property list\n");
leave(EXIT_FAILURE);
} /* end if */
leave(EXIT_SUCCESS);
} /* end main() */
-
diff --git a/tools/misc/h5repart.c b/tools/misc/h5repart.c
index 461f631..e079df9 100644
--- a/tools/misc/h5repart.c
+++ b/tools/misc/h5repart.c
@@ -27,28 +27,27 @@
#include "H5private.h"
#ifndef FALSE
-# define FALSE 0
+#define FALSE 0
#endif
#ifndef TRUE
-# define TRUE 1
+#define TRUE 1
#endif
-# define NAMELEN 4096
-#define GB *1024*1024*1024
+#define NAMELEN 4096
+#define GB *1024 * 1024 * 1024
#ifndef MIN
-# define MIN(X,Y) ((X)<(Y)?(X):(Y))
+#define MIN(X, Y) ((X) < (Y) ? (X) : (Y))
#endif
#ifndef MIN3
-# define MIN3(X,Y,Z) MIN(MIN(X,Y),Z)
+#define MIN3(X, Y, Z) MIN(MIN(X, Y), Z)
#endif
/*Make these 2 private properties(defined in H5Fprivate.h) available to h5repart.
*The first one updates the member file size in the superblock. The second one
*change file driver from family to sec2. */
-#define H5F_ACS_FAMILY_NEWSIZE_NAME "family_newsize"
-#define H5F_ACS_FAMILY_TO_SEC2_NAME "family_to_sec2"
+#define H5F_ACS_FAMILY_NEWSIZE_NAME "family_newsize"
+#define H5F_ACS_FAMILY_TO_SEC2_NAME "family_to_sec2"
-
/*-------------------------------------------------------------------------
* Function: usage
*
@@ -64,10 +63,9 @@
*-------------------------------------------------------------------------
*/
static void
-usage (const char *progname)
+usage(const char *progname)
{
- HDfprintf(stderr, "usage: %s [-v] [-V] [-[b|m] N[g|m|k]] [-family_to_sec2] SRC DST\n",
- progname);
+ HDfprintf(stderr, "usage: %s [-v] [-V] [-[b|m] N[g|m|k]] [-family_to_sec2] SRC DST\n", progname);
HDfprintf(stderr, " -v Produce verbose output\n");
HDfprintf(stderr, " -V Print a version number and exit\n");
HDfprintf(stderr, " -b N The I/O block size, defaults to 1kB\n");
@@ -76,13 +74,12 @@ usage (const char *progname)
HDfprintf(stderr, " SRC The name of the source file\n");
HDfprintf(stderr, " DST The name of the destination files\n");
HDfprintf(stderr, "Sizes may be suffixed with `g' for GB, `m' for MB or "
- "`k' for kB.\n");
+ "`k' for kB.\n");
HDfprintf(stderr, "File family names include an integer printf "
- "format such as `%%d'\n");
- HDexit (EXIT_FAILURE);
+ "format such as `%%d'\n");
+ HDexit(EXIT_FAILURE);
}
-
/*-------------------------------------------------------------------------
* Function: get_size
*
@@ -106,48 +103,47 @@ usage (const char *progname)
*-------------------------------------------------------------------------
*/
static off_t
-get_size (const char *progname, int *argno, int argc, char *argv[])
+get_size(const char *progname, int *argno, int argc, char *argv[])
{
- off_t retval=-1;
- char *suffix;
+ off_t retval = -1;
+ char *suffix;
- if (isdigit ((int)(argv[*argno][2]))) {
- retval = HDstrtol(argv[*argno]+2, &suffix, 10);
+ if (isdigit((int)(argv[*argno][2]))) {
+ retval = HDstrtol(argv[*argno] + 2, &suffix, 10);
(*argno)++;
}
- else if (argv[*argno][2] || *argno+1>=argc) {
- usage (progname);
+ else if (argv[*argno][2] || *argno + 1 >= argc) {
+ usage(progname);
}
else {
- retval = HDstrtol(argv[*argno+1], &suffix, 0);
- if (suffix == argv[*argno+1])
- usage (progname);
+ retval = HDstrtol(argv[*argno + 1], &suffix, 0);
+ if (suffix == argv[*argno + 1])
+ usage(progname);
*argno += 2;
}
if (suffix && suffix[0] && !suffix[1]) {
switch (*suffix) {
- case 'G':
- case 'g':
- retval *= 1024 * 1024 * 1024;
- break;
- case 'M':
- case 'm':
- retval *= 1024 * 1024;
- break;
- case 'k':
- retval *= 1024;
- break;
- default:
- usage(progname);
+ case 'G':
+ case 'g':
+ retval *= 1024 * 1024 * 1024;
+ break;
+ case 'M':
+ case 'm':
+ retval *= 1024 * 1024;
+ break;
+ case 'k':
+ retval *= 1024;
+ break;
+ default:
+ usage(progname);
}
}
else if (suffix && suffix[0]) {
- usage (progname);
+ usage(progname);
}
return retval;
}
-
/*-------------------------------------------------------------------------
* Function: main
*
@@ -165,47 +161,47 @@ get_size (const char *progname, int *argno, int argc, char *argv[])
*-------------------------------------------------------------------------
*/
int
-main (int argc, char *argv[])
+main(int argc, char *argv[])
{
- const char *prog_name; /*program name */
- size_t blk_size=1024; /*size of each I/O block */
- char *buf=NULL; /*I/O block buffer */
- size_t n, i; /*counters */
- ssize_t nio; /*I/O return value */
- int argno=1; /*program argument number */
- int src, dst=-1; /*source & destination files */
- int need_seek=FALSE; /*destination needs to seek? */
- int need_write; /*data needs to be written? */
- h5_stat_t sb; /*temporary file stat buffer */
-
- int verbose=FALSE; /*display file names? */
-
- const char *src_gen_name; /*general source name */
- char *src_name=NULL; /*source member name */
-
- int src_is_family; /*is source name a family name? */
- int src_membno=0; /*source member number */
-
- const char *dst_gen_name; /*general destination name */
- char *dst_name=NULL; /*destination member name */
- int dst_is_family; /*is dst name a family name? */
- int dst_membno=0; /*destination member number */
-
- off_t left_overs=0; /*amount of zeros left over */
- off_t src_offset=0; /*offset in source member */
- off_t dst_offset=0; /*offset in destination member */
- off_t src_size; /*source logical member size */
- off_t src_act_size; /*source actual member size */
- off_t dst_size=1 GB; /*destination logical memb size */
- hid_t fapl; /*file access property list */
- hid_t file;
- hsize_t hdsize; /*destination logical memb size */
- hbool_t family_to_sec2=FALSE; /*change family to sec2 driver? */
+ const char *prog_name; /*program name */
+ size_t blk_size = 1024; /*size of each I/O block */
+ char * buf = NULL; /*I/O block buffer */
+ size_t n, i; /*counters */
+ ssize_t nio; /*I/O return value */
+ int argno = 1; /*program argument number */
+ int src, dst = -1; /*source & destination files */
+ int need_seek = FALSE; /*destination needs to seek? */
+ int need_write; /*data needs to be written? */
+ h5_stat_t sb; /*temporary file stat buffer */
+
+ int verbose = FALSE; /*display file names? */
+
+ const char *src_gen_name; /*general source name */
+ char * src_name = NULL; /*source member name */
+
+ int src_is_family; /*is source name a family name? */
+ int src_membno = 0; /*source member number */
+
+ const char *dst_gen_name; /*general destination name */
+ char * dst_name = NULL; /*destination member name */
+ int dst_is_family; /*is dst name a family name? */
+ int dst_membno = 0; /*destination member number */
+
+ off_t left_overs = 0; /*amount of zeros left over */
+ off_t src_offset = 0; /*offset in source member */
+ off_t dst_offset = 0; /*offset in destination member */
+ off_t src_size; /*source logical member size */
+ off_t src_act_size; /*source actual member size */
+ off_t dst_size = 1 GB; /*destination logical memb size */
+ hid_t fapl; /*file access property list */
+ hid_t file;
+ hsize_t hdsize; /*destination logical memb size */
+ hbool_t family_to_sec2 = FALSE; /*change family to sec2 driver? */
/*
* Get the program name from argv[0]. Use only the last component.
*/
- if ((prog_name = HDstrrchr (argv[0], '/')))
+ if ((prog_name = HDstrrchr(argv[0], '/')))
prog_name++;
else
prog_name = argv[0];
@@ -217,25 +213,31 @@ main (int argc, char *argv[])
if (!HDstrcmp(argv[argno], "-v")) {
verbose = TRUE;
argno++;
- } else if (!HDstrcmp(argv[argno], "-V")) {
- HDprintf("This is %s version %u.%u release %u\n", prog_name, H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE);
+ }
+ else if (!HDstrcmp(argv[argno], "-V")) {
+ HDprintf("This is %s version %u.%u release %u\n", prog_name, H5_VERS_MAJOR, H5_VERS_MINOR,
+ H5_VERS_RELEASE);
HDexit(EXIT_SUCCESS);
- } else if (!HDstrcmp(argv[argno], "-family_to_sec2")) {
+ }
+ else if (!HDstrcmp(argv[argno], "-family_to_sec2")) {
family_to_sec2 = TRUE;
argno++;
- } else if ('b' == argv[argno][1]) {
- blk_size = (size_t) get_size(prog_name, &argno, argc, argv);
- } else if ('m' == argv[argno][1]) {
+ }
+ else if ('b' == argv[argno][1]) {
+ blk_size = (size_t)get_size(prog_name, &argno, argc, argv);
+ }
+ else if ('m' == argv[argno][1]) {
dst_size = get_size(prog_name, &argno, argc, argv);
- } else {
+ }
+ else {
usage(prog_name);
} /* end if */
- } /* end while */
+ } /* end while */
/* allocate names */
- if(NULL == (src_name = (char *)HDcalloc((size_t)NAMELEN, sizeof(char))))
+ if (NULL == (src_name = (char *)HDcalloc((size_t)NAMELEN, sizeof(char))))
HDexit(EXIT_FAILURE);
- if(NULL == (dst_name = (char *)HDcalloc((size_t)NAMELEN, sizeof(char))))
+ if (NULL == (dst_name = (char *)HDcalloc((size_t)NAMELEN, sizeof(char))))
HDexit(EXIT_FAILURE);
/*
@@ -246,7 +248,7 @@ main (int argc, char *argv[])
usage(prog_name);
src_gen_name = argv[argno++];
HDsprintf(src_name, src_gen_name, src_membno);
- src_is_family = strcmp (src_name, src_gen_name);
+ src_is_family = strcmp(src_name, src_gen_name);
if ((src = HDopen(src_name, O_RDONLY, 0)) < 0) {
HDperror(src_name);
@@ -264,13 +266,13 @@ main (int argc, char *argv[])
/*
* Get the name for the destination file and open the first member.
*/
- if (argno>=argc)
- usage (prog_name);
+ if (argno >= argc)
+ usage(prog_name);
dst_gen_name = argv[argno++];
HDsprintf(dst_name, dst_gen_name, dst_membno);
dst_is_family = HDstrcmp(dst_name, dst_gen_name);
- if ((dst = HDopen(dst_name, O_RDWR|O_CREAT|O_TRUNC, 0666)) < 0) {
+ if ((dst = HDopen(dst_name, O_RDWR | O_CREAT | O_TRUNC, 0666)) < 0) {
HDperror(dst_name);
HDexit(EXIT_FAILURE);
}
@@ -279,32 +281,32 @@ main (int argc, char *argv[])
/* No more arguments */
if (argno < argc)
- usage (prog_name);
+ usage(prog_name);
/* Now the real work, split the file */
buf = (char *)HDmalloc(blk_size);
- while (src_offset<src_size) {
+ while (src_offset < src_size) {
- /* Read a block. The amount to read is the minimum of:
- * 1. The I/O block size
- * 2. What's left to write in the destination member
- * 3. Left over zeros or what's left in the source member.
- */
+ /* Read a block. The amount to read is the minimum of:
+ * 1. The I/O block size
+ * 2. What's left to write in the destination member
+ * 3. Left over zeros or what's left in the source member.
+ */
n = blk_size;
if (dst_is_family)
- n = (size_t)MIN((off_t)n, dst_size-dst_offset);
+ n = (size_t)MIN((off_t)n, dst_size - dst_offset);
if (left_overs) {
- n = (size_t)MIN((off_t)n, left_overs);
- left_overs = left_overs - (off_t) n;
+ n = (size_t)MIN((off_t)n, left_overs);
+ left_overs = left_overs - (off_t)n;
need_write = FALSE;
}
else if (src_offset < src_act_size) {
- n = (size_t)MIN((off_t)n, src_act_size-src_offset);
+ n = (size_t)MIN((off_t)n, src_act_size - src_offset);
if ((nio = HDread(src, buf, n)) < 0) {
HDperror("read");
HDexit(EXIT_FAILURE);
}
- else if ((size_t) nio != n) {
+ else if ((size_t)nio != n) {
HDfprintf(stderr, "%s: short read\n", src_name);
HDexit(EXIT_FAILURE);
}
@@ -315,18 +317,18 @@ main (int argc, char *argv[])
need_write = (i < n);
}
else {
- n = 0;
+ n = 0;
left_overs = src_size - src_act_size;
need_write = FALSE;
}
- /*
- * If the block contains non-zero data then write it to the
- * destination, otherwise just remember that we'll have to do a seek
- * later in the destination when we finally get non-zero data.
- */
+ /*
+ * If the block contains non-zero data then write it to the
+ * destination, otherwise just remember that we'll have to do a seek
+ * later in the destination when we finally get non-zero data.
+ */
if (need_write) {
- if (need_seek && HDlseek (dst, dst_offset, SEEK_SET) < 0) {
+ if (need_seek && HDlseek(dst, dst_offset, SEEK_SET) < 0) {
HDperror("HDlseek");
HDexit(EXIT_FAILURE);
}
@@ -334,7 +336,7 @@ main (int argc, char *argv[])
HDperror("write");
HDexit(EXIT_FAILURE);
}
- else if ((size_t) nio != n) {
+ else if ((size_t)nio != n) {
HDfprintf(stderr, "%s: short write\n", dst_name);
HDexit(EXIT_FAILURE);
}
@@ -344,64 +346,64 @@ main (int argc, char *argv[])
need_seek = TRUE;
}
- /*
- * Update the source offset and open the next source family member if
- * necessary. The source stream ends at the first member which
- * cannot be opened because it doesn't exist. At the end of the
- * source stream, update the destination offset and break out of the
- * loop. The destination offset must be updated so we can fix
- * trailing holes.
- */
- src_offset = src_offset + (off_t) n;
+ /*
+ * Update the source offset and open the next source family member if
+ * necessary. The source stream ends at the first member which
+ * cannot be opened because it doesn't exist. At the end of the
+ * source stream, update the destination offset and break out of the
+ * loop. The destination offset must be updated so we can fix
+ * trailing holes.
+ */
+ src_offset = src_offset + (off_t)n;
if (src_offset == src_act_size) {
HDclose(src);
if (!src_is_family) {
- dst_offset = dst_offset + (off_t) n;
+ dst_offset = dst_offset + (off_t)n;
break;
}
HDsprintf(src_name, src_gen_name, ++src_membno);
if ((src = HDopen(src_name, O_RDONLY)) < 0 && ENOENT == errno) {
- dst_offset = dst_offset + (off_t) n;
+ dst_offset = dst_offset + (off_t)n;
break;
}
else if (src < 0) {
HDperror(src_name);
HDexit(EXIT_FAILURE);
}
- if (HDfstat (src, &sb) < 0) {
+ if (HDfstat(src, &sb) < 0) {
HDperror("fstat");
HDexit(EXIT_FAILURE);
}
src_act_size = sb.st_size;
if (src_act_size > src_size) {
- HDfprintf(stderr, "%s: member truncated to %lu bytes\n", src_name, (unsigned long) src_size);
+ HDfprintf(stderr, "%s: member truncated to %lu bytes\n", src_name, (unsigned long)src_size);
}
src_offset = 0;
if (verbose)
HDfprintf(stderr, "< %s\n", src_name);
}
- /*
- * Update the destination offset, opening a new member if one will be
- * needed. The first member is extended to the logical member size
- * but other members might be smaller if they end with a hole.
- */
- dst_offset = dst_offset + (off_t) n;
+ /*
+ * Update the destination offset, opening a new member if one will be
+ * needed. The first member is extended to the logical member size
+ * but other members might be smaller if they end with a hole.
+ */
+ dst_offset = dst_offset + (off_t)n;
if (dst_is_family && dst_offset == dst_size) {
if (0 == dst_membno) {
- if (HDlseek (dst, dst_size-1, SEEK_SET) < 0) {
+ if (HDlseek(dst, dst_size - 1, SEEK_SET) < 0) {
HDperror("HDHDlseek");
HDexit(EXIT_FAILURE);
}
- if (HDread (dst, buf, 1) < 0) {
+ if (HDread(dst, buf, 1) < 0) {
HDperror("read");
HDexit(EXIT_FAILURE);
}
- if (HDlseek (dst, dst_size-1, SEEK_SET) < 0) {
+ if (HDlseek(dst, dst_size - 1, SEEK_SET) < 0) {
HDperror("HDlseek");
HDexit(EXIT_FAILURE);
}
- if (HDwrite (dst, buf, 1) < 0) {
+ if (HDwrite(dst, buf, 1) < 0) {
HDperror("write");
HDexit(EXIT_FAILURE);
}
@@ -413,7 +415,7 @@ main (int argc, char *argv[])
HDexit(EXIT_FAILURE);
}
dst_offset = 0;
- need_seek = FALSE;
+ need_seek = FALSE;
if (verbose)
HDfprintf(stderr, "> %s\n", dst_name);
}
@@ -425,55 +427,55 @@ main (int argc, char *argv[])
* family has been truncated.
*/
if (need_seek) {
- if (HDlseek (dst, dst_offset-1, SEEK_SET)<0) {
- HDperror ("HDlseek");
- HDexit (EXIT_FAILURE);
+ if (HDlseek(dst, dst_offset - 1, SEEK_SET) < 0) {
+ HDperror("HDlseek");
+ HDexit(EXIT_FAILURE);
}
- if (HDread (dst, buf, 1)<0) {
- HDperror ("read");
- HDexit (EXIT_FAILURE);
+ if (HDread(dst, buf, 1) < 0) {
+ HDperror("read");
+ HDexit(EXIT_FAILURE);
}
- if (HDlseek (dst, dst_offset-1, SEEK_SET)<0) {
- HDperror ("HDlseek");
- HDexit (EXIT_FAILURE);
+ if (HDlseek(dst, dst_offset - 1, SEEK_SET) < 0) {
+ HDperror("HDlseek");
+ HDexit(EXIT_FAILURE);
}
- if (HDwrite (dst, buf, 1)<0) {
- HDperror ("write");
- HDexit (EXIT_FAILURE);
+ if (HDwrite(dst, buf, 1) < 0) {
+ HDperror("write");
+ HDexit(EXIT_FAILURE);
}
}
- HDclose (dst);
+ HDclose(dst);
/* Modify family driver information saved in superblock through private property.
* These private properties are for this tool only. */
- if ((fapl=H5Pcreate(H5P_FILE_ACCESS)) < 0) {
- HDperror ("H5Pcreate");
- HDexit (EXIT_FAILURE);
+ if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) {
+ HDperror("H5Pcreate");
+ HDexit(EXIT_FAILURE);
}
- if(family_to_sec2) {
+ if (family_to_sec2) {
/* The user wants to change file driver from family to sec2. Open the file
* with sec2 driver. This property signals the library to ignore the family
* driver information saved in the superblock. */
- if(H5Pset(fapl, H5F_ACS_FAMILY_TO_SEC2_NAME, &family_to_sec2) < 0) {
- HDperror ("H5Pset");
- HDexit (EXIT_FAILURE);
+ if (H5Pset(fapl, H5F_ACS_FAMILY_TO_SEC2_NAME, &family_to_sec2) < 0) {
+ HDperror("H5Pset");
+ HDexit(EXIT_FAILURE);
}
}
else {
/* Modify family size saved in superblock through private property. It signals
* library to save the new member size(specified in command line) in superblock.
* This private property is for this tool only. */
- if(H5Pset_fapl_family(fapl, H5F_FAMILY_DEFAULT, H5P_DEFAULT) < 0) {
- HDperror ("H5Pset_fapl_family");
- HDexit (EXIT_FAILURE);
+ if (H5Pset_fapl_family(fapl, H5F_FAMILY_DEFAULT, H5P_DEFAULT) < 0) {
+ HDperror("H5Pset_fapl_family");
+ HDexit(EXIT_FAILURE);
}
/* Set the property of the new member size as hsize_t */
hdsize = (hsize_t)dst_size;
- if(H5Pset(fapl, H5F_ACS_FAMILY_NEWSIZE_NAME, &hdsize) < 0) {
- HDperror ("H5Pset");
- HDexit (EXIT_FAILURE);
+ if (H5Pset(fapl, H5F_ACS_FAMILY_NEWSIZE_NAME, &hdsize) < 0) {
+ HDperror("H5Pset");
+ HDexit(EXIT_FAILURE);
}
}
@@ -484,18 +486,17 @@ main (int argc, char *argv[])
* driver when the new file is opened. If the original file is a sec2 file and the
* new file can only be a sec2 file, reopen the new file should fail. There's
* nothing to do in this case. */
- H5E_BEGIN_TRY {
- file = H5Fopen(dst_gen_name, H5F_ACC_RDWR, fapl);
- } H5E_END_TRY;
+ H5E_BEGIN_TRY { file = H5Fopen(dst_gen_name, H5F_ACC_RDWR, fapl); }
+ H5E_END_TRY;
- if(file >= 0) {
- if(H5Fclose(file) < 0) {
+ if (file >= 0) {
+ if (H5Fclose(file) < 0) {
HDperror("H5Fclose");
HDexit(EXIT_FAILURE);
} /* end if */
- } /* end if */
+ } /* end if */
- if(H5Pclose(fapl) < 0) {
+ if (H5Pclose(fapl) < 0) {
HDperror("H5Pclose");
HDexit(EXIT_FAILURE);
} /* end if */
diff --git a/tools/misc/h5repart_gentest.c b/tools/misc/h5repart_gentest.c
index 5c1ff87..c534ca6 100644
--- a/tools/misc/h5repart_gentest.c
+++ b/tools/misc/h5repart_gentest.c
@@ -21,79 +21,78 @@
#include "hdf5.h"
#include "H5private.h"
-#define FAMILY_NUMBER 4
-#define FAMILY_SIZE 1024
-#define FILENAME "family_file%05d.h5"
+#define FAMILY_NUMBER 4
+#define FAMILY_SIZE 1024
+#define FILENAME "family_file%05d.h5"
static int buf[FAMILY_NUMBER][FAMILY_SIZE];
-int main(void)
+int
+main(void)
{
- hid_t file=(-1), fapl, space=(-1), dset=(-1);
- char dname[]="dataset";
- int i, j;
- hsize_t dims[2]={FAMILY_NUMBER, FAMILY_SIZE};
+ hid_t file = (-1), fapl, space = (-1), dset = (-1);
+ char dname[] = "dataset";
+ int i, j;
+ hsize_t dims[2] = {FAMILY_NUMBER, FAMILY_SIZE};
/* Set property list and file name for FAMILY driver */
- if ((fapl=H5Pcreate(H5P_FILE_ACCESS)) < 0) {
- perror ("H5Pcreate");
- exit (EXIT_FAILURE);
+ if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) {
+ perror("H5Pcreate");
+ exit(EXIT_FAILURE);
}
- if(H5Pset_fapl_family(fapl, (hsize_t)FAMILY_SIZE, H5P_DEFAULT) < 0) {
- perror ("H5Pset_fapl_family");
- exit (EXIT_FAILURE);
+ if (H5Pset_fapl_family(fapl, (hsize_t)FAMILY_SIZE, H5P_DEFAULT) < 0) {
+ perror("H5Pset_fapl_family");
+ exit(EXIT_FAILURE);
}
- if((file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) {
+ if ((file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) {
perror("H5Fcreate");
exit(EXIT_FAILURE);
}
/* Create and write dataset */
- if((space = H5Screate_simple(2, dims, NULL)) < 0) {
+ if ((space = H5Screate_simple(2, dims, NULL)) < 0) {
perror("H5Screate_simple");
exit(EXIT_FAILURE);
}
-
- if((dset = H5Dcreate2(file, dname, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
+ if ((dset = H5Dcreate2(file, dname, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
perror("H5Dcreate2");
exit(EXIT_FAILURE);
}
-
- for(i = 0; i<FAMILY_NUMBER; i++)
- for(j = 0; j<FAMILY_SIZE; j++)
+ for (i = 0; i < FAMILY_NUMBER; i++)
+ for (j = 0; j < FAMILY_SIZE; j++)
buf[i][j] = i * 10000 + j;
- if(H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) {
+ if (H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) {
perror("H5Dwrite");
exit(EXIT_FAILURE);
}
-
- if(H5Sclose(space) < 0) {
- perror ("H5Sclose");
- exit (EXIT_FAILURE);
+ if (H5Sclose(space) < 0) {
+ perror("H5Sclose");
+ exit(EXIT_FAILURE);
}
- if(H5Dclose(dset) < 0) {
- perror ("H5Dclose");
- exit (EXIT_FAILURE);
+ if (H5Dclose(dset) < 0) {
+ perror("H5Dclose");
+ exit(EXIT_FAILURE);
}
- if(H5Pclose(fapl) < 0) {
- perror ("H5Pclose");
- exit (EXIT_FAILURE);
+ if (H5Pclose(fapl) < 0) {
+ perror("H5Pclose");
+ exit(EXIT_FAILURE);
}
- if(H5Fclose(file) < 0) {
- perror ("H5Fclose");
- exit (EXIT_FAILURE);
+ if (H5Fclose(file) < 0) {
+ perror("H5Fclose");
+ exit(EXIT_FAILURE);
}
- puts(" PASSED"); fflush(stdout);
+ puts(" PASSED");
+ fflush(stdout);
return 0;
}
diff --git a/tools/misc/repart_test.c b/tools/misc/repart_test.c
index 0b54333..a17da83 100644
--- a/tools/misc/repart_test.c
+++ b/tools/misc/repart_test.c
@@ -19,22 +19,16 @@
#include "hdf5.h"
#include "H5private.h"
-#define KB 1024
-#define FAMILY_H5REPART_SIZE1 20000
-#define FAMILY_H5REPART_SIZE2 (5*KB)
-#define MAX(a,b) (a>b ? a:b)
-
-const char *FILENAME[] = {
- "fst_family%05d.h5",
- "scd_family%05d.h5",
- "family_to_sec2.h5",
- NULL
-};
+#define KB 1024
+#define FAMILY_H5REPART_SIZE1 20000
+#define FAMILY_H5REPART_SIZE2 (5 * KB)
+#define MAX(a, b) (a > b ? a : b)
+
+const char *FILENAME[] = {"fst_family%05d.h5", "scd_family%05d.h5", "family_to_sec2.h5", NULL};
herr_t test_family_h5repart_opens(void);
herr_t test_sec2_h5repart_opens(void);
-
/*-------------------------------------------------------------------------
* Function: test_family_h5repart_opens
*
@@ -47,8 +41,8 @@ herr_t test_sec2_h5repart_opens(void);
herr_t
test_family_h5repart_opens(void)
{
- hid_t fid = H5I_INVALID_HID;
- hid_t fapl_id = H5I_INVALID_HID;
+ hid_t fid = H5I_INVALID_HID;
+ hid_t fapl_id = H5I_INVALID_HID;
/* open 1st file(single member file) with correct family size(20000 byte) */
if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0)
@@ -57,7 +51,7 @@ test_family_h5repart_opens(void)
if (H5Pset_fapl_family(fapl_id, (hsize_t)FAMILY_H5REPART_SIZE1, H5P_DEFAULT) < 0)
goto error;
- if ((fid = H5Fopen(FILENAME[0], H5F_ACC_RDWR, fapl_id))<0)
+ if ((fid = H5Fopen(FILENAME[0], H5F_ACC_RDWR, fapl_id)) < 0)
goto error;
if (H5Fclose(fid) < 0)
@@ -79,17 +73,17 @@ test_family_h5repart_opens(void)
return SUCCEED;
error:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Pclose(fapl_id);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return FAIL;
} /* end test_family_h5repart_opens() */
-
-
/*-------------------------------------------------------------------------
* Function: test_sec2_h5repart_opens
*
@@ -102,7 +96,7 @@ error:
herr_t
test_sec2_h5repart_opens(void)
{
- hid_t fid = H5I_INVALID_HID;
+ hid_t fid = H5I_INVALID_HID;
/* open the sec2 file */
if ((fid = H5Fopen(FILENAME[2], H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
@@ -114,15 +108,13 @@ test_sec2_h5repart_opens(void)
return SUCCEED;
error:
- H5E_BEGIN_TRY {
- H5Fclose(fid);
- } H5E_END_TRY;
+ H5E_BEGIN_TRY { H5Fclose(fid); }
+ H5E_END_TRY;
return FAIL;
} /* end test_sec2_h5repart_opens() */
-
/*-------------------------------------------------------------------------
* Function: main
*
@@ -135,10 +127,10 @@ error:
int
main(void)
{
- int nerrors = 0;
+ int nerrors = 0;
- nerrors += test_family_h5repart_opens() < 0 ? 1 : 0;
- nerrors += test_sec2_h5repart_opens() < 0 ? 1 : 0;
+ nerrors += test_family_h5repart_opens() < 0 ? 1 : 0;
+ nerrors += test_sec2_h5repart_opens() < 0 ? 1 : 0;
if (nerrors)
goto error;
@@ -147,8 +139,6 @@ main(void)
error:
nerrors = MAX(1, nerrors);
- HDprintf("***** %d FAMILY FILE TEST%s FAILED! *****\n",
- nerrors, 1 == nerrors ? "" : "S");
+ HDprintf("***** %d FAMILY FILE TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S");
HDexit(EXIT_FAILURE);
} /* end main() */
-
diff --git a/tools/misc/talign.c b/tools/misc/talign.c
index c69d1f7..2cf73ae 100644
--- a/tools/misc/talign.c
+++ b/tools/misc/talign.c
@@ -20,7 +20,7 @@
#include "H5private.h"
#include "h5tools.h"
-const char *fname = "talign.h5";
+const char *fname = "talign.h5";
const char *setname = "align";
/*
@@ -30,26 +30,27 @@ const char *setname = "align";
* another per construction)
*/
-int main(void)
+int
+main(void)
{
- hid_t fil=H5I_INVALID_HID, spc=H5I_INVALID_HID, set=H5I_INVALID_HID;
- hid_t cs6=H5I_INVALID_HID, cmp=H5I_INVALID_HID, fix=H5I_INVALID_HID;
- hid_t cmp1=H5I_INVALID_HID, cmp2=H5I_INVALID_HID, cmp3=H5I_INVALID_HID;
- hid_t plist=H5I_INVALID_HID;
- hid_t array_dt=H5I_INVALID_HID;
+ hid_t fil = H5I_INVALID_HID, spc = H5I_INVALID_HID, set = H5I_INVALID_HID;
+ hid_t cs6 = H5I_INVALID_HID, cmp = H5I_INVALID_HID, fix = H5I_INVALID_HID;
+ hid_t cmp1 = H5I_INVALID_HID, cmp2 = H5I_INVALID_HID, cmp3 = H5I_INVALID_HID;
+ hid_t plist = H5I_INVALID_HID;
+ hid_t array_dt = H5I_INVALID_HID;
hsize_t dim[2];
hsize_t cdim[4];
- char string5[5];
- float fok[2] = {1234.0f, 2341.0f};
- float fnok[2] = {5678.0f, 6785.0f};
- float *fptr = NULL;
+ char string5[5];
+ float fok[2] = {1234.0f, 2341.0f};
+ float fnok[2] = {5678.0f, 6785.0f};
+ float *fptr = NULL;
char *data = NULL;
- int result = 0;
- herr_t error = 1;
+ int result = 0;
+ herr_t error = 1;
HDprintf("%-70s", "Testing alignment in compound datatypes");
@@ -62,9 +63,8 @@ int main(void)
return 1;
}
- H5E_BEGIN_TRY {
- (void)H5Ldelete(fil, setname, H5P_DEFAULT);
- } H5E_END_TRY;
+ H5E_BEGIN_TRY { (void)H5Ldelete(fil, setname, H5P_DEFAULT); }
+ H5E_END_TRY;
cs6 = H5Tcopy(H5T_C_S1);
H5Tset_size(cs6, sizeof(string5));
@@ -73,20 +73,20 @@ int main(void)
cmp = H5Tcreate(H5T_COMPOUND, sizeof(fok) + sizeof(string5) + sizeof(fnok));
H5Tinsert(cmp, "Awkward length", 0, cs6);
- cdim[0] = sizeof(fok) / sizeof(float);
+ cdim[0] = sizeof(fok) / sizeof(float);
array_dt = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, cdim);
H5Tinsert(cmp, "Ok", sizeof(string5), array_dt);
H5Tclose(array_dt);
- cdim[0] = sizeof(fnok) / sizeof(float);
+ cdim[0] = sizeof(fnok) / sizeof(float);
array_dt = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, cdim);
H5Tinsert(cmp, "Not Ok", sizeof(fok) + sizeof(string5), array_dt);
H5Tclose(array_dt);
- fix = H5Tget_native_type(cmp, H5T_DIR_DEFAULT);
+ fix = H5Tget_native_type(cmp, H5T_DIR_DEFAULT);
cmp1 = H5Tcreate(H5T_COMPOUND, sizeof(fok));
- cdim[0] = sizeof(fok) / sizeof(float);
+ cdim[0] = sizeof(fok) / sizeof(float);
array_dt = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, cdim);
H5Tinsert(cmp1, "Ok", 0, array_dt);
H5Tclose(array_dt);
@@ -96,13 +96,13 @@ int main(void)
cmp3 = H5Tcreate(H5T_COMPOUND, sizeof(fnok));
- cdim[0] = sizeof(fnok) / sizeof(float);
+ cdim[0] = sizeof(fnok) / sizeof(float);
array_dt = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, cdim);
H5Tinsert(cmp3, "Not Ok", 0, array_dt);
H5Tclose(array_dt);
plist = H5Pcreate(H5P_DATASET_XFER);
- if((error = H5Pset_preserve(plist, 1)) < 0)
+ if ((error = H5Pset_preserve(plist, 1)) < 0)
goto out;
/*
@@ -110,8 +110,8 @@ int main(void)
* in turn so that we are avoid alignment issues at this point
*/
dim[0] = 1;
- spc = H5Screate_simple(1, dim, NULL);
- set = H5Dcreate2(fil, setname, cmp, spc, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ spc = H5Screate_simple(1, dim, NULL);
+ set = H5Dcreate2(fil, setname, cmp, spc, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
H5Dwrite(set, cmp1, spc, H5S_ALL, plist, fok);
H5Dwrite(set, cmp2, spc, H5S_ALL, plist, string5);
@@ -122,7 +122,7 @@ int main(void)
/* Now open the set, and read it back in */
data = (char *)HDmalloc(H5Tget_size(fix));
- if(!data) {
+ if (!data) {
HDperror("malloc() failed");
HDabort();
}
@@ -134,61 +134,56 @@ int main(void)
H5Dclose(set);
out:
- if(error < 0) {
+ if (error < 0) {
result = 1;
HDputs("*FAILED - HDF5 library error*");
- } else if(!(H5_FLT_ABS_EQUAL(fok[0], fptr[0]))
- || !(H5_FLT_ABS_EQUAL(fok[1], fptr[1]))
- || !(H5_FLT_ABS_EQUAL(fnok[0], fptr[2]))
- || !(H5_FLT_ABS_EQUAL(fnok[1], fptr[3]))) {
+ }
+ else if (!(H5_FLT_ABS_EQUAL(fok[0], fptr[0])) || !(H5_FLT_ABS_EQUAL(fok[1], fptr[1])) ||
+ !(H5_FLT_ABS_EQUAL(fnok[0], fptr[2])) || !(H5_FLT_ABS_EQUAL(fnok[1], fptr[3]))) {
char *mname;
result = 1;
- mname = H5Tget_member_name(fix, 0);
- HDprintf("%14s (%2d) %6s = %s\n",
- mname ? mname : "(null)", (int)H5Tget_member_offset(fix,0),
- string5, (char *)(data + H5Tget_member_offset(fix, 0)));
- if(mname)
+ mname = H5Tget_member_name(fix, 0);
+ HDprintf("%14s (%2d) %6s = %s\n", mname ? mname : "(null)", (int)H5Tget_member_offset(fix, 0),
+ string5, (char *)(data + H5Tget_member_offset(fix, 0)));
+ if (mname)
H5free_memory(mname);
- fptr = (float *)((void *)(data + H5Tget_member_offset(fix, 1)));
+ fptr = (float *)((void *)(data + H5Tget_member_offset(fix, 1)));
mname = H5Tget_member_name(fix, 1);
HDprintf("Data comparison:\n"
- "%14s (%2d) %6f = %f\n"
- " %6f = %f\n",
- mname ? mname : "(null)", (int)H5Tget_member_offset(fix,1),
- (double)fok[0], (double)fptr[0],
- (double)fok[1], (double)fptr[1]);
- if(mname)
+ "%14s (%2d) %6f = %f\n"
+ " %6f = %f\n",
+ mname ? mname : "(null)", (int)H5Tget_member_offset(fix, 1), (double)fok[0], (double)fptr[0],
+ (double)fok[1], (double)fptr[1]);
+ if (mname)
H5free_memory(mname);
- fptr = (float *)((void *)(data + H5Tget_member_offset(fix, 2)));
+ fptr = (float *)((void *)(data + H5Tget_member_offset(fix, 2)));
mname = H5Tget_member_name(fix, 2);
HDprintf("%14s (%2d) %6f = %f\n"
- " %6f = %6f\n",
- mname ? mname : "(null)", (int)H5Tget_member_offset(fix,2),
- (double)fnok[0], (double)fptr[0],
- (double)fnok[1], (double)fptr[1]);
- if(mname)
+ " %6f = %6f\n",
+ mname ? mname : "(null)", (int)H5Tget_member_offset(fix, 2), (double)fnok[0],
+ (double)fptr[0], (double)fnok[1], (double)fptr[1]);
+ if (mname)
H5free_memory(mname);
fptr = (float *)((void *)(data + H5Tget_member_offset(fix, 1)));
HDprintf("\n"
- "Short circuit\n"
- " %6f = %f\n"
- " %6f = %f\n"
- " %6f = %f\n"
- " %6f = %f\n",
- (double)fok[0], (double)fptr[0],
- (double)fok[1], (double)fptr[1],
- (double)fnok[0], (double)fptr[2],
- (double)fnok[1], (double)fptr[3]);
+ "Short circuit\n"
+ " %6f = %f\n"
+ " %6f = %f\n"
+ " %6f = %f\n"
+ " %6f = %f\n",
+ (double)fok[0], (double)fptr[0], (double)fok[1], (double)fptr[1], (double)fnok[0],
+ (double)fptr[2], (double)fnok[1], (double)fptr[3]);
HDputs("*FAILED - compound type alignmnent problem*");
- } else {
+ }
+ else {
HDputs(" PASSED");
}
- if(data)
+ if (data)
HDfree(data);
H5Sclose(spc);
H5Tclose(cs6);
@@ -203,4 +198,3 @@ out:
HDfflush(stdout);
return result;
}
-