Skip to content

Commit

Permalink
Sync tools with develop (#3301)
Browse files Browse the repository at this point in the history
  • Loading branch information
derobins authored Jul 28, 2023
1 parent fe4b1c5 commit f563c2b
Show file tree
Hide file tree
Showing 84 changed files with 785 additions and 626 deletions.
12 changes: 6 additions & 6 deletions tools/lib/h5diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ h5diff(const char *fname1, const char *fname2, const char *objname1, const char
if (HDstrncmp(objname1, "/", 1) != 0) {
#ifdef H5_HAVE_ASPRINTF
/* Use the asprintf() routine, since it does what we're trying to do below */
if (HDasprintf(&obj1fullname, "/%s", objname1) < 0)
if (asprintf(&obj1fullname, "/%s", objname1) < 0)
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "name buffer allocation failed");
#else /* H5_HAVE_ASPRINTF */
/* (malloc 2 more for "/" and end-of-line) */
Expand All @@ -725,7 +725,7 @@ h5diff(const char *fname1, const char *fname2, const char *objname1, const char
if (HDstrncmp(objname2, "/", 1) != 0) {
#ifdef H5_HAVE_ASPRINTF
/* Use the asprintf() routine, since it does what we're trying to do below */
if (HDasprintf(&obj2fullname, "/%s", objname2) < 0)
if (asprintf(&obj2fullname, "/%s", objname2) < 0)
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "name buffer allocation failed");
#else /* H5_HAVE_ASPRINTF */
/* (malloc 2 more for "/" and end-of-line) */
Expand Down Expand Up @@ -1087,7 +1087,7 @@ h5diff(const char *fname1, const char *fname2, const char *objname1, const char
if (fapl2_id != H5P_DEFAULT)
H5Pclose(fapl2_id);
}
H5E_END_TRY;
H5E_END_TRY

H5TOOLS_ENDDEBUG(" - errstat:%d", opts->err_stat);

Expand Down Expand Up @@ -1182,7 +1182,7 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, hid_t file2_id,
/* make full path for obj1 */
#ifdef H5_HAVE_ASPRINTF
/* Use the asprintf() routine, since it does what we're trying to do below */
if (HDasprintf(&obj1_fullpath, "%s%s", grp1_path, table->objs[i].name) < 0) {
if (asprintf(&obj1_fullpath, "%s%s", grp1_path, table->objs[i].name) < 0) {
H5TOOLS_ERROR(H5DIFF_ERR, "name buffer allocation failed");
}
#else /* H5_HAVE_ASPRINTF */
Expand All @@ -1200,7 +1200,7 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, hid_t file2_id,
/* make full path for obj2 */
#ifdef H5_HAVE_ASPRINTF
/* Use the asprintf() routine, since it does what we're trying to do below */
if (HDasprintf(&obj2_fullpath, "%s%s", grp2_path, table->objs[i].name) < 0) {
if (asprintf(&obj2_fullpath, "%s%s", grp2_path, table->objs[i].name) < 0) {
H5TOOLS_ERROR(H5DIFF_ERR, "name buffer allocation failed");
}
#else /* H5_HAVE_ASPRINTF */
Expand Down Expand Up @@ -1928,7 +1928,7 @@ diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_
H5Gclose(grp2_id);
/* enable error reporting */
}
H5E_END_TRY;
H5E_END_TRY

H5TOOLS_ENDDEBUG(": %d - errstat:%d", nfound, opts->err_stat);

Expand Down
16 changes: 8 additions & 8 deletions tools/lib/h5diff_array.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
static hbool_t not_comparable;

#define PER(A, B) \
{ \
do { \
per = -1; \
not_comparable = FALSE; \
both_zero = FALSE; \
Expand All @@ -93,10 +93,10 @@ static hbool_t not_comparable;
per = (double)ABS((double)((B) - (A)) / (double)(A)); \
else \
not_comparable = TRUE; \
}
} while (0)

#define PER_UNSIGN(TYPE, A, B) \
{ \
do { \
per = -1; \
not_comparable = FALSE; \
both_zero = FALSE; \
Expand All @@ -106,7 +106,7 @@ static hbool_t not_comparable;
per = ABS((double)((TYPE)((B) - (A))) / (double)(A)); \
else \
not_comparable = TRUE; \
}
} while (0)

#define PDIFF(a, b) (((b) > (a)) ? ((b) - (a)) : ((a) - (b)))

Expand Down Expand Up @@ -684,7 +684,7 @@ diff_datum(void *_mem1, void *_mem2, hsize_t elemtno, diff_opt_t *opts, hid_t co
}
/* enable error reporting */
}
H5E_END_TRY;
H5E_END_TRY
}
break;

Expand Down Expand Up @@ -1371,7 +1371,7 @@ diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t region2_id, di
npoints1 = H5Sget_select_elem_npoints(region1_id);
npoints2 = H5Sget_select_elem_npoints(region2_id);
}
H5E_END_TRY;
H5E_END_TRY
H5TOOLS_DEBUG("blocks: 1=%" PRIdHSIZE "-2=%" PRIdHSIZE, nblocks1, nblocks2);
H5TOOLS_DEBUG("points: 1=%" PRIdHSIZE "-2=%" PRIdHSIZE, npoints1, npoints2);

Expand Down Expand Up @@ -3117,7 +3117,7 @@ ull2float(unsigned long long ull_value, float *f_value)
{
H5Pclose(dxpl_id);
}
H5E_END_TRY;
H5E_END_TRY

if (buf)
free(buf);
Expand Down Expand Up @@ -3345,7 +3345,7 @@ print_pos(diff_opt_t *opts, hsize_t idx, size_t u)
int j;
hsize_t count;
hsize_t block;
hsize_t stride;
hsize_t stride = 0;
hsize_t tmp = 0;
hsize_t k0 = 0; /* whole location beyond current dimension */
hsize_t k1 = 0; /* partial location within dimension */
Expand Down
6 changes: 3 additions & 3 deletions tools/lib/h5diff_attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t **table_out,
H5Aclose(attr1_id);
H5Aclose(attr2_id);
}
H5E_END_TRY;
H5E_END_TRY

