Silence most conversion warnings in nc4hdf.c

This commit is contained in:
Peter Hill 2023-11-30 09:40:13 +00:00
parent 58abc9b9b9
commit 4f55d4c716
No known key found for this signature in database
GPG Key ID: 0C6B9742E72848EE

View File

@ -43,13 +43,12 @@ static int
flag_atts_dirty(NCindex *attlist) {
NC_ATT_INFO_T *att = NULL;
int i;
if(attlist == NULL) {
return NC_NOERR;
}
for(i=0;i<ncindexsize(attlist);i++) {
for(size_t i=0;i<ncindexsize(attlist);i++) {
att = (NC_ATT_INFO_T*)ncindexith(attlist,i);
if(att == NULL) continue;
att->dirty = NC_TRUE;
@ -79,7 +78,7 @@ rec_reattach_scales(NC_GRP_INFO_T *grp, int dimid, hid_t dimscaleid)
{
NC_VAR_INFO_T *var;
NC_GRP_INFO_T *child_grp;
int d, i;
size_t i;
int retval;
assert(grp && grp->hdr.name && dimid >= 0 && dimscaleid >= 0);
@ -104,7 +103,7 @@ rec_reattach_scales(NC_GRP_INFO_T *grp, int dimid, hid_t dimscaleid)
hdf5_var = (NC_HDF5_VAR_INFO_T*)var->format_var_info;
assert(hdf5_var != NULL);
for (d = 0; d < var->ndims; d++)
for (unsigned int d = 0; d < var->ndims; d++)
{
if (var->dimids[d] == dimid && !hdf5_var->dimscale)
{
@ -144,7 +143,7 @@ rec_detach_scales(NC_GRP_INFO_T *grp, int dimid, hid_t dimscaleid)
{
NC_VAR_INFO_T *var;
NC_GRP_INFO_T *child_grp;
int d, i;
size_t i;
int retval;
assert(grp && grp->hdr.name && dimid >= 0 && dimscaleid >= 0);
@ -166,7 +165,7 @@ rec_detach_scales(NC_GRP_INFO_T *grp, int dimid, hid_t dimscaleid)
assert(var && var->format_var_info);
hdf5_var = (NC_HDF5_VAR_INFO_T *)var->format_var_info;
for (d = 0; d < var->ndims; d++)
for (unsigned int d = 0; d < var->ndims; d++)
{
if (var->dimids[d] == dimid && !hdf5_var->dimscale)
{
@ -208,7 +207,7 @@ nc4_open_var_grp2(NC_GRP_INFO_T *grp, int varid, hid_t *dataset)
assert(grp && grp->format_grp_info && dataset);
/* Find the requested varid. */
if (!(var = (NC_VAR_INFO_T *)ncindexith(grp->vars, varid)))
if (!(var = (NC_VAR_INFO_T *)ncindexith(grp->vars, (size_t)varid)))
return NC_ENOTVAR;
assert(var && var->hdr.id == varid && var->format_var_info);
hdf5_var = (NC_HDF5_VAR_INFO_T *)var->format_var_info;
@ -461,7 +460,7 @@ put_att_grpa(NC_GRP_INFO_T *grp, int varid, NC_ATT_INFO_T *att)
/* Get the length ready, and find the HDF type we'll be
* writing. */
dims[0] = att->len;
dims[0] = (hsize_t)att->len;
if ((retval = nc4_get_hdf_typeid(grp->nc4_info, att->nc_typeid,
&file_typeid, 0)))
BAIL(retval);
@ -609,9 +608,8 @@ write_attlist(NCindex *attlist, int varid, NC_GRP_INFO_T *grp)
{
NC_ATT_INFO_T *att;
int retval;
int i;
for(i = 0; i < ncindexsize(attlist); i++)
for(size_t i = 0; i < ncindexsize(attlist); i++)
{
att = (NC_ATT_INFO_T *)ncindexith(attlist, i);
assert(att);
@ -898,19 +896,16 @@ var_create_dataset(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var, nc_bool_t write_dimid
if(H5Pset_shuffle(plistid) < 0)
BAIL(NC_EHDFERR);
} else if(fi->filterid == H5Z_FILTER_DEFLATE) {/* Handle zip case here */
unsigned level;
if(fi->nparams != 1)
BAIL(NC_EFILTER);
level = (int)fi->params[0];
unsigned int level = fi->params[0];
if(H5Pset_deflate(plistid, level) < 0)
BAIL(NC_EFILTER);
} else if(fi->filterid == H5Z_FILTER_SZIP) {/* Handle szip case here */
int options_mask;
int bits_per_pixel;
if(fi->nparams != 2)
BAIL(NC_EFILTER);
options_mask = (int)fi->params[0];
bits_per_pixel = (int)fi->params[1];
unsigned int options_mask = fi->params[0];
unsigned int bits_per_pixel = fi->params[1];
if(H5Pset_szip(plistid, options_mask, bits_per_pixel) < 0)
BAIL(NC_EFILTER);
} else {
@ -970,8 +965,8 @@ var_create_dataset(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var, nc_bool_t write_dimid
if (dim->unlimited)
chunksize[d] = 1;
else
chunksize[d] = pow((double)DEFAULT_CHUNK_SIZE/type_size,
1/(double)(var->ndims - unlimdim));
chunksize[d] = (hsize_t)pow(DEFAULT_CHUNK_SIZE/(double)type_size,
1/(double)((int)var->ndims - unlimdim));
/* If the chunksize is greater than the dim
* length, make it the dim length. */
@ -985,7 +980,7 @@ var_create_dataset(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var, nc_bool_t write_dimid
}
/* Create the dataspace. */
if ((spaceid = H5Screate_simple(var->ndims, dimsize, maxdimsize)) < 0)
if ((spaceid = H5Screate_simple((int)var->ndims, dimsize, maxdimsize)) < 0)
BAIL(NC_EHDFERR);
}
else
@ -1009,7 +1004,7 @@ var_create_dataset(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var, nc_bool_t write_dimid
}
else if (var->ndims)
{
if (H5Pset_chunk(plistid, var->ndims, chunksize) < 0)
if (H5Pset_chunk(plistid, (int)var->ndims, chunksize) < 0)
BAIL(NC_EHDFERR);
}
@ -1420,10 +1415,9 @@ attach_dimscales(NC_GRP_INFO_T *grp)
{
NC_VAR_INFO_T *var;
NC_HDF5_VAR_INFO_T *hdf5_var;
int d, v;
/* Attach dimension scales. */
for (v = 0; v < ncindexsize(grp->vars); v++)
for (size_t v = 0; v < ncindexsize(grp->vars); v++)
{
/* Get pointer to var and HDF5-specific var info. */
var = (NC_VAR_INFO_T *)ncindexith(grp->vars, v);
@ -1436,7 +1430,7 @@ attach_dimscales(NC_GRP_INFO_T *grp)
continue;
/* Find the scale for each dimension, if any, and attach it. */
for (d = 0; d < var->ndims; d++)
for (unsigned int d = 0; d < var->ndims; d++)
{
/* Is there a dimscale for this dimension? */
if (hdf5_var->dimscale_attached)
@ -1660,8 +1654,6 @@ write_var(NC_VAR_INFO_T *var, NC_GRP_INFO_T *grp, nc_bool_t write_dimid)
* and delete dimscale attributes from the var. */
if (var->was_coord_var && hdf5_var->dimscale_attached)
{
int d;
/* If the variable already exists in the file, Remove any dimension scale
* attributes from it, if they exist. */
if (var->created)
@ -1669,7 +1661,7 @@ write_var(NC_VAR_INFO_T *var, NC_GRP_INFO_T *grp, nc_bool_t write_dimid)
return retval;
/* If this is a regular var, detach all its dim scales. */
for (d = 0; d < var->ndims; d++)
for (unsigned int d = 0; d < var->ndims; d++)
{
if (hdf5_var->dimscale_attached[d])
{
@ -1941,10 +1933,9 @@ nc4_rec_write_metadata(NC_GRP_INFO_T *grp, nc_bool_t bad_coord_order)
NC_VAR_INFO_T *var = NULL;
NC_GRP_INFO_T *child_grp = NULL;
int coord_varid = -1;
int var_index = 0;
int dim_index = 0;
size_t var_index = 0;
size_t dim_index = 0;
int retval;
int i;
assert(grp && grp->hdr.name &&
((NC_HDF5_GRP_INFO_T *)(grp->format_grp_info))->hdf_grpid);
@ -2003,7 +1994,7 @@ nc4_rec_write_metadata(NC_GRP_INFO_T *grp, nc_bool_t bad_coord_order)
}
/* If there are any child groups, write their metadata. */
for (i = 0; i < ncindexsize(grp->children); i++)
for (size_t i = 0; i < ncindexsize(grp->children); i++)
{
child_grp = (NC_GRP_INFO_T *)ncindexith(grp->children, i);
assert(child_grp);
@ -2029,7 +2020,7 @@ nc4_rec_write_groups_types(NC_GRP_INFO_T *grp)
NC_HDF5_GRP_INFO_T *hdf5_grp;
NC_TYPE_INFO_T *type;
int retval;
int i;
size_t i;
assert(grp && grp->hdr.name && grp->format_grp_info);
LOG((3, "%s: grp->hdr.name %s", __func__, grp->hdr.name));
@ -2085,7 +2076,7 @@ nc4_rec_match_dimscales(NC_GRP_INFO_T *grp)
NC_VAR_INFO_T *var;
NC_DIM_INFO_T *dim;
int retval = NC_NOERR;
int i;
size_t i;
assert(grp && grp->hdr.name);
LOG((4, "%s: grp->hdr.name %s", __func__, grp->hdr.name));
@ -2104,7 +2095,6 @@ nc4_rec_match_dimscales(NC_GRP_INFO_T *grp)
for (i = 0; i < ncindexsize(grp->vars); i++)
{
NC_HDF5_VAR_INFO_T *hdf5_var;
int ndims;
int d;
/* Get pointer to var and to the HDF5-specific var info. */
@ -2127,8 +2117,8 @@ nc4_rec_match_dimscales(NC_GRP_INFO_T *grp)
The solution I choose is to modify nc4_var_list_add to initialize dimids to
illegal values (-1). This is another example of the problems with dimscales.
*/
ndims = var->ndims;
for (d = 0; d < ndims; d++)
const size_t ndims = var->ndims;
for (size_t d = 0; d < ndims; d++)
{
if (var->dim[d] == NULL) {
nc4_find_dim(grp, var->dimids[d], &var->dim[d], NULL);
@ -2139,13 +2129,10 @@ nc4_rec_match_dimscales(NC_GRP_INFO_T *grp)
/* Skip dimension scale variables */
if (!hdf5_var->dimscale)
{
int d;
int j;
/* Are there dimscales for this variable? */
if (hdf5_var->dimscale_hdf5_objids)
{
for (d = 0; d < var->ndims; d++)
for (size_t d = 0; d < var->ndims; d++)
{
nc_bool_t finished = NC_FALSE;
LOG((5, "%s: var %s has dimscale info...", __func__, var->hdr.name));
@ -2154,7 +2141,7 @@ nc4_rec_match_dimscales(NC_GRP_INFO_T *grp)
for (g = grp; g && !finished; g = g->parent)
{
/* Check all dims in this group. */
for (j = 0; j < ncindexsize(g->dim); j++)
for (size_t j = 0; j < ncindexsize(g->dim); j++)
{
/* Get the HDF5 specific dim info. */
NC_HDF5_DIM_INFO_T *hdf5_dim;
@ -2243,19 +2230,18 @@ nc4_rec_match_dimscales(NC_GRP_INFO_T *grp)
* size. */
for (d = 0; d < var->ndims; d++)
{
int k;
int match;
nc_bool_t match = NC_FALSE;
/* Is there already a phony dimension of the correct size? */
for(match=-1,k=0;k<ncindexsize(grp->dim);k++) {
for(size_t k=0;k<ncindexsize(grp->dim);k++) {
if((dim = (NC_DIM_INFO_T*)ncindexith(grp->dim,k)) == NULL) continue;
if ((dim->len == h5dimlen[d]) &&
((h5dimlenmax[d] == H5S_UNLIMITED && dim->unlimited) ||
(h5dimlenmax[d] != H5S_UNLIMITED && !dim->unlimited)))
{match = k; break;}
{match = NC_TRUE; break;}
}
/* Didn't find a phony dim? Then create one. */
if (match < 0)
if (match == NC_FALSE)
{
char phony_dim_name[NC_MAX_NAME + 1];
snprintf(phony_dim_name, sizeof(phony_dim_name), "phony_dim_%d", grp->nc4_info->next_dimid);
@ -2607,8 +2593,7 @@ NC4_walk(hid_t gid, int* countp)
if(aid >= 0) {
const NC_reservedatt* ra;
ssize_t len = H5Aget_name(aid, NC_HDF5_MAX_NAME, name);
if(len < 0) return len;
/* Is this a netcdf-4 marker attribute */
if(len < 0) return (int)len;
/* Is this a netcdf-4 marker attribute */
ra = NC_findreserved(name);
if(ra != NULL)