Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix warnings in tests and examples #2884

Merged
merged 6 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/C/pres_temp_4D_rd.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ main()
float lats[NLAT], lons[NLON];

/* Loop indexes. */
int lvl, lat, lon, rec, i = 0;
int lvl, lat, lon, i = 0;

/* Error handling. */
int retval;
Expand Down Expand Up @@ -128,7 +128,7 @@ main()
start[3] = 0;

/* Read and check one record at a time. */
for (rec = 0; rec < NREC; rec++)
for (size_t rec = 0; rec < NREC; rec++)
{
start[0] = rec;
if ((retval = nc_get_vara_float(ncid, pres_varid, start,
Expand Down
4 changes: 2 additions & 2 deletions examples/C/pres_temp_4D_wr.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ main()
float lats[NLAT], lons[NLON];

/* Loop indexes. */
int lvl, lat, lon, rec, i = 0;
int lvl, lat, lon, i = 0;

/* Error handling. */
int retval;
Expand Down Expand Up @@ -188,7 +188,7 @@ main()
surface temperature data. The arrays only hold one timestep worth
of data. We will just rewrite the same data for each timestep. In
a real application, the data would change between timesteps. */
for (rec = 0; rec < NREC; rec++)
for (size_t rec = 0; rec < NREC; rec++)
{
start[0] = rec;
if ((retval = nc_put_vara_float(ncid, pres_varid, start, count,
Expand Down
7 changes: 4 additions & 3 deletions h5_test/tst_h_atts.c
Original file line number Diff line number Diff line change
Expand Up @@ -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...");
Expand Down Expand Up @@ -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};
Expand Down Expand Up @@ -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"};
Expand Down
8 changes: 4 additions & 4 deletions h5_test/tst_h_atts3.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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. */

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions h5_test/tst_h_atts4.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions h5_test/tst_h_compounds.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ main()

{
hsize_t num_obj;
int i, obj_type;
int obj_type;
char name[STR_LEN + 1];
htri_t equal;

Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 3 additions & 4 deletions h5_test/tst_h_dimscales.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);*/
Expand Down
16 changes: 8 additions & 8 deletions h5_test/tst_h_dimscales2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions h5_test/tst_h_enums.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions h5_test/tst_h_files.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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. */
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions h5_test/tst_h_files4.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand All @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions h5_test/tst_h_rename.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
}
Expand All @@ -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,
Expand All @@ -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; */
}
Expand Down
3 changes: 1 addition & 2 deletions h5_test/tst_h_vars.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
Loading
Loading