summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2013-03-20 04:41:16 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2013-03-20 04:41:16 (GMT)
commit1d95950134130c55247df3dd6bf833756db28625 (patch)
tree36efd13fbfdde2fa7f01dd52acdc23d29efa54a3 /tools
parent1e56e8ce4f8725320c1903aa028c349f43dcb9da (diff)
downloadhdf5-1d95950134130c55247df3dd6bf833756db28625.zip
hdf5-1d95950134130c55247df3dd6bf833756db28625.tar.gz
hdf5-1d95950134130c55247df3dd6bf833756db28625.tar.bz2
[svn-r23396] Description:
Bring r23395 from trunk to 1.8 branch: Bring Coverity changes from branch to trunk: r20682: fixed coverity: 76, 77, 635, 636, 1164, 1165, 1166, 1121, 1122, 1117, 1343 Tested on: Mac OSX/64 10.8.3 (amazon) w/C++ & FORTRAN (too minor to require h5committest)
Diffstat (limited to 'tools')
-rw-r--r--tools/h5copy/h5copy.c39
-rw-r--r--tools/h5ls/h5ls.c247
-rw-r--r--tools/lib/h5diff.c34
-rw-r--r--tools/lib/h5diff.h205
-rw-r--r--tools/lib/h5diff_array.c689
-rw-r--r--tools/lib/h5diff_attr.c14
-rw-r--r--tools/lib/h5tools_utils.h2
7 files changed, 619 insertions, 611 deletions
diff --git a/tools/h5copy/h5copy.c b/tools/h5copy/h5copy.c
index 574ba94..b2ad9d0 100644
--- a/tools/h5copy/h5copy.c
+++ b/tools/h5copy/h5copy.c
@@ -199,23 +199,21 @@ static int parse_flag(const char* str_flag, unsigned *flag)
int
main (int argc, const char *argv[])
{
- hid_t fid_src=-1;
- hid_t fid_dst=-1;
- char *fname_src=NULL;
- char *fname_dst=NULL;
- char *oname_src=NULL;
- char *oname_dst=NULL;
- unsigned flag=0;
- unsigned verbose=0;
- unsigned parents=0;
+ hid_t fid_src = -1;
+ hid_t fid_dst = -1;
+ char *fname_src = NULL;
+ char *fname_dst = NULL;
+ char *oname_src = NULL;
+ char *oname_dst = NULL;
+ char *str_flag = NULL;
+ unsigned flag = 0;
+ unsigned verbose = 0;
+ unsigned parents = 0;
hid_t ocpl_id = (-1); /* Object copy property list */
hid_t lcpl_id = (-1); /* Link creation property list */
- char str_flag[20];
int opt;
int li_ret;
h5tool_link_info_t linkinfo;
- int i, len;
- char *str_ptr=NULL;
h5tools_setprogname(PROGRAMNAME);
h5tools_setstatus(EXIT_SUCCESS);
@@ -249,7 +247,7 @@ main (int argc, const char *argv[])
usage();
leave(EXIT_FAILURE);
}
- HDstrcpy(str_flag,opt_arg);
+ str_flag = HDstrdup(opt_arg);
break;
case 'h':
@@ -377,8 +375,10 @@ main (int argc, const char *argv[])
{
printf("Copying file <%s> and object <%s> to file <%s> and object <%s>\n",
fname_src, oname_src, fname_dst, oname_dst);
- if (flag)
+ if (flag) {
+ HDassert(str_flag);
printf("Using %s flag\n", str_flag);
+ }
}
@@ -417,14 +417,19 @@ main (int argc, const char *argv[])
} /* end if */
else /* error, if parent groups doesn't already exist in destination file */
{
+ size_t i, len;
+
len = HDstrlen(oname_dst);
+
/* check if all the parents groups exist. skip root group */
for (i = 1; i < len; i++)
{
if ('/'==oname_dst[i])
{
- str_ptr = (char*)HDcalloc((size_t)i+1, sizeof(char));
- HDstrncpy (str_ptr, oname_dst, (size_t)i);
+ char *str_ptr;
+
+ str_ptr = (char *)HDcalloc(i + 1, sizeof(char));
+ HDstrncpy(str_ptr, oname_dst, i);
str_ptr[i]='\0';
if (H5Lexists(fid_dst, str_ptr, H5P_DEFAULT) <= 0)
{
@@ -513,6 +518,8 @@ error:
HDfree(oname_dst);
if (oname_src)
HDfree(oname_src);
+ if (str_flag)
+ HDfree(str_flag);
h5tools_close();
diff --git a/tools/h5ls/h5ls.c b/tools/h5ls/h5ls.c
index 7135e4e..832d91f 100644
--- a/tools/h5ls/h5ls.c
+++ b/tools/h5ls/h5ls.c
@@ -115,8 +115,8 @@ typedef struct {
hid_t gid; /* Group ID */
hbool_t symlink_target; /* Whether this is the target of an symbolic link */
symlink_trav_t *symlink_list; /* List of visited symbolic links */
- int base_len; /* Length of base path name, if not root */
- int name_start; /* # of leading characters to strip off path names on output */
+ size_t base_len; /* Length of base path name, if not root */
+ size_t name_start; /* # of leading characters to strip off path names on output */
}iter_t;
/* Command-line switches */
@@ -154,7 +154,6 @@ static struct dispatch_t {
dispatch_g[TYPE].list2 = (LIST2); \
}
-static void display_type(hid_t type, int ind);
static void print_type(h5tools_str_t *buffer, hid_t type, int ind);
static herr_t visit_obj(hid_t file, const char *oname, iter_t *iter);
@@ -342,7 +341,7 @@ print_obj_name(h5tools_str_t *buffer, const iter_t *iter, const char *oname,
int n;
if(show_file_name_g)
- sprintf(fullname, "%s/%s", iter->fname, oname + iter->name_start);
+ HDsnprintf(fullname, sizeof(fullname), "%s/%s", iter->fname, oname + iter->name_start);
else
name = oname + iter->name_start;
@@ -553,14 +552,14 @@ print_precision(h5tools_str_t *buffer, hid_t type, int ind)
/* If the precision is less than the total size then show the precision
* and offset on the following line. Also display the padding
* information. */
- if (8*H5Tget_size(type)!=(prec=H5Tget_precision(type))) {
+ if(8 * H5Tget_size(type) != (prec = H5Tget_precision(type))) {
h5tools_str_append(buffer, "\n%*s(%lu bit%s of precision beginning at bit %lu)",
- ind, "", (unsigned long)prec, 1==prec?"":"s",
+ ind, "", (unsigned long)prec, 1 == prec ? "" : "s",
(unsigned long)H5Tget_offset(type));
H5Tget_pad(type, &plsb, &pmsb);
- if (H5Tget_offset(type)>0) {
- switch (plsb) {
+ if(H5Tget_offset(type) > 0) {
+ switch(plsb) {
case H5T_PAD_ZERO:
plsb_s = "zero";
break;
@@ -575,12 +574,11 @@ print_precision(h5tools_str_t *buffer, hid_t type, int ind)
plsb_s = "unknown";
break;
default:
- ;
break;
}
}
- if (H5Tget_offset(type)+prec<8*H5Tget_size(type)) {
- switch (pmsb) {
+ if((unsigned)H5Tget_offset(type) + prec < 8 * H5Tget_size(type)) {
+ switch(pmsb) {
case H5T_PAD_ZERO:
pmsb_s = "zero";
break;
@@ -595,23 +593,22 @@ print_precision(h5tools_str_t *buffer, hid_t type, int ind)
pmsb_s = "unknown";
break;
default:
- ;
break;
}
}
if (plsb_s || pmsb_s) {
h5tools_str_append(buffer, "\n%*s(", ind, "");
if (plsb_s) {
- nbits = H5Tget_offset(type);
+ nbits = (unsigned)H5Tget_offset(type);
h5tools_str_append(buffer, "%lu %s bit%s at bit 0",
- (unsigned long)nbits, plsb_s, 1==nbits?"":"s");
+ (unsigned long)nbits, plsb_s, 1 == nbits ? "" : "s");
}
if (plsb_s && pmsb_s) h5tools_str_append(buffer, ", ");
if (pmsb_s) {
- nbits = 8*H5Tget_size(type)-(H5Tget_offset(type)+prec);
+ nbits = (8 * H5Tget_size(type)) - ((unsigned)H5Tget_offset(type) + prec);
h5tools_str_append(buffer, "%lu %s bit%s at bit %lu",
- (unsigned long)nbits, pmsb_s, 1==nbits?"":"s",
- (unsigned long)(8*H5Tget_size(type)-nbits));
+ (unsigned long)nbits, pmsb_s, 1 == nbits ? "" : "s",
+ (unsigned long)(8 * H5Tget_size(type) - nbits));
}
h5tools_str_append(buffer, ")");
}
@@ -829,14 +826,18 @@ print_cmpd_type(h5tools_str_t *buffer, hid_t type, int ind)
char *name=NULL; /* member name */
size_t size; /* total size of type in bytes */
hid_t subtype; /* member data type */
- unsigned nmembs; /* number of members */
+ int nmembs; /* number of members */
int n; /* miscellaneous counters */
unsigned i; /* miscellaneous counters */
- if (H5T_COMPOUND!=H5Tget_class(type)) return FALSE;
+ if(H5T_COMPOUND != H5Tget_class(type))
+ return FALSE;
+ nmembs = H5Tget_nmembers(type);
+ if(nmembs <= 0)
+ return FALSE;
+
h5tools_str_append(buffer, "struct {");
- nmembs=H5Tget_nmembers(type);
- for (i=0; i<nmembs; i++) {
+ for(i = 0; i < (unsigned)nmembs; i++) {
/* Name and offset */
name = H5Tget_member_name(type, i);
@@ -877,89 +878,109 @@ print_cmpd_type(h5tools_str_t *buffer, hid_t type, int ind)
static hbool_t
print_enum_type(h5tools_str_t *buffer, hid_t type, int ind)
{
- char **name=NULL; /* member names */
- unsigned char *value=NULL; /* value array */
- unsigned char *copy = NULL; /* a pointer to value array */
- unsigned nmembs; /* number of members */
- int nchars; /* number of output characters */
+ int nmembs; /* number of members */
hid_t super; /* enum base integer type */
- hid_t native=-1; /* native integer data type */
- size_t dst_size; /* destination value type size */
- unsigned i; /* miscellaneous counters */
- size_t j;
- if (H5T_ENUM!=H5Tget_class(type)) return FALSE;
+ if(H5T_ENUM != H5Tget_class(type))
+ return FALSE;
nmembs = H5Tget_nmembers(type);
- HDassert(nmembs>0);
+ if(nmembs < 0)
+ return FALSE;
+
super = H5Tget_super(type);
h5tools_str_append(buffer, "enum ");
- print_type(buffer, super, ind+4);
+ print_type(buffer, super, ind + 4);
h5tools_str_append(buffer, " {");
- /* Determine what data type to use for the native values. To simplify
- * things we entertain three possibilities:
- * 1. long long -- the largest native signed integer
- * 2. unsigned long long -- the largest native unsigned integer
- * 3. raw format */
- if (H5Tget_size(type)<=sizeof(long long)) {
- dst_size = sizeof(long long);
- if (H5T_SGN_NONE==H5Tget_sign(type)) {
- native = H5T_NATIVE_ULLONG;
- } else {
- native = H5T_NATIVE_LLONG;
+ if(nmembs > 0) {
+ char **name; /* member names */
+ unsigned char *value; /* value array */
+ hid_t native = -1; /* native integer data type */
+ size_t dst_size; /* destination value type size */
+ unsigned i; /* miscellaneous counters */
+
+ /* Determine what data type to use for the native values. To simplify
+ * things we entertain three possibilities:
+ * 1. long long -- the largest native signed integer
+ * 2. unsigned long long -- the largest native unsigned integer
+ * 3. raw format */
+ if(H5Tget_size(type) <= sizeof(long long)) {
+ dst_size = sizeof(long long);
+ if(H5T_SGN_NONE == H5Tget_sign(type))
+ native = H5T_NATIVE_ULLONG;
+ else
+ native = H5T_NATIVE_LLONG;
+ } /* end if */
+ else
+ dst_size = H5Tget_size(type);
+
+ /* Get the names and raw values of all members */
+ name = (char **)HDcalloc((size_t)nmembs, sizeof(char *));
+ value = (unsigned char *)HDcalloc((size_t)nmembs, MAX(H5Tget_size(type), dst_size));
+ for(i = 0; i < (unsigned)nmembs; i++) {
+ name[i] = H5Tget_member_name(type, i);
+ H5Tget_member_value(type, i, value + i * H5Tget_size(type));
}
- } else {
- dst_size = H5Tget_size(type);
- }
-
- /* Get the names and raw values of all members */
- name = HDcalloc(nmembs, sizeof(char*));
- value = (unsigned char *)HDcalloc(nmembs, MAX(H5Tget_size(type), dst_size));
- for (i=0; i<nmembs; i++) {
- name[i] = H5Tget_member_name(type, i);
- H5Tget_member_value(type, i, value+i*H5Tget_size(type));
- }
- /* Convert values to native data type */
- if (native>0) H5Tconvert(super, native, nmembs, value, NULL, H5P_DEFAULT);
+ /* Convert values to native data type */
+ if(native > 0)
+ if(H5Tconvert(super, native, (size_t)nmembs, value, NULL, H5P_DEFAULT) < 0) {
+ /* Release resources */
+ for(i = 0; i < (unsigned)nmembs; i++)
+ HDfree(name[i]);
+ HDfree(name);
+ HDfree(value);
- /* Sort members by increasing value */
- /*not implemented yet*/
-
- /* Print members */
- for (i=0; i<nmembs; i++) {
- h5tools_str_append(buffer, "\n%*s", ind+4, "");
- nchars = print_string(buffer, name[i], TRUE);
- h5tools_str_append(buffer, "%*s = ", MAX(0, 16-nchars), "");
+ return FALSE;
+ }
- if (native<0) {
- h5tools_str_append(buffer, "0x");
- for (j=0; j<dst_size; j++)
- h5tools_str_append(buffer, "%02x", value[i*dst_size+j]);
- }
- else if (H5T_SGN_NONE==H5Tget_sign(native)) {
- /*On SGI Altix(cobalt), wrong values were printed out with "value+i*dst_size"
- *strangely, unless use another pointer "copy".*/
- copy = value+i*dst_size;
- h5tools_str_append(buffer, HSIZE_T_FORMAT, *((unsigned long long*)((void*)copy)));
- }
- else {
- /*On SGI Altix(cobalt), wrong values were printed out with "value+i*dst_size"
- *strangely, unless use another pointer "copy".*/
- copy = value+i*dst_size;
- h5tools_str_append(buffer, "%"H5_PRINTF_LL_WIDTH"d",
- *((long long*)((void*)copy)));
+ /* Sort members by increasing value */
+ /*not implemented yet*/
+
+ /* Print members */
+ for(i = 0; i < (unsigned)nmembs; i++) {
+ unsigned char *copy; /* a pointer to value array */
+ int nchars; /* number of output characters */
+
+ h5tools_str_append(buffer, "\n%*s", ind+4, "");
+ nchars = print_string(buffer, name[i], TRUE);
+ h5tools_str_append(buffer, "%*s = ", MAX(0, 16 - nchars), "");
+
+ if(native < 0) {
+ size_t j;
+
+ h5tools_str_append(buffer, "0x");
+ for(j = 0; j < dst_size; j++)
+ h5tools_str_append(buffer, "%02x", value[i*dst_size+j]);
+ }
+ else if(H5T_SGN_NONE == H5Tget_sign(native)) {
+ /*On SGI Altix(cobalt), wrong values were printed out with "value+i*dst_size"
+ *strangely, unless use another pointer "copy".*/
+ copy = value + i * dst_size;
+ h5tools_str_append(buffer, HSIZE_T_FORMAT, *((unsigned long long*)((void*)copy)));
+ }
+ else {
+ /*On SGI Altix(cobalt), wrong values were printed out with "value+i*dst_size"
+ *strangely, unless use another pointer "copy".*/
+ copy = value + i * dst_size;
+ h5tools_str_append(buffer, "%"H5_PRINTF_LL_WIDTH"d",
+ *((long long*)((void*)copy)));
+ }
}
+
+ /* Release resources */
+ for(i = 0; i < (unsigned)nmembs; i++)
+ HDfree(name[i]);
+ HDfree(name);
+ HDfree(value);
}
+ else
+ h5tools_str_append(buffer, "\n%*s <empty>", ind+4, "");
+
+ h5tools_str_append(buffer, "\n%*s}", ind, "");
- /* Release resources */
- for (i=0; i<nmembs; i++) HDfree(name[i]);
- HDfree(name);
- HDfree(value);
H5Tclose(super);
- if (0==nmembs) h5tools_str_append(buffer, "\n%*s <empty>", ind+4, "");
- h5tools_str_append(buffer, "\n%*s}", ind, "");
return TRUE;
}
@@ -1189,10 +1210,11 @@ print_array_type(h5tools_str_t *buffer, hid_t type, int ind)
int ndims, i;
hsize_t *dims=NULL;
- if (H5T_ARRAY!=H5Tget_class(type)) return FALSE;
+ if (H5T_ARRAY!=H5Tget_class(type))
+ return FALSE;
ndims = H5Tget_array_ndims(type);
if (ndims) {
- dims = (hsize_t *)HDmalloc(ndims*sizeof(dims[0]));
+ dims = (hsize_t *)HDmalloc((unsigned)ndims * sizeof(dims[0]));
H5Tget_array_dims2(type, dims);
/* Print dimensions */
@@ -1202,9 +1224,8 @@ print_array_type(h5tools_str_t *buffer, hid_t type, int ind)
HDfree(dims);
}
- else {
+ else
h5tools_str_append(buffer, " [SCALAR]\n", rawoutstream);
- }
/* Print parent type */
@@ -1390,7 +1411,7 @@ dump_dataset_values(hid_t dset)
outputformat.line_per_line = 1;
}
else {
- outputformat.line_ncols = width_g;
+ outputformat.line_ncols = (unsigned)width_g;
}
if (label_g) outputformat.cmpd_name = "%s=";
outputformat.line_pre = " %s ";
@@ -1412,9 +1433,9 @@ dump_dataset_values(hid_t dset)
}
outputformat.arr_linebreak = 0;
/* Floating point types should display full precision */
- sprintf(fmt_float, "%%1.%dg", FLT_DIG);
+ HDsnprintf(fmt_float, sizeof(fmt_float), "%%1.%dg", FLT_DIG);
outputformat.fmt_float = fmt_float;
- sprintf(fmt_double, "%%1.%dg", DBL_DIG);
+ HDsnprintf(fmt_double, sizeof(fmt_double), "%%1.%dg", DBL_DIG);
outputformat.fmt_double = fmt_double;
if (hexdump_g) {
@@ -1428,8 +1449,7 @@ dump_dataset_values(hid_t dset)
outputformat.ascii = TRUE;
outputformat.elmt_suf1 = "";
outputformat.elmt_suf2 = "";
- strcpy(string_prefix, outputformat.line_pre);
- strcat(string_prefix, "\"");
+ HDsnprintf(string_prefix, sizeof(string_prefix), "%s\"", outputformat.line_pre);
outputformat.line_pre = string_prefix;
outputformat.line_suf = "\"";
}
@@ -1487,7 +1507,6 @@ list_attr(hid_t obj, const char *attr_name, const H5A_info_t UNUSED *ainfo,
size_t need;
int ndims;
int i;
- int n;
void *buf;
H5S_class_t space_type;
hsize_t curr_pos = 0; /* total data element position */
@@ -1502,7 +1521,7 @@ list_attr(hid_t obj, const char *attr_name, const H5A_info_t UNUSED *ainfo,
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, " Attribute: ");
- n = print_string(&buffer, attr_name, TRUE);
+ print_string(&buffer, attr_name, TRUE);
if((attr = H5Aopen(obj, attr_name, H5P_DEFAULT))) {
space = H5Aget_space(attr);
@@ -1535,6 +1554,7 @@ list_attr(hid_t obj, const char *attr_name, const H5A_info_t UNUSED *ainfo,
h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0);
break;
+ case H5S_NO_CLASS:
default:
/* Unknown dataspace type */
h5tools_str_append(&buffer, " unknown\n");
@@ -1570,7 +1590,7 @@ list_attr(hid_t obj, const char *attr_name, const H5A_info_t UNUSED *ainfo,
outputformat.str_repeat = 8;
}
- outputformat.line_ncols = width_g;
+ outputformat.line_ncols = (unsigned)width_g;
if(label_g)
outputformat.cmpd_name = "%s=";
if(string_g && 1==H5Tget_size(type) &&
@@ -1777,7 +1797,7 @@ dataset_list2(hid_t dset, const char UNUSED *name)
}
/* Print total raw storage size */
- total = H5Sget_simple_extent_npoints(space) * H5Tget_size(type);
+ total = (hsize_t)H5Sget_simple_extent_npoints(space) * H5Tget_size(type);
used = H5Dget_storage_size(dset);
tclass = H5Tget_class(type);
h5tools_str_append(&buffer, " %-10s ", "Storage:");
@@ -1795,13 +1815,24 @@ dataset_list2(hid_t dset, const char UNUSED *name)
}
break;
+ case H5T_NO_CLASS:
+ case H5T_INTEGER:
+ case H5T_FLOAT:
+ case H5T_TIME:
+ case H5T_STRING:
+ case H5T_BITFIELD:
+ case H5T_OPAQUE:
+ case H5T_COMPOUND:
+ case H5T_ENUM:
+ case H5T_ARRAY:
+ case H5T_NCLASSES:
default:
h5tools_str_append(&buffer, HSIZE_T_FORMAT" logical byte%s, "HSIZE_T_FORMAT" allocated byte%s",
total, 1==total?"":"s",
used, 1==used?"":"s");
if (used>0)
{
- utilization = (total*100.0)/used;
+ utilization = ((double)total * (double)100.0f) / (double)used;
h5tools_str_append(&buffer, ", %1.2f%% utilization", utilization);
}
}
@@ -1811,7 +1842,8 @@ dataset_list2(hid_t dset, const char UNUSED *name)
/* Print information about external strorage */
if((nf = H5Pget_external_count(dcpl)) > 0) {
for(i = 0, max_len = 0; i < nf; i++) {
- H5Pget_external(dcpl, (unsigned)i, sizeof(f_name), f_name, NULL, NULL);
+ if(H5Pget_external(dcpl, (unsigned)i, sizeof(f_name), f_name, NULL, NULL) < 0)
+ continue;
n = print_string(NULL, f_name, TRUE);
max_len = MAX(max_len, n);
} /* end for */
@@ -1857,7 +1889,7 @@ dataset_list2(hid_t dset, const char UNUSED *name)
filt_id = H5Pget_filter2(dcpl, (unsigned)i, &filt_flags, &cd_nelmts,
cd_values, sizeof(f_name), f_name, NULL);
f_name[sizeof(f_name) - 1] = '\0';
- sprintf(s, "Filter-%d:", i);
+ HDsnprintf(s, sizeof(s), "Filter-%d:", i);
h5tools_str_append(&buffer, " %-10s %s-%u %s {", s,
(f_name[0] ? f_name : "method"),
(unsigned)filt_id,
@@ -2054,7 +2086,7 @@ list_obj(const char *name, const H5O_info_t *oinfo, const char *first_seen, void
if (cmt_bufsize > 0) {
comment = (char *)HDmalloc((size_t)cmt_bufsize + 1); /* new_size including null terminator */
if(comment) {
- cmt_bufsize = H5Oget_comment(obj, comment, cmt_bufsize);
+ cmt_bufsize = H5Oget_comment(obj, comment, (size_t)cmt_bufsize);
if(cmt_bufsize > 0) {
comment[cmt_bufsize] = 0;
h5tools_str_reset(&buffer);
@@ -2267,6 +2299,9 @@ list_lnk(const char *name, const H5L_info_t *linfo, void *_iter)
}
break;
+ case H5L_TYPE_ERROR:
+ case H5L_TYPE_HARD:
+ case H5L_TYPE_MAX:
default:
h5tools_str_append(&buffer, "UD Link {cannot follow UD links}\n");
h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0);
@@ -2457,7 +2492,7 @@ get_width(void)
static hbool_t
is_valid_args(void)
{
- herr_t ret = TRUE;
+ hbool_t ret = TRUE;
if(recursive_g && grp_literal_g)
{
diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c
index 9d73d2b..a9f2433 100644
--- a/tools/lib/h5diff.c
+++ b/tools/lib/h5diff.c
@@ -241,7 +241,6 @@ static int is_exclude_path (char * path, h5trav_type_t type, diff_opt_t *options
struct exclude_path_list * exclude_path_ptr;
int ret_cmp;
int ret = 0;
- int len_grp;
/* check if exclude path option is given */
if (!options->exclude_path)
@@ -260,6 +259,8 @@ static int is_exclude_path (char * path, h5trav_type_t type, diff_opt_t *options
HDstrlen(exclude_path_ptr->obj_path));
if (ret_cmp == 0) /* found matching members */
{
+ size_t len_grp;
+
/* check if given path belong to an excluding group, if so
* exclude it as well.
* This verifies if “/grp1/dset1” is only under “/grp1”, but
@@ -338,7 +339,6 @@ static void free_exclude_path_list(diff_opt_t *options)
*------------------------------------------------------------------------*/
static void build_match_list (const char *objname1, trav_info_t *info1, const char *objname2, trav_info_t *info2, trav_table_t ** table_out, diff_opt_t *options)
{
- unsigned i;
size_t curr1 = 0;
size_t curr2 = 0;
unsigned infile[2];
@@ -346,8 +346,8 @@ static void build_match_list (const char *objname1, trav_info_t *info1, const ch
char * path2_lp;
h5trav_type_t type1_l;
h5trav_type_t type2_l;
- int path1_offset = 0;
- int path2_offset = 0;
+ size_t path1_offset = 0;
+ size_t path2_offset = 0;
int cmp;
trav_table_t *table;
size_t idx;
@@ -614,8 +614,8 @@ hsize_t h5diff(const char *fname1,
int i;
int l_ret1 = -1;
int l_ret2 = -1;
- const char * obj1fullname = NULL;
- const char * obj2fullname = NULL;
+ char * obj1fullname = NULL;
+ char * obj2fullname = NULL;
int both_objs_grp = 0;
/* init to group type */
h5trav_type_t obj1type = H5TRAV_TYPE_GROUP;
@@ -697,25 +697,25 @@ hsize_t h5diff(const char *fname1,
/* make the given object1 fullpath, start with "/" */
if (HDstrncmp(objname1, "/", 1))
{
- HDstrcpy((char *)obj1fullname, "/");
- HDstrcat((char *)obj1fullname, objname1);
+ HDstrcpy(obj1fullname, "/");
+ HDstrcat(obj1fullname, objname1);
}
else
- HDstrcpy((char *)obj1fullname, objname1);
+ HDstrcpy(obj1fullname, objname1);
/* make the given object2 fullpath, start with "/" */
if (HDstrncmp(objname2, "/", 1))
{
- HDstrcpy((char *)obj2fullname, "/");
- HDstrcat((char *)obj2fullname, objname2);
+ HDstrcpy(obj2fullname, "/");
+ HDstrcat(obj2fullname, objname2);
}
else
- HDstrcpy((char *)obj2fullname, objname2);
+ HDstrcpy(obj2fullname, objname2);
/*----------------------------------------------------------
* check if obj1 is root, group, single object or symlink
*/
- if(!HDstrcmp((char *)obj1fullname, "/"))
+ if(!HDstrcmp(obj1fullname, "/"))
{
obj1type = H5TRAV_TYPE_GROUP;
}
@@ -833,10 +833,10 @@ hsize_t h5diff(const char *fname1,
{
/* set root group */
obj1fullname = (char*)HDcalloc(2, sizeof(char));
- HDstrcat((char *)obj1fullname, "/");
+ HDstrcat(obj1fullname, "/");
obj1type = H5TRAV_TYPE_GROUP;
obj2fullname = (char*)HDcalloc(2, sizeof(char));
- HDstrcat((char *)obj2fullname, "/");
+ HDstrcat(obj2fullname, "/");
obj2type = H5TRAV_TYPE_GROUP;
}
@@ -1061,9 +1061,9 @@ out:
/* free buffers */
if (obj1fullname)
- HDfree((char *)obj1fullname);
+ HDfree(obj1fullname);
if (obj2fullname)
- HDfree((char *)obj2fullname);
+ HDfree(obj2fullname);
/* free link info buffer */
if (trg_linfo1.trg_path)
diff --git a/tools/lib/h5diff.h b/tools/lib/h5diff.h
index 2530805..9e1c8bb 100644
--- a/tools/lib/h5diff.h
+++ b/tools/lib/h5diff.h
@@ -196,210 +196,5 @@ int print_objname(diff_opt_t *options, hsize_t nfound);
void do_print_objname (const char *OBJ, const char *path1, const char *path2, diff_opt_t * opts);
void do_print_attrname (const char *attr, const char *path1, const char *path2);
-
-/*-------------------------------------------------------------------------
- * XCAO, 11/10/2010
- * added to improve performance for compound datasets
- */
-typedef struct mcomp_t
-{
- int n; /* number of members */
- hid_t *ids; /* member type id */
- unsigned char *flags;
- size_t *offsets;
- struct mcomp_t **m; /* members */
-}mcomp_t;
-
-hsize_t diff_datum(void *_mem1,
- void *_mem2,
- hid_t m_type,
- hsize_t i,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- hid_t container1_id,
- hid_t container2_id, /*where the reference came from*/
- int *ph, /*print header */
- mcomp_t *members); /*compound members */
-
-
-
-hsize_t diff_float(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph);
-
-hsize_t diff_double(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph);
-
-#if H5_SIZEOF_LONG_DOUBLE !=0
-
-hsize_t diff_ldouble(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph);
-
-#endif
-
-hsize_t diff_schar(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph);
-
-hsize_t diff_uchar(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph);
-
-hsize_t diff_short(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph);
-
-hsize_t diff_ushort(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph);
-
-hsize_t diff_int(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph);
-
-hsize_t diff_uint(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph);
-
-hsize_t diff_long(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph);
-
-hsize_t diff_ulong(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph);
-
-hsize_t diff_llong(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph);
-
-hsize_t diff_ullong(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph);
-
#endif /* H5DIFF_H__ */
diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c
index 57a5599..e5b8f79 100644
--- a/tools/lib/h5diff_array.c
+++ b/tools/lib/h5diff_array.c
@@ -36,7 +36,6 @@
#endif
#define I_FORMAT "%-15d %-15d %-15d\n"
-#define C_FORMAT "%-16c %-17c\n"
#define S_FORMAT "%-16s %-17s\n"
#define UI_FORMAT "%-15u %-15u %-15u\n"
#define LI_FORMAT "%-15ld %-15ld %-15ld\n"
@@ -101,43 +100,44 @@
*-------------------------------------------------------------------------
*/
-static int not_comparable;
+static hbool_t not_comparable;
-#define PER(A,B) { per=-1; \
- not_comparable=0; \
- both_zero=0; \
- if (A==0 && B==0) \
- both_zero=1; \
- if (A!=0) \
- per = (double)ABS( ( double)(B-A) / (double)A ); \
+#define PER(A,B) { \
+ per = -1; \
+ not_comparable = FALSE; \
+ both_zero = FALSE; \
+ if(FP_ZERO == fpclassify(A) && FP_ZERO == fpclassify(B)) \
+ both_zero = TRUE; \
+ if(FP_ZERO != fpclassify(A)) \
+ per = (double)ABS((double)(B - A) / (double)A); \
else \
- not_comparable=1; \
+ not_comparable = TRUE; \
}
-#define PER_UNSIGN(TYPE,A,B) { per=-1; \
- not_comparable=0; \
- both_zero=0; \
- if (A==0 && B==0) \
- both_zero=1; \
- if (A!=0) \
- per = ABS((double)((TYPE)(B-A)) / (double)A) ; \
+#define PER_UNSIGN(TYPE,A,B) { \
+ per = -1; \
+ not_comparable = FALSE; \
+ both_zero = FALSE; \
+ if(A == 0 && B == 0) \
+ both_zero = TRUE; \
+ if(A != 0) \
+ per = ABS((double)((TYPE)(B - A)) / (double)A) ; \
else \
- not_comparable=1; \
+ not_comparable = TRUE; \
}
-#define BOTH_ZERO(A,B) { both_zero=0; \
- if (A==0 && B==0) \
- both_zero=1; \
-}
+# define PDIFF(a,b) ( (b>a) ? (b-a) : (a-b))
-#define IS_ZERO(A) { is_zero=0; \
- if (A==0) \
- is_zero=1; \
-}
+typedef struct mcomp_t
+{
+ unsigned n; /* number of members */
+ hid_t *ids; /* member type id */
+ size_t *offsets;
+ struct mcomp_t **m; /* members */
+}mcomp_t;
-# define PDIFF(a,b) ( (b>a) ? (b-a) : (a-b))
/*-------------------------------------------------------------------------
* local prototypes
@@ -146,7 +146,7 @@ static int not_comparable;
static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id,hid_t region1_id, hid_t region2_id, diff_opt_t *options);
static hbool_t all_zero(const void *_mem, size_t size);
static int ull2float(unsigned long long ull_value, float *f_value);
-static hsize_t character_compare(unsigned char *mem1,unsigned char *mem2,hsize_t i,unsigned u,int rank,hsize_t *dims,hsize_t *acc,hsize_t *pos,diff_opt_t *options,const char *obj1,const char *obj2,int *ph);
+static hsize_t character_compare(char *mem1,char *mem2,hsize_t i,unsigned u,int rank,hsize_t *dims,hsize_t *acc,hsize_t *pos,diff_opt_t *options,const char *obj1,const char *obj2,int *ph);
static hsize_t character_compare_opt(unsigned char *mem1,unsigned char *mem2,hsize_t i,int rank,hsize_t *dims,hsize_t *acc,hsize_t *pos,diff_opt_t *options,const char *obj1,const char *obj2,int *ph);
static hbool_t equal_float(float value, float expected, diff_opt_t *options);
static hbool_t equal_double(double value, double expected, diff_opt_t *options);
@@ -157,6 +157,179 @@ static int print_data(diff_opt_t *options);
static void print_pos(int *ph,int pp,hsize_t curr_pos,hsize_t *acc,hsize_t *pos,int rank,hsize_t *dims,const char *obj1,const char *obj2 );
static void print_char_pos(int *ph,int pp,hsize_t curr_pos,unsigned u,hsize_t *acc,hsize_t *pos,int rank,hsize_t *dims,const char *obj1,const char *obj2 );
static void h5diff_print_char(char ch);
+static hsize_t diff_datum(void *_mem1,
+ void *_mem2,
+ hid_t m_type,
+ hsize_t i,
+ int rank,
+ hsize_t *dims,
+ hsize_t *acc,
+ hsize_t *pos,
+ diff_opt_t *options,
+ const char *obj1,
+ const char *obj2,
+ hid_t container1_id,
+ hid_t container2_id, /*where the reference came from*/
+ int *ph, /*print header */
+ mcomp_t *members); /*compound members */
+static hsize_t diff_float(unsigned char *mem1,
+ unsigned char *mem2,
+ hsize_t nelmts,
+ hsize_t hyper_start,
+ int rank,
+ hsize_t *dims,
+ hsize_t *acc,
+ hsize_t *pos,
+ diff_opt_t *options,
+ const char *obj1,
+ const char *obj2,
+ int *ph);
+static hsize_t diff_double(unsigned char *mem1,
+ unsigned char *mem2,
+ hsize_t nelmts,
+ hsize_t hyper_start,
+ int rank,
+ hsize_t *dims,
+ hsize_t *acc,
+ hsize_t *pos,
+ diff_opt_t *options,
+ const char *obj1,
+ const char *obj2,
+ int *ph);
+#if H5_SIZEOF_LONG_DOUBLE !=0
+static hsize_t diff_ldouble(unsigned char *mem1,
+ unsigned char *mem2,
+ hsize_t nelmts,
+ hsize_t hyper_start,
+ int rank,
+ hsize_t *dims,
+ hsize_t *acc,
+ hsize_t *pos,
+ diff_opt_t *options,
+ const char *obj1,
+ const char *obj2,
+ int *ph);
+#endif
+static hsize_t diff_schar(unsigned char *mem1,
+ unsigned char *mem2,
+ hsize_t nelmts,
+ hsize_t hyper_start,
+ int rank,
+ hsize_t *dims,
+ hsize_t *acc,
+ hsize_t *pos,
+ diff_opt_t *options,
+ const char *obj1,
+ const char *obj2,
+ int *ph);
+static hsize_t diff_uchar(unsigned char *mem1,
+ unsigned char *mem2,
+ hsize_t nelmts,
+ hsize_t hyper_start,
+ int rank,
+ hsize_t *dims,
+ hsize_t *acc,
+ hsize_t *pos,
+ diff_opt_t *options,
+ const char *obj1,
+ const char *obj2,
+ int *ph);
+static hsize_t diff_short(unsigned char *mem1,
+ unsigned char *mem2,
+ hsize_t nelmts,
+ hsize_t hyper_start,
+ int rank,
+ hsize_t *dims,
+ hsize_t *acc,
+ hsize_t *pos,
+ diff_opt_t *options,
+ const char *obj1,
+ const char *obj2,
+ int *ph);
+static hsize_t diff_ushort(unsigned char *mem1,
+ unsigned char *mem2,
+ hsize_t nelmts,
+ hsize_t hyper_start,
+ int rank,
+ hsize_t *dims,
+ hsize_t *acc,
+ hsize_t *pos,
+ diff_opt_t *options,
+ const char *obj1,
+ const char *obj2,
+ int *ph);
+static hsize_t diff_int(unsigned char *mem1,
+ unsigned char *mem2,
+ hsize_t nelmts,
+ hsize_t hyper_start,
+ int rank,
+ hsize_t *dims,
+ hsize_t *acc,
+ hsize_t *pos,
+ diff_opt_t *options,
+ const char *obj1,
+ const char *obj2,
+ int *ph);
+static hsize_t diff_uint(unsigned char *mem1,
+ unsigned char *mem2,
+ hsize_t nelmts,
+ hsize_t hyper_start,
+ int rank,
+ hsize_t *dims,
+ hsize_t *acc,
+ hsize_t *pos,
+ diff_opt_t *options,
+ const char *obj1,
+ const char *obj2,
+ int *ph);
+static hsize_t diff_long(unsigned char *mem1,
+ unsigned char *mem2,
+ hsize_t nelmts,
+ hsize_t hyper_start,
+ int rank,
+ hsize_t *dims,
+ hsize_t *acc,
+ hsize_t *pos,
+ diff_opt_t *options,
+ const char *obj1,
+ const char *obj2,
+ int *ph);
+static hsize_t diff_ulong(unsigned char *mem1,
+ unsigned char *mem2,
+ hsize_t nelmts,
+ hsize_t hyper_start,
+ int rank,
+ hsize_t *dims,
+ hsize_t *acc,
+ hsize_t *pos,
+ diff_opt_t *options,
+ const char *obj1,
+ const char *obj2,
+ int *ph);
+static hsize_t diff_llong(unsigned char *mem1,
+ unsigned char *mem2,
+ hsize_t nelmts,
+ hsize_t hyper_start,
+ int rank,
+ hsize_t *dims,
+ hsize_t *acc,
+ hsize_t *pos,
+ diff_opt_t *options,
+ const char *obj1,
+ const char *obj2,
+ int *ph);
+static hsize_t diff_ullong(unsigned char *mem1,
+ unsigned char *mem2,
+ hsize_t nelmts,
+ hsize_t hyper_start,
+ int rank,
+ hsize_t *dims,
+ hsize_t *acc,
+ hsize_t *pos,
+ diff_opt_t *options,
+ const char *obj1,
+ const char *obj2,
+ int *ph);
/*-------------------------------------------------------------------------
@@ -180,7 +353,7 @@ typedef enum dtype_t
} dtype_t;
#endif
-static int my_isnan(dtype_t type, void *val);
+static hbool_t my_isnan(dtype_t type, void *val);
/*-------------------------------------------------------------------------
* XCAO, 11/10/2010
@@ -259,6 +432,9 @@ hsize_t diff_array( void *_mem1,
switch (type_class)
{
+ case H5T_NO_CLASS:
+ case H5T_TIME:
+ case H5T_NCLASSES:
default:
HDassert(0);
break;
@@ -385,21 +561,21 @@ hsize_t diff_array( void *_mem1,
* Dereference the object and compare the type (basic object type).
*-------------------------------------------------------------------------
*/
-hsize_t diff_datum(void *_mem1,
- void *_mem2,
- hid_t m_type,
- hsize_t i,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- hid_t container1_id,
- hid_t container2_id, /*where the reference came from*/
- int *ph, /*print header */
- mcomp_t *members) /*compound members */
+static hsize_t diff_datum(void *_mem1,
+ void *_mem2,
+ hid_t m_type,
+ hsize_t i,
+ int rank,
+ hsize_t *dims,
+ hsize_t *acc,
+ hsize_t *pos,
+ diff_opt_t *options,
+ const char *obj1,
+ const char *obj2,
+ hid_t container1_id,
+ hid_t container2_id, /*where the reference came from*/
+ int *ph, /*print header */
+ mcomp_t *members) /*compound members */
{
unsigned char *mem1 = (unsigned char*)_mem1;
unsigned char *mem2 = (unsigned char*)_mem2;
@@ -409,19 +585,19 @@ hsize_t diff_datum(void *_mem1,
H5T_sign_t type_sign;
H5T_class_t type_class;
size_t offset;
- int nmembs;
- int j;
+ unsigned nmembs;
+ unsigned j;
hsize_t nelmts;
size_t size=0;
- int iszero1;
- int iszero2;
+ hbool_t iszero1;
+ hbool_t iszero2;
hid_t obj1_id;
hid_t obj2_id;
hsize_t nfound=0; /* differences found */
int ret=0; /* check return error */
float f1, f2;
double per;
- int both_zero;
+ hbool_t both_zero;
type_size = H5Tget_size( m_type );
type_class = H5Tget_class(m_type);
@@ -439,10 +615,10 @@ hsize_t diff_datum(void *_mem1,
switch (H5Tget_class(m_type))
{
- default:
- HDassert(0);
- break;
+ case H5T_NO_CLASS:
case H5T_TIME:
+ case H5T_NCLASSES:
+ default:
HDassert(0);
break;
@@ -461,8 +637,8 @@ hsize_t diff_datum(void *_mem1,
memb_type = members->ids[j];
nfound+=diff_datum(
- mem1+offset,
- mem2+offset,
+ mem1 + offset,
+ mem2 + offset,
memb_type,
i,
rank,
@@ -505,10 +681,10 @@ hsize_t diff_datum(void *_mem1,
else
{
/* Get pointer to first string */
- s1 = mem1;
+ s1 = (char *)mem1;
size1 = H5Tget_size(m_type);
/* Get pointer to second string */
- s2 = mem2;
+ s2 = (char *)mem2;
size2 = H5Tget_size(m_type);
}
@@ -631,11 +807,11 @@ hsize_t diff_datum(void *_mem1,
*/
err1 = H5Tenum_nameof(m_type, mem1, enum_name1, sizeof enum_name1);
if(err1 < 0)
- strcpy(enum_name1, "**INVALID VALUE**");
+ HDsnprintf(enum_name1, sizeof(enum_name1), "**INVALID VALUE**");
err2 = H5Tenum_nameof(m_type, mem2, enum_name2, sizeof enum_name2);
if(err2 < 0)
- strcpy(enum_name2, "**INVALID VALUE**");
+ HDsnprintf(enum_name2, sizeof(enum_name2), "**INVALID VALUE**");
if(err1 < 0 || err2 < 0)
{
@@ -699,7 +875,8 @@ hsize_t diff_datum(void *_mem1,
{
hsize_t adims[H5S_MAX_RANK];
- hsize_t ndims;
+ int ndims;
+
/* get the array's base datatype for each element */
memb_type = H5Tget_super(m_type);
size = H5Tget_size(memb_type);
@@ -708,7 +885,7 @@ hsize_t diff_datum(void *_mem1,
HDassert(ndims >= 1 && ndims <= H5S_MAX_RANK);
/* calculate the number of array elements */
- for (u = 0, nelmts = 1; u <ndims; u++)
+ for (u = 0, nelmts = 1; u < (unsigned)ndims; u++)
nelmts *= adims[u];
for (u = 0; u < nelmts; u++)
{
@@ -858,22 +1035,22 @@ hsize_t diff_datum(void *_mem1,
/* get the number of sequence elements */
nelmts = ((hvl_t *)mem1)->len;
- for (j = 0; j < (int)nelmts; j++)
- nfound+=diff_datum(
- ((char *)(((hvl_t *)mem1)->p)) + j * size,
- ((char *)(((hvl_t *)mem2)->p)) + j * size, /* offset */
- memb_type,
- i, /* index position */
- rank,
- dims,
- acc,
- pos,
- options,
- obj1,
- obj2,
- container1_id,
- container2_id,
- ph, members);
+ for (j = 0; j < nelmts; j++)
+ nfound += diff_datum(
+ ((char *)(((hvl_t *)mem1)->p)) + j * size,
+ ((char *)(((hvl_t *)mem2)->p)) + j * size, /* offset */
+ memb_type,
+ i, /* index position */
+ rank,
+ dims,
+ acc,
+ pos,
+ options,
+ obj1,
+ obj2,
+ container1_id,
+ container2_id,
+ ph, members);
H5Tclose(memb_type);
@@ -1418,7 +1595,7 @@ hsize_t diff_datum(void *_mem1,
{
print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint));
+ parallel_print(UI_FORMAT_P_NOTCOMP,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint));
}
nfound++;
}
@@ -1431,7 +1608,7 @@ hsize_t diff_datum(void *_mem1,
{
print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint),per);
+ parallel_print(UI_FORMAT_P,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint),per);
}
nfound++;
}
@@ -1447,7 +1624,7 @@ hsize_t diff_datum(void *_mem1,
{
print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint));
+ parallel_print(UI_FORMAT_P_NOTCOMP,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint));
}
nfound++;
}
@@ -1460,7 +1637,7 @@ hsize_t diff_datum(void *_mem1,
{
print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint),per);
+ parallel_print(UI_FORMAT_P,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint),per);
}
nfound++;
}
@@ -1901,8 +2078,8 @@ hsize_t diff_datum(void *_mem1,
{
float temp1_float;
float temp2_float;
- int isnan1=0;
- int isnan2=0;
+ hbool_t isnan1 = FALSE;
+ hbool_t isnan2 = FALSE;
HDassert(type_size==sizeof(float));
@@ -1930,29 +2107,29 @@ hsize_t diff_datum(void *_mem1,
}
/* both not NaN, do the comparison */
- if ( isnan1==0 && isnan2==0)
+ if ( !isnan1 && !isnan2)
{
- if (ABS(temp1_float-temp2_float) > options->delta)
+ if (ABS(temp1_float-temp2_float) > (float)options->delta)
{
if ( print_data(options) )
{
print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_float,temp2_float,ABS(temp1_float-temp2_float));
+ parallel_print(F_FORMAT,(double)temp1_float,(double)temp2_float, (double)ABS(temp1_float - temp2_float));
}
nfound++;
}
}
/* only one is NaN, assume difference */
- else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2))
{
if ( print_data(options) )
{
print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_float,temp2_float,ABS(temp1_float-temp2_float));
+ parallel_print(F_FORMAT, (double)temp1_float, (double)temp2_float, (double)ABS(temp1_float - temp2_float));
}
nfound++;
@@ -1976,7 +2153,7 @@ hsize_t diff_datum(void *_mem1,
}
/* both not NaN, do the comparison */
- if ( isnan1==0 && isnan2==0)
+ if ( !isnan1 && !isnan2)
{
PER(temp1_float,temp2_float);
@@ -1987,35 +2164,35 @@ hsize_t diff_datum(void *_mem1,
{
print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
parallel_print(SPACES);
- parallel_print(F_FORMAT_P_NOTCOMP,temp1_float,temp2_float,ABS(temp1_float-temp2_float));
+ parallel_print(F_FORMAT_P_NOTCOMP, (double)temp1_float, (double)temp2_float, (double)ABS(temp1_float - temp2_float));
}
nfound++;
}
else
- if ( per > options->percent && ABS(temp1_float-temp2_float) > options->delta )
+ if ( per > options->percent && (double)ABS(temp1_float-temp2_float) > options->delta )
{
if ( print_data(options) )
{
print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
parallel_print(SPACES);
- parallel_print(F_FORMAT_P,temp1_float,temp2_float,
- ABS(temp1_float-temp2_float),
- ABS(1-temp2_float/temp1_float));
+ parallel_print(F_FORMAT_P, (double)temp1_float, (double)temp2_float,
+ (double)ABS(temp1_float - temp2_float),
+ (double)ABS(1 - temp2_float / temp1_float));
}
nfound++;
}
}
/* only one is NaN, assume difference */
- else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2))
{
if ( print_data(options) )
{
print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_float,temp2_float,ABS(temp1_float-temp2_float));
+ parallel_print(F_FORMAT, (double)temp1_float, (double)temp2_float, (double)ABS(temp1_float - temp2_float));
}
nfound++;
@@ -2041,7 +2218,7 @@ hsize_t diff_datum(void *_mem1,
}
/* both not NaN, do the comparison */
- if ( isnan1==0 && isnan2==0)
+ if ( !isnan1 && !isnan2)
{
PER(temp1_float,temp2_float);
@@ -2052,8 +2229,8 @@ hsize_t diff_datum(void *_mem1,
{
print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
parallel_print(SPACES);
- parallel_print(F_FORMAT_P_NOTCOMP,temp1_float,temp2_float,
- ABS(temp1_float-temp2_float));
+ parallel_print(F_FORMAT_P_NOTCOMP, (double)temp1_float, (double)temp2_float,
+ (double)ABS(temp1_float - temp2_float));
}
nfound++;
}
@@ -2066,22 +2243,22 @@ hsize_t diff_datum(void *_mem1,
{
print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
parallel_print(SPACES);
- parallel_print(F_FORMAT_P,temp1_float,temp2_float,
- ABS(temp1_float-temp2_float),
- ABS(1-temp2_float/temp1_float));
+ parallel_print(F_FORMAT_P, (double)temp1_float, (double)temp2_float,
+ (double)ABS(temp1_float - temp2_float),
+ (double)ABS(1 - temp2_float / temp1_float));
}
nfound++;
}
}
/* only one is NaN, assume difference */
- else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2))
{
if ( print_data(options) )
{
print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_float,temp2_float,ABS(temp1_float-temp2_float));
+ parallel_print(F_FORMAT, (double)temp1_float, (double)temp2_float, (double)ABS(temp1_float - temp2_float));
}
nfound++;
@@ -2099,7 +2276,7 @@ hsize_t diff_datum(void *_mem1,
{
print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_float,temp2_float,ABS(temp1_float-temp2_float));
+ parallel_print(F_FORMAT, (double)temp1_float, (double)temp2_float, (double)ABS(temp1_float - temp2_float));
}
nfound++;
}
@@ -2114,8 +2291,8 @@ hsize_t diff_datum(void *_mem1,
{
double temp1_double;
double temp2_double;
- int isnan1=0;
- int isnan2=0;
+ hbool_t isnan1 = FALSE;
+ hbool_t isnan2 = FALSE;
HDassert(type_size==sizeof(double));
@@ -2141,7 +2318,7 @@ hsize_t diff_datum(void *_mem1,
}
/* both not NaN, do the comparison */
- if ( isnan1==0 && isnan2==0)
+ if ( !isnan1 && !isnan2)
{
if (ABS(temp1_double-temp2_double) > options->delta)
@@ -2157,7 +2334,7 @@ hsize_t diff_datum(void *_mem1,
}
/* only one is NaN, assume difference */
- else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2))
{
if ( print_data(options) )
{
@@ -2188,7 +2365,7 @@ hsize_t diff_datum(void *_mem1,
}
/* both not NaN, do the comparison */
- if ( isnan1==0 && isnan2==0)
+ if ( !isnan1 && !isnan2)
{
PER(temp1_double,temp2_double);
@@ -2222,7 +2399,7 @@ hsize_t diff_datum(void *_mem1,
}
/* only one is NaN, assume difference */
- else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2))
{
if ( print_data(options) )
{
@@ -2253,7 +2430,7 @@ hsize_t diff_datum(void *_mem1,
}
/* both not NaN, do the comparison */
- if ( isnan1==0 && isnan2==0)
+ if ( !isnan1 && !isnan2)
{
PER(temp1_double,temp2_double);
@@ -2288,7 +2465,7 @@ hsize_t diff_datum(void *_mem1,
}
/* only one is NaN, assume difference */
- else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2))
{
if ( print_data(options) )
{
@@ -2328,8 +2505,8 @@ hsize_t diff_datum(void *_mem1,
{
long double temp1_double;
long double temp2_double;
- int isnan1=0;
- int isnan2=0;
+ hbool_t isnan1 = FALSE;
+ hbool_t isnan2 = FALSE;
HDassert(type_size==sizeof(long double));
@@ -2357,7 +2534,7 @@ hsize_t diff_datum(void *_mem1,
}
/* both not NaN, do the comparison */
- if ( isnan1==0 && isnan2==0)
+ if ( !isnan1 && !isnan2)
{
if (ABS(temp1_double-temp2_double) > options->delta)
@@ -2372,7 +2549,7 @@ hsize_t diff_datum(void *_mem1,
}
} /* NaN */
/* only one is NaN, assume difference */
- else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2))
{
if ( print_data(options) )
{
@@ -2402,7 +2579,7 @@ hsize_t diff_datum(void *_mem1,
}
/* both not NaN, do the comparison */
- if ( isnan1==0 && isnan2==0)
+ if ( !isnan1 && !isnan2)
{
PER(temp1_double,temp2_double);
@@ -2436,7 +2613,7 @@ hsize_t diff_datum(void *_mem1,
} /* NaN */
/* only one is NaN, assume difference */
- else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2))
{
if ( print_data(options) )
{
@@ -2466,7 +2643,7 @@ hsize_t diff_datum(void *_mem1,
}
/* both not NaN, do the comparison */
- if ( isnan1==0 && isnan2==0)
+ if ( !isnan1 && !isnan2)
{
PER(temp1_double,temp2_double);
@@ -2501,7 +2678,7 @@ hsize_t diff_datum(void *_mem1,
} /* NaN */
/* only one is NaN, assume difference */
- else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2))
{
if ( print_data(options) )
{
@@ -2667,14 +2844,15 @@ hsize_t diff_region(hid_t obj1_id,
*-------------------------------------------------------------------------
*/
if(nblocks1 > 0) {
- alloc_size = nblocks1 * ndims1 * 2 * sizeof(ptdata1[0]);
+ HDassert(ndims1 > 0);
+ alloc_size = (hsize_t)nblocks1 * (unsigned)ndims1 * 2 * sizeof(ptdata1[0]);
HDassert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/
- ptdata1 = HDmalloc((size_t)alloc_size);
+ ptdata1 = (hsize_t *)HDmalloc((size_t)alloc_size);
H5_CHECK_OVERFLOW(nblocks1, hssize_t, hsize_t);
H5Sget_select_hyper_blocklist(region1_id, (hsize_t)0, (hsize_t)nblocks1, ptdata1);
- ptdata2 = HDmalloc((size_t)alloc_size);
+ ptdata2 = (hsize_t *)HDmalloc((size_t)alloc_size);
H5_CHECK_OVERFLOW(nblocks2, hssize_t, hsize_t);
H5Sget_select_hyper_blocklist(region2_id, (hsize_t)0, (hsize_t)nblocks2, ptdata2);
@@ -2722,14 +2900,14 @@ hsize_t diff_region(hid_t obj1_id,
*-------------------------------------------------------------------------
*/
if(npoints1 > 0) {
- alloc_size = npoints1 * ndims1 * sizeof(ptdata1[0]);
+ alloc_size = (hsize_t)npoints1 * (unsigned)ndims1 * sizeof(ptdata1[0]);
HDassert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/
- ptdata1 = HDmalloc((size_t)alloc_size);
+ ptdata1 = (hsize_t *)HDmalloc((size_t)alloc_size);
H5_CHECK_OVERFLOW(npoints1,hssize_t,hsize_t);
H5Sget_select_elem_pointlist(region1_id, (hsize_t)0, (hsize_t)npoints1, ptdata1);
- ptdata2 = HDmalloc((size_t)alloc_size);
+ ptdata2 = (hsize_t *)HDmalloc((size_t)alloc_size);
H5_CHECK_OVERFLOW(npoints1,hssize_t,hsize_t);
H5Sget_select_elem_pointlist(region2_id, (hsize_t)0, (hsize_t)npoints2, ptdata2);
@@ -2786,8 +2964,8 @@ hsize_t diff_region(hid_t obj1_id,
HDfree(ptdata2);
}
- nfound_b = nfound_b/ndims1;
- nfound_p = nfound_p/ndims1;
+ nfound_b = nfound_b / (unsigned)ndims1;
+ nfound_p = nfound_p / (unsigned)ndims1;
return (nfound_p + nfound_b);
}
@@ -2803,8 +2981,8 @@ hsize_t diff_region(hid_t obj1_id,
*/
static
-hsize_t character_compare(unsigned char *mem1,
- unsigned char *mem2,
+hsize_t character_compare(char *mem1,
+ char *mem2,
hsize_t i,
unsigned u,
int rank,
@@ -2817,8 +2995,8 @@ hsize_t character_compare(unsigned char *mem1,
int *ph)
{
hsize_t nfound=0; /* differences found */
- unsigned char temp1_uchar;
- unsigned char temp2_uchar;
+ char temp1_uchar;
+ char temp2_uchar;
HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char));
HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char));
@@ -2851,7 +3029,7 @@ hsize_t character_compare(unsigned char *mem1,
*-------------------------------------------------------------------------
*/
-hsize_t character_compare_opt(unsigned char *mem1,
+static hsize_t character_compare_opt(unsigned char *mem1,
unsigned char *mem2,
hsize_t i,
int rank,
@@ -2867,7 +3045,7 @@ hsize_t character_compare_opt(unsigned char *mem1,
unsigned char temp1_uchar;
unsigned char temp2_uchar;
double per;
- int both_zero;
+ hbool_t both_zero;
HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char));
HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char));
@@ -2942,7 +3120,7 @@ hsize_t character_compare_opt(unsigned char *mem1,
*
*-------------------------------------------------------------------------
*/
-hsize_t diff_float(unsigned char *mem1,
+static hsize_t diff_float(unsigned char *mem1,
unsigned char *mem2,
hsize_t nelmts,
hsize_t hyper_start,
@@ -2961,9 +3139,9 @@ hsize_t diff_float(unsigned char *mem1,
float temp2_float;
hsize_t i;
double per;
- int both_zero;
- int isnan1=0;
- int isnan2=0;
+ hbool_t both_zero;
+ hbool_t isnan1 = FALSE;
+ hbool_t isnan2 = FALSE;
/*-------------------------------------------------------------------------
@@ -2989,27 +3167,27 @@ hsize_t diff_float(unsigned char *mem1,
}
/* both not NaN, do the comparison */
- if ( isnan1==0 && isnan2==0)
+ if ( !isnan1 && !isnan2)
{
- if (ABS(temp1_float-temp2_float) > options->delta)
+ if ((double)ABS(temp1_float-temp2_float) > options->delta)
{
if ( print_data(options) )
{
print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_float,temp2_float,ABS(temp1_float-temp2_float));
+ parallel_print(F_FORMAT, (double)temp1_float, (double)temp2_float, (double)ABS(temp1_float - temp2_float));
}
nfound++;
}
}
/* only one is NaN, assume difference */
- else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2))
{
if ( print_data(options) )
{
print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_float,temp2_float,ABS(temp1_float-temp2_float));
+ parallel_print(F_FORMAT, (double)temp1_float, (double)temp2_float, (double)ABS(temp1_float - temp2_float));
}
nfound++;
@@ -3042,7 +3220,7 @@ hsize_t diff_float(unsigned char *mem1,
isnan2 = my_isnan(FLT_FLOAT,&temp2_float);
}
/* both not NaN, do the comparison */
- if ( isnan1==0 && isnan2==0)
+ if ( (!isnan1 && !isnan2))
{
PER(temp1_float,temp2_float);
@@ -3053,8 +3231,8 @@ hsize_t diff_float(unsigned char *mem1,
{
print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
parallel_print(SPACES);
- parallel_print(F_FORMAT_P_NOTCOMP,temp1_float,temp2_float,
- ABS(temp1_float-temp2_float));
+ parallel_print(F_FORMAT_P_NOTCOMP, (double)temp1_float, (double)temp2_float,
+ (double)ABS(temp1_float - temp2_float));
}
nfound++;
}
@@ -3067,21 +3245,21 @@ hsize_t diff_float(unsigned char *mem1,
{
print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
parallel_print(SPACES);
- parallel_print(F_FORMAT_P,temp1_float,temp2_float,
- ABS(temp1_float-temp2_float),
- ABS(1-temp2_float/temp1_float));
+ parallel_print(F_FORMAT_P, (double)temp1_float, (double)temp2_float,
+ (double)ABS(temp1_float - temp2_float),
+ (double)ABS(1 - temp2_float / temp1_float));
}
nfound++;
}
}
/* only one is NaN, assume difference */
- else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2))
{
if ( print_data(options) )
{
print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_float,temp2_float,ABS(temp1_float-temp2_float));
+ parallel_print(F_FORMAT, (double)temp1_float, (double)temp2_float, (double)ABS(temp1_float - temp2_float));
}
nfound++;
@@ -3116,7 +3294,7 @@ hsize_t diff_float(unsigned char *mem1,
}
/* both not NaN, do the comparison */
- if ( isnan1==0 && isnan2==0)
+ if ( !isnan1 && !isnan2)
{
PER(temp1_float,temp2_float);
@@ -3127,36 +3305,36 @@ hsize_t diff_float(unsigned char *mem1,
{
print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
parallel_print(SPACES);
- parallel_print(F_FORMAT_P_NOTCOMP,temp1_float,temp2_float,
- ABS(temp1_float-temp2_float));
+ parallel_print(F_FORMAT_P_NOTCOMP, (double)temp1_float, (double)temp2_float,
+ (double)ABS(temp1_float - temp2_float));
}
nfound++;
}
else
- if ( per > options->percent && ABS(temp1_float-temp2_float) > options->delta )
+ if ( per > options->percent && (double)ABS(temp1_float - temp2_float) > options->delta )
{
if ( print_data(options) )
{
print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
parallel_print(SPACES);
- parallel_print(F_FORMAT_P,temp1_float,temp2_float,
- ABS(temp1_float-temp2_float),
- ABS(1-temp2_float/temp1_float));
+ parallel_print(F_FORMAT_P, (double)temp1_float, (double)temp2_float,
+ (double)ABS(temp1_float - temp2_float),
+ (double)ABS(1 - temp2_float / temp1_float));
}
nfound++;
}
}
/* only one is NaN, assume difference */
- else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2))
{
if ( print_data(options) )
{
print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_float,temp2_float,ABS(temp1_float-temp2_float));
+ parallel_print(F_FORMAT, (double)temp1_float, (double)temp2_float, (double)ABS(temp1_float - temp2_float));
}
nfound++;
@@ -3185,7 +3363,7 @@ hsize_t diff_float(unsigned char *mem1,
{
print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_float,temp2_float,ABS(temp1_float-temp2_float));
+ parallel_print(F_FORMAT, (double)temp1_float, (double)temp2_float, (double)ABS(temp1_float - temp2_float));
}
nfound++;
}
@@ -3216,7 +3394,7 @@ hsize_t diff_float(unsigned char *mem1,
*
*-------------------------------------------------------------------------
*/
-hsize_t diff_double(unsigned char *mem1,
+static hsize_t diff_double(unsigned char *mem1,
unsigned char *mem2,
hsize_t nelmts,
hsize_t hyper_start,
@@ -3235,9 +3413,9 @@ hsize_t diff_double(unsigned char *mem1,
double temp2_double;
hsize_t i;
double per;
- int both_zero;
- int isnan1=0;
- int isnan2=0;
+ hbool_t both_zero;
+ hbool_t isnan1 = FALSE;
+ hbool_t isnan2 = FALSE;
/*-------------------------------------------------------------------------
* -d and !-p
@@ -3262,7 +3440,7 @@ hsize_t diff_double(unsigned char *mem1,
}
/* both not NaN, do the comparison */
- if ( isnan1==0 && isnan2==0)
+ if ( !isnan1 && !isnan2)
{
if (ABS(temp1_double-temp2_double) > options->delta)
{
@@ -3276,7 +3454,7 @@ hsize_t diff_double(unsigned char *mem1,
}
}
/* only one is NaN, assume difference */
- else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2))
{
if ( print_data(options) )
{
@@ -3315,7 +3493,7 @@ hsize_t diff_double(unsigned char *mem1,
isnan2 = my_isnan(FLT_DOUBLE,&temp2_double);
}
/* both not NaN, do the comparison */
- if ( isnan1==0 && isnan2==0)
+ if ( !isnan1 && !isnan2)
{
PER(temp1_double,temp2_double);
@@ -3348,7 +3526,7 @@ hsize_t diff_double(unsigned char *mem1,
}
}
/* only one is NaN, assume difference */
- else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2))
{
if ( print_data(options) )
{
@@ -3389,7 +3567,7 @@ hsize_t diff_double(unsigned char *mem1,
}
/* both not NaN, do the comparison */
- if ( isnan1==0 && isnan2==0)
+ if ( !isnan1 && !isnan2)
{
PER(temp1_double,temp2_double);
@@ -3423,7 +3601,7 @@ hsize_t diff_double(unsigned char *mem1,
}
/* only one is NaN, assume difference */
- else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2))
{
if ( print_data(options) )
{
@@ -3498,7 +3676,7 @@ hsize_t diff_double(unsigned char *mem1,
*/
#if H5_SIZEOF_LONG_DOUBLE !=0
-hsize_t diff_ldouble(unsigned char *mem1,
+static hsize_t diff_ldouble(unsigned char *mem1,
unsigned char *mem2,
hsize_t nelmts,
hsize_t hyper_start,
@@ -3517,9 +3695,9 @@ hsize_t diff_ldouble(unsigned char *mem1,
long double temp2_double;
hsize_t i;
double per;
- int both_zero;
- int isnan1=0;
- int isnan2=0;
+ hbool_t both_zero;
+ hbool_t isnan1 = FALSE;
+ hbool_t isnan2 = FALSE;
/*-------------------------------------------------------------------------
@@ -3545,7 +3723,7 @@ hsize_t diff_ldouble(unsigned char *mem1,
}
/* both not NaN, do the comparison */
- if ( isnan1==0 && isnan2==0)
+ if ( !isnan1 && !isnan2)
{
if (ABS(temp1_double-temp2_double) > options->delta)
{
@@ -3559,7 +3737,7 @@ hsize_t diff_ldouble(unsigned char *mem1,
}
}
/* only one is NaN, assume difference */
- else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2))
{
if ( print_data(options) )
{
@@ -3598,7 +3776,7 @@ hsize_t diff_ldouble(unsigned char *mem1,
isnan2 = my_isnan(FLT_LDOUBLE,&temp2_double);
}
/* both not NaN, do the comparison */
- if ( isnan1==0 && isnan2==0)
+ if ( !isnan1 && !isnan2)
{
PER(temp1_double,temp2_double);
@@ -3631,7 +3809,7 @@ hsize_t diff_ldouble(unsigned char *mem1,
}
}
/* only one is NaN, assume difference */
- else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2))
{
if ( print_data(options) )
{
@@ -3672,7 +3850,7 @@ hsize_t diff_ldouble(unsigned char *mem1,
}
/* both not NaN, do the comparison */
- if ( isnan1==0 && isnan2==0)
+ if ( !isnan1 && !isnan2)
{
PER(temp1_double,temp2_double);
@@ -3706,7 +3884,7 @@ hsize_t diff_ldouble(unsigned char *mem1,
}
/* only one is NaN, assume difference */
- else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2))
{
if ( print_data(options) )
{
@@ -3781,7 +3959,7 @@ hsize_t diff_ldouble(unsigned char *mem1,
*
*-------------------------------------------------------------------------
*/
-hsize_t diff_schar(unsigned char *mem1,
+static hsize_t diff_schar(unsigned char *mem1,
unsigned char *mem2,
hsize_t nelmts,
hsize_t hyper_start,
@@ -3800,7 +3978,7 @@ hsize_t diff_schar(unsigned char *mem1,
char temp2_char;
hsize_t i;
double per;
- int both_zero;
+ hbool_t both_zero;
/* -d and !-p */
@@ -3958,7 +4136,7 @@ hsize_t diff_schar(unsigned char *mem1,
*
*-------------------------------------------------------------------------
*/
-hsize_t diff_uchar(unsigned char *mem1,
+static hsize_t diff_uchar(unsigned char *mem1,
unsigned char *mem2,
hsize_t nelmts,
hsize_t hyper_start,
@@ -3977,7 +4155,7 @@ hsize_t diff_uchar(unsigned char *mem1,
unsigned char temp2_uchar;
hsize_t i;
double per;
- int both_zero;
+ hbool_t both_zero;
/* -d and !-p */
@@ -4134,7 +4312,7 @@ hsize_t diff_uchar(unsigned char *mem1,
*
*-------------------------------------------------------------------------
*/
-hsize_t diff_short(unsigned char *mem1,
+static hsize_t diff_short(unsigned char *mem1,
unsigned char *mem2,
hsize_t nelmts,
hsize_t hyper_start,
@@ -4153,7 +4331,7 @@ hsize_t diff_short(unsigned char *mem1,
short temp2_short;
hsize_t i;
double per;
- int both_zero;
+ hbool_t both_zero;
/* -d and !-p */
if (options->d && !options->p)
@@ -4312,7 +4490,7 @@ hsize_t diff_short(unsigned char *mem1,
*
*-------------------------------------------------------------------------
*/
-hsize_t diff_ushort(unsigned char *mem1,
+static hsize_t diff_ushort(unsigned char *mem1,
unsigned char *mem2,
hsize_t nelmts,
hsize_t hyper_start,
@@ -4331,7 +4509,7 @@ hsize_t diff_ushort(unsigned char *mem1,
unsigned short temp2_ushort;
hsize_t i;
double per;
- int both_zero;
+ hbool_t both_zero;
/* -d and !-p */
if (options->d && !options->p)
@@ -4491,7 +4669,7 @@ hsize_t diff_ushort(unsigned char *mem1,
*
*-------------------------------------------------------------------------
*/
-hsize_t diff_int(unsigned char *mem1,
+static hsize_t diff_int(unsigned char *mem1,
unsigned char *mem2,
hsize_t nelmts,
hsize_t hyper_start,
@@ -4510,7 +4688,7 @@ hsize_t diff_int(unsigned char *mem1,
int temp2_int;
hsize_t i;
double per;
- int both_zero;
+ hbool_t both_zero;
/* -d and !-p */
if (options->d && !options->p)
@@ -4670,7 +4848,7 @@ hsize_t diff_int(unsigned char *mem1,
*
*-------------------------------------------------------------------------
*/
-hsize_t diff_uint(unsigned char *mem1,
+static hsize_t diff_uint(unsigned char *mem1,
unsigned char *mem2,
hsize_t nelmts,
hsize_t hyper_start,
@@ -4689,7 +4867,7 @@ hsize_t diff_uint(unsigned char *mem1,
unsigned int temp2_uint;
hsize_t i;
double per;
- int both_zero;
+ hbool_t both_zero;
/* -d and !-p */
if (options->d && !options->p)
@@ -4847,7 +5025,7 @@ hsize_t diff_uint(unsigned char *mem1,
*
*-------------------------------------------------------------------------
*/
-hsize_t diff_long(unsigned char *mem1,
+static hsize_t diff_long(unsigned char *mem1,
unsigned char *mem2,
hsize_t nelmts,
hsize_t hyper_start,
@@ -4866,7 +5044,7 @@ hsize_t diff_long(unsigned char *mem1,
long temp2_long;
hsize_t i;
double per;
- int both_zero;
+ hbool_t both_zero;
/* -d and !-p */
if (options->d && !options->p)
@@ -5030,7 +5208,7 @@ hsize_t diff_long(unsigned char *mem1,
*
*-------------------------------------------------------------------------
*/
-hsize_t diff_ulong(unsigned char *mem1,
+static hsize_t diff_ulong(unsigned char *mem1,
unsigned char *mem2,
hsize_t nelmts,
hsize_t hyper_start,
@@ -5049,7 +5227,7 @@ hsize_t diff_ulong(unsigned char *mem1,
unsigned long temp2_ulong;
hsize_t i;
double per;
- int both_zero;
+ hbool_t both_zero;
/* -d and !-p */
@@ -5213,7 +5391,7 @@ hsize_t diff_ulong(unsigned char *mem1,
*
*-------------------------------------------------------------------------
*/
-hsize_t diff_llong(unsigned char *mem1,
+static hsize_t diff_llong(unsigned char *mem1,
unsigned char *mem2,
hsize_t nelmts,
hsize_t hyper_start,
@@ -5232,7 +5410,7 @@ hsize_t diff_llong(unsigned char *mem1,
long long temp2_llong;
hsize_t i;
double per;
- int both_zero;
+ hbool_t both_zero;
/* -d and !-p */
if (options->d && !options->p)
@@ -5386,7 +5564,7 @@ hsize_t diff_llong(unsigned char *mem1,
*
*-------------------------------------------------------------------------
*/
-hsize_t diff_ullong(unsigned char *mem1,
+static hsize_t diff_ullong(unsigned char *mem1,
unsigned char *mem2,
hsize_t nelmts,
hsize_t hyper_start,
@@ -5406,7 +5584,7 @@ hsize_t diff_ullong(unsigned char *mem1,
hsize_t i;
float f1, f2;
double per;
- int both_zero;
+ hbool_t both_zero;
/* -d and !-p */
if (options->d && !options->p)
@@ -5627,8 +5805,8 @@ hbool_t equal_double(double value, double expected, diff_opt_t *options)
* detect NaNs
*-------------------------------------------------------------------------
*/
- int isnan1 = my_isnan(FLT_DOUBLE,&value);
- int isnan2 = my_isnan(FLT_DOUBLE,&expected);
+ hbool_t isnan1 = my_isnan(FLT_DOUBLE,&value);
+ hbool_t isnan2 = my_isnan(FLT_DOUBLE,&expected);
/*-------------------------------------------------------------------------
* we consider NaN == NaN to be true
@@ -5680,8 +5858,8 @@ hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *optio
* detect NaNs
*-------------------------------------------------------------------------
*/
- int isnan1 = my_isnan(FLT_LDOUBLE,&value);
- int isnan2 = my_isnan(FLT_LDOUBLE,&expected);
+ hbool_t isnan1 = my_isnan(FLT_LDOUBLE,&value);
+ hbool_t isnan2 = my_isnan(FLT_LDOUBLE,&expected);
/*-------------------------------------------------------------------------
* we consider NaN == NaN to be true
@@ -5737,8 +5915,8 @@ hbool_t equal_float(float value, float expected, diff_opt_t *options)
* detect NaNs
*-------------------------------------------------------------------------
*/
- int isnan1 = my_isnan(FLT_FLOAT,&value);
- int isnan2 = my_isnan(FLT_FLOAT,&expected);
+ hbool_t isnan1 = my_isnan(FLT_FLOAT,&value);
+ hbool_t isnan2 = my_isnan(FLT_FLOAT,&expected);
/*-------------------------------------------------------------------------
* we consider NaN == NaN to be true
@@ -5789,39 +5967,38 @@ hbool_t equal_float(float value, float expected, diff_opt_t *options)
*
*-------------------------------------------------------------------------
*/
-static int
+static hbool_t
my_isnan(dtype_t type, void *val)
{
- int retval = 0;
+ hbool_t retval = FALSE;
char s[256];
if (FLT_FLOAT==type)
{
float x;
+
HDmemcpy(&x, val, sizeof(float));
retval = (x!=x);
-
-
-
}
else if (FLT_DOUBLE==type)
{
double x;
+
HDmemcpy(&x, val, sizeof(double));
retval = (x!=x);
-
-#if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE!=0
}
+#if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE!=0
else if (FLT_LDOUBLE==type)
{
long double x;
+
HDmemcpy(&x, val, sizeof(long double));
retval = (x!=x);
-#endif
}
+#endif
else
{
- return 0;
+ return FALSE;
}
/*
@@ -5833,44 +6010,39 @@ my_isnan(dtype_t type, void *val)
if (FLT_FLOAT==type)
{
float x;
- HDmemcpy(&x, val, sizeof(float));
- sprintf(s, "%g", x);
-
+ HDmemcpy(&x, val, sizeof(float));
+ HDsnprintf(s, sizeof(s), "%g", (double)x);
}
else if (FLT_DOUBLE==type)
{
double x;
+
HDmemcpy(&x, val, sizeof(double));
- sprintf(s, "%g", x);
-#if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE!=0
+ HDsnprintf(s, sizeof(s), "%g", x);
}
+#if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE!=0
else if (FLT_LDOUBLE==type)
{
long double x;
+
HDmemcpy(&x, val, sizeof(long double));
- sprintf(s, "%Lg", x);
-#endif
+ HDsnprintf(s, sizeof(s), "%Lg", x);
}
+#endif
else
{
- return 0;
+ return FALSE;
}
-
if ( HDstrstr(s, "NaN") ||
HDstrstr(s, "NAN") ||
HDstrstr(s, "nan") ||
HDstrstr(s, "-1.#IND") /* WIN32 */
)
{
-
- retval = 1;
+ retval = TRUE;
}
-
-
-
-
}
#ifdef H5_VMS
@@ -5881,15 +6053,17 @@ my_isnan(dtype_t type, void *val)
if (FLT_FLOAT==type)
{
float x;
+
HDmemcpy(&x, val, sizeof(float));
retval = (x==FLT_MAX || x==-FLT_MAX);
} else if (FLT_DOUBLE==type) {
double x;
+
HDmemcpy(&x, val, sizeof(double));
retval = (x==DBL_MAX || x==-DBL_MAX);
} else
{
- return 0;
+ return FALSE;
}
}
#endif /*H5_VMS*/
@@ -5898,9 +6072,6 @@ my_isnan(dtype_t type, void *val)
}
-
-
-
/*-------------------------------------------------------------------------
*
* Local functions
@@ -6119,8 +6290,8 @@ static void h5diff_print_char(char ch)
*/
static void get_member_types(hid_t tid, mcomp_t *members)
{
- int i;
int tclass;
+ unsigned u;
if (tid <=0 || !members)
return;
@@ -6134,23 +6305,24 @@ static void get_member_types(hid_t tid, mcomp_t *members)
}
else if (tclass == H5T_COMPOUND)
{
- members->n = H5Tget_nmembers( tid );
- if (members->n <=0)
+ int nmembs;
+
+ nmembs = H5Tget_nmembers(tid);
+ if(nmembs <= 0)
return;
+ members->n = (unsigned)nmembs;
- members->ids = HDcalloc(members->n, sizeof(hid_t));
- members->flags = HDcalloc(members->n, sizeof(unsigned char));
- members->offsets = HDcalloc(members->n, sizeof(size_t));
- members->m = HDcalloc(members->n, sizeof(mcomp_t *));
+ members->ids = (hid_t *)HDcalloc(members->n, sizeof(hid_t));
+ members->offsets = (size_t *)HDcalloc(members->n, sizeof(size_t));
+ members->m = (mcomp_t **)HDcalloc(members->n, sizeof(mcomp_t *));
- for (i=0; i< members->n; i++)
+ for(u = 0; u < members->n; u++)
{
- members->ids[i] = H5Tget_member_type( tid, i );
- members->flags[i] = H5Tis_variable_str( members->ids[i] );
- members->offsets[i] = H5Tget_member_offset( tid, i );
- members->m[i] = (mcomp_t *)HDmalloc(sizeof(mcomp_t));
- HDmemset(members->m[i], 0, sizeof(mcomp_t));
- get_member_types(members->ids[i], members->m[i]);
+ members->ids[u] = H5Tget_member_type( tid, u );
+ members->offsets[u] = H5Tget_member_offset( tid, u );
+ members->m[u] = (mcomp_t *)HDmalloc(sizeof(mcomp_t));
+ HDmemset(members->m[u], 0, sizeof(mcomp_t));
+ get_member_types(members->ids[u], members->m[u]);
}
}
@@ -6166,24 +6338,23 @@ static void get_member_types(hid_t tid, mcomp_t *members)
*/
static void close_member_types(mcomp_t *members)
{
- int i;
+ unsigned u;
if (!members || members->n<=0 || !members->ids)
return;
- for (i=0; i<members->n; i++)
+ for(u = 0; u < members->n; u++)
{
- if (members->m[i])
+ if(members->m[u])
{
- close_member_types(members->m[i]);
- HDfree(members->m[i]);
+ close_member_types(members->m[u]);
+ HDfree(members->m[u]);
}
- H5Tclose(members->ids[i]);
+ H5Tclose(members->ids[u]);
}
- HDfree (members->m);
- HDfree (members->ids);
- HDfree (members->flags);
- HDfree (members->offsets);
+ HDfree(members->m);
+ HDfree(members->ids);
+ HDfree(members->offsets);
}
diff --git a/tools/lib/h5diff_attr.c b/tools/lib/h5diff_attr.c
index 4899200..ef1d761 100644
--- a/tools/lib/h5diff_attr.c
+++ b/tools/lib/h5diff_attr.c
@@ -108,17 +108,17 @@ static void table_attrs_free( table_attrs_t *table )
*------------------------------------------------------------------------*/
static void table_attr_mark_exist(unsigned *exist, char *name, table_attrs_t *table)
{
- unsigned int new;
+ size_t new_val;
if(table->nattrs == table->size) {
table->size = MAX(1, table->size * 2);
table->attrs = (match_attr_t *)HDrealloc(table->attrs, table->size * sizeof(match_attr_t));
} /* end if */
- new = table->nattrs++;
- table->attrs[new].exist[0] = exist[0];
- table->attrs[new].exist[1] = exist[1];
- table->attrs[new].name = (char *)HDstrdup(name);
+ new_val = table->nattrs++;
+ table->attrs[new_val].exist[0] = exist[0];
+ table->attrs[new_val].exist[1] = exist[1];
+ table->attrs[new_val].name = (char *)HDstrdup(name);
}
/*-------------------------------------------------------------------------
@@ -459,8 +459,8 @@ hsize_t diff_attr(hid_t loc1_id,
goto error;
/* format output string */
- sprintf(np1,"%s of <%s>",name1,path1);
- sprintf(np2,"%s of <%s>",name2,path2);
+ HDsnprintf(np1, sizeof(np1), "%s of <%s>", name1, path1);
+ HDsnprintf(np2, sizeof(np1), "%s of <%s>", name2, path2);
/*---------------------------------------------------------------------
* array compare
diff --git a/tools/lib/h5tools_utils.h b/tools/lib/h5tools_utils.h
index 10c643d..3285278 100644
--- a/tools/lib/h5tools_utils.h
+++ b/tools/lib/h5tools_utils.h
@@ -159,7 +159,7 @@ typedef struct {
/* obtain link info from H5tools_get_symlink_info() */
typedef struct {
H5O_type_t trg_type; /* OUT: target type */
- const char *trg_path; /* OUT: target obj path. This must be freed
+ char *trg_path; /* OUT: target obj path. This must be freed
* when used with H5tools_get_symlink_info() */
haddr_t objno; /* OUT: target object address */
unsigned long fileno; /* OUT: File number that target object is located in */