summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/h5import/h5import.c17
-rw-r--r--tools/lib/h5diff.c2
-rw-r--r--tools/lib/h5trav.c102
-rw-r--r--tools/lib/h5trav.h12
4 files changed, 55 insertions, 78 deletions
diff --git a/tools/h5import/h5import.c b/tools/h5import/h5import.c
index a10ef24..74c67b9 100644
--- a/tools/h5import/h5import.c
+++ b/tools/h5import/h5import.c
@@ -863,11 +863,11 @@ static int processStrData(FILE *strm, struct Input *in, hid_t file_id)
hid_t handle;
hsize_t dims[1];
char str[1024];
- char c;
+ int c;
int i = 0;
int j;
- int nlines = 0;
- int line;
+ hsize_t nlines = 0;
+ hsize_t line;
/*-------------------------------------------------------------------------
* get number of lines in the input file
@@ -877,9 +877,8 @@ static int processStrData(FILE *strm, struct Input *in, hid_t file_id)
while (!HDfeof(strm)) {
c = HDfgetc(strm);
- if (c == 10) { /* eol */
+ if (c == 10) /* eol */
nlines++;
- }
}
if (!nlines)
@@ -944,7 +943,7 @@ static int processStrData(FILE *strm, struct Input *in, hid_t file_id)
while (!HDfeof(strm)) {
c = HDfgetc(strm);
- str[i] = c;
+ str[i] = (char)c;
i++;
@@ -1012,7 +1011,7 @@ static int processStrHDFData(FILE *strm, struct Input *in, hid_t file_id)
char *str3 = NULL;
char str[1024] = "";
int j;
- int line;
+ hsize_t line;
/*-------------------------------------------------------------------------
* read file and generate an HDF5 dataset
@@ -1079,7 +1078,7 @@ static int processStrHDFData(FILE *strm, struct Input *in, hid_t file_id)
str2 = NULL;
str3 = NULL;
#ifdef H5DEBUGIMPORT
- printf("processStrHDFData DATATYPE STRING[%d]={%s}\n", line, str1);
+ printf("processStrHDFData DATATYPE STRING[%llu]={%s}\n", (unsigned long long)line, str1);
#endif
/* process string to remove the first and last quote char */
str2 = strchr(str1, '"');
@@ -1108,7 +1107,7 @@ static int processStrHDFData(FILE *strm, struct Input *in, hid_t file_id)
hsize_t count[1] = { 1 };
#ifdef H5DEBUGIMPORT
- printf("processStrHDFData DATATYPE STRING[%d] store %s\n", line, str2);
+ printf("processStrHDFData DATATYPE STRING[%llu] store %s\n", (unsigned long long)line, str2);
#endif
if ((fspace_id = H5Dget_space(dset_id)) < 0)
goto out;
diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c
index ab21bfd..884a85d 100644
--- a/tools/lib/h5diff.c
+++ b/tools/lib/h5diff.c
@@ -1096,7 +1096,6 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1,
char * grp2_path = "";
char * obj1_fullpath = NULL;
char * obj2_fullpath = NULL;
- h5trav_type_t objtype;
diff_args_t argdata;
size_t idx1 = 0;
size_t idx2 = 0;
@@ -1163,7 +1162,6 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1,
{
if( table->objs[i].flags[0] && table->objs[i].flags[1])
{
- objtype = table->objs[i].type;
/* make full path for obj1 */
obj1_fullpath = (char*)HDcalloc (HDstrlen(grp1_path) + strlen (table->objs[i].name) + 1, sizeof (char));
HDstrcpy(obj1_fullpath, grp1_path);
diff --git a/tools/lib/h5trav.c b/tools/lib/h5trav.c
index fca3096..d0a4a76 100644
--- a/tools/lib/h5trav.c
+++ b/tools/lib/h5trav.c
@@ -21,13 +21,15 @@
* local typedefs
*-------------------------------------------------------------------------
*/
+typedef struct trav_addr_path_t {
+ haddr_t addr;
+ char *path;
+} trav_addr_path_t;
+
typedef struct trav_addr_t {
size_t nalloc;
size_t nused;
- struct {
- haddr_t addr;
- char *path;
- } *objs;
+ trav_addr_path_t *objs;
} trav_addr_t;
typedef struct {
@@ -132,7 +134,7 @@ trav_addr_add(trav_addr_t *visited, haddr_t addr, const char *path)
/* Allocate space if necessary */
if(visited->nused == visited->nalloc) {
visited->nalloc = MAX(1, visited->nalloc * 2);;
- visited->objs = HDrealloc(visited->objs, visited->nalloc * sizeof(visited->objs[0]));
+ visited->objs = (trav_addr_path_t *)HDrealloc(visited->objs, visited->nalloc * sizeof(trav_addr_path_t));
} /* end if */
/* Append it */
@@ -194,14 +196,15 @@ traverse_cb(hid_t loc_id, const char *path, const H5L_info_t *linfo,
/* Create the full path name for the link */
if(udata->is_absolute) {
size_t base_len = HDstrlen(udata->base_grp_name);
- size_t add_slash = base_len ? ((udata->base_grp_name)[base_len-1] != '/') : 1;
+ size_t add_slash = base_len ? ((udata->base_grp_name)[base_len - 1] != '/') : 1;
+ size_t new_name_len = base_len + add_slash + HDstrlen(path) + 1;
- if(NULL == (new_name = (char*)HDmalloc(base_len + add_slash + HDstrlen(path) + 1)))
+ if(NULL == (new_name = (char*)HDmalloc(new_name_len)))
return(H5_ITER_ERROR);
- HDstrcpy(new_name, udata->base_grp_name);
- if (add_slash)
- new_name[base_len] = '/';
- HDstrcpy(new_name + base_len + add_slash, path);
+ if(add_slash)
+ HDsnprintf(new_name, new_name_len, "%s/%s", udata->base_grp_name, path);
+ else
+ HDsnprintf(new_name, new_name_len, "%s%s", udata->base_grp_name, path);
full_name = new_name;
} /* end if */
else
@@ -216,7 +219,7 @@ traverse_cb(hid_t loc_id, const char *path, const H5L_info_t *linfo,
if(new_name)
HDfree(new_name);
return(H5_ITER_ERROR);
- }
+ } /* end if */
/* If the object has multiple links, add it to the list of addresses
* already visited, if it isn't there already
@@ -231,7 +234,7 @@ traverse_cb(hid_t loc_id, const char *path, const H5L_info_t *linfo,
if(new_name)
HDfree(new_name);
return(H5_ITER_ERROR);
- }
+ } /* end if */
} /* end if */
else {
/* Make 'visit link' callback */
@@ -240,7 +243,7 @@ traverse_cb(hid_t loc_id, const char *path, const H5L_info_t *linfo,
if(new_name)
HDfree(new_name);
return(H5_ITER_ERROR);
- }
+ } /* end if */
} /* end else */
if(new_name)
@@ -730,7 +733,7 @@ trav_table_add(trav_table_t *table,
if(table->nobjs == table->size) {
table->size = MAX(1, table->size * 2);
- table->objs = (trav_obj_t*)HDrealloc(table->objs, table->size * sizeof(trav_obj_t));
+ table->objs = (trav_obj_t *)HDrealloc(table->objs, table->size * sizeof(trav_obj_t));
} /* end if */
new_obj = table->nobjs++;
@@ -774,7 +777,7 @@ trav_table_addlink(trav_table_t *table, haddr_t objno, const char *path)
/* allocate space if necessary */
if(table->objs[i].nlinks == (unsigned)table->objs[i].sizelinks) {
table->objs[i].sizelinks = MAX(1, table->objs[i].sizelinks * 2);
- table->objs[i].links = (trav_link_t*)HDrealloc(table->objs[i].links, table->objs[i].sizelinks * sizeof(trav_link_t));
+ table->objs[i].links = (trav_link_t *)HDrealloc(table->objs[i].links, table->objs[i].sizelinks * sizeof(trav_link_t));
} /* end if */
/* insert it */
@@ -1168,31 +1171,21 @@ h5trav_visit(hid_t fid, const char *grp_name, hbool_t visit_start,
*
* Date: September 5, 2008
*
- * Modified:
- * Jonathan Kim
- * - Moved from h5ls.c to share among tools. (Sep 16, 2010)
- * - Renamed from elink_trav_add to symlink_visit_add for both soft and
- * external links. (May 25, 2010)
- * - Add type parameter to distingush between soft and external link for
- * sure, which prevent from mixing up visited link when the target names
- * are same between the soft and external link, as code marks with the
- * target name. (May 25,2010)
- *
*-------------------------------------------------------------------------
*/
herr_t
symlink_visit_add(symlink_trav_t *visited, H5L_type_t type, const char *file, const char *path)
{
size_t idx; /* Index of address to use */
- void *tmp_ptr;
/* Allocate space if necessary */
- if(visited->nused == visited->nalloc)
- {
+ if(visited->nused == visited->nalloc) {
+ void *tmp_ptr;
+
visited->nalloc = MAX(1, visited->nalloc * 2);
- if(NULL == (tmp_ptr = HDrealloc(visited->objs, visited->nalloc * sizeof(visited->objs[0]))))
+ if(NULL == (tmp_ptr = HDrealloc(visited->objs, visited->nalloc * sizeof(symlink_trav_path_t))))
return -1;
- visited->objs = tmp_ptr;
+ visited->objs = (symlink_trav_path_t *)tmp_ptr;
} /* end if */
/* Append it */
@@ -1202,22 +1195,19 @@ symlink_visit_add(symlink_trav_t *visited, H5L_type_t type, const char *file, co
visited->objs[idx].file = NULL;
visited->objs[idx].path = NULL;
- if (type == H5L_TYPE_EXTERNAL)
- {
- if(NULL == (visited->objs[idx].file = HDstrdup(file)))
- {
+ if(type == H5L_TYPE_EXTERNAL) {
+ if(NULL == (visited->objs[idx].file = HDstrdup(file))) {
visited->nused--;
return -1;
- }
- }
+ } /* end if */
+ } /* end if */
- if(NULL == (visited->objs[idx].path = HDstrdup(path)))
- {
+ if(NULL == (visited->objs[idx].path = HDstrdup(path))) {
visited->nused--;
- if (visited->objs[idx].file)
+ if(visited->objs[idx].file)
HDfree (visited->objs[idx].file);
return -1;
- }
+ } /* end if */
return 0;
} /* end symlink_visit_add() */
@@ -1235,16 +1225,6 @@ symlink_visit_add(symlink_trav_t *visited, H5L_type_t type, const char *file, co
*
* Date: September 5, 2008
*
- * Modified:
- * Jonathan Kim
- * - Moved from h5ls.c to share among tools. (Sep 16, 2010)
- * - Renamed from elink_trav_visited to symlink_is_visited for both soft and
- * external links. (May 25, 2010)
- * - Add type parameter to distingush between soft and external link for
- * sure, which prevent from mixing up visited link when the target names
- * are same between the soft and external link, as code marks with the
- * target name. (May 25,2010)
- *
*-------------------------------------------------------------------------
*/
hbool_t
@@ -1253,21 +1233,19 @@ symlink_is_visited(symlink_trav_t *visited, H5L_type_t type, const char *file, c
size_t u; /* Local index variable */
/* Look for symlink */
- for(u = 0; u < visited->nused; u++)
- {
+ for(u = 0; u < visited->nused; u++) {
/* Check for symlink values already in array */
/* check type and path pair to distingush between symbolic links */
- if ((visited->objs[u].type == type) && !HDstrcmp(visited->objs[u].path, path))
- {
+ if((visited->objs[u].type == type) && !HDstrcmp(visited->objs[u].path, path)) {
/* if external link, file need to be matched as well */
- if (visited->objs[u].type == H5L_TYPE_EXTERNAL)
- {
- if (!HDstrcmp(visited->objs[u].file, file))
- return (TRUE);
- }
+ if(visited->objs[u].type == H5L_TYPE_EXTERNAL)
+ if(!HDstrcmp(visited->objs[u].file, file))
+ return(TRUE);
+
return (TRUE);
- }
- }
+ } /* end if */
+ } /* end for */
+
/* Didn't find symlink */
return(FALSE);
} /* end symlink_is_visited() */
diff --git a/tools/lib/h5trav.h b/tools/lib/h5trav.h
index 3548c6b..352a9e5 100644
--- a/tools/lib/h5trav.h
+++ b/tools/lib/h5trav.h
@@ -51,14 +51,16 @@ typedef enum {
/* Struct to keep track of symbolic link targets visited.
* Functions: symlink_visit_add() and symlink_is_visited()
*/
+typedef struct symlink_trav_path_t {
+ H5L_type_t type;
+ char *file;
+ char *path;
+} symlink_trav_path_t;
+
typedef struct symlink_trav_t {
size_t nalloc;
size_t nused;
- struct {
- H5L_type_t type;
- char *file;
- char *path;
- } *objs;
+ symlink_trav_path_t *objs;
hbool_t dangle_link;
} symlink_trav_t;