summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2012-10-18 19:47:39 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2012-10-18 19:47:39 (GMT)
commite9519f5e6a437650aedf200356d1af7138f68b22 (patch)
tree6e9510fd472ad9567524b7c226cb68e4fd1bbfcb
parent0324f055660fde2ddbdd928b6b674814a9e53210 (diff)
downloadhdf5-e9519f5e6a437650aedf200356d1af7138f68b22.zip
hdf5-e9519f5e6a437650aedf200356d1af7138f68b22.tar.gz
hdf5-e9519f5e6a437650aedf200356d1af7138f68b22.tar.bz2
[svn-r22921] Description:
Review Coverity changes and bring them back to trunk. (QK & JK) r20402: Added #includes for h5tools.y or h5tools_utils.h as required to remedy implicit function declarations which caused compiler warnings and coverity issues 703-4 and 708-11. r20414: This is related to the previous checkin r20399. There were incorrect updates which caused incorrect behavior when no file was given. Also possible segfault when handling hyperslab options. Simplify the code changes. r20449: Description: Modified H5E_walk2_cb to check return value of H5I_object_verify. r20450: fixed coverity 813 Tested on: Mac OSX/64 10.8.2 (amazon) w/C++, FORTRAN, debug & threadsafe (too minor to require h5committest)
-rw-r--r--src/H5Eint.c4
-rw-r--r--tools/h5copy/h5copygentest.c10
-rw-r--r--tools/h5dump/h5dump.c5
-rw-r--r--tools/h5dump/h5dump_xml.c3
-rw-r--r--tools/h5dump/h5dump_xml.h8
-rw-r--r--tools/h5import/h5import.c369
-rw-r--r--tools/h5import/h5import.h35
-rw-r--r--tools/lib/h5tools.h2
-rw-r--r--tools/misc/talign.c23
9 files changed, 196 insertions, 263 deletions
diff --git a/src/H5Eint.c b/src/H5Eint.c
index 76eaaf5..88dfdee 100644
--- a/src/H5Eint.c
+++ b/src/H5Eint.c
@@ -380,6 +380,10 @@ H5E_walk2_cb(unsigned n, const H5E_error2_t *err_desc, void *client_data)
* they might be different. */
cls_ptr = (H5E_cls_t *)H5I_object_verify(err_desc->cls_id, H5I_ERROR_CLASS);
+ /* Check for bad pointer(s), but can't issue error, just leave */
+ if(!cls_ptr)
+ HGOTO_DONE(FAIL)
+
/* Print error class header if new class */
if(eprint->cls.lib_name == NULL || HDstrcmp(cls_ptr->lib_name, eprint->cls.lib_name)) {
/* update to the new class information */
diff --git a/tools/h5copy/h5copygentest.c b/tools/h5copy/h5copygentest.c
index e658e92..e45d24a 100644
--- a/tools/h5copy/h5copygentest.c
+++ b/tools/h5copy/h5copygentest.c
@@ -284,14 +284,14 @@ static void gent_nested_vl(hid_t loc_id)
/* allocate and initialize VL dataset to write */
buf[0].len = 1;
buf[0].p = malloc( 1 * sizeof(hvl_t));
- tvl = buf[0].p;
+ tvl = (hvl_t *)buf[0].p;
tvl->p = malloc( 1 * sizeof(int) );
tvl->len = 1;
((int *)tvl->p)[0]=1;
buf[1].len = 1;
buf[1].p = malloc( 1 * sizeof(hvl_t));
- tvl = buf[1].p;
+ tvl = (hvl_t *)buf[1].p;
tvl->p = malloc( 2 * sizeof(int) );
tvl->len = 2;
((int *)tvl->p)[0]=2;
@@ -642,7 +642,7 @@ out:
* Purpose: Testing with various objects
*
*------------------------------------------------------------------------*/
-static void Test_Obj_Copy()
+static void Test_Obj_Copy(void)
{
hid_t fid=0;
@@ -673,7 +673,7 @@ out:
* Purpose: Testing with various references
*
*------------------------------------------------------------------------*/
-static void Test_Ref_Copy()
+static void Test_Ref_Copy(void)
{
hid_t fid=0;
herr_t status;
@@ -839,7 +839,7 @@ out:
* Purpose: gerenate external link files
*
*------------------------------------------------------------------------*/
-static void Test_Extlink_Copy()
+static void Test_Extlink_Copy(void)
{
hid_t fid1=0;
hid_t fid2=0;
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c
index 85d3bc8..34b8bc4 100644
--- a/tools/h5dump/h5dump.c
+++ b/tools/h5dump/h5dump.c
@@ -997,7 +997,7 @@ parse_command_line(int argc, const char *argv[])
/* this will be plenty big enough to hold the info */
if((hand = (struct handler_t *)HDcalloc((size_t)argc, sizeof(struct handler_t)))==NULL) {
- goto error;
+ goto error;
}
/* parse command line options */
@@ -1054,7 +1054,7 @@ parse_start:
break;
case 'w':
h5tools_nCols = HDatoi(opt_arg);
- if (h5tools_nCols==0) {
+ if (h5tools_nCols <= 0) {
h5tools_nCols = 65535;
}
last_was_dset = FALSE;
@@ -1356,6 +1356,7 @@ error:
return hand;
}
+
/*-------------------------------------------------------------------------
* Function: main
diff --git a/tools/h5dump/h5dump_xml.c b/tools/h5dump/h5dump_xml.c
index 1a29659..28264e7 100644
--- a/tools/h5dump/h5dump_xml.c
+++ b/tools/h5dump/h5dump_xml.c
@@ -3761,7 +3761,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t UNUSED * sset)
/* Print information about storage layout */
if (H5D_CHUNKED == H5Pget_layout(dcpl)) {
maxdims = H5Sget_simple_extent_ndims(space);
- chsize = (hsize_t *) HDmalloc(maxdims * sizeof(hsize_t));
+ HDassert(maxdims >= 0);
+ chsize = (hsize_t *)HDmalloc((size_t)maxdims * sizeof(hsize_t));
ctx.indent_level++;
dump_indent += COL;
diff --git a/tools/h5dump/h5dump_xml.h b/tools/h5dump/h5dump_xml.h
index 28485f8..258fd38 100644
--- a/tools/h5dump/h5dump_xml.h
+++ b/tools/h5dump/h5dump_xml.h
@@ -102,14 +102,6 @@ static h5tool_format_t xml_dataformat = {
extern "C" {
#endif
-/* internal functions used by XML option */
-static void xml_print_datatype(hid_t, unsigned);
-static void xml_print_enum(hid_t);
-static int xml_print_refs(hid_t, int);
-static int xml_print_strs(hid_t, int);
-static char *xml_escape_the_string(const char *, int);
-static char *xml_escape_the_name(const char *);
-
/* The dump functions of the dump_function_table */
/* XML format: same interface, alternative output */
diff --git a/tools/h5import/h5import.c b/tools/h5import/h5import.c
index 34870fb..9497e58 100644
--- a/tools/h5import/h5import.c
+++ b/tools/h5import/h5import.c
@@ -32,6 +32,43 @@
#define READ_OPEN_FLAGS "r"
#endif
+/* Local function declarations */
+static int gtoken(char *s);
+static int process(struct Options *opt);
+static int processConfigurationFile(char *infile, struct Input *in);
+static int mapKeywordToIndex(char *key);
+static int parsePathInfo(struct path_info *path, char *strm);
+static int parseDimensions(struct Input *in, char *strm);
+static int getInputSize(struct Input *in, int ival);
+static int getInputClass(struct Input *in, char * strm);
+static int getInputClassType(struct Input *in, char * strm);
+static int InputClassStrToInt(char *temp);
+static int getRank(struct Input *in, FILE *strm);
+static int getDimensionSizes(struct Input *in, FILE *strm);
+static int getOutputSize(struct Input *in, FILE *strm);
+static int getOutputClass(struct Input *in, FILE *strm);
+static int OutputClassStrToInt(char *temp);
+static int getOutputArchitecture(struct Input *in, FILE *strm);
+static int OutputArchStrToInt(const char *temp);
+static int getOutputByteOrder(struct Input *in, FILE *strm);
+static int OutputByteOrderStrToInt(const char *temp);
+static int getChunkedDimensionSizes(struct Input *in, FILE *strm);
+static int getCompressionType(struct Input *in, FILE *strm);
+static int CompressionTypeStrToInt(char *temp);
+static int getCompressionParameter(struct Input *in, FILE *strm);
+static int getExternalFilename(struct Input *in, FILE *strm);
+static int getMaximumDimensionSizes(struct Input *in, FILE *strm);
+static int processDataFile(char *infile, struct Input *in, hid_t file_id);
+static int readIntegerData(FILE *strm, struct Input *in);
+static int readFloatData(FILE *strm, struct Input *in);
+static int allocateIntegerStorage(struct Input *in);
+static int allocateFloatStorage(struct Input *in);
+static int readUIntegerData(FILE *strm, struct Input *in);
+static int allocateUIntegerStorage(struct Input *in);
+static int validateConfigurationParameters(struct Input *in);
+static int processStrData(FILE *strm, struct Input *in, hid_t file_id);
+static int processStrHDFData(FILE *strm, struct Input *in, hid_t file_id);
+
int main(int argc, char *argv[])
{
struct Options opt;
@@ -301,7 +338,7 @@ static int gtoken(char *s)
static int processDataFile(char *infile, struct Input *in, hid_t file_id)
{
- FILE *strm;
+ FILE *strm = NULL;
const char *err1 = "Unable to open the input file %s for reading.\n";
const char *err2 = "Error in allocating integer data storage.\n";
const char *err3 = "Error in allocating floating-point data storage.\n";
@@ -311,6 +348,7 @@ static int processDataFile(char *infile, struct Input *in, hid_t file_id)
const char *err7 = "Error in reading unsigned integer data.\n";
const char *err10 = "Unrecognized input class type.\n";
const char *err11 = "Error in reading string data.\n";
+ int retval = -1;
/*-------------------------------------------------------------------------
* special case for opening binary classes in H5_HAVE_WIN32_API
@@ -323,7 +361,7 @@ static int processDataFile(char *infile, struct Input *in, hid_t file_id)
if ((strm = HDfopen(infile, READ_OPEN_FLAGS)) == NULL) {
(void) HDfprintf(stderr, err1, infile);
- return (-1);
+ goto error;
}
}
/*-------------------------------------------------------------------------
@@ -333,7 +371,7 @@ static int processDataFile(char *infile, struct Input *in, hid_t file_id)
else {
if ((strm = HDfopen(infile, "r")) == NULL) {
(void) HDfprintf(stderr, err1, infile);
- return (-1);
+ goto error;
}
}
@@ -342,14 +380,12 @@ static int processDataFile(char *infile, struct Input *in, hid_t file_id)
case 4: /* IN */
if (allocateIntegerStorage(in) == -1) {
(void) HDfprintf(stderr, err2, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
if (readIntegerData(strm, in) == -1) {
(void) HDfprintf(stderr, err4, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
break;
@@ -358,15 +394,13 @@ static int processDataFile(char *infile, struct Input *in, hid_t file_id)
case 3: /* FP */
if (allocateFloatStorage(in) == -1) {
(void) HDfprintf(stderr, err3, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
if (readFloatData(strm, in) == -1) {
(void) HDfprintf(stderr, err5, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
break;
@@ -374,15 +408,13 @@ static int processDataFile(char *infile, struct Input *in, hid_t file_id)
if (in->h5dumpInput) {
if (processStrHDFData(strm, in, file_id) == -1) {
(void) HDfprintf(stderr, err11, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
}
else {
if (processStrData(strm, in, file_id) == -1) {
(void) HDfprintf(stderr, err11, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
}
@@ -392,23 +424,26 @@ static int processDataFile(char *infile, struct Input *in, hid_t file_id)
case 7: /* UIN */
if (allocateUIntegerStorage(in) == -1) {
(void) HDfprintf(stderr, err6, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
if (readUIntegerData(strm, in) == -1) {
(void) HDfprintf(stderr, err7, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
break;
default:
(void) HDfprintf(stderr, "%s", err10);
- HDfclose(strm);
- return (-1);
+ goto error;
}
- HDfclose(strm);
- return (0);
+
+ /* Set success return value */
+ retval = 0;
+
+error:
+ if(strm)
+ HDfclose(strm);
+ return(retval);
}
static int readIntegerData(FILE *strm, struct Input *in)
@@ -1251,12 +1286,13 @@ static int allocateFloatStorage(struct Input *in)
static int processConfigurationFile(char *infile, struct Input *in)
{
- FILE *strm;
+ FILE *strm = NULL;
char key[255];
int kindex;
char temp[255];
int ival;
int scanret;
+ int retval = -1;
const char *err1 = "Unable to open the configuration file: %s for reading.\n";
const char *err2 = "Unknown keyword in configuration file: %s\n";
@@ -1303,7 +1339,7 @@ static int processConfigurationFile(char *infile, struct Input *in)
if ((strm = HDfopen(infile, "r")) == NULL) {
(void) HDfprintf(stderr, err1, infile);
- return (-1);
+ goto error;
}
scanret = fscanf(strm, "%s", key);
@@ -1323,21 +1359,18 @@ static int processConfigurationFile(char *infile, struct Input *in)
#endif
if (in->configOptionVector[PATH] == 1) {
(void) HDfprintf(stderr, err3a, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
if (fscanf(strm, "%s", temp) != 1) {
(void) HDfprintf(stderr, "%s", err18);
- HDfclose(strm);
- return (-1);
+ goto error;
}
#ifdef H5DEBUGIMPORT
printf("h5dump DATASET %s found\n", temp);
#endif
if (parsePathInfo(&in->path, temp) == -1) {
(void) HDfprintf(stderr, err3b, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
in->configOptionVector[PATH] = 1;
scanret = fscanf(strm, "%s", temp); /* start bracket */
@@ -1351,22 +1384,19 @@ static int processConfigurationFile(char *infile, struct Input *in)
#endif
if (in->configOptionVector[INPUT_CLASS] == 1) {
(void) HDfprintf(stderr, err4a, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
if (fscanf(strm, "%s", temp) != 1) {
(void) HDfprintf(stderr, "%s", err18);
- HDfclose(strm);
- return (-1);
+ goto error;
}
#ifdef H5DEBUGIMPORT
printf("h5dump DATATYPE %s found\n", temp);
#endif
if ((kindex = getInputClassType(in, temp)) == -1) {
(void) HDfprintf(stderr, err4b, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
#ifdef H5DEBUGIMPORT
printf("h5dump DATATYPE type %d inputClass\n", in->inputClass);
@@ -1396,23 +1426,20 @@ static int processConfigurationFile(char *infile, struct Input *in)
#endif
if (fscanf(strm, "%s", temp) != 1) { /* start bracket */
(void) HDfprintf(stderr, "%s", err18);
- HDfclose(strm);
- return (-1);
+ goto error;
}
#ifdef H5DEBUGIMPORT
printf("h5dump DATATYPE STRING %s found\n", temp);
#endif
if (fscanf(strm, "%s", temp) != 1) { /* string properties */
(void) HDfprintf(stderr, "%s", err18);
- HDfclose(strm);
- return (-1);
+ goto error;
}
while (get_next_prop) {
if(!HDstrcmp("STRSIZE", temp)) { /* STRSIZE */
if (fscanf(strm, "%s", temp) != 1) {
(void) HDfprintf(stderr, "%s", err19);
- HDfclose(strm);
- return (-1);
+ goto error;
}
#ifdef H5DEBUGIMPORT
printf("h5dump DATATYPE STRING STRSIZE %s found\n", temp);
@@ -1422,8 +1449,7 @@ static int processConfigurationFile(char *infile, struct Input *in)
ival = HDstrtol(more, &more, 10);
if (getInputSize(in, ival) == -1) {
(void) HDfprintf(stderr, err5b, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
#ifdef H5DEBUGIMPORT
printf("h5dump DATATYPE STRING %d InputSize\n", in->inputSize);
@@ -1433,8 +1459,7 @@ static int processConfigurationFile(char *infile, struct Input *in)
else if(!HDstrcmp("STRPAD", temp)) { /* STRPAD */
if (fscanf(strm, "%s", temp) != 1) { /* STRPAD type */
(void) HDfprintf(stderr, "%s", err18);
- HDfclose(strm);
- return (-1);
+ goto error;
}
#ifdef H5DEBUGIMPORT
printf("h5dump DATATYPE STRING STRPAD %s found\n", temp);
@@ -1443,8 +1468,7 @@ static int processConfigurationFile(char *infile, struct Input *in)
else if(!HDstrcmp("CSET", key)) { /* CSET */
if (fscanf(strm, "%s", temp) != 1) { /* CSET type */
(void) HDfprintf(stderr, "%s", err18);
- HDfclose(strm);
- return (-1);
+ goto error;
}
#ifdef H5DEBUGIMPORT
printf("h5dump DATATYPE STRING CSET %s found\n", temp);
@@ -1454,8 +1478,7 @@ static int processConfigurationFile(char *infile, struct Input *in)
else if(!HDstrcmp("CTYPE", temp)) { /* CTYPE */
if (fscanf(strm, "%s", temp) != 1) { /* CTYPE type */
(void) HDfprintf(stderr, "%s", err18);
- HDfclose(strm);
- return (-1);
+ goto error;
}
#ifdef H5DEBUGIMPORT
printf("h5dump DATATYPE STRING CTYPE %s found\n", temp);
@@ -1463,8 +1486,7 @@ static int processConfigurationFile(char *infile, struct Input *in)
} /* if(!HDstrcmp("CSET", key)) */
if (fscanf(strm, "%s", temp) != 1) {
(void) HDfprintf(stderr, "%s", err18);
- HDfclose(strm);
- return (-1);
+ goto error;
}
#ifdef H5DEBUGIMPORT
printf("h5dump DATATYPE STRING %s found\n", temp);
@@ -1483,16 +1505,14 @@ static int processConfigurationFile(char *infile, struct Input *in)
#endif
if (fscanf(strm, "%s", temp) != 1) {
(void) HDfprintf(stderr, "%s", err18);
- HDfclose(strm);
- return (-1);
+ goto error;
}
if(!HDstrcmp("SCALAR", temp)) { /* SCALAR */
in->rank = 0;
} /* if(!HDstrcmp("SCALAR", key)) */
else if(!HDstrcmp("NULL", temp)) { /* NULL */
(void) HDfprintf(stderr, err6b, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
} /* else if(!HDstrcmp("NULL", key)) */
else if(!HDstrcmp("SIMPLE", temp)) { /* SIMPLE */
int icount = 0;
@@ -1501,16 +1521,14 @@ static int processConfigurationFile(char *infile, struct Input *in)
#endif
if (fscanf(strm, "%s", temp) != 1) { /* start bracket */
(void) HDfprintf(stderr, err6b, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
#ifdef H5DEBUGIMPORT
printf("h5dump DATASPACE SIMPLE %s found\n", temp);
#endif
if (fscanf(strm, "%s", temp) != 1) { /* start paren */
(void) HDfprintf(stderr, err6b, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
#ifdef H5DEBUGIMPORT
printf("h5dump DATASPACE SIMPLE %s found\n", temp);
@@ -1521,8 +1539,7 @@ static int processConfigurationFile(char *infile, struct Input *in)
if (fscanf(strm, "%s", temp) != 1) { /* Dimension with optional comma */
(void) HDfprintf(stderr, err16c, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
#ifdef H5DEBUGIMPORT
printf("h5dump DATASPACE SIMPLE %s found\n", temp);
@@ -1532,8 +1549,7 @@ static int processConfigurationFile(char *infile, struct Input *in)
temp_dims[icount] = HDstrtoull(more, &more, 10);
if (fscanf(strm, "%s", temp) != 1) { /* Dimension or end paren */
(void) HDfprintf(stderr, err6b, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
#ifdef H5DEBUGIMPORT
printf("h5dump DATASPACE SIMPLE %s found\n", temp);
@@ -1547,15 +1563,13 @@ static int processConfigurationFile(char *infile, struct Input *in)
icount++;
if (icount > MAX_NUM_DIMENSION) {
(void) HDfprintf(stderr, "Invalid value for rank.\n");
- HDfclose(strm);
- return (-1);
+ goto error;
}
}
} /* while (get_next_dim) */
if ((in->sizeOfDimension = (hsize_t *) HDmalloc ((size_t) in->rank * sizeof(hsize_t))) == NULL) {
- (void) HDfprintf(stderr, "Unable to allocate dynamic memory.\n");
- return (-1);
+ goto error;
}
#ifdef H5DEBUGIMPORT
printf("h5dump DATASPACE SIMPLE %d rank\n", in->rank);
@@ -1574,26 +1588,22 @@ static int processConfigurationFile(char *infile, struct Input *in)
} /* if(!HDstrcmp("(", key)) start paren */
else {
(void) HDfprintf(stderr, err5b, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
if (fscanf(strm, "%s", temp) != 1) {
(void) HDfprintf(stderr, "%s", err18);
- HDfclose(strm);
- return (-1);
+ goto error;
}
#ifdef H5DEBUGIMPORT
printf("h5dump DATASPACE SIMPLE %s found\n", temp);
#endif
if(!HDstrcmp("/", temp)) { /* / max dims */
if ((in->maxsizeOfDimension = (hsize_t *) HDmalloc ((size_t) in->rank * sizeof(hsize_t))) == NULL) {
- (void) HDfprintf(stderr, "Unable to allocate dynamic memory.\n");
- return (-1);
+ goto error;
}
if (fscanf(strm, "%s", temp) != 1) { /* start paren */
(void) HDfprintf(stderr, err6b, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
#ifdef H5DEBUGIMPORT
printf("h5dump DATASPACE SIMPLE %s found\n", temp);
@@ -1607,8 +1617,7 @@ static int processConfigurationFile(char *infile, struct Input *in)
#endif
if (fscanf(strm, "%s", temp) != 1) { /* max dim with optional comma */
(void) HDfprintf(stderr, err16c, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
#ifdef H5DEBUGIMPORT
printf("h5dump DATASPACE SIMPLE %s found\n", temp);
@@ -1627,8 +1636,7 @@ static int processConfigurationFile(char *infile, struct Input *in)
}
if (fscanf(strm, "%s", temp) != 1) { /* max dim or end paren */
(void) HDfprintf(stderr, err16c, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
#ifdef H5DEBUGIMPORT
printf("h5dump DATASPACE SIMPLE %s found\n", temp);
@@ -1640,8 +1648,7 @@ static int processConfigurationFile(char *infile, struct Input *in)
i++;
if (i > MAX_NUM_DIMENSION) {
(void) HDfprintf(stderr, "Invalid value for rank.\n");
- HDfclose(strm);
- return (-1);
+ goto error;
}
}
} /* while (get_next_dim) */
@@ -1656,8 +1663,7 @@ static int processConfigurationFile(char *infile, struct Input *in)
} /* if(!HDstrcmp("(", key)) start paren */
else {
(void) HDfprintf(stderr, err16c, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
scanret = fscanf(strm, "%s", temp); /* end bracket */
#ifdef H5DEBUGIMPORT
@@ -1667,8 +1673,7 @@ static int processConfigurationFile(char *infile, struct Input *in)
} /* else if(!HDstrcmp("SIMPLE", key)) */
else {
(void) HDfprintf(stderr, err5b, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
} /* else if(!HDstrcmp("DATASPACE", key)) RANK and DIMENSIONS */
else if(!HDstrcmp("STORAGE_LAYOUT", key)) { /* CHUNKED-DIMENSION-SIZES */
@@ -1677,16 +1682,14 @@ static int processConfigurationFile(char *infile, struct Input *in)
#endif
if (fscanf(strm, "%s", temp) != 1) { /* start bracket */
(void) HDfprintf(stderr, err6b, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
#ifdef H5DEBUGIMPORT
printf("h5dump STORAGE_LAYOUT %s found\n", temp);
#endif
if (fscanf(strm, "%s", temp) != 1) { /* CHUNKED */
(void) HDfprintf(stderr, err6b, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
#ifdef H5DEBUGIMPORT
printf("h5dump STORAGE_LAYOUT %s found\n", temp);
@@ -1694,12 +1697,11 @@ static int processConfigurationFile(char *infile, struct Input *in)
if(!HDstrcmp("CHUNKED", temp)) { /* CHUNKED */
if ((in->sizeOfChunk = (hsize_t *) HDmalloc ((size_t) in->rank * sizeof(hsize_t))) == NULL) {
(void) HDfprintf(stderr, "Unable to allocate dynamic memory.\n");
- return (-1);
+ goto error;
}
if (fscanf(strm, "%s", temp) != 1) { /* start paren */
(void) HDfprintf(stderr, err6b, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
#ifdef H5DEBUGIMPORT
printf("h5dump STORAGE_LAYOUT CHUNKED %s found\n", temp);
@@ -1710,8 +1712,7 @@ static int processConfigurationFile(char *infile, struct Input *in)
if (fscanf(strm, "%s", temp) != 1) { /* Dimension with optional comma */
(void) HDfprintf(stderr, err16c, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
#ifdef H5DEBUGIMPORT
printf("h5dump STORAGE_LAYOUT CHUNKED %s found\n", temp);
@@ -1721,8 +1722,7 @@ static int processConfigurationFile(char *infile, struct Input *in)
in->sizeOfChunk[icount] = HDstrtoull(more, &more, 10);
if (fscanf(strm, "%s", temp) != 1) { /* Dimension or end paren */
(void) HDfprintf(stderr, err6b, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
#ifdef H5DEBUGIMPORT
printf("h5dump STORAGE_LAYOUT CHUNKED %s found\n", temp);
@@ -1735,8 +1735,7 @@ static int processConfigurationFile(char *infile, struct Input *in)
icount++;
if (icount > MAX_NUM_DIMENSION) {
(void) HDfprintf(stderr, "Invalid value for rank.\n");
- HDfclose(strm);
- return (-1);
+ goto error;
}
}
} /* while (get_next_dim) */
@@ -1751,13 +1750,11 @@ static int processConfigurationFile(char *infile, struct Input *in)
} /* if(!HDstrcmp("(", key)) start paren */
else {
(void) HDfprintf(stderr, err5b, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
if (fscanf(strm, "%s", temp) != 1) { /* SIZE */
(void) HDfprintf(stderr, err6b, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
#ifdef H5DEBUGIMPORT
printf("h5dump STORAGE_LAYOUT CHUNKED %s found\n", temp);
@@ -1765,8 +1762,7 @@ static int processConfigurationFile(char *infile, struct Input *in)
if(!HDstrcmp("SIZE", temp)) { /* SIZE */
if (fscanf(strm, "%d", (&ival)) != 1) {
(void) HDfprintf(stderr, "%s", err19);
- HDfclose(strm);
- return (-1);
+ goto error;
}
#ifdef H5DEBUGIMPORT
printf("h5dump STORAGE_LAYOUT CHUNKED SIZE %d found\n", ival);
@@ -1775,8 +1771,7 @@ static int processConfigurationFile(char *infile, struct Input *in)
while (HDstrcmp("}", temp)) {
if (fscanf(strm, "%s", temp) != 1) { /* end bracket */
(void) HDfprintf(stderr, "%s", err18);
- HDfclose(strm);
- return (-1);
+ goto error;
}
#ifdef H5DEBUGIMPORT
printf("h5dump STORAGE_LAYOUT CHUNKED %s found\n", temp);
@@ -1791,16 +1786,14 @@ static int processConfigurationFile(char *infile, struct Input *in)
#endif
if (fscanf(strm, "%s", temp) != 1) { /* start bracket */
(void) HDfprintf(stderr, err6b, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
#ifdef H5DEBUGIMPORT
printf("h5dump FILTERS %s found\n", temp);
#endif
if (fscanf(strm, "%s", temp) != 1) {
(void) HDfprintf(stderr, err6b, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
#ifdef H5DEBUGIMPORT
printf("h5dump FILTERS %s found\n", temp);
@@ -1811,32 +1804,28 @@ static int processConfigurationFile(char *infile, struct Input *in)
#endif
if (fscanf(strm, "%s", temp) != 1) { /* DEFLATE */
(void) HDfprintf(stderr, "%s", err18);
- HDfclose(strm);
- return (-1);
+ goto error;
}
#ifdef H5DEBUGIMPORT
printf("h5dump FILTERS COMPRESSION %s found\n", temp);
#endif
if (fscanf(strm, "%s", temp) != 1) { /* bgin bracket */
(void) HDfprintf(stderr, "%s", err18);
- HDfclose(strm);
- return (-1);
+ goto error;
}
#ifdef H5DEBUGIMPORT
printf("h5dump FILTERS COMPRESSION %s found\n", temp);
#endif
if (fscanf(strm, "%s", temp) != 1) { /* LEVEL */
(void) HDfprintf(stderr, "%s", err18);
- HDfclose(strm);
- return (-1);
+ goto error;
}
#ifdef H5DEBUGIMPORT
printf("h5dump FILTERS COMPRESSION %s found\n", temp);
#endif
if (fscanf(strm, "%d", (&ival)) != 1) {
(void) HDfprintf(stderr, "%s", err19);
- HDfclose(strm);
- return (-1);
+ goto error;
}
#ifdef H5DEBUGIMPORT
printf("h5dump FILTERS COMPRESSION LEVEL %d found\n", ival);
@@ -1844,8 +1833,7 @@ static int processConfigurationFile(char *infile, struct Input *in)
in->compressionParam = ival;
if (fscanf(strm, "%s", temp) != 1) { /* end bracket */
(void) HDfprintf(stderr, "%s", err18);
- HDfclose(strm);
- return (-1);
+ goto error;
}
#ifdef H5DEBUGIMPORT
printf("h5dump FILTERS COMPRESSION %s found\n", temp);
@@ -1867,8 +1855,7 @@ static int processConfigurationFile(char *infile, struct Input *in)
}
if (fscanf(strm, "%s", temp) != 1) { /* end bracket */
(void) HDfprintf(stderr, "%s", err18);
- HDfclose(strm);
- return (-1);
+ goto error;
}
#ifdef H5DEBUGIMPORT
printf("h5dump FILTERS %s found\n", temp);
@@ -1909,25 +1896,21 @@ static int processConfigurationFile(char *infile, struct Input *in)
while (scanret == 1) {
if ((kindex = mapKeywordToIndex(key)) == -1) {
(void) HDfprintf(stderr, err2, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
switch (kindex) {
case 0: /* PATH */
if (in->configOptionVector[PATH] == 1) {
(void) HDfprintf(stderr, err3a, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
if (fscanf(strm, "%s", temp) != 1) {
(void) HDfprintf(stderr, "%s", err18);
- HDfclose(strm);
- return (-1);
+ goto error;
}
if (parsePathInfo(&in->path, temp) == -1) {
(void) HDfprintf(stderr, err3b, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
in->configOptionVector[PATH] = 1;
break;
@@ -1935,19 +1918,16 @@ static int processConfigurationFile(char *infile, struct Input *in)
case 1: /* INPUT-CLASS */
if (in->configOptionVector[INPUT_CLASS] == 1) {
(void) HDfprintf(stderr, err4a, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
if (fscanf(strm, "%s", temp) != 1) {
(void) HDfprintf(stderr, "%s", err18);
- HDfclose(strm);
- return (-1);
+ goto error;
}
if (getInputClass(in, temp) == -1) {
(void) HDfprintf(stderr, err4b, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
in->configOptionVector[INPUT_CLASS] = 1;
@@ -1967,18 +1947,15 @@ static int processConfigurationFile(char *infile, struct Input *in)
case 2: /* INPUT-SIZE */
if (in->configOptionVector[INPUT_SIZE] == 1) {
(void) HDfprintf(stderr, err5a, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
if (fscanf(strm, "%d", (&ival)) != 1) {
(void) HDfprintf(stderr, "%s", err19);
- HDfclose(strm);
- return (-1);
+ goto error;
}
if (getInputSize(in, ival) == -1) {
(void) HDfprintf(stderr, err5b, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
in->configOptionVector[INPUT_SIZE] = 1;
@@ -1990,14 +1967,12 @@ static int processConfigurationFile(char *infile, struct Input *in)
case 3: /* RANK */
if (in->configOptionVector[RANK] == 1) {
(void) HDfprintf(stderr, err6a, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
if (getRank(in, strm) == -1) {
(void) HDfprintf(stderr, err6b, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
in->configOptionVector[RANK] = 1;
break;
@@ -2005,19 +1980,16 @@ static int processConfigurationFile(char *infile, struct Input *in)
case 4: /* DIMENSION-SIZES */
if (in->configOptionVector[DIM] == 1) {
(void) HDfprintf(stderr, err7a, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
if (in->configOptionVector[RANK] == 0) {
(void) HDfprintf(stderr, err7b, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
if (getDimensionSizes(in, strm) == -1) {
(void) HDfprintf(stderr, err7c, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
in->configOptionVector[DIM] = 1;
break;
@@ -2025,14 +1997,12 @@ static int processConfigurationFile(char *infile, struct Input *in)
case 5: /* OUTPUT-CLASS */
if (in->configOptionVector[OUTPUT_CLASS] == 1) {
(void) HDfprintf(stderr, err8a, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
if (getOutputClass(in, strm) == -1) {
(void) HDfprintf(stderr, err8b, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
in->configOptionVector[OUTPUT_CLASS] = 1;
break;
@@ -2040,14 +2010,12 @@ static int processConfigurationFile(char *infile, struct Input *in)
case 6: /* OUTPUT-SIZE */
if (in->configOptionVector[OUTPUT_SIZE] == 1) {
(void) HDfprintf(stderr, err9a, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
if (getOutputSize(in, strm) == -1) {
(void) HDfprintf(stderr, err9b, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
in->configOptionVector[OUTPUT_SIZE] = 1;
break;
@@ -2055,14 +2023,12 @@ static int processConfigurationFile(char *infile, struct Input *in)
case 7: /* OUTPUT-ARCHITECTURE */
if (in->configOptionVector[OUTPUT_ARCH] == 1) {
(void) HDfprintf(stderr, err10a, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
if (getOutputArchitecture(in, strm) == -1) {
(void) HDfprintf(stderr, err10b, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
in->configOptionVector[OUTPUT_ARCH] = 1;
break;
@@ -2070,14 +2036,12 @@ static int processConfigurationFile(char *infile, struct Input *in)
case 8: /* OUTPUT-BYTE-ORDER */
if (in->configOptionVector[OUTPUT_B_ORDER] == 1) {
(void) HDfprintf(stderr, err11a, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
if (getOutputByteOrder(in, strm) == -1) {
(void) HDfprintf(stderr, err11b, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
in->configOptionVector[OUTPUT_B_ORDER] = 1;
break;
@@ -2085,20 +2049,17 @@ static int processConfigurationFile(char *infile, struct Input *in)
case 9: /* CHUNKED-DIMENSION-SIZES */
if (in->configOptionVector[CHUNK] == 1) {
(void) HDfprintf(stderr, err12a, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
/* cant appear before dimension sizes have been provided */
if (in->configOptionVector[DIM] == 0) {
(void) HDfprintf(stderr, err12b, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
if (getChunkedDimensionSizes(in, strm) == -1) {
(void) HDfprintf(stderr, err12c, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
in->configOptionVector[CHUNK] = 1;
break;
@@ -2106,14 +2067,12 @@ static int processConfigurationFile(char *infile, struct Input *in)
case 10: /* COMPRESSION-TYPE */
if (in->configOptionVector[COMPRESS] == 1) {
(void) HDfprintf(stderr, err13a, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
if (getCompressionType(in, strm) == -1) {
(void) HDfprintf(stderr, err13b, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
in->configOptionVector[COMPRESS] = 1;
@@ -2126,14 +2085,12 @@ static int processConfigurationFile(char *infile, struct Input *in)
case 11: /* COMPRESSION-PARAM */
if (in->configOptionVector[COMPRESS_PARAM] == 1) {
(void) HDfprintf(stderr, err14a, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
if (getCompressionParameter(in, strm) == -1) {
(void) HDfprintf(stderr, err14b, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
in->configOptionVector[COMPRESS_PARAM] = 1;
@@ -2146,14 +2103,12 @@ static int processConfigurationFile(char *infile, struct Input *in)
case 12: /* EXTERNAL-STORAGE */
if (in->configOptionVector[EXTERNALSTORE] == 1) {
(void) HDfprintf(stderr, err15a, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
if (getExternalFilename(in, strm) == -1) {
(void) HDfprintf(stderr, err15b, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
in->configOptionVector[EXTERNALSTORE] = 1;
break;
@@ -2161,19 +2116,16 @@ static int processConfigurationFile(char *infile, struct Input *in)
case 13: /* MAXIMUM-DIMENSIONS */
if (in->configOptionVector[EXTEND] == 1) {
(void) HDfprintf(stderr, err16a, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
/* cant appear before dimension sizes have been provided */
if (in->configOptionVector[DIM] == 0) {
(void) HDfprintf(stderr, err16b, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
if (getMaximumDimensionSizes(in, strm) == -1) {
(void) HDfprintf(stderr, err16c, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
in->configOptionVector[EXTEND] = 1;
break;
@@ -2192,11 +2144,16 @@ static int processConfigurationFile(char *infile, struct Input *in)
if (validateConfigurationParameters(in) == -1) {
(void) HDfprintf(stderr, err17, infile);
- HDfclose(strm);
- return (-1);
+ goto error;
}
- HDfclose(strm);
- return (0);
+
+ /* Set success return value */
+ retval = 0;
+
+error:
+ if(strm)
+ HDfclose(strm);
+ return(retval);
}
static int validateConfigurationParameters(struct Input *in)
@@ -3279,7 +3236,7 @@ static int getOutputArchitecture(struct Input *in, FILE *strm)
return (0);
}
-static int OutputArchStrToInt(char *temp)
+static int OutputArchStrToInt(const char *temp)
{
int i;
char outputArchKeywordTable[8][15] = { "NATIVE", "STD", "IEEE", "INTEL",
@@ -3311,7 +3268,7 @@ static int getOutputByteOrder(struct Input *in, FILE *strm)
return (0);
}
-static int OutputByteOrderStrToInt(char *temp)
+static int OutputByteOrderStrToInt(const char *temp)
{
int i;
char outputByteOrderKeywordTable[2][15] = { "BE", "LE" };
@@ -3716,6 +3673,10 @@ hid_t createInputDataType(struct Input *in)
case 64:
new_type = H5Tcopy(H5T_NATIVE_LLONG);
break;
+
+ default:
+ (void) HDfprintf(stderr, "%s", err1);
+ return (-1);
}
break;
@@ -3730,6 +3691,10 @@ hid_t createInputDataType(struct Input *in)
case 64:
new_type = H5Tcopy(H5T_NATIVE_DOUBLE);
break;
+
+ default:
+ (void) HDfprintf(stderr, "%s", err1);
+ return (-1);
}
break;
@@ -3754,6 +3719,10 @@ hid_t createInputDataType(struct Input *in)
case 64:
new_type = H5Tcopy(H5T_NATIVE_ULLONG);
break;
+
+ default:
+ (void) HDfprintf(stderr, "%s", err1);
+ return (-1);
}
break;
diff --git a/tools/h5import/h5import.h b/tools/h5import/h5import.h
index c686624..c242483 100644
--- a/tools/h5import/h5import.h
+++ b/tools/h5import/h5import.h
@@ -191,43 +191,8 @@ void usage(char *);
void setDefaultValues(struct Input *in, int count);
void help(char *);
-static int gtoken(char *s);
-static int process(struct Options *opt);
-static int processConfigurationFile(char *infile, struct Input *in);
-static int mapKeywordToIndex(char *key);
-static int parsePathInfo(struct path_info *path, char *strm);
-static int parseDimensions(struct Input *in, char *strm);
-static int getInputSize(struct Input *in, int ival);
-static int getInputClass(struct Input *in, char * strm);
-static int getInputClassType(struct Input *in, char * strm);
-static int InputClassStrToInt(char *temp);
-static int getRank(struct Input *in, FILE *strm);
-static int getDimensionSizes(struct Input *in, FILE *strm);
-static int getOutputSize(struct Input *in, FILE *strm);
-static int getOutputClass(struct Input *in, FILE *strm);
-static int OutputClassStrToInt(char *temp);
-static int getOutputArchitecture(struct Input *in, FILE *strm);
-static int OutputArchStrToInt(char *temp);
-static int getOutputByteOrder(struct Input *in, FILE *strm);
-static int OutputByteOrderStrToInt(char *temp);
-static int getChunkedDimensionSizes(struct Input *in, FILE *strm);
-static int getCompressionType(struct Input *in, FILE *strm);
-static int CompressionTypeStrToInt(char *temp);
-static int getCompressionParameter(struct Input *in, FILE *strm);
-static int getExternalFilename(struct Input *in, FILE *strm);
-static int getMaximumDimensionSizes(struct Input *in, FILE *strm);
-static int processDataFile(char *infile, struct Input *in, hid_t file_id);
-static int readIntegerData(FILE *strm, struct Input *in);
-static int readFloatData(FILE *strm, struct Input *in);
-static int allocateIntegerStorage(struct Input *in);
-static int allocateFloatStorage(struct Input *in);
hid_t createOutputDataType(struct Input *in);
hid_t createInputDataType(struct Input *in);
-static int readUIntegerData(FILE *strm, struct Input *in);
-static int allocateUIntegerStorage(struct Input *in);
-static int validateConfigurationParameters(struct Input *in);
-static int processStrData(FILE *strm, struct Input *in, hid_t file_id);
-static int processStrHDFData(FILE *strm, struct Input *in, hid_t file_id);
#endif /* H5IMPORT_H__ */
diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h
index 3e3a4cf..4fbd84f 100644
--- a/tools/lib/h5tools.h
+++ b/tools/lib/h5tools.h
@@ -435,7 +435,7 @@ typedef struct h5tool_format_t {
* indentlevel: a string that shows how far to indent if extra spacing
* is needed. dumper uses it.
*/
- int line_ncols; /*columns of output */
+ unsigned line_ncols; /*columns of output */
size_t line_per_line; /*max elements per line */
const char *line_pre; /*prefix at front of each line */
const char *line_1st; /*alternate pre. on first line */
diff --git a/tools/misc/talign.c b/tools/misc/talign.c
index b77d846..017eb55 100644
--- a/tools/misc/talign.c
+++ b/tools/misc/talign.c
@@ -23,6 +23,7 @@
#include "hdf5.h"
#include "H5private.h"
+#include "h5tools.h"
const char *fname = "talign.h5";
const char *setname = "align";
@@ -46,8 +47,8 @@ int main(void)
hsize_t cdim[4];
char string5[5];
- float fok[2] = {1234., 2341.};
- float fnok[2] = {5678., 6785.};
+ float fok[2] = {1234.0f, 2341.0f};
+ float fnok[2] = {5678.0f, 6785.0f};
float *fptr;
char *data = NULL;
@@ -125,7 +126,7 @@ int main(void)
H5Dclose(set);
/* Now open the set, and read it back in */
- data = malloc(H5Tget_size(fix));
+ data = (char *)malloc(H5Tget_size(fix));
if(!data) {
perror("malloc() failed");
@@ -159,8 +160,8 @@ out:
"%14s (%2d) %6f = %f\n"
" %6f = %f\n",
mname ? mname : "(null)", (int)H5Tget_member_offset(fix,1),
- fok[0], fptr[0],
- fok[1], fptr[1]);
+ (double)fok[0], (double)fptr[0],
+ (double)fok[1], (double)fptr[1]);
if(mname)
free(mname);
@@ -169,8 +170,8 @@ out:
printf("%14s (%2d) %6f = %f\n"
" %6f = %6f\n",
mname ? mname : "(null)", (int)H5Tget_member_offset(fix,2),
- fnok[0], fptr[0],
- fnok[1], fptr[1]);
+ (double)fnok[0], (double)fptr[0],
+ (double)fnok[1], (double)fptr[1]);
if(mname)
free(mname);
@@ -181,10 +182,10 @@ out:
" %6f = %f\n"
" %6f = %f\n"
" %6f = %f\n",
- fok[0], fptr[0],
- fok[1], fptr[1],
- fnok[0], fptr[2],
- fnok[1], fptr[3]);
+ (double)fok[0], (double)fptr[0],
+ (double)fok[1], (double)fptr[1],
+ (double)fnok[0], (double)fptr[2],
+ (double)fnok[1], (double)fptr[3]);
puts("*FAILED - compound type alignmnent problem*");
} else {
puts(" PASSED");