summaryrefslogtreecommitdiffstats
path: root/tools/h5dump/h5dump.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/h5dump/h5dump.c')
-rw-r--r--tools/h5dump/h5dump.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c
index 261fe15..6b1f576 100644
--- a/tools/h5dump/h5dump.c
+++ b/tools/h5dump/h5dump.c
@@ -132,7 +132,7 @@ static h5tool_format_t dataformat = {
"", /*fmt_raw */
"%d", /*fmt_int */
"%u", /*fmt_uint */
- "%d", /*fmt_schar */
+ "%hhd", /*fmt_schar */
"%u", /*fmt_uchar */
"%d", /*fmt_short */
"%u", /*fmt_ushort */
@@ -216,7 +216,7 @@ static h5tool_format_t xml_dataformat = {
"", /*fmt_raw */
"%d", /*fmt_int */
"%u", /*fmt_uint */
- "%d", /*fmt_schar */
+ "%hhd", /*fmt_schar */
"%u", /*fmt_uchar */
"%d", /*fmt_short */
"%u", /*fmt_ushort */
@@ -2211,7 +2211,6 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset)
unsigned attr_crt_order_flags;
hid_t dcpl_id; /* dataset creation property list ID */
-
if ((dcpl_id = H5Dget_create_plist(did)) < 0)
{
error_msg("error in getting creation property list ID\n");
@@ -2646,15 +2645,27 @@ dump_oid(hid_t oid)
static void
dump_comment(hid_t obj_id)
{
- char comment[50];
-
- comment[0] = '\0';
- H5Oget_comment(obj_id, comment, sizeof(comment));
+ size_t buf_size = 0;
+ char* comment = NULL;
+ ssize_t cmt_bufsize = -1;
+
+ cmt_bufsize = H5Oget_comment(obj_id, comment, buf_size);
+
+ /* call H5Oget_comment again with the correct value.
+ * If the call to H5Oget_comment returned an error, skip this block */
+ if (cmt_bufsize > 0) {
+ comment = (char *)HDmalloc((size_t)cmt_bufsize); /* new_size including null terminator */
+ if(comment) {
+ cmt_bufsize = H5Oget_comment(obj_id, comment, cmt_bufsize);
+ if(cmt_bufsize > 0) {
+ comment[cmt_bufsize] = '\0'; /* necessary because null char is not returned */
+ indentation(indent);
+ printf("COMMENT \"%s\"\n", comment);
+ } /* end if */
+ HDfree(comment);
+ }
+ }
- if(comment[0]) {
- indentation(indent);
- printf("COMMENT \"%s\"\n", comment);
- } /* end if */
} /* end dump_comment() */
@@ -3988,7 +3999,7 @@ parse_start:
leave(EXIT_SUCCESS);
break;
case 'w':
- nCols = atoi(opt_arg);
+ nCols = HDatoi(opt_arg);
last_was_dset = FALSE;
break;
case 'a':