H5TOOLS_ENDDEBUG(" - errstat:%d", opts->err_stat);

Expand Down Expand Up @@ -576,7 +576,7 @@ diff_attr_data(hid_t attr1_id, hid_t attr2_id, const char *name1, const char *na
H5Sclose(space1_id);
H5Sclose(space2_id);
}
H5E_END_TRY;
H5E_END_TRY

H5TOOLS_ENDDEBUG(" - errstat:%d", opts->err_stat);

Expand Down Expand Up @@ -669,7 +669,7 @@ diff_attr(hid_t loc1_id, hid_t loc2_id, const char *path1, const char *path2, di
H5Aclose(attr1_id);
H5Aclose(attr2_id);
}
H5E_END_TRY;
H5E_END_TRY

H5TOOLS_ENDDEBUG(" - errstat:%d", opts->err_stat);
return nfound_total;
Expand Down
4 changes: 2 additions & 2 deletions tools/lib/h5diff_dset.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ diff_dataset(hid_t file1_id, hid_t file2_id, const char *obj1_name, const char *
H5Dclose(did2);
/* enable error reporting */
}
H5E_END_TRY;
H5E_END_TRY

H5TOOLS_ENDDEBUG(":%d - errstat:%d", nfound, opts->err_stat);
return nfound;
Expand Down Expand Up @@ -931,7 +931,7 @@ diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char *obj2_n
H5Tclose(m_tid2);
/* enable error reporting */
}
H5E_END_TRY;
H5E_END_TRY

H5TOOLS_ENDDEBUG(": %d with nfound:%d", ret_value, nfound);
return nfound;
Expand Down
33 changes: 18 additions & 15 deletions tools/lib/h5tools.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ int region_output; /* region output */
int oid_output; /* oid output */
int data_output; /* data output */
int attr_data_output; /* attribute data output */
int compound_data;

unsigned packed_bits_num; /* number of packed bits to display */
unsigned packed_data_offset; /* offset of packed bits to display */
Expand Down Expand Up @@ -246,7 +245,7 @@ h5tools_set_data_output_file(const char *fname, int is_bin)
* so that rawdatastream is changed only when succeeded */

