Fix warnings in h5_test

This commit is contained in:
Peter Hill 2024-03-11 17:12:04 +00:00
parent b3a3389202
commit e7540a33de
No known key found for this signature in database
GPG Key ID: 0C6B9742E72848EE
12 changed files with 44 additions and 46 deletions

View File

@ -45,7 +45,7 @@ main()
hssize_t size;
size_t type_size;
int ndims;
hsize_t num_obj;
int num_obj;
printf("\n*** Checking HDF5 attribute functions.\n");
printf("*** Checking HDF5 attribute ordering...");
@ -544,7 +544,8 @@ main()
#define DIM2_LEN 2
hid_t fileid, grpid, attid, spaceid, dimscaleid, att_spaceid;
hid_t fcpl_id, fapl_id;
hsize_t num_obj, dims[1];
hsize_t dims[1];
int num_obj;
char obj_name[MAX_LEN + 1];
char att_name[3][20] = {"first", "second", "third"};
signed char b[DIM2_LEN] = {-127, 126};
@ -630,7 +631,7 @@ main()
#define ATT_MAX_NAME 2
{
hid_t fileid, grpid, attid, att_spaceid;
hsize_t num_obj;
int num_obj;
char obj_name[MAX_LEN + 1];
char name[NUM_SIMPLE_ATTS][ATT_MAX_NAME + 1] = {"Gc", "Gb", "Gs", "Gi", "Gf",
"Gd", "G7", "G8", "G9"};

View File

@ -68,7 +68,7 @@ main()
/* Create some output data: a struct s3 array (length ATT_LEN)
* which holds an array of vlen (length NUM_VL) of struct s1. */
for (i = 0; i < ATT_LEN; i++)
for (size_t i = 0; i < ATT_LEN; i++)
for (j = 0; j < NUM_VL; j++)
{
cvc_out[i].data[j].len = i + 1;
@ -149,7 +149,7 @@ main()
if (num_obj != NUM_OBJ) ERR;
/* For each object in the group... */
for (i = 0; i < num_obj; i++)
for (hsize_t i = 0; i < num_obj; i++)
{
/* Get the name, and make sure this is a type. */
@ -223,7 +223,7 @@ main()
/* Create some output data: an array of vlen (length ATT_LEN) of
* int. */
for (i = 0; i < ATT_LEN; i++)
for (size_t i = 0; i < ATT_LEN; i++)
{
vc_out[i].len = i + 1;
if (!(vc_out[i].p = calloc(sizeof(int), vc_out[i].len))) ERR;
@ -278,7 +278,7 @@ main()
if (num_obj != NUM_OBJ_1) ERR;
/* For each object in the group... */
for (i = 0; i < num_obj; i++)
for (hsize_t i = 0; i < num_obj; i++)
{
/* Get the name, and make sure this is a type. */
#if H5_VERSION_GE(1,12,0)

View File

@ -69,7 +69,7 @@ main()
/* Create some output data: an array of vlen (length ATT_LEN) of
* struct s1. */
if (!(vc_out = calloc(sizeof(hvl_t), ATT_LEN))) ERR;
for (i = 0; i < ATT_LEN; i++)
for (size_t i = 0; i < ATT_LEN; i++)
{
vc_out[i].len = i + 1;
if (!(vc_out[i].p = calloc(sizeof(struct s1), vc_out[i].len))) ERR;
@ -140,7 +140,7 @@ main()
if (num_obj != NUM_OBJ_2) ERR;
/* For each object in the group... */
for (i = 0; i < num_obj; i++)
for (hsize_t i = 0; i < num_obj; i++)
{
/* Get the name, and make sure this is a type. */
#if H5_VERSION_GE(1,12,0)

View File

@ -156,7 +156,7 @@ main()
{
hsize_t num_obj;
int i, obj_type;
int obj_type;
char name[STR_LEN + 1];
htri_t equal;
@ -165,7 +165,7 @@ main()
if ((fileid = H5Fopen(FILE_NAME, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) ERR;
if ((osmonds_grpid = H5Gopen1(fileid, OSMONDS)) < 0) ERR;
if (H5Gget_num_objs(osmonds_grpid, &num_obj) < 0) ERR;
for (i=0; i<num_obj; i++)
for (hsize_t i=0; i<num_obj; i++)
{
if (H5Gget_objname_by_idx(osmonds_grpid, i, name, STR_LEN+1) < 0) ERR;
if ((obj_type = H5Gget_objtype_by_idx(osmonds_grpid, i)) < 0) ERR;
@ -301,8 +301,8 @@ main()
/* Initialize data. */
for (i = 0; i < DIM6_LEN; i++)
{
obsdata[i].day = 15 * (char)i + 1;
obsdata[i].elev = 2 * (short)i + 1;
obsdata[i].day = (char)(15 * i + 1);
obsdata[i].elev = (short)(2 * i + 1);
obsdata[i].count = 2 * i + 1;
obsdata[i].relhum = 2.0f * (float)i + 1;
obsdata[i].time = 2.0 * i + 1;

View File

@ -46,7 +46,7 @@ rec_scan_group(hid_t grpid)
htri_t is_scale;
int num_scales;
hsize_t dims[MAX_DIMS], max_dims[MAX_DIMS];
int ndims, d;
int ndims;
/* Loop through datasets to find variables. */
if (H5Gget_num_objs(grpid, &num_obj) < 0) ERR;
@ -93,7 +93,7 @@ rec_scan_group(hid_t grpid)
if (num_scales != 1) ERR;
/* Go through all dimscales for this var and learn about them. */
for (d = 0; d < ndims; d++)
for (unsigned int d = 0; d < ndims; d++)
if (H5DSiterate_scales(datasetid, d, NULL, alien_visitor,
&visitor_data) < 0) ERR;
}
@ -563,7 +563,6 @@ main()
htri_t is_scale;
int num_scales;
hsize_t dims[NDIMS], max_dims[NDIMS];
int d;
/* Reopen the file and group. */
if ((fileid = H5Fopen(FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) ERR;
@ -631,7 +630,7 @@ main()
/* Go through all dimscales for this var and learn
* about them. What I want is the dataset id of each
* dimscale. Then... */
for (d = 0; d < NDIMS; d++)
for (unsigned int d = 0; d < NDIMS; d++)
if (H5DSiterate_scales(datasetid, d, NULL, alien_visitor,
&visitor_data) < 0) ERR;
/*printf("visitor_data: 0x%x\n", visitor_data);*/

View File

@ -297,7 +297,7 @@ main()
#endif
HDF5_OBJID_T dimscale_obj[2], vars_dimscale_obj[2];
int dimscale_cnt = 0;
int d, ndims;
int ndims;
/* Open the file. */
if ((fileid = H5Fopen(FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) ERR;
@ -355,7 +355,7 @@ main()
if (num_scales != 1) ERR;
/* Go through all dimscales for this var and learn about them. */
for (d = 0; d < ndims; d++)
for (unsigned int d = 0; d < ndims; d++)
{
if (H5DSiterate_scales(datasetid, d, NULL, alien_visitor2,
&(vars_dimscale_obj[d])) < 0) ERR;
@ -420,7 +420,7 @@ main()
#endif
HDF5_OBJID_T dimscale_obj[2], vars_dimscale_obj[2];
int dimscale_cnt = 0;
int d, ndims;
int ndims;
/* Create file access and create property lists. */
if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) ERR;
@ -553,7 +553,7 @@ main()
if (num_scales != 1) ERR;
/* Go through all dimscales for this var and learn about them. */
for (d = 0; d < ndims; d++)
for (unsigned int d = 0; d < ndims; d++)
{
if (H5DSiterate_scales(datasetid, d, NULL, alien_visitor2,
&(vars_dimscale_obj[d])) < 0) ERR;
@ -743,7 +743,7 @@ main()
#endif
HDF5_OBJID_T dimscale_obj[NUM_DIMSCALES1], vars_dimscale_obj[NUM_DIMSCALES1];
int dimscale_cnt = 0;
int d, ndims;
int ndims;
/* Create file access and create property lists. */
if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) ERR;
@ -874,7 +874,7 @@ main()
if (num_scales != 1) ERR;
/* Go through all dimscales for this var and learn about them. */
for (d = 0; d < ndims; d++)
for (unsigned int d = 0; d < ndims; d++)
{
if (H5DSiterate_scales(datasetid, d, NULL, alien_visitor2,
&(vars_dimscale_obj[d])) < 0) ERR;
@ -947,7 +947,7 @@ main()
#endif
HDF5_OBJID_T dimscale_obj[NUM_DIMSCALES2], vars_dimscale_obj[NUM_DIMSCALES2];
int dimscale_cnt = 0;
int d, ndims;
int ndims;
/* Create file access and create property lists. */
if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) ERR;
@ -1078,7 +1078,7 @@ main()
if (num_scales != 1) ERR;
/* Go through all dimscales for this var and learn about them. */
for (d = 0; d < ndims; d++)
for (unsigned int d = 0; d < ndims; d++)
{
if (H5DSiterate_scales(datasetid, d, NULL, alien_visitor2,
&(vars_dimscale_obj[d])) < 0) ERR;

View File

@ -65,9 +65,9 @@ main()
hid_t base_hdf_typeid;
for (i=0; i < NUM_VALS; i++)
for (short i=0; i < NUM_VALS; i++)
val[i] = i*2;
for (i=0; i < DIM1_LEN; i++)
for (short i=0; i < DIM1_LEN; i++)
data[i] = i*2;
/* Open file. */
@ -115,7 +115,7 @@ main()
if (!types_equal) ERR;
/* Check each value and number in the enum. */
for (i=0; i < NUM_VALS; i++)
for (unsigned int i=0; i < NUM_VALS; i++)
{
if (H5Tget_member_value(typeid, i, &the_value) < 0) ERR;
if (the_value != val[i]) ERR;
@ -229,7 +229,7 @@ main()
if (!types_equal) ERR;
/* Check each value and number in the enum. */
for (i=0; i < NUM_LANG; i++)
for (unsigned int i=0; i < NUM_LANG; i++)
{
if (H5Tget_member_value(typeid, i, &the_value) < 0) ERR;
if (the_value != val[i]) ERR;

View File

@ -108,7 +108,7 @@ main()
printf("*** Checking HDF5 file creates and opens some more...");
{
int objs;
ssize_t objs;
hid_t fileid, fileid2, grpid, access_plist;
/* Set the access list so that closes will fail if something is
@ -178,7 +178,7 @@ main()
hsize_t dims[1];
int *data;
int num_steps;
int i, s;
int i;
/* We will write the same slice of random data over and over to
* fill the file. */
@ -206,7 +206,7 @@ main()
/* Write the data in num_step steps. */
num_steps = DIM1_LEN/SC;
count[0] = SC;
for (s = 0; s < num_steps; s++)
for (hsize_t s = 0; s < num_steps; s++)
{
/* Select hyperslab for write of one slice. */
start[0] = s * SC;

View File

@ -186,7 +186,6 @@ main()
hsize_t num_obj;
ssize_t size;
char obj_name[STR_LEN + 1];
int i;
if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) ERR;
if (H5Pset_fclose_degree(fapl_id, H5F_CLOSE_STRONG)) ERR;
@ -197,7 +196,7 @@ main()
/* How many objects in this group? */
if (H5Gget_num_objs(grpid, &num_obj) < 0) ERR;
for (i = 0; i < num_obj; i++)
for (hsize_t i = 0; i < num_obj; i++)
{
#if H5_VERSION_GE(1,12,0)
if (H5Oget_info_by_idx3(grpid, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC,
@ -209,7 +208,7 @@ main()
if ((size = H5Lget_name_by_idx(grpid, ".", idx_field, H5_ITER_INC, i,
NULL, 0, H5P_DEFAULT)) < 0) ERR;
if (H5Lget_name_by_idx(grpid, ".", idx_field, H5_ITER_INC, i,
obj_name, size+1, H5P_DEFAULT) < 0) ERR;
obj_name, (size_t)size+1, H5P_DEFAULT) < 0) ERR;
}
if (H5Gclose(grpid) < 0) ERR;

View File

@ -85,7 +85,7 @@ main()
if (H5Gget_num_objs(grpid, &num_obj) < 0) ERR;
if (num_obj != NUM_ELEMENTS) ERR;
printf("Original order:\n");
for (i = 0; i < num_obj; i++)
for (hsize_t i = 0; i < num_obj; i++)
{
#if H5_VERSION_GE(1,12,0)
if (H5Oget_info_by_idx3(grpid, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC,
@ -98,7 +98,7 @@ main()
if ((size = H5Lget_name_by_idx(grpid, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, i,
NULL, 0, H5P_DEFAULT)) < 0) ERR;
H5Lget_name_by_idx(grpid, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, i,
name, size+1, H5P_DEFAULT);
name, (size_t)size+1, H5P_DEFAULT);
if (strcmp(name, names[i])) ERR;
printf("name %s\n", name);
}
@ -121,7 +121,7 @@ main()
if (H5Gget_num_objs(grpid, &num_obj) < 0) ERR;
if (num_obj != NUM_ELEMENTS) ERR;
printf("New order:\n");
for (i = 0; i < num_obj; i++)
for (hsize_t i = 0; i < num_obj; i++)
{
#if H5_VERSION_GE(1,12,0)
if (H5Oget_info_by_idx3(grpid, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC,
@ -134,7 +134,7 @@ main()
if ((size = H5Lget_name_by_idx(grpid, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, i,
NULL, 0, H5P_DEFAULT)) < 0) ERR;
H5Lget_name_by_idx(grpid, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, i,
name, size+1, H5P_DEFAULT);
name, (size_t)size+1, H5P_DEFAULT);
printf("name %s\n", name);
/* if (strcmp(name, names2[i])) ERR; */
}

View File

@ -252,7 +252,6 @@ main()
size_t namelen = MAX_NAME;
char name[MAX_NAME + 1];
int found_shuffle = 0, found_fletcher32 = 0, found_deflate = 0;
int f;
/* Open file and create group. */
if ((fileid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT,
@ -290,7 +289,7 @@ main()
* found in H5Zpublic.h. */
if ((num_filters = H5Pget_nfilters(propid)) < 0) ERR;
if (num_filters != 3) ERR;
for (f = 0; f < num_filters; f++)
for (unsigned int f = 0; f < num_filters; f++)
{
if ((filter = H5Pget_filter2(propid, f, &flags, &cd_nelems, cd_values,
namelen, name, &filter_config)) < 0) ERR;

View File

@ -83,7 +83,7 @@ main()
if (H5Gget_num_objs(grpid, &num_obj) < 0) ERR;
if (num_obj != NUM_ELEMENTS) ERR;
for (i = 0; i < num_obj; i++)
for (hsize_t i = 0; i < num_obj; i++)
{
#if H5_VERSION_GE(1,12,0)
if (H5Oget_info_by_idx3(grpid, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC,
@ -96,7 +96,7 @@ main()
if ((size = H5Lget_name_by_idx(grpid, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, i,
NULL, 0, H5P_DEFAULT)) < 0) ERR;
H5Lget_name_by_idx(grpid, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, i,
name, size+1, H5P_DEFAULT);
name, (size_t)size+1, H5P_DEFAULT);
if (strcmp(name, names[i])) ERR;
}
if (H5Pclose(fapl_id) < 0 ||
@ -166,7 +166,7 @@ main()
if (H5Gget_num_objs(grpid, &num_obj) < 0) ERR;
if (num_obj != NUM_DIMSCALES) ERR;
for (i = 0; i < num_obj; i++)
for (hsize_t i = 0; i < num_obj; i++)
{
#if H5_VERSION_GE(1,12,0)
if (H5Oget_info_by_idx3(grpid, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC,
@ -179,7 +179,7 @@ main()
if ((size = H5Lget_name_by_idx(grpid, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, i,
NULL, 0, H5P_DEFAULT)) < 0) ERR;
if (H5Lget_name_by_idx(grpid, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, i,
name, size+1, H5P_DEFAULT) < 0) ERR;
name, (size_t)size+1, H5P_DEFAULT) < 0) ERR;
if (strcmp(name, names[i])) ERR;
}
if (H5Pclose(fapl_id) < 0 ||
@ -276,7 +276,7 @@ main()
if ((size = H5Lget_name_by_idx(grpid, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, 0,
NULL, 0, H5P_DEFAULT)) < 0) ERR;
H5Lget_name_by_idx(grpid, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, 0,
name, size+1, H5P_DEFAULT);
name, (size_t)size+1, H5P_DEFAULT);
if (strcmp(name, VAR_NAME)) ERR;
if (H5Pclose(fapl_id) < 0 ||
H5Gclose(grpid) < 0 ||