summaryrefslogtreecommitdiffstats
path: root/tools/lib
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2010-08-19 19:55:48 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2010-08-19 19:55:48 (GMT)
commit2f6e3cb5bee1abac0be573123439938cb5d3096e (patch)
treefac2c21a94dde6fc226321a0df5a775d31f04269 /tools/lib
parente56b6f6c4019ad7dddf2325c91b134646fcb55e6 (diff)
downloadhdf5-2f6e3cb5bee1abac0be573123439938cb5d3096e.zip
hdf5-2f6e3cb5bee1abac0be573123439938cb5d3096e.tar.gz
hdf5-2f6e3cb5bee1abac0be573123439938cb5d3096e.tar.bz2
[svn-r19252] Description:
Bring Coverity changes from branch to trunk: r19161: Fixed the part for matching the subset info with dataset r19189: BZ1646: h5dump does not check number of dimensions for subsetting parameters against the dataset Changed subset_t structure from holding hsize_t pointers to holding new subset_d pointers, which hold the original hsize_t pointer + len. this len is then checked against dataset ndims in the handle_dataset function of h5dump. Changed all references to use new data structure. Added tests for each subset parameter. r19190: Added new h5dump ddl files Tested on: Mac OS X/32 10.6.4 (amazon) w/debug & production (h5committested on branch)
Diffstat (limited to 'tools/lib')
-rw-r--r--tools/lib/h5diff.h1
-rw-r--r--tools/lib/h5diff_util.c70
-rw-r--r--tools/lib/h5tools.c35
-rw-r--r--tools/lib/h5tools.h13
-rw-r--r--tools/lib/h5tools_utils.c80
-rw-r--r--tools/lib/h5tools_utils.h5
-rw-r--r--tools/lib/ph5diff.h2
7 files changed, 106 insertions, 100 deletions
diff --git a/tools/lib/h5diff.h b/tools/lib/h5diff.h
index ede6ea0..71993b8 100644
--- a/tools/lib/h5diff.h
+++ b/tools/lib/h5diff.h
@@ -154,7 +154,6 @@ hsize_t diff_attr(hid_t loc1_id,
*/
void print_found(hsize_t nfound);
-void parallel_print(const char* format, ... );
void print_type(hid_t type);
const char* diff_basename(const char *name);
const char* get_type(h5trav_type_t type);
diff --git a/tools/lib/h5diff_util.c b/tools/lib/h5diff_util.c
index 721c3d7..5df94fa 100644
--- a/tools/lib/h5diff_util.c
+++ b/tools/lib/h5diff_util.c
@@ -21,76 +21,6 @@
/* global variables */
int g_nTasks = 1;
-unsigned char g_Parallel = 0; /*0 for serial, 1 for parallel */
-char outBuff[OUTBUFF_SIZE];
-int outBuffOffset;
-FILE* overflow_file = NULL;
-
-/*-------------------------------------------------------------------------
- * Function: parallel_print
- *
- * Purpose: wrapper for printf for use in parallel mode.
- *
- * Programmer: Leon Arber
- *
- * Date: December 1, 2004
- *
- *-------------------------------------------------------------------------
- */
-void parallel_print(const char* format, ...)
-{
- int bytes_written;
- va_list ap;
-
- va_start(ap, format);
-
- if(!g_Parallel)
- vprintf(format, ap);
- else
- {
-
- if(overflow_file == NULL) /*no overflow has occurred yet */
- {
-#if 0
- printf("calling HDvsnprintf: OUTBUFF_SIZE=%ld, outBuffOffset=%ld, ", (long)OUTBUFF_SIZE, (long)outBuffOffset);
-#endif
- bytes_written = HDvsnprintf(outBuff+outBuffOffset, OUTBUFF_SIZE-outBuffOffset, format, ap);
-#if 0
- printf("bytes_written=%ld\n", (long)bytes_written);
-#endif
- va_end(ap);
- va_start(ap, format);
-
-#if 0
- printf("Result: bytes_written=%ld, OUTBUFF_SIZE-outBuffOffset=%ld\n", (long)bytes_written, (long)OUTBUFF_SIZE-outBuffOffset);
-#endif
-
- if ((bytes_written < 0) ||
-#ifdef H5_VSNPRINTF_WORKS
- (bytes_written >= (OUTBUFF_SIZE-outBuffOffset))
-#else
- ((bytes_written+1) == (OUTBUFF_SIZE-outBuffOffset))
-#endif
- )
- {
- /* Terminate the outbuff at the end of the previous output */
- outBuff[outBuffOffset] = '\0';
-
- overflow_file = HDtmpfile();
- if(overflow_file == NULL)
- fprintf(stderr, "warning: could not create overflow file. Output may be truncated.\n");
- else
- bytes_written = HDvfprintf(overflow_file, format, ap);
- }
- else
- outBuffOffset += bytes_written;
- }
- else
- bytes_written = HDvfprintf(overflow_file, format, ap);
-
- }
- va_end(ap);
-}
/*-------------------------------------------------------------------------
* Function: print_dimensions
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c
index 60f5d01..3cfe56b 100644
--- a/tools/lib/h5tools.c
+++ b/tools/lib/h5tools.c
@@ -1985,7 +1985,7 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c
if (ctx->ndims > 0)
init_acc_pos(ctx, total_size);
- size_row_block = sset->block[row_dim];
+ size_row_block = sset->block.data[row_dim];
/* display loop */
for (; hyperslab_count > 0; temp_start[row_dim] += temp_stride[row_dim], hyperslab_count--) {
@@ -1993,9 +1993,9 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c
cases where block > 1 only and stride > block */
if (size_row_block > 1
&& row_counter == size_row_block
- && sset->stride[row_dim] > sset->block[row_dim]) {
+ && sset->stride.data[row_dim] > sset->block.data[row_dim]) {
- hsize_t increase_rows = sset->stride[row_dim] - sset->block[row_dim];
+ hsize_t increase_rows = sset->stride.data[row_dim] - sset->block.data[row_dim];
temp_start[row_dim] += increase_rows;
row_counter = 0;
}
@@ -2153,22 +2153,22 @@ h5tools_display_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools
if (ctx->ndims > 2)
for (i = 0; i < (size_t) ctx->ndims - 2; i++) {
/* consider block size */
- outer_count = outer_count * sset->count[i] * sset->block[i];
+ outer_count = outer_count * sset->count.data[i] * sset->block.data[i];
}
/* initialize temporary start, count and maximum start */
for (i = 0; i < (size_t) ctx->ndims; i++) {
- temp_start[i] = sset->start[i];
- temp_count[i] = sset->count[i];
- temp_block[i] = sset->block[i];
- temp_stride[i] = sset->stride[i];
+ temp_start[i] = sset->start.data[i];
+ temp_count[i] = sset->count.data[i];
+ temp_block[i] = sset->block.data[i];
+ temp_stride[i] = sset->stride.data[i];
max_start[i] = 0;
}
if (ctx->ndims > 2) {
for (i = 0; i < (size_t) ctx->ndims - 2; i++) {
- max_start[i] = temp_start[i] + sset->count[i];
+ max_start[i] = temp_start[i] + sset->count.data[i];
temp_count[i] = 1;
}
@@ -2181,14 +2181,14 @@ h5tools_display_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools
/* count is the number of iterations to display all the rows,
the block size count times */
- count = sset->count[row_dim] * sset->block[row_dim];
+ count = sset->count.data[row_dim] * sset->block.data[row_dim];
/* always 1 row_counter at a time, that is a block of size 1, 1 time */
temp_count[row_dim] = 1;
temp_block[row_dim] = 1;
/* advance 1 row_counter at a time */
- if (sset->block[row_dim] > 1)
+ if (sset->block.data[row_dim] > 1)
temp_stride[row_dim] = 1;
}
@@ -2207,7 +2207,7 @@ h5tools_display_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools
/* set start to original from current_outer_dim up */
for (i = current_outer_dim + 1; i < ctx->ndims; i++) {
- temp_start[i] = sset->start[i];
+ temp_start[i] = sset->start.data[i];
}
/* increment start dimension */
@@ -2215,10 +2215,10 @@ h5tools_display_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools
reset_dim = 0;
temp_start[current_outer_dim]++;
if (temp_start[current_outer_dim] >= max_start[current_outer_dim]) {
- temp_start[current_outer_dim] = sset->start[current_outer_dim];
+ temp_start[current_outer_dim] = sset->start.data[current_outer_dim];
/* consider block */
- if (sset->block[current_outer_dim] > 1)
+ if (sset->block.data[current_outer_dim] > 1)
temp_start[current_outer_dim]++;
current_outer_dim--;
@@ -2626,7 +2626,6 @@ h5tools_dump_dset(FILE *stream, const h5tool_format_t *info, hid_t dset,
H5S_class_t space_type;
int status = FAIL;
h5tool_format_t info_dflt;
-
/* Use default values */
if (!stream)
stream = stdout;
@@ -2661,12 +2660,10 @@ h5tools_dump_dset(FILE *stream, const h5tool_format_t *info, hid_t dset,
/* Print the data */
if (space_type == H5S_SIMPLE || space_type == H5S_SCALAR) {
- if (!sset) {
+ if(!sset)
status = h5tools_dump_simple_dset(stream, info, dset, p_type, indentlevel);
- }
- else {
+ else
status = h5tools_dump_simple_subset(stream, info, dset, p_type, sset, indentlevel);
- }
}
else
/* space is H5S_NULL */
diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h
index ab72025..b3e3dd2 100644
--- a/tools/lib/h5tools.h
+++ b/tools/lib/h5tools.h
@@ -507,12 +507,17 @@ typedef struct h5tools_context_t {
hsize_t sm_pos; /* current stripmine element position */
} h5tools_context_t;
+typedef struct subset_d {
+ hsize_t *data;
+ unsigned int len;
+} subset_d;
+
/* a structure to hold the subsetting particulars for a dataset */
struct subset_t {
- hsize_t *start;
- hsize_t *stride;
- hsize_t *count;
- hsize_t *block;
+ subset_d start;
+ subset_d stride;
+ subset_d count;
+ subset_d block;
};
/* The following include, h5tools_str.h, must be after the
diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c
index b226bd7..2e3c756 100644
--- a/tools/lib/h5tools_utils.c
+++ b/tools/lib/h5tools_utils.c
@@ -42,6 +42,12 @@ const char *opt_arg; /*flag argument (or value) */
static int h5tools_d_status = 0;
static const char *h5tools_progname = "h5tools";
+/* ``parallel_print'' variables */
+unsigned char g_Parallel = 0; /*0 for serial, 1 for parallel */
+char outBuff[OUTBUFF_SIZE];
+int outBuffOffset;
+FILE* overflow_file = NULL;
+
/* local functions */
static void init_table(table_t **tbl);
#ifdef H5DUMP_DEBUG
@@ -49,6 +55,72 @@ static void dump_table(char* tablename, table_t *table);
#endif /* H5DUMP_DEBUG */
static void add_obj(table_t *table, haddr_t objno, const char *objname, hbool_t recorded);
+/*-------------------------------------------------------------------------
+ * Function: parallel_print
+ *
+ * Purpose: wrapper for printf for use in parallel mode.
+ *
+ * Programmer: Leon Arber
+ *
+ * Date: December 1, 2004
+ *
+ *-------------------------------------------------------------------------
+ */
+void parallel_print(const char* format, ...)
+{
+ int bytes_written;
+ va_list ap;
+
+ va_start(ap, format);
+
+ if(!g_Parallel)
+ vprintf(format, ap);
+ else
+ {
+
+ if(overflow_file == NULL) /*no overflow has occurred yet */
+ {
+#if 0
+ printf("calling HDvsnprintf: OUTBUFF_SIZE=%ld, outBuffOffset=%ld, ", (long)OUTBUFF_SIZE, (long)outBuffOffset);
+#endif
+ bytes_written = HDvsnprintf(outBuff+outBuffOffset, OUTBUFF_SIZE-outBuffOffset, format, ap);
+#if 0
+ printf("bytes_written=%ld\n", (long)bytes_written);
+#endif
+ va_end(ap);
+ va_start(ap, format);
+
+#if 0
+ printf("Result: bytes_written=%ld, OUTBUFF_SIZE-outBuffOffset=%ld\n", (long)bytes_written, (long)OUTBUFF_SIZE-outBuffOffset);
+#endif
+
+ if ((bytes_written < 0) ||
+#ifdef H5_VSNPRINTF_WORKS
+ (bytes_written >= (OUTBUFF_SIZE-outBuffOffset))
+#else
+ ((bytes_written+1) == (OUTBUFF_SIZE-outBuffOffset))
+#endif
+ )
+ {
+ /* Terminate the outbuff at the end of the previous output */
+ outBuff[outBuffOffset] = '\0';
+
+ overflow_file = HDtmpfile();
+ if(overflow_file == NULL)
+ fprintf(stderr, "warning: could not create overflow file. Output may be truncated.\n");
+ else
+ bytes_written = HDvfprintf(overflow_file, format, ap);
+ }
+ else
+ outBuffOffset += bytes_written;
+ }
+ else
+ bytes_written = HDvfprintf(overflow_file, format, ap);
+
+ }
+ va_end(ap);
+}
+
/*-------------------------------------------------------------------------
* Function: error_msg
@@ -591,7 +663,7 @@ add_obj(table_t *table, haddr_t objno, const char *objname, hbool_t record)
/* See if we need to make table larger */
if(table->nobjs == table->size) {
table->size *= 2;
- table->objs = HDrealloc(table->objs, table->size * sizeof(table->objs[0]));
+ table->objs = (struct obj_t *)HDrealloc(table->objs, table->size * sizeof(table->objs[0]));
} /* end if */
/* Increment number of objects in table */
@@ -690,7 +762,7 @@ H5tools_get_link_info(hid_t file_id, const char * linkpath, h5tool_link_info_t *
HDassert(link_info->trg_path);
/* get link value */
- if(H5Lget_val(file_id, linkpath, link_info->trg_path, link_info->linfo.u.val_size, H5P_DEFAULT) < 0) {
+ if(H5Lget_val(file_id, linkpath, (void *)link_info->trg_path, link_info->linfo.u.val_size, H5P_DEFAULT) < 0) {
if(link_info->opt.msg_mode == 1)
parallel_print("Warning: unable to get link value from <%s>\n",linkpath);
goto out;
@@ -769,12 +841,12 @@ void h5tools_setstatus(int D_status)
h5tools_d_status = D_status;
}
-const char*h5tools_getprogname()
+const char*h5tools_getprogname(void)
{
return h5tools_progname;
}
-int h5tools_getstatus()
+int h5tools_getstatus(void)
{
return h5tools_d_status;
}
diff --git a/tools/lib/h5tools_utils.h b/tools/lib/h5tools_utils.h
index 14a7daa..82a5a02 100644
--- a/tools/lib/h5tools_utils.h
+++ b/tools/lib/h5tools_utils.h
@@ -28,6 +28,10 @@
extern "C" {
#endif
+/* ``parallel_print'' information */
+#define PRINT_DATA_MAX_SIZE 512
+#define OUTBUFF_SIZE (PRINT_DATA_MAX_SIZE*4)
+
/*
* begin get_option section
*/
@@ -110,6 +114,7 @@ H5TOOLS_DLLVAR int nCols; /*max number of columns for outputti
/* Definitions of useful routines */
H5TOOLS_DLL void indentation(int);
H5TOOLS_DLL void print_version(const char *progname);
+H5TOOLS_DLL void parallel_print(const char* format, ... );
H5TOOLS_DLL void error_msg(const char *fmt, ...);
H5TOOLS_DLL void warn_msg(const char *fmt, ...);
H5TOOLS_DLL void free_table(table_t *table);
diff --git a/tools/lib/ph5diff.h b/tools/lib/ph5diff.h
index 3ad158f..e48a643 100644
--- a/tools/lib/ph5diff.h
+++ b/tools/lib/ph5diff.h
@@ -16,8 +16,6 @@
#ifndef _PH5DIFF_H__
#define _PH5DIFF_H__
-#define PRINT_DATA_MAX_SIZE 512
-#define OUTBUFF_SIZE (PRINT_DATA_MAX_SIZE*4)
/* Send from manager to workers */
#define MPI_TAG_ARGS 1
#define MPI_TAG_PRINT_TOK 2