summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2003-10-13 19:31:33 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2003-10-13 19:31:33 (GMT)
commit324cd9d1e28824d4f686809b21e3d41deb1bf515 (patch)
tree26ba64ea19947af4a9933ceb479af5005137686e /tools
parent4a4f9cd82d950fb752587125cb2a011d14ec2223 (diff)
downloadhdf5-324cd9d1e28824d4f686809b21e3d41deb1bf515.zip
hdf5-324cd9d1e28824d4f686809b21e3d41deb1bf515.tar.gz
hdf5-324cd9d1e28824d4f686809b21e3d41deb1bf515.tar.bz2
[svn-r7616] Purpose:
Code cleanup Description: Change field member count and indices for compound and enumerated types from 'int' to 'unsigned' to better reflect actual use. Cleaned up a few other minor compiler warnings, etc. Platforms tested: FreeBSD 4.9 (sleipnir) Linux 2.4 (verbena) too minor to require h5committest
Diffstat (limited to 'tools')
-rw-r--r--tools/h5dump/h5dump.c70
-rw-r--r--tools/h5ls/h5ls.c66
-rw-r--r--tools/lib/h5tools_str.c5
3 files changed, 76 insertions, 65 deletions
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c
index 84bf544..24a0e08 100644
--- a/tools/h5dump/h5dump.c
+++ b/tools/h5dump/h5dump.c
@@ -619,8 +619,11 @@ static void
print_datatype(hid_t type,unsigned in_group)
{
char *fname;
- hid_t nmembers, mtype, str_type;
- int i, j, ndims, perm[H5DUMP_MAX_RANK];
+ hid_t mtype, str_type;
+ unsigned nmembers;
+ int perm[H5DUMP_MAX_RANK];
+ unsigned ndims;
+ unsigned i;
size_t size=0;
hsize_t dims[H5DUMP_MAX_RANK];
H5T_str_t str_pad;
@@ -629,16 +632,17 @@ print_datatype(hid_t type,unsigned in_group)
hid_t super;
hid_t tmp_type;
htri_t is_vlstr=FALSE;
+ herr_t ret; /* Generic return value */
if (!in_group && H5Tcommitted(type) > 0) {
H5Gget_objinfo(type, ".", TRUE, &statbuf);
- i = search_obj(type_table, statbuf.objno);
+ ret = search_obj(type_table, statbuf.objno);
- if (i >= 0) {
- if (!type_table->objs[i].recorded)
- HDfprintf(stdout,"\"/#%a\"", type_table->objs[i].objno);
+ if (ret >= 0) {
+ if (!type_table->objs[ret].recorded)
+ HDfprintf(stdout,"\"/#%a\"", type_table->objs[ret].objno);
else
- printf("\"%s\"", type_table->objs[i].objname);
+ printf("\"%s\"", type_table->objs[ret].objname);
} else {
error_msg(progname, "unknown committed type.\n");
d_status = EXIT_FAILURE;
@@ -901,8 +905,8 @@ print_datatype(hid_t type,unsigned in_group)
H5Tget_array_dims(type, dims, perm);
/* Print array dimensions */
- for (j = 0; j < ndims; j++)
- printf("[%d]", (int) dims[j]);
+ for (i = 0; i < ndims; i++)
+ printf("[%d]", (int) dims[i]);
printf(" ");
@@ -3004,14 +3008,15 @@ print_enum(hid_t type)
{
char **name = NULL; /*member names */
unsigned char *value = NULL; /*value array */
- int nmembs; /*number of members */
+ unsigned nmembs; /*number of members */
int nchars; /*number of output characters */
hid_t super; /*enum base integer type */
hid_t native = -1; /*native integer data type */
size_t dst_size; /*destination value type size */
- int i;
+ unsigned i;
nmembs = H5Tget_nmembers(type);
+ assert(nmembs>0);
super = H5Tget_super(type);
/*
@@ -3034,9 +3039,8 @@ print_enum(hid_t type)
}
/* Get the names and raw values of all members */
- assert(nmembs>0);
- name = calloc((size_t)nmembs, sizeof(char *));
- value = calloc((size_t)nmembs, MAX(H5Tget_size(type), dst_size));
+ name = calloc(nmembs, sizeof(char *));
+ value = calloc(nmembs, MAX(H5Tget_size(type), dst_size));
for (i = 0; i < nmembs; i++) {
name[i] = H5Tget_member_name(type, i);
@@ -3624,8 +3628,11 @@ static void
xml_print_datatype(hid_t type, unsigned in_group)
{
char *fname;
- hid_t nmembers, mtype;
- int i, j, ndims, perm[H5DUMP_MAX_RANK];
+ hid_t mtype;
+ unsigned nmembers;
+ int perm[H5DUMP_MAX_RANK];
+ unsigned ndims;
+ unsigned i;
size_t size;
hsize_t dims[H5DUMP_MAX_RANK];
H5T_str_t str_pad;
@@ -3642,20 +3649,21 @@ xml_print_datatype(hid_t type, unsigned in_group)
size_t msize;
int nmembs;
htri_t is_vlstr=FALSE;
+ herr_t ret;
if (!in_group && H5Tcommitted(type) > 0) {
/* detect a shared datatype, output only once */
H5Gget_objinfo(type, ".", TRUE, &statbuf);
- i = search_obj(type_table, statbuf.objno);
+ ret = search_obj(type_table, statbuf.objno);
- if (i >= 0) {
+ if (ret >= 0) {
/* This should be defined somewhere else */
/* These 2 cases are handled the same right now, but
probably will have something different eventually */
int res;
char * dtxid = malloc(100);
- res = xml_name_to_XID(type_table->objs[i].objname,dtxid,100,1);
- if (!type_table->objs[i].recorded) {
+ res = xml_name_to_XID(type_table->objs[ret].objname,dtxid,100,1);
+ if (!type_table->objs[ret].recorded) {
/* 'anonymous' NDT. Use it's object num.
as it's name. */
printf("<%sNamedDataTypePtr OBJ-XID=\"/%s\"/>\n",
@@ -3663,7 +3671,7 @@ xml_print_datatype(hid_t type, unsigned in_group)
dtxid);
} else {
/* point to the NDT by name */
- char *t_objname = xml_escape_the_name(type_table->objs[i].objname);
+ char *t_objname = xml_escape_the_name(type_table->objs[ret].objname);
printf("<%sNamedDataTypePtr OBJ-XID=\"%s\" H5Path=\"%s\"/>\n",
xmlnsprefix,
dtxid,t_objname);
@@ -3943,7 +3951,7 @@ xml_print_datatype(hid_t type, unsigned in_group)
indentation(indent);
printf("<%sArrayType Ndims=\"",xmlnsprefix);
ndims = H5Tget_array_ndims(type);
- printf("%d\">\n", ndims);
+ printf("%u\">\n", ndims);
/* Get array information */
H5Tget_array_dims(type, dims, perm);
@@ -3952,17 +3960,17 @@ xml_print_datatype(hid_t type, unsigned in_group)
indent += COL;
if (perm != NULL) {
/* for each dimension, list */
- for (j = 0; j < ndims; j++) {
+ for (i = 0; i < ndims; i++) {
indentation(indent);
printf("<%sArrayDimension DimSize=\"%u\" DimPerm=\"%u\"/>\n",
- xmlnsprefix,(int) dims[j], (int) perm[j]);
+ xmlnsprefix,(int) dims[i], (int) perm[i]);
}
} else {
- for (j = 0; j < ndims; j++) {
+ for (i = 0; i < ndims; i++) {
indentation(indent);
printf("<%sArrayDimension DimSize=\"%u\" DimPerm=\"0\"/>\n",
xmlnsprefix,
- (int) dims[j]);
+ (int) dims[i]);
}
}
indent -= COL;
@@ -5073,7 +5081,7 @@ char * name;
case H5T_ENUM:
indentation(indent);
printf("<%sDataFromFile>\n",xmlnsprefix);
- name = H5Tget_member_name(type, *(int *)buf);
+ name = H5Tget_member_name(type, *(unsigned *)buf);
indentation(indent);
printf("\"%s\"\n",name);
indentation(indent);
@@ -5412,11 +5420,11 @@ xml_print_enum(hid_t type)
{
char **name = NULL; /*member names */
unsigned char *value = NULL; /*value array */
- int nmembs; /*number of members */
+ unsigned nmembs; /*number of members */
hid_t super; /*enum base integer type */
hid_t native = -1; /*native integer data type */
size_t dst_size; /*destination value type size */
- int i; /*miscellaneous counters */
+ unsigned i; /*miscellaneous counters */
size_t j;
nmembs = H5Tget_nmembers(type);
@@ -5448,8 +5456,8 @@ xml_print_enum(hid_t type)
}
/* Get the names and raw values of all members */
- name = calloc((size_t)nmembs, sizeof(char *));
- value = calloc((size_t)nmembs, MAX(H5Tget_size(type), dst_size));
+ name = calloc(nmembs, sizeof(char *));
+ value = calloc(nmembs, MAX(H5Tget_size(type), dst_size));
for (i = 0; i < nmembs; i++) {
name[i] = H5Tget_member_name(type, i);
diff --git a/tools/h5ls/h5ls.c b/tools/h5ls/h5ls.c
index 0ee57ed..267e40f 100644
--- a/tools/h5ls/h5ls.c
+++ b/tools/h5ls/h5ls.c
@@ -703,11 +703,14 @@ display_cmpd_type(hid_t type, int ind)
char *name=NULL; /* member name */
size_t size; /* total size of type in bytes */
hid_t subtype; /* member data type */
- int i, n; /* miscellaneous counters */
+ unsigned nmembs; /* number of members */
+ int n; /* miscellaneous counters */
+ unsigned i; /* miscellaneous counters */
if (H5T_COMPOUND!=H5Tget_class(type)) return FALSE;
printf("struct {");
- for (i=0; i<H5Tget_nmembers(type); i++) {
+ nmembs=H5Tget_nmembers(type);
+ for (i=0; i<nmembs; i++) {
/* Name and offset */
name = H5Tget_member_name(type, i);
@@ -750,16 +753,17 @@ display_enum_type(hid_t type, int ind)
{
char **name=NULL; /* member names */
unsigned char *value=NULL; /* value array */
- int nmembs; /* number of members */
+ unsigned nmembs; /* number of members */
int nchars; /* number of output characters */
hid_t super; /* enum base integer type */
hid_t native=-1; /* native integer data type */
size_t dst_size; /* destination value type size */
- int i; /* miscellaneous counters */
+ unsigned i; /* miscellaneous counters */
size_t j;
if (H5T_ENUM!=H5Tget_class(type)) return FALSE;
nmembs = H5Tget_nmembers(type);
+ assert(nmembs>0);
super = H5Tget_super(type);
printf("enum ");
display_type(super, ind+4);
@@ -771,23 +775,22 @@ display_enum_type(hid_t type, int ind)
* 2. unsigned long_long -- the largest native unsigned integer
* 3. raw format */
if (H5Tget_size(type)<=sizeof(long_long)) {
- dst_size = sizeof(long_long);
- if (H5T_SGN_NONE==H5Tget_sign(type)) {
- native = H5T_NATIVE_ULLONG;
- } else {
- native = H5T_NATIVE_LLONG;
- }
+ dst_size = sizeof(long_long);
+ if (H5T_SGN_NONE==H5Tget_sign(type)) {
+ native = H5T_NATIVE_ULLONG;
+ } else {
+ native = H5T_NATIVE_LLONG;
+ }
} else {
- dst_size = H5Tget_size(type);
+ dst_size = H5Tget_size(type);
}
/* Get the names and raw values of all members */
- assert(nmembs>0);
- name = calloc((size_t)nmembs, sizeof(char*));
- value = calloc((size_t)nmembs, MAX(H5Tget_size(type), dst_size));
+ name = calloc(nmembs, sizeof(char*));
+ value = calloc(nmembs, MAX(H5Tget_size(type), dst_size));
for (i=0; i<nmembs; i++) {
- name[i] = H5Tget_member_name(type, i);
- H5Tget_member_value(type, i, value+i*H5Tget_size(type));
+ name[i] = H5Tget_member_name(type, i);
+ H5Tget_member_value(type, i, value+i*H5Tget_size(type));
}
/* Convert values to native data type */
@@ -798,22 +801,21 @@ display_enum_type(hid_t type, int ind)
/* Print members */
for (i=0; i<nmembs; i++) {
- printf("\n%*s", ind+4, "");
- nchars = display_string(stdout, name[i], TRUE);
- printf("%*s = ", MAX(0, 16-nchars), "");
-
- if (native<0) {
- printf("0x");
- for (j=0; j<dst_size; j++) {
- printf("%02x", value[i*dst_size+j]);
- }
- } else if (H5T_SGN_NONE==H5Tget_sign(native)) {
- HDfprintf(stdout,"%"H5_PRINTF_LL_WIDTH"u",
- *((unsigned long_long*)((void*)(value+i*dst_size))));
- } else {
- HDfprintf(stdout,"%"H5_PRINTF_LL_WIDTH"d",
- *((long_long*)((void*)(value+i*dst_size))));
- }
+ printf("\n%*s", ind+4, "");
+ nchars = display_string(stdout, name[i], TRUE);
+ printf("%*s = ", MAX(0, 16-nchars), "");
+
+ if (native<0) {
+ printf("0x");
+ for (j=0; j<dst_size; j++)
+ printf("%02x", value[i*dst_size+j]);
+ } else if (H5T_SGN_NONE==H5Tget_sign(native)) {
+ HDfprintf(stdout,"%"H5_PRINTF_LL_WIDTH"u",
+ *((unsigned long_long*)((void*)(value+i*dst_size))));
+ } else {
+ HDfprintf(stdout,"%"H5_PRINTF_LL_WIDTH"d",
+ *((long_long*)((void*)(value+i*dst_size))));
+ }
}
/* Release resources */
diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c
index ea65adc..de1bf72 100644
--- a/tools/lib/h5tools_str.c
+++ b/tools/lib/h5tools_str.c
@@ -515,7 +515,8 @@ h5tools_str_sprint(h5tools_str_t *str, const h5dump_t *info, hid_t container,
unsigned char *ucp_vp = (unsigned char *)vp;
char *cp_vp = (char *)vp;
hid_t memb, obj, region;
- int nmembs, otype;
+ unsigned nmembs;
+ int otype;
static char fmt_llong[8], fmt_ullong[8];
H5T_str_t pad;
H5G_stat_t sb;
@@ -682,7 +683,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5dump_t *info, hid_t container,
h5tools_str_append(str, OPT(info->fmt_ullong, fmt_ullong), tempullong);
}
} else if (H5Tget_class(type) == H5T_COMPOUND) {
- int j;
+ unsigned j;
nmembs = H5Tget_nmembers(type);
h5tools_str_append(str, "%s", OPT(info->cmpd_pre, "{"));