if (rawdatastream && rawdatastream != stdout) {
if (HDfclose(rawdatastream))
if (fclose(rawdatastream))
HDperror("closing rawdatastream");
else
rawdatastream = NULL;
Expand Down Expand Up @@ -294,7 +293,7 @@ h5tools_set_attr_output_file(const char *fname, int is_bin)
* so that rawattrstream is changed only when succeeded */

if (rawattrstream && rawattrstream != stdout) {
if (HDfclose(rawattrstream))
if (fclose(rawattrstream))
HDperror("closing rawattrstream");
else
rawattrstream = NULL;
Expand Down Expand Up @@ -343,7 +342,7 @@ h5tools_set_input_file(const char *fname, int is_bin)
* so that rawinstream is changed only when succeeded */

if (rawinstream && rawinstream != stdin) {
if (HDfclose(rawinstream))
if (fclose(rawinstream))
HDperror("closing rawinstream");
else
rawinstream = NULL;
Expand Down Expand Up @@ -391,7 +390,7 @@ h5tools_set_output_file(const char *fname, int is_bin)
* so that rawoutstream is changed only when succeeded */

if (rawoutstream && rawoutstream != stdout) {
if (HDfclose(rawoutstream))
if (fclose(rawoutstream))
HDperror("closing rawoutstream");
else
rawoutstream = NULL;
Expand Down Expand Up @@ -438,7 +437,7 @@ h5tools_set_error_file(const char *fname, int is_bin)
* so that rawerrorstream is changed only when succeeded */

if (rawerrorstream && rawerrorstream != stderr) {
if (HDfclose(rawerrorstream))
if (fclose(rawerrorstream))
HDperror("closing rawerrorstream");
else
rawerrorstream = NULL;
Expand Down Expand Up @@ -566,8 +565,12 @@ h5tools_set_fapl_vfd(hid_t fapl_id, h5tools_vfd_info_t *vfd_info)
#ifdef H5_HAVE_ROS3_VFD
if (!vfd_info->info)
H5TOOLS_GOTO_ERROR(FAIL, "Read-only S3 VFD info is invalid");
if (H5Pset_fapl_ros3(fapl_id, (const H5FD_ros3_fapl_t *)vfd_info->info) < 0)
if (H5Pset_fapl_ros3(fapl_id, &((const H5FD_ros3_fapl_ext_t *)vfd_info->info)->fa) < 0)
H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_ros3() failed");

if (H5Pset_fapl_ros3_token(fapl_id, ((const H5FD_ros3_fapl_ext_t *)vfd_info->info)->token) <
0)
H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_ros3_token() failed");
#else
H5TOOLS_GOTO_ERROR(FAIL, "Read-only S3 VFD is not enabled");
#endif
Expand Down Expand Up @@ -975,7 +978,7 @@ h5tools_fopen(const char *fname, unsigned flags, hid_t fapl_id, hbool_t use_spec
{
fid = H5Fopen(fname, flags, fapl_id);
}
H5E_END_TRY;
H5E_END_TRY
}

/* If we succeeded in opening the file, we're done. */
Expand Down Expand Up @@ -1036,7 +1039,7 @@ h5tools_fopen(const char *fname, unsigned flags, hid_t fapl_id, hbool_t use_spec
{
fid = h5tools_fopen(fname, flags, tmp_fapl_id, TRUE, drivername, drivername_size);
}
H5E_END_TRY;
H5E_END_TRY

if (fid >= 0) {
used_fapl_id = tmp_fapl_id;
Expand Down Expand Up @@ -1811,9 +1814,9 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t
else
bytes_in = (size_t)block_index;

bytes_wrote = HDfwrite(mem, 1, bytes_in, stream);
bytes_wrote = fwrite(mem, 1, bytes_in, stream);

if (bytes_wrote != bytes_in || (0 == bytes_wrote && HDferror(stream)))
if (bytes_wrote != bytes_in || (0 == bytes_wrote && ferror(stream)))
H5TOOLS_THROW((-1), "fwrite failed");

block_index -= (hsize_t)bytes_wrote;
Expand Down Expand Up @@ -1844,7 +1847,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t
}
for (i = 0; i < size && (s[i] || pad != H5T_STR_NULLTERM); i++) {
memcpy(&tempuchar, &s[i], sizeof(unsigned char));
if (1 != HDfwrite(&tempuchar, sizeof(unsigned char), 1, stream))
if (1 != fwrite(&tempuchar, sizeof(unsigned char), 1, stream))
H5TOOLS_THROW((-1), "fwrite failed");
} /* i */
} /* for (block_index = 0; block_index < block_nelmts; block_index++) */
Expand Down Expand Up @@ -1991,7 +1994,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t
H5TOOLS_DEBUG("H5T_OPAQUE");
for (block_index = 0; block_index < block_nelmts; block_index++) {
mem = ((unsigned char *)_mem) + block_index * size;
if (size != HDfwrite(mem, sizeof(char), size, stream))
if (size != fwrite(mem, sizeof(char), size, stream))
H5TOOLS_THROW((-1), "fwrite failed");
} /* end for */
break;
Expand Down Expand Up @@ -2165,7 +2168,7 @@ render_bin_output_region_blocks(hid_t region_space, hid_t region_id, FILE *strea
if (dtype > 0 && H5Tclose(dtype) < 0)
H5TOOLS_ERROR(FALSE, "H5Tclose failed");

H5_LEAVE(TRUE)
H5_LEAVE(TRUE);

CATCH
H5TOOLS_ENDDEBUG(" ");
Expand Down Expand Up @@ -2280,7 +2283,7 @@ render_bin_output_region_points(hid_t region_space, hid_t region_id, FILE *strea
if (dtype > 0 && H5Tclose(dtype) < 0)
H5TOOLS_ERROR(FALSE, "H5Tclose failed");

H5_LEAVE(ret_value)
H5_LEAVE(ret_value);
CATCH
H5TOOLS_ENDDEBUG(" ");
return ret_value;
Expand Down
6 changes: 3 additions & 3 deletions tools/lib/h5tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
/* Stream macros */
#define FLUSHSTREAM(S) \
if (S != NULL) \
HDfflush(S)
fflush(S)
#define PRINTSTREAM(S, F, ...) \
if (S != NULL) \
HDfprintf(S, F, __VA_ARGS__)
fprintf(S, F, __VA_ARGS__)
#define PRINTVALSTREAM(S, V) \
if (S != NULL) \
HDfprintf(S, V)
fprintf(S, V)
#define PUTSTREAM(X, S) \
do { \
if (S != NULL) \
Expand Down
11 changes: 5 additions & 6 deletions tools/lib/h5tools_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ h5tools_dump_region_attribute(hid_t region_id, FILE *stream, const h5tool_format
h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
/* Render the region } element end */

H5_LEAVE(dimension_break)
H5_LEAVE(dimension_break);

CATCH

Expand Down Expand Up @@ -843,7 +843,7 @@ h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id, FILE *strea
h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
/* Render the region } element end */

H5_LEAVE(dimension_break)
H5_LEAVE(dimension_break);

CATCH

Expand Down Expand Up @@ -1198,7 +1198,7 @@ h5tools_dump_region_data_points(hid_t region_space, hid_t region_id, FILE *strea
h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
/* Render the region } element end */

H5_LEAVE(dimension_break)
H5_LEAVE(dimension_break);
CATCH

H5TOOLS_ENDDEBUG(" ");
Expand Down Expand Up @@ -3485,8 +3485,7 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info, h5tools_context_t *
(hsize_t)0, (hsize_t)0);
break;
case H5Z_FILTER_SZIP:
szip_options_mask = cd_values[0];
;
szip_options_mask = cd_values[0];
szip_pixels_per_block = cd_values[1];

h5tools_str_append(&buffer, "%s %s", SZIP, BEGIN);
Expand Down Expand Up @@ -3939,7 +3938,7 @@ h5tools_print_packed_bits(h5tools_str_t *buffer, hid_t type)
error_msg("Packed Bit offset+length value(%u) too large. Max is %d\n",
packed_data_offset + packed_data_length, packed_bits_size);
packed_data_mask = 0;
};
}
h5tools_str_append(buffer, "%s %s=%u %s=%u", PACKED_BITS, PACKED_OFFSET, packed_data_offset,
PACKED_LENGTH, packed_data_length);
}
Expand Down
Loading

0 comments on commit f563c2b

Please sign in to comment.