summaryrefslogtreecommitdiffstats
path: root/tools/lib
diff options
context:
space:
mode:
Diffstat (limited to 'tools/lib')
-rw-r--r--tools/lib/h5diff.c12
-rw-r--r--tools/lib/h5diff_array.c16
-rw-r--r--tools/lib/h5diff_attr.c6
-rw-r--r--tools/lib/h5diff_dset.c4
-rw-r--r--tools/lib/h5tools.c33
-rw-r--r--tools/lib/h5tools.h6
-rw-r--r--tools/lib/h5tools_dump.c11
-rw-r--r--tools/lib/h5tools_error.h58
-rw-r--r--tools/lib/h5tools_ref.c4
-rw-r--r--tools/lib/h5tools_str.c12
-rw-r--r--tools/lib/h5tools_utils.c97
-rw-r--r--tools/lib/h5tools_utils.h12
-rw-r--r--tools/lib/h5trav.c6
13 files changed, 156 insertions, 121 deletions
diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c
index 7232ed0..502b2ec 100644
--- a/tools/lib/h5diff.c
+++ b/tools/lib/h5diff.c
@@ -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) */
@@ -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) */
@@ -1087,7 +1087,7 @@ done:
if (fapl2_id != H5P_DEFAULT)
H5Pclose(fapl2_id);
}
- H5E_END_TRY;
+ H5E_END_TRY
H5TOOLS_ENDDEBUG(" - errstat:%d", opts->err_stat);
@@ -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 */
@@ -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 */
@@ -1928,7 +1928,7 @@ done:
H5Gclose(grp2_id);
/* enable error reporting */
}
- H5E_END_TRY;
+ H5E_END_TRY
H5TOOLS_ENDDEBUG(": %d - errstat:%d", nfound, opts->err_stat);
diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c
index 85defbe..abb81b9 100644
--- a/tools/lib/h5diff_array.c
+++ b/tools/lib/h5diff_array.c
@@ -83,7 +83,7 @@
static hbool_t not_comparable;
#define PER(A, B) \
- { \
+ do { \
per = -1; \
not_comparable = FALSE; \
both_zero = FALSE; \
@@ -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; \
@@ -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)))
@@ -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;
@@ -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);
@@ -3117,7 +3117,7 @@ done:
{
H5Pclose(dxpl_id);
}
- H5E_END_TRY;
+ H5E_END_TRY
if (buf)
free(buf);
@@ -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 */
diff --git a/tools/lib/h5diff_attr.c b/tools/lib/h5diff_attr.c
index 474d83c..0c377af 100644
--- a/tools/lib/h5diff_attr.c
+++ b/tools/lib/h5diff_attr.c
@@ -295,7 +295,7 @@ done:
H5Aclose(attr1_id);
H5Aclose(attr2_id);
}
- H5E_END_TRY;
+ H5E_END_TRY
H5TOOLS_ENDDEBUG(" - errstat:%d", opts->err_stat);
@@ -576,7 +576,7 @@ done:
H5Sclose(space1_id);
H5Sclose(space2_id);
}
- H5E_END_TRY;
+ H5E_END_TRY
H5TOOLS_ENDDEBUG(" - errstat:%d", opts->err_stat);
@@ -669,7 +669,7 @@ done:
H5Aclose(attr1_id);
H5Aclose(attr2_id);
}
- H5E_END_TRY;
+ H5E_END_TRY
H5TOOLS_ENDDEBUG(" - errstat:%d", opts->err_stat);
return nfound_total;
diff --git a/tools/lib/h5diff_dset.c b/tools/lib/h5diff_dset.c
index c30532b..78f52bc 100644
--- a/tools/lib/h5diff_dset.c
+++ b/tools/lib/h5diff_dset.c
@@ -95,7 +95,7 @@ done:
H5Dclose(did2);
/* enable error reporting */
}
- H5E_END_TRY;
+ H5E_END_TRY
H5TOOLS_ENDDEBUG(":%d - errstat:%d", nfound, opts->err_stat);
return nfound;
@@ -931,7 +931,7 @@ done:
H5Tclose(m_tid2);
/* enable error reporting */
}
- H5E_END_TRY;
+ H5E_END_TRY
H5TOOLS_ENDDEBUG(": %d with nfound:%d", ret_value, nfound);
return nfound;
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c
index 58be037..0e063c7 100644
--- a/tools/lib/h5tools.c
+++ b/tools/lib/h5tools.c
@@ -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 */
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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
@@ -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. */
@@ -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;
@@ -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;
@@ -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++) */
@@ -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;
@@ -2165,7 +2168,7 @@ done:
if (dtype > 0 && H5Tclose(dtype) < 0)
H5TOOLS_ERROR(FALSE, "H5Tclose failed");
- H5_LEAVE(TRUE)
+ H5_LEAVE(TRUE);
CATCH
H5TOOLS_ENDDEBUG(" ");
@@ -2280,7 +2283,7 @@ done:
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;
diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h
index 1c63ed0..97f56e0 100644
--- a/tools/lib/h5tools.h
+++ b/tools/lib/h5tools.h
@@ -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) \
diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c
index 956c41d..6028f92 100644
--- a/tools/lib/h5tools_dump.c
+++ b/tools/lib/h5tools_dump.c
@@ -441,7 +441,7 @@ done:
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
@@ -843,7 +843,7 @@ done:
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
@@ -1198,7 +1198,7 @@ done:
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(" ");
@@ -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);
@@ -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);
}
diff --git a/tools/lib/h5tools_error.h b/tools/lib/h5tools_error.h
index 5417eb9..8a7414c 100644
--- a/tools/lib/h5tools_error.h
+++ b/tools/lib/h5tools_error.h
@@ -40,27 +40,27 @@ H5TOOLS_DLLVAR hid_t H5E_tools_min_dbg_id_g;
\
/* Create new HDF5 error stack for the tools to use */ \
if ((H5tools_ERR_STACK_g = H5Ecreate_stack()) < 0) \
- HDfprintf(stderr, "Failed to create HDF5 tools error stack\n"); \
+ fprintf(stderr, "Failed to create HDF5 tools error stack\n"); \
\
/* Register errors from the HDF5 tools as a new error class */ \
if ((H5tools_ERR_CLS_g = H5Eregister_class("H5tools", "HDF5:tools", lib_str)) < 0) \
- HDfprintf(stderr, "Failed to register HDF5 tools error class\n"); \
+ fprintf(stderr, "Failed to register HDF5 tools error class\n"); \
\
/* Create a new HDF5 major error message for errors from the tools library */ \
if ((H5E_tools_g = H5Ecreate_msg(H5tools_ERR_CLS_g, H5E_MAJOR, "Failure in tools library")) < 0) \
- HDfprintf(stderr, "Failed to register major error message for tools library errors\n"); \
+ fprintf(stderr, "Failed to register major error message for tools library errors\n"); \
\
/* Create a new HDF5 minor error message for errors from the tools library */ \
if ((H5E_tools_min_id_g = H5Ecreate_msg(H5tools_ERR_CLS_g, H5E_MINOR, "error in function")) < 0) \
- HDfprintf(stderr, "Failed to register minor error message for tools library errors\n"); \
+ fprintf(stderr, "Failed to register minor error message for tools library errors\n"); \
\
/* Create a new HDF5 minor error message for info messages from the tools library */ \
if ((H5E_tools_min_info_id_g = H5Ecreate_msg(H5tools_ERR_CLS_g, H5E_MINOR, "function info")) < 0) \
- HDfprintf(stderr, "Failed to register minor error message for tools library info messages\n"); \
+ fprintf(stderr, "Failed to register minor error message for tools library info messages\n"); \
\
/* Create a new HDF5 minor error message for debug messages from the tools library */ \
if ((H5E_tools_min_dbg_id_g = H5Ecreate_msg(H5tools_ERR_CLS_g, H5E_MINOR, "function debug")) < 0) \
- HDfprintf(stderr, "Failed to register minor error message for tools library debug messages\n"); \
+ fprintf(stderr, "Failed to register minor error message for tools library debug messages\n"); \
} while (0)
/*
@@ -70,21 +70,21 @@ H5TOOLS_DLLVAR hid_t H5E_tools_min_dbg_id_g;
do { \
/* Close all error messages created by H5TOOLS_INIT_ERROR() */ \
if (H5Eclose_msg(H5E_tools_min_dbg_id_g) < 0) \
- HDfprintf(stderr, "Failed to close minor error message for tools library debug messages\n"); \
+ fprintf(stderr, "Failed to close minor error message for tools library debug messages\n"); \
if (H5Eclose_msg(H5E_tools_min_info_id_g) < 0) \
- HDfprintf(stderr, "Failed to close minor error message for tools library info messages\n"); \
+ fprintf(stderr, "Failed to close minor error message for tools library info messages\n"); \
if (H5Eclose_msg(H5E_tools_min_id_g) < 0) \
- HDfprintf(stderr, "Failed to close minor error message for tools library errors\n"); \
+ fprintf(stderr, "Failed to close minor error message for tools library errors\n"); \
if (H5Eclose_msg(H5E_tools_g) < 0) \
- HDfprintf(stderr, "Failed to close major error message for tools library errors\n"); \
+ fprintf(stderr, "Failed to close major error message for tools library errors\n"); \
\
/* Unregister the HDF5 tools error class */ \
if (H5Eunregister_class(H5tools_ERR_CLS_g) < 0) \
- HDfprintf(stderr, "Failed to unregister the HDF5 tools error class\n"); \
+ fprintf(stderr, "Failed to unregister the HDF5 tools error class\n"); \
\
/* Close the tools error stack */ \
if (H5Eclose_stack(H5tools_ERR_STACK_g) < 0) \
- HDfprintf(stderr, "Failed to close HDF5 tools error stack\n"); \
+ fprintf(stderr, "Failed to close HDF5 tools error stack\n"); \
} while (0)
/*
@@ -98,8 +98,8 @@ H5TOOLS_DLLVAR hid_t H5E_tools_min_dbg_id_g;
H5Epush2(estack_id, __FILE__, __func__, __LINE__, err_cls, maj_err_id, min_err_id, \
__VA_ARGS__); \
else { \
- HDfprintf(stderr, __VA_ARGS__); \
- HDfprintf(stderr, "\n"); \
+ fprintf(stderr, __VA_ARGS__); \
+ fprintf(stderr, "\n"); \
} \
} \
} while (0)
@@ -166,27 +166,27 @@ H5TOOLS_DLLVAR hid_t H5E_tools_min_dbg_id_g;
#define H5TOOLS_START_DEBUG(...) \
do { \
H5tools_INDENT_g += 2; \
- HDfprintf(stderr, "%*sENTER %s:%d in %s()...", H5tools_INDENT_g, "", __FILE__, __LINE__, __func__); \
- HDfprintf(stderr, __VA_ARGS__); \
- HDfprintf(stderr, "\n"); \
- HDfflush(stderr); \
+ fprintf(stderr, "%*sENTER %s:%d in %s()...", H5tools_INDENT_g, "", __FILE__, __LINE__, __func__); \
+ fprintf(stderr, __VA_ARGS__); \
+ fprintf(stderr, "\n"); \
+ fflush(stderr); \
} while (0)
#define H5TOOLS_DEBUG(...) \
do { \
- HDfprintf(stderr, "%*s %s:%d in %s()...", H5tools_INDENT_g, "", __FILE__, __LINE__, __func__); \
- HDfprintf(stderr, __VA_ARGS__); \
- HDfprintf(stderr, "\n"); \
- HDfflush(stderr); \
+ fprintf(stderr, "%*s %s:%d in %s()...", H5tools_INDENT_g, "", __FILE__, __LINE__, __func__); \
+ fprintf(stderr, __VA_ARGS__); \
+ fprintf(stderr, "\n"); \
+ fflush(stderr); \
} while (0)
#define H5TOOLS_ENDDEBUG(...) \
do { \
- HDfprintf(stderr, "%*sEXIT %s:%d in %s()...", H5tools_INDENT_g, "", __FILE__, __LINE__, __func__); \
- HDfprintf(stderr, __VA_ARGS__); \
- HDfprintf(stderr, "\n"); \
+ fprintf(stderr, "%*sEXIT %s:%d in %s()...", H5tools_INDENT_g, "", __FILE__, __LINE__, __func__); \
+ fprintf(stderr, __VA_ARGS__); \
+ fprintf(stderr, "\n"); \
H5tools_INDENT_g -= 2; \
- HDfflush(stderr); \
+ fflush(stderr); \
} while (0)
#else
@@ -222,11 +222,11 @@ catch_except:;
* it.
*/
#define H5_LEAVE(v) \
- { \
+ do { \
ret_value = v; \
if (!past_catch) \
goto catch_except; \
- }
+ } while (0)
/*
* H5TOOLS_THROW macro, used to facilitate error reporting within a function body.
@@ -238,7 +238,7 @@ catch_except:;
do { \
H5TOOLS_PUSH_ERROR(H5tools_ERR_STACK_g, H5tools_ERR_CLS_g, H5E_tools_g, H5E_tools_min_id_g, \
__VA_ARGS__); \
- H5_LEAVE(ret_val) \
+ H5_LEAVE(ret_val); \
} while (0)
#endif /* H5TOOLS_ERROR_H */
diff --git a/tools/lib/h5tools_ref.c b/tools/lib/h5tools_ref.c
index 065fce1..d89c546 100644
--- a/tools/lib/h5tools_ref.c
+++ b/tools/lib/h5tools_ref.c
@@ -242,7 +242,7 @@ ref_path_table_put(const char *path, const H5O_token_t *token)
/*
* counter used to disambiguate multiple instances of same object.
*/
-int xid = 1;
+static int xid = 1;
int
get_next_xid(void)
@@ -256,7 +256,7 @@ get_next_xid(void)
* minimizes the chance of collision with a real object id.
*
*/
-haddr_t fake_xid = HADDR_MAX;
+static haddr_t fake_xid = HADDR_MAX;
void
get_fake_token(H5O_token_t *token)
diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c
index 2906cc5..ff7fab5 100644
--- a/tools/lib/h5tools_str.c
+++ b/tools/lib/h5tools_str.c
@@ -447,7 +447,7 @@ h5tools_str_dump_space_blocks(h5tools_str_t *str, hid_t rspace, const h5tool_for
{
snblocks = H5Sget_select_hyper_nblocks(rspace);
}
- H5E_END_TRY;
+ H5E_END_TRY
/* Print block information */
if (snblocks > 0) {
@@ -508,7 +508,7 @@ h5tools_str_dump_space_points(h5tools_str_t *str, hid_t rspace, const h5tool_for
{
snpoints = H5Sget_select_elem_npoints(rspace);
}
- H5E_END_TRY;
+ H5E_END_TRY
/* Print point information */
if (snpoints > 0) {
@@ -1548,10 +1548,10 @@ h5tools_escape(char *s /*in,out*/, size_t size)
/*would overflow*/
return NULL;
- HDmemmove(s + i + esc_size, s + i + 1, n - i); /*make room*/
- memcpy(s + i, escape, esc_size); /*insert*/
- n += esc_size - 1; /* adjust total string size */
- i += esc_size; /* adjust string position */
+ memmove(s + i + esc_size, s + i + 1, n - i); /*make room*/
+ memcpy(s + i, escape, esc_size); /*insert*/
+ n += esc_size - 1; /* adjust total string size */
+ i += esc_size; /* adjust string position */
}
}
diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c
index c5c1f5b..fc9a646 100644
--- a/tools/lib/h5tools_utils.c
+++ b/tools/lib/h5tools_utils.c
@@ -187,7 +187,7 @@ parse_hsize_list(const char *h_list, subset_d *d)
H5TOOLS_START_DEBUG(" - h_list:%s", h_list);
/* count how many integers do we have */
for (ptr = h_list; ptr && *ptr && *ptr != ';' && *ptr != ']'; ptr++)
- if (HDisdigit(*ptr)) {
+ if (isdigit(*ptr)) {
if (!last_digit)
/* the last read character wasn't a digit */
size_count++;
@@ -209,11 +209,11 @@ parse_hsize_list(const char *h_list, subset_d *d)
H5TOOLS_INFO("Unable to allocate space for subset data");
for (ptr = h_list; i < size_count && ptr && *ptr && *ptr != ';' && *ptr != ']'; ptr++)
- if (HDisdigit(*ptr)) {
+ if (isdigit(*ptr)) {
/* we should have an integer now */
- p_list[i++] = (hsize_t)HDstrtoull(ptr, NULL, 0);
+ p_list[i++] = (hsize_t)strtoull(ptr, NULL, 0);
- while (HDisdigit(*ptr))
+ while (isdigit(*ptr))
/* scroll to end of integer */
ptr++;
}
@@ -996,7 +996,7 @@ h5tools_getenv_update_hyperslab_bufsize(void)
/* check if environment variable is set for the hyperslab buffer size */
if (NULL != (env_str = HDgetenv("H5TOOLS_BUFSIZE"))) {
errno = 0;
- hyperslab_bufsize_mb = HDstrtol(env_str, (char **)NULL, 10);
+ hyperslab_bufsize_mb = strtol(env_str, (char **)NULL, 10);
if (errno != 0 || hyperslab_bufsize_mb <= 0)
H5TOOLS_GOTO_ERROR(FAIL, "hyperslab buffer size failed");
@@ -1025,9 +1025,9 @@ done:
*----------------------------------------------------------------------------
*/
herr_t
-h5tools_parse_ros3_fapl_tuple(const char *tuple_str, int delim, H5FD_ros3_fapl_t *fapl_config_out)
+h5tools_parse_ros3_fapl_tuple(const char *tuple_str, int delim, H5FD_ros3_fapl_ext_t *fapl_config_out)
{
- const char *ccred[3];
+ const char *ccred[4];
unsigned nelems = 0;
char *s3cred_src = NULL;
char **s3cred = NULL;
@@ -1038,12 +1038,18 @@ h5tools_parse_ros3_fapl_tuple(const char *tuple_str, int delim, H5FD_ros3_fapl_t
H5TOOLS_GOTO_ERROR(FAIL, "failed to parse S3 VFD info tuple");
/* Sanity-check tuple count */
- if (nelems != 3)
+ if (nelems != 3 && nelems != 4)
H5TOOLS_GOTO_ERROR(FAIL, "invalid S3 VFD credentials");
ccred[0] = (const char *)s3cred[0];
ccred[1] = (const char *)s3cred[1];
ccred[2] = (const char *)s3cred[2];
+ if (nelems == 3) {
+ ccred[3] = "";
+ }
+ else {
+ ccred[3] = (const char *)s3cred[3];
+ }
if (0 == h5tools_populate_ros3_fapl(fapl_config_out, ccred))
H5TOOLS_GOTO_ERROR(FAIL, "failed to populate S3 VFD FAPL config");
@@ -1090,34 +1096,35 @@ done:
* * NULL fapl pointer: (NULL, {...} )
* * Warning: In all cases below, fapl will be set as "default"
* before error occurs.
- * * NULL value strings: (&fa, {NULL?, NULL? NULL?, ...})
+ * * NULL value strings: (&fa, {NULL?, NULL? NULL?, NULL?, ...})
* * Incomplete fapl info:
- * * empty region, non-empty id, key either way
- * * (&fa, {"", "...", "?"})
- * * empty id, non-empty region, key either way
- * * (&fa, {"...", "", "?"})
- * * "non-empty key and either id or region empty
- * * (&fa, {"", "", "...")
- * * (&fa, {"", "...", "...")
- * * (&fa, {"...", "", "...")
+ * * empty region, non-empty id, key either way, token either way
+ * * (&fa, token, {"", "...", "?", "?"})
+ * * empty id, non-empty region, key either way, token either way
+ * * (&fa, token, {"...", "", "?", "?"})
+ * * "non-empty key, token either way and either id or region empty
+ * * (&fa, token, {"", "", "...", "?")
+ * * (&fa, token, {"", "...", "...", "?")
+ * * (&fa, token, {"...", "", "...", "?")
* * Any string would overflow allowed space in fapl definition.
* or
* 1 (success)
* * Sets components in fapl_t pointer, copying strings as appropriate.
* * "Default" fapl (valid version, authenticate->False, empty strings)
* * `values` pointer is NULL
- * * (&fa, NULL)
- * * first three strings in `values` are empty ("")
- * * (&fa, {"", "", "", ...}
+ * * (&fa, token, NULL)
+ * * first four strings in `values` are empty ("")
+ * * (&fa, token, {"", "", "", "", ...})
* * Authenticating fapl
- * * region, id, and optional key provided
- * * (&fa, {"...", "...", ""})
- * * (&fa, {"...", "...", "..."})
+ * * region, id, optional key and option session token provided
+ * * (&fa, token, {"...", "...", "", ""})
+ * * (&fa, token, {"...", "...", "...", ""})
+ * * (&fa, token, {"...", "...", "...", "..."})
*
*----------------------------------------------------------------------------
*/
int
-h5tools_populate_ros3_fapl(H5FD_ros3_fapl_t *fa, const char **values)
+h5tools_populate_ros3_fapl(H5FD_ros3_fapl_ext_t *fa, const char **values)
{
int show_progress = 0; /* set to 1 for debugging */
int ret_value = 1; /* 1 for success, 0 for failure */
@@ -1138,11 +1145,12 @@ h5tools_populate_ros3_fapl(H5FD_ros3_fapl_t *fa, const char **values)
if (show_progress) {
printf(" preset fapl with default values\n");
}
- fa->version = H5FD_CURR_ROS3_FAPL_T_VERSION;
- fa->authenticate = FALSE;
- *(fa->aws_region) = '\0';
- *(fa->secret_id) = '\0';
- *(fa->secret_key) = '\0';
+ fa->fa.version = H5FD_CURR_ROS3_FAPL_T_VERSION;
+ fa->fa.authenticate = FALSE;
+ *(fa->fa.aws_region) = '\0';
+ *(fa->fa.secret_id) = '\0';
+ *(fa->fa.secret_key) = '\0';
+ *(fa->token) = '\0';
/* sanity-check supplied values
*/
@@ -1168,6 +1176,13 @@ h5tools_populate_ros3_fapl(H5FD_ros3_fapl_t *fa, const char **values)
ret_value = 0;
goto done;
}
+ if (values[3] == NULL) {
+ if (show_progress) {
+ printf(" ERROR: token value cannot be NULL\n");
+ }
+ ret_value = 0;
+ goto done;
+ }
/* if region and ID are supplied (key optional), write to fapl...
* fail if value would overflow
@@ -1180,7 +1195,7 @@ h5tools_populate_ros3_fapl(H5FD_ros3_fapl_t *fa, const char **values)
ret_value = 0;
goto done;
}
- memcpy(fa->aws_region, values[0], (HDstrlen(values[0]) + 1));
+ memcpy(fa->fa.aws_region, values[0], (HDstrlen(values[0]) + 1));
if (show_progress) {
printf(" aws_region set\n");
}
@@ -1192,7 +1207,7 @@ h5tools_populate_ros3_fapl(H5FD_ros3_fapl_t *fa, const char **values)
ret_value = 0;
goto done;
}
- memcpy(fa->secret_id, values[1], (HDstrlen(values[1]) + 1));
+ memcpy(fa->fa.secret_id, values[1], (HDstrlen(values[1]) + 1));
if (show_progress) {
printf(" secret_id set\n");
}
@@ -1204,17 +1219,29 @@ h5tools_populate_ros3_fapl(H5FD_ros3_fapl_t *fa, const char **values)
ret_value = 0;
goto done;
}
- memcpy(fa->secret_key, values[2], (HDstrlen(values[2]) + 1));
+ memcpy(fa->fa.secret_key, values[2], (HDstrlen(values[2]) + 1));
if (show_progress) {
printf(" secret_key set\n");
}
- fa->authenticate = TRUE;
+ if (HDstrlen(values[3]) > H5FD_ROS3_MAX_SECRET_TOK_LEN) {
+ if (show_progress) {
+ printf(" ERROR: token value too long\n");
+ }
+ ret_value = 0;
+ goto done;
+ }
+ memcpy(fa->token, values[3], (HDstrlen(values[3]) + 1));
+ if (show_progress) {
+ printf(" token set\n");
+ }
+
+ fa->fa.authenticate = TRUE;
if (show_progress) {
printf(" set to authenticate\n");
}
}
- else if (*values[0] != '\0' || *values[1] != '\0' || *values[2] != '\0') {
+ else if (*values[0] != '\0' || *values[1] != '\0' || *values[2] != '\0' || *values[3] != '\0') {
if (show_progress) {
printf(" ERROR: invalid assortment of empty/non-empty values\n");
}
@@ -1277,7 +1304,7 @@ h5tools_parse_hdfs_fapl_tuple(const char *tuple_str, int delim, H5FD_hdfs_fapl_t
HDstrncpy(fapl_config_out->user_name, (const char *)props[3], HDstrlen(props[3]));
}
if (HDstrncmp(props[4], "", 1)) {
- k = HDstrtoul((const char *)props[4], NULL, 0);
+ k = strtoul((const char *)props[4], NULL, 0);
if (errno == ERANGE)
H5TOOLS_GOTO_ERROR(FAIL, "supposed buffersize number wasn't");
fapl_config_out->stream_buffer_size = (int32_t)k;
diff --git a/tools/lib/h5tools_utils.h b/tools/lib/h5tools_utils.h
index c721ab4..2efa53f 100644
--- a/tools/lib/h5tools_utils.h
+++ b/tools/lib/h5tools_utils.h
@@ -61,6 +61,14 @@ typedef struct find_objs_t {
table_t *dset_table;
} find_objs_t;
+#ifdef H5_HAVE_ROS3_VFD
+/*extended configuration struct for holding the configuration data to the #H5FD_ROS3 driver */
+typedef struct H5FD_ros3_fapl_ext_t {
+ H5FD_ros3_fapl_t fa; /* ROS3 configuration struct*/
+ char token[H5FD_ROS3_MAX_SECRET_TOK_LEN + 1]; /* Session/security token*/
+} H5FD_ros3_fapl_ext_t;
+#endif /* H5_HAVE_ROS3_VFD */
+
H5TOOLS_DLLVAR unsigned h5tools_nCols; /*max number of columns for outputting */
/* Definitions of useful routines */
@@ -126,8 +134,8 @@ H5TOOLS_DLL void h5tools_setstatus(int d_status);
H5TOOLS_DLL int h5tools_getenv_update_hyperslab_bufsize(void);
#ifdef H5_HAVE_ROS3_VFD
H5TOOLS_DLL herr_t h5tools_parse_ros3_fapl_tuple(const char *tuple_str, int delim,
- H5FD_ros3_fapl_t *fapl_config_out);
-H5TOOLS_DLL int h5tools_populate_ros3_fapl(H5FD_ros3_fapl_t *fa, const char **values);
+ H5FD_ros3_fapl_ext_t *fapl_config_out);
+H5TOOLS_DLL int h5tools_populate_ros3_fapl(H5FD_ros3_fapl_ext_t *fa, const char **values);
#endif /* H5_HAVE_ROS3_VFD */
#ifdef H5_HAVE_LIBHDFS
H5TOOLS_DLL herr_t h5tools_parse_hdfs_fapl_tuple(const char *tuple_str, int delim,
diff --git a/tools/lib/h5trav.c b/tools/lib/h5trav.c
index 6b3ad0a..5ae379e 100644
--- a/tools/lib/h5trav.c
+++ b/tools/lib/h5trav.c
@@ -119,7 +119,6 @@ trav_token_add(trav_addr_t *visited, H5O_token_t *token, const char *path)
/* Allocate space if necessary */
if (visited->nused == visited->nalloc) {
visited->nalloc = MAX(1, visited->nalloc * 2);
- ;
visited->objs =
(trav_addr_path_t *)realloc(visited->objs, visited->nalloc * sizeof(trav_addr_path_t));
} /* end if */
@@ -322,8 +321,7 @@ trav_info_add(trav_info_t *info, const char *path, h5trav_type_t obj_type)
/* Allocate space if necessary */
if (info->nused == info->nalloc) {
info->nalloc = MAX(1, info->nalloc * 2);
- ;
- info->paths = (trav_path_t *)realloc(info->paths, info->nalloc * sizeof(trav_path_t));
+ info->paths = (trav_path_t *)realloc(info->paths, info->nalloc * sizeof(trav_path_t));
} /* end if */
/* Append it */
@@ -956,7 +954,7 @@ trav_print_visit_lnk(const char *path, const H5L_info2_t *linfo, void *udata)
printf(" %-10s %s -> %s\n", "link", path, targbuf);
free(targbuf);
}
- } /* end if */
+ }
else
printf(" %-10s %s ->\n", "link", path);
break;