Merge pull request #2840 from ZedThree/silence-ncdump-warnings

Silence ncdump warnings
This commit is contained in:
Ward Fisher 2024-02-09 16:49:01 -07:00 committed by GitHub
commit 25fc13bd80
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 104 additions and 133 deletions

View File

@ -196,7 +196,7 @@ dimchunkspec_size(int indimid) {
/* Return number of dimensions for which chunking was specified in
* chunkspec string on command line, 0 if no chunkspec string was
* specified. */
int
size_t
dimchunkspec_ndims(void) {
return dimchunkspecs.ndims;
}
@ -337,8 +337,7 @@ done:
int
varchunkspec_kind(int grpid, int varid)
{
int i;
for(i=0;i<listlength(varchunkspecs);i++) {
for(size_t i=0;i<listlength(varchunkspecs);i++) {
struct VarChunkSpec* spec = listget(varchunkspecs,i);
if(spec->igrpid == grpid && spec->ivarid == varid)
return spec->kind;
@ -349,8 +348,7 @@ varchunkspec_kind(int grpid, int varid)
bool_t
varchunkspec_exists(int igrpid, int ivarid)
{
int i;
for(i=0;i<listlength(varchunkspecs);i++) {
for(size_t i=0;i<listlength(varchunkspecs);i++) {
struct VarChunkSpec* spec = listget(varchunkspecs,i);
if(spec->igrpid == igrpid && spec->ivarid == ivarid)
return true;
@ -361,8 +359,7 @@ varchunkspec_exists(int igrpid, int ivarid)
bool_t
varchunkspec_omit(int igrpid, int ivarid)
{
int i;
for(i=0;i<listlength(varchunkspecs);i++) {
for(size_t i=0;i<listlength(varchunkspecs);i++) {
struct VarChunkSpec* spec = listget(varchunkspecs,i);
if(spec->igrpid == igrpid && spec->ivarid == ivarid)
return spec->omit;
@ -373,8 +370,7 @@ varchunkspec_omit(int igrpid, int ivarid)
size_t*
varchunkspec_chunksizes(int igrpid, int ivarid)
{
int i;
for(i=0;i<listlength(varchunkspecs);i++) {
for(size_t i=0;i<listlength(varchunkspecs);i++) {
struct VarChunkSpec* spec = listget(varchunkspecs,i);
if(spec->igrpid == igrpid && spec->ivarid == ivarid)
return spec->chunksizes;
@ -385,8 +381,7 @@ varchunkspec_chunksizes(int igrpid, int ivarid)
size_t
varchunkspec_rank(int igrpid, int ivarid)
{
int i;
for(i=0;i<listlength(varchunkspecs);i++) {
for(size_t i=0;i<listlength(varchunkspecs);i++) {
struct VarChunkSpec* spec = listget(varchunkspecs,i);
if(spec->igrpid == igrpid && spec->ivarid == ivarid)
return spec->rank;

View File

@ -6,6 +6,9 @@
#ifndef _CHUNKSPEC_H_
#define _CHUNKSPEC_H_
#include <stddef.h>
#include "utils.h"
/* Parse chunkspec string and convert into internal data structure,
* associating dimids from open file or group specified by ncid with
* corresponding chunk sizes */
@ -25,7 +28,7 @@ dimchunkspec_exists(int indimid);
/* Return number of dimensions for which chunking was specified in
* chunkspec string on command line, 0 if no chunkspec string was
* specified. */
extern int
extern size_t
dimchunkspec_ndims(void);
/* Return whether chunking should be omitted, due to explicit

View File

@ -861,7 +861,7 @@ int ncstring_typ_tostring(const nctype_t *typ, safebuf_t *sfbf, const void *valp
sp = sout;
*sp++ = '"' ;
while(*cp) {
switch (uc = *cp++ & 0377) {
switch (uc = (unsigned char)*cp++ & 0377) {
case '\b':
*sp++ = '\\';
*sp++ = 'b' ;
@ -904,7 +904,7 @@ int ncstring_typ_tostring(const nctype_t *typ, safebuf_t *sfbf, const void *valp
sp += 4;
}
else
*sp++ = uc;
*sp++ = (char)uc;
break;
}
}
@ -1045,7 +1045,7 @@ chars_tostring(
len--;
for (iel = 0; iel < len; iel++) {
unsigned char uc;
switch (uc = *vals++ & 0377) {
switch (uc = (unsigned char)(*vals++ & 0377)) {
case '\b':
case '\f':
case '\n':
@ -1062,7 +1062,7 @@ chars_tostring(
if (isprint(uc))
*cp++ = *(char *)&uc; /* just copy, even if char is signed */
else {
size_t remaining = sout_size - (cp - sout);
size_t remaining = sout_size - (size_t)(cp - sout);
snprintf(cp,remaining,"\\%.3o",uc);
cp += 4;
}
@ -1806,10 +1806,8 @@ print_type_name(int locid, int typeid) {
static int
init_is_unlim(int ncid, int **is_unlim_p)
{
int num_grps; /* total number of groups */
int num_dims = 0; /* total number of dimensions in all groups */
size_t num_grps; /* total number of groups */
int max_dimid = -1; /* maximum dimid across whole dataset */
int num_undims = 0; /* total number of unlimited dimensions in all groups */
int *grpids = NULL; /* temporary list of all grpids */
int igrp;
int grpid;
@ -1824,7 +1822,7 @@ init_is_unlim(int ncid, int **is_unlim_p)
return NC_EBADGRPID;
/* Now ncid is root group. Get total number of groups and their ids */
NC_CHECK( nc_inq_grps_full(ncid, &num_grps, NULL) );
grpids = emalloc((size_t)(num_grps + 1) * sizeof(int));
grpids = emalloc((num_grps + 1) * sizeof(int));
NC_CHECK( nc_inq_grps_full(ncid, &num_grps, grpids) );
#define DONT_INCLUDE_PARENTS 0
/* Get all dimensions in groups and info about which ones are unlimited */
@ -1836,7 +1834,6 @@ init_is_unlim(int ncid, int **is_unlim_p)
int* dimids = NULL;
grpid = grpids[igrp];
NC_CHECK( nc_inq_dimids(grpid, &ndims, NULL, DONT_INCLUDE_PARENTS) );
num_dims += ndims;
dimids = (int*)emalloc((size_t)ndims*sizeof(int));
NC_CHECK( nc_inq_dimids(grpid, &ndims, dimids, DONT_INCLUDE_PARENTS) );
for(i=0;i<ndims;i++) {if(dimids[i] > max_dimid) max_dimid = dimids[i];}
@ -1863,7 +1860,6 @@ init_is_unlim(int ncid, int **is_unlim_p)
int* isunlim = *is_unlim_p;
int did = dimids[idim];
isunlim[did] = 1;
num_undims++;
}
if(dimids)
free(dimids);

View File

@ -40,8 +40,7 @@ int
listfreeall(List* l)
{
if(l) {
int i;
for(i=0;i<listlength(l);i++) {
for(size_t i=0;i<listlength(l);i++) {
void* elem = listget(l,i);
if(elem != NULL) free(elem);
}

View File

@ -313,9 +313,8 @@ printNode(NC4printer* out, NCID* node, int depth)
CAT(">\n");
depth++;
for(i=0;i<count;i++) {
long long value;
if((ret=nc_inq_enum_member(GROUPOF(node),node->id,i,name,&numvalue))) FAIL;
value = getNumericValue(numvalue,node->base->id);
long long value = (long long)getNumericValue(numvalue,node->base->id);
INDENT(depth);
CAT("<EnumConst");
printXMLAttributeName(out, "name", name);
@ -443,7 +442,6 @@ static int
printAttribute(NC4printer* out, NCID* attr, int depth)
{
int ret = NC_NOERR;
int i = 0;
void* values;
INDENT(depth); CAT("<Attribute");
@ -451,7 +449,7 @@ printAttribute(NC4printer* out, NCID* attr, int depth)
CAT(">\n");
if((ret=readAttributeValues(attr,&values))) FAIL;
depth++;
for(i=0;i<attr->size;i++) {
for(size_t i=0;i<attr->size;i++) {
void* value = computeOffset(attr->base,values,i);
if((ret=printValue(out,attr->base,value,depth))) FAIL;
}
@ -696,7 +694,7 @@ entityEscape(NCbytes* escaped, const char* s)
const char* p;
ncbytesclear(escaped);
for(p=s;*p;p++) {
int c = *p;
char c = *p;
switch (c) {
case '&': ncbytescat(escaped,"&amp;"); break;
case '<': ncbytescat(escaped,"&lt;"); break;
@ -735,7 +733,7 @@ printString(NCbytes* out, const char* s, int quotes)
if(quotes) ncbytesappend(out,'"');
if(s == NULL) s = "";
for(p=s;*p;p++) {
int c = *p;
char c = *p;
if(c == '\\') ncbytescat(out,"\\\\");
else if(c == '"') ncbytescat(out,"\\\"");
else ncbytesappend(out,c);

View File

@ -288,7 +288,6 @@ parsefilterspec(const char* optarg0, List* speclist)
char* p = NULL;
char* remainder = NULL;
List* vlist = NULL;
int i;
int isnone = 0;
size_t nfilters = 0;
NC_H5_Filterspec** filters = NULL;
@ -325,7 +324,7 @@ parsefilterspec(const char* optarg0, List* speclist)
}
/* Construct a spec entry for each element in vlist */
for(i=0;i<listlength(vlist);i++) {
for(size_t i=0;i<listlength(vlist);i++) {
int k;
size_t vlen;
struct FilterOption* filtopt = NULL;
@ -341,9 +340,9 @@ parsefilterspec(const char* optarg0, List* speclist)
filtopt->fqn[0] = '\0'; /* for strlcat */
if(strcmp(var,"*") != 0 && var[0] != '/') strlcat(filtopt->fqn,"/",vlen+2);
strlcat(filtopt->fqn,var,vlen+2);
if(isnone)
if(isnone) {
filtopt->nofilter = 1;
else {
} else {
filtopt->pfs = *nsf;
if(nsf->nparams != 0) {
/* Duplicate the params */
@ -369,11 +368,10 @@ done:
static int
varfiltersactive(const char* ofqn)
{
int i;
int hasnone = 0;
int hasactive = 0;
/* See which output filter options are defined for this output variable */
for(i=0;i<listlength(filteroptions);i++) {
for(size_t i=0;i<listlength(filteroptions);i++) {
struct FilterOption* opt = listget(filteroptions,i);
if(strcmp(opt->fqn,"*")==0 || strcmp(opt->fqn,ofqn)==0)
{if(opt->nofilter) hasnone = 1;} else {hasactive = 1;}
@ -385,10 +383,9 @@ varfiltersactive(const char* ofqn)
static int
varfilterssuppress(const char* ofqn)
{
int i;
int hasnone = 0;
/* See which output filter options are defined for this output variable */
for(i=0;i<listlength(filteroptions);i++) {
for(size_t i=0;i<listlength(filteroptions);i++) {
struct FilterOption* opt = listget(filteroptions,i);
if(strcmp(opt->fqn,"*")==0 || strcmp(opt->fqn,ofqn)==0)
{if(opt->nofilter) hasnone = 1;}
@ -400,11 +397,10 @@ varfilterssuppress(const char* ofqn)
static List*
filteroptsforvar(const char* ofqn)
{
int i;
List* list = listnew();
/* See which output filter options are defined for this output variable;
both active and none. */
for(i=0;i<listlength(filteroptions);i++) {
for(size_t i=0;i<listlength(filteroptions);i++) {
struct FilterOption* opt = listget(filteroptions,i);
if(strcmp(opt->fqn,"*")==0 || strcmp(opt->fqn,ofqn)==0) {
if(!opt->nofilter) /* Add to the list */
@ -461,7 +457,6 @@ inq_var_chunking_params(int igrp, int ivarid, int ogrp, int ovarid,
int stat = NC_NOERR;
int ndims;
size_t *ichunksizes, *ochunksizes;
int dim;
int icontig = NC_CONTIGUOUS, ocontig = NC_CONTIGUOUS;
nc_type vartype;
size_t value_size;
@ -497,7 +492,7 @@ inq_var_chunking_params(int igrp, int ivarid, int ogrp, int ovarid,
if(icontig != NC_CHUNKED) { /* if input contiguous|compact, treat as if chunked on
* first dimension */
ichunksizes[0] = 1;
for(dim = 1; dim < ndims; dim++) {
for(size_t dim = 1; dim < ndims; dim++) {
ichunksizes[dim] = dim;
}
} else {
@ -510,7 +505,7 @@ inq_var_chunking_params(int igrp, int ivarid, int ogrp, int ovarid,
nelems = 1;
oprod = value_size;
for(dim = 0; dim < ndims; dim++) {
for(size_t dim = 0; dim < ndims; dim++) {
nelems += 1 + (ichunksizes[dim] - 1) / ochunksizes[dim];
iprod *= ichunksizes[dim];
oprod *= ochunksizes[dim];
@ -681,14 +676,14 @@ static int
copy_groups(int iroot, int oroot)
{
int stat = NC_NOERR;
int numgrps;
size_t numgrps;
int *grpids;
int i;
/* get total number of groups and their ids, including all descendants */
NC_CHECK(nc_inq_grps_full(iroot, &numgrps, NULL));
if(numgrps > 1) { /* there's always 1 root group */
grpids = emalloc((size_t)numgrps * sizeof(int));
grpids = emalloc(numgrps * sizeof(int));
NC_CHECK(nc_inq_grps_full(iroot, NULL, grpids));
/* create corresponding new groups in ogrp, except for root group */
for(i = 1; i < numgrps; i++) {
@ -879,8 +874,7 @@ copy_var_filter(int igrp, int varid, int ogrp, int o_varid, int inkind, int outk
/* Apply actual filter spec if any */
if(!unfiltered) {
/* add all the actual filters */
int k;
for(k=0;k<listlength(actualspecs);k++) {
for(size_t k=0;k<listlength(actualspecs);k++) {
struct FilterOption* actual = (struct FilterOption*)listget(actualspecs,k);
if((stat=nc_def_var_filter(ovid.grpid,ovid.varid,
actual->pfs.filterid,
@ -956,7 +950,7 @@ copy_chunking(int igrp, int i_varid, int ogrp, int o_varid, int ndims, int inkin
/* Figure out the chunking even if we do not decide to do so*/
if(varchunkspec_exists(igrp,i_varid)
&& varchunkspec_kind(igrp,i_varid) == NC_CHUNKED)
memcpy(ochunkp,varchunkspec_chunksizes(igrp,i_varid),ndims*sizeof(size_t));
memcpy(ochunkp,varchunkspec_chunksizes(igrp,i_varid),(size_t)ndims*sizeof(size_t));
/* If any kind of output filter was specified, then not contiguous */
ovid.grpid = ogrp;
@ -1566,12 +1560,12 @@ copy_schema(int igrp, int ogrp)
/* Return number of values for a variable varid in a group igrp */
static int
inq_nvals(int igrp, int varid, long long *nvalsp) {
inq_nvals(int igrp, int varid, size_t *nvalsp) {
int stat = NC_NOERR;
int ndims;
int *dimids;
int dim;
long long nvals = 1;
size_t nvals = 1;
NC_CHECK(nc_inq_varndims(igrp, varid, &ndims));
dimids = (int *) emalloc((size_t)(ndims + 1) * sizeof(int));
@ -1594,7 +1588,7 @@ copy_var_data(int igrp, int varid, int ogrp)
{
int stat = NC_NOERR;
nc_type vartype;
long long nvalues; /* number of values for this variable */
size_t nvalues; /* number of values for this variable */
size_t ntoget; /* number of values to access this iteration */
size_t value_size; /* size of a single value of this variable */
static void *buf = 0; /* buffer for the variable values */
@ -1898,7 +1892,6 @@ copy_fixed_size_data(int igrp, int ogrp, size_t nfixed_vars, int *fixed_varids)
static int
copy_rec_var_data(int ncid, /* input */
int ogrp, /* output */
int irec, /* record number */
int varid, /* input variable id */
int ovarid, /* output variable id */
size_t *start, /* start indices for record data */
@ -1970,7 +1963,7 @@ copy_record_data(int ncid, int ogrp, size_t nrec_vars, int *rec_varids) {
varid = rec_varids[ivar];
ovarid = rec_ovarids[ivar];
start[ivar][0] = irec;
NC_CHECK(copy_rec_var_data(ncid, ogrp, irec, varid, ovarid,
NC_CHECK(copy_rec_var_data(ncid, ogrp, varid, ovarid,
start[ivar], count[ivar], buf[ivar]));
}
}
@ -2044,10 +2037,9 @@ copy(char* infile, char* outfile)
#ifdef USE_NETCDF4
if(listlength(option_chunkspecs) > 0) {
int i;
/* Now that input is open, can parse option_chunkspecs into binary
* structure. */
for(i=0;i<listlength(option_chunkspecs);i++) {
for(size_t i=0;i<listlength(option_chunkspecs);i++) {
char* spec = (char*)listget(option_chunkspecs,i);
NC_CHECK(chunkspec_parse(igrp, spec));
}
@ -2114,7 +2106,7 @@ copy(char* infile, char* outfile)
}
#endif /* USE_NETCDF4 */
ndims = count_dims(igrp);
ndims = (size_t)count_dims(igrp);
NC_CHECK(dimmap_init(ndims));
NC_CHECK(copy_schema(igrp, ogrp));
NC_CHECK(nc_enddef(ogrp));
@ -2295,7 +2287,7 @@ main(int argc, char**argv)
option_kind = NC_FORMAT_NETCDF4_CLASSIC;
break;
case 'd': /* non-default compression level specified */
option_deflate_level = strtol(optarg, NULL, 10);
option_deflate_level = (int)strtol(optarg, NULL, 10);
if(option_deflate_level < 0 || option_deflate_level > 9) {
error("invalid deflation level: %d", option_deflate_level);
}
@ -2395,9 +2387,9 @@ main(int argc, char**argv)
case 'M': /* set min chunk size */
#ifdef USE_NETCDF4
if(optarg == NULL)
option_min_chunk_bytes = 0;
option_min_chunk_bytes = 0;
else
option_min_chunk_bytes = atol(optarg);
option_min_chunk_bytes = (size_t)atol(optarg);
break;
#else
error("-M requires netcdf-4");
@ -2459,8 +2451,7 @@ main(int argc, char**argv)
static void
freefilteroptlist(List* specs)
{
int i;
for(i=0;i<listlength(specs);i++) {
for(size_t i=0;i<listlength(specs);i++) {
struct FilterOption* spec = (struct FilterOption*)listget(specs,i);
if(spec->fqn) free(spec->fqn);
nullfree(spec->pfs.params);

View File

@ -5,6 +5,7 @@ Research/Unidata. See \ref copyright file for more info. */
#include "config.h"
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#ifdef HAVE_GETOPT_H
#include <getopt.h>
@ -429,7 +430,7 @@ pr_att_string(
while (len != 0 && *sp-- == '\0')
len--;
for (iel = 0; iel < len; iel++)
switch (uc = *cp++ & 0377) {
switch (uc = (unsigned char)(*cp++ & 0377)) {
case '\b':
printf ("\\b");
break;
@ -500,7 +501,7 @@ pr_attx_string(
while (len != 0 && *sp-- == '\0')
len--;
for (iel = 0; iel < len; iel++)
switch (uc = *cp++ & 0377) {
switch (uc = (unsigned char)*cp++ & 0377) {
case '\"':
printf ("&quot;");
break;
@ -908,7 +909,7 @@ pr_att(
value = *((int64_t *)data + i);
break;
case NC_UINT64:
value = *((uint64_t *)data + i);
value = (int64_t)*((uint64_t *)data + i);
break;
default:
error("enum must have an integer base type: %d", base_nc_type);
@ -1395,7 +1396,7 @@ print_enum_type(int ncid, nc_type typeid) {
memval = *(int64_t *)raw;
break;
case NC_UINT64:
memval = *(uint64_t *)raw;
memval = (int64_t)*(uint64_t *)raw;
break;
default:
error("Bad base type for enum!");
@ -2567,7 +2568,7 @@ searchgrouptreedim(int ncid, int dimid, int* parentidp)
int gid;
uintptr_t id;
id = ncid;
id = (uintptr_t)ncid;
nclistpush(queue,(void*)id); /* prime the queue */
while(nclistlength(queue) > 0) {
id = (uintptr_t)nclistremove(queue,0);
@ -2589,7 +2590,7 @@ searchgrouptreedim(int ncid, int dimid, int* parentidp)
goto done;
/* push onto the end of the queue */
for(i=0;i<nids;i++) {
id = ids[i];
id = (uintptr_t)ids[i];
nclistpush(queue,(void*)id);
}
free(ids); ids = NULL;

View File

@ -15,7 +15,7 @@ main(int argc, char** argv)
char vn[256];
char* major, *minor, *patch;
char* p;
int i;
size_t i;
strcpy(v5,H5_VERSION);
major = v5; minor = NULL; patch = NULL;

View File

@ -26,7 +26,7 @@ nc_blkio_init(size_t bufsize, /* size in bytes of in-memory copy buffer */
{
int stat = NC_NOERR;
int i;
long long prod;
size_t prod;
size_t *dims = iter->dimsizes;
iter->rank = rank;
@ -184,7 +184,6 @@ nc_get_iter(int ncid,
size_t value_size = 0; /* size in bytes of each variable element */
int ndims; /* number of dimensions for variable */
int *dimids;
long long nvalues = 1;
int dim;
int chunked = 0;
@ -203,7 +202,6 @@ nc_get_iter(int ncid,
for(dim = 0; dim < ndims; dim++) {
size_t len;
NC_CHECK(nc_inq_dimlen(ncid, dimids[dim], &len));
nvalues *= len;
iterp->dimsizes[dim] = len;
}
NC_CHECK(nc_inq_vartype(ncid, varid, &vartype));

View File

@ -24,6 +24,7 @@
#include <stdarg.h>
#include <assert.h>
#include <netcdf.h>
#include "nctime.h"
#include "utils.h"
#include "nccomps.h"
#include "dumplib.h" /* for sbuf_... prototypes */
@ -55,12 +56,11 @@ bounds_add(char *bounds_name, int ncid, int varid) {
* calendar type, if present. */
cdCalenType
calendar_type(int ncid, int varid) {
int ctype;
int stat;
ncatt_t catt;
static struct {
char* attname;
int type;
cdCalenType type;
} calmap[] = {
{"gregorian", cdMixed},
{"standard", cdMixed}, /* synonym */
@ -77,7 +77,7 @@ calendar_type(int ncid, int varid) {
};
#define CF_CAL_ATT_NAME "calendar"
int ncals = (sizeof calmap)/(sizeof calmap[0]);
ctype = cdMixed; /* default mixed Gregorian/Julian ala udunits */
cdCalenType ctype = cdMixed; /* default mixed Gregorian/Julian ala udunits */
stat = nc_inq_att(ncid, varid, CF_CAL_ATT_NAME, &catt.type, &catt.len);
if(stat == NC_NOERR && (catt.type == NC_CHAR || catt.type == NC_STRING) && catt.len > 0) {
char *calstr;
@ -88,7 +88,7 @@ calendar_type(int ncid, int varid) {
nc_get_att_single_string(ncid, varid, &catt, &calstr);
int itype;
int calstr_len = strlen(calstr);
size_t calstr_len = strlen(calstr);
for(itype = 0; itype < ncals; itype++) {
if(strncasecmp(calstr, calmap[itype].attname, calstr_len) == 0) {
ctype = calmap[itype].type;

View File

@ -115,7 +115,7 @@ static const char nada[4] = {0, 0, 0, 0};
/* useful for aligning memory */
#define _RNDUP(x, unit) ((((x) + (unit) - 1) / (unit)) * (unit))
#define ERR_ADDR (((size_t) gbp->pos - (size_t) gbp->base) + gbp->offset - gbp->size)
#define ERR_ADDR (((size_t) gbp->pos - (size_t) gbp->base) + (size_t) gbp->offset - gbp->size)
#define IS_RECVAR(vp) ((vp)->shape != NULL ? (*(vp)->shape == NC_UNLIMITED) : 0 )
@ -425,7 +425,7 @@ hdr_len_NC_name(size_t nchars,
long long sz = sizeof_t; /* nelems */
if (nchars != 0) /* namestring */
sz += _RNDUP(nchars, X_ALIGN);
sz += _RNDUP((long long)nchars, X_ALIGN);
return sz;
}
@ -951,7 +951,7 @@ val_fetch(int fd, bufferinfo *gbp) {
fprintf(stderr,"Error at line %d: read %s\n",__LINE__,strerror(errno));
return -1;
}
gbp->offset += (gbp->size - slack);
gbp->offset += (off_t)(gbp->size - (size_t)slack);
return NC_NOERR;
}
@ -962,7 +962,7 @@ val_fetch(int fd, bufferinfo *gbp) {
static int
val_check_buffer(int fd,
bufferinfo *gbp,
long long nextread)
size_t nextread)
{
size_t pos_addr, base_addr;
@ -1014,12 +1014,12 @@ hdr_get_NON_NEG(int fd, bufferinfo *gbp, long long *sp)
* NON_NEG = <non-negative INT> | // CDF-1 and CDF-2
* <non-negative INT64> // CDF-5
*/
int sizeof_NON_NEG, status;
int status;
sizeof_NON_NEG = (gbp->version < 5) ? 4 : 8;
size_t sizeof_NON_NEG = (gbp->version < 5) ? 4 : 8;
status = val_check_buffer(fd, gbp, sizeof_NON_NEG);
if (status != NC_NOERR) {
if (verbose) printf("%d-byte size is expected for ", sizeof_NON_NEG);
if (verbose) printf("%zu-byte size is expected for ", sizeof_NON_NEG);
return status;
}
if (gbp->version < 5)
@ -1070,13 +1070,13 @@ hdr_get_name(int fd,
padding = _RNDUP(nchars, X_ALIGN) - nchars;
pos_addr = (size_t) gbp->pos;
base_addr = (size_t) gbp->base;
bufremain = gbp->size - (pos_addr - base_addr);
bufremain = (long long)(gbp->size - (pos_addr - base_addr));
cpos = *namep;
while (nchars > 0) {
if (bufremain > 0) {
strcount = MIN(bufremain, nchars);
(void) memcpy(cpos, gbp->pos, strcount);
(void) memcpy(cpos, gbp->pos, (size_t)strcount);
nchars -= strcount;
gbp->pos = (void *)((char *)gbp->pos + strcount);
cpos += strcount;
@ -1091,20 +1091,20 @@ hdr_get_name(int fd,
*namep = NULL;
return err;
}
bufremain = gbp->size;
bufremain = (long long)gbp->size;
}
}
if (padding > 0) {
err_addr = ERR_ADDR;
err = val_check_buffer(fd, gbp, padding);
err = val_check_buffer(fd, gbp, (size_t)padding);
if (err != NC_NOERR) {
if (verbose) printf("Error @ [0x%8.8zx]:\n", err_addr);
if (verbose) printf("\t%s - fetching name string padding\n", loc);
return err;
}
memset(pad, 0, X_ALIGN-1);
if (memcmp(gbp->pos, pad, padding) != 0) {
if (memcmp(gbp->pos, pad, (size_t)padding) != 0) {
/* This is considered not a fatal error, we continue to validate */
if (verbose) printf("Error @ [0x%8.8zx]:\n", err_addr);
if (verbose) printf("\t%s \"%s\": name padding is non-null byte\n", loc, *namep);
@ -1112,7 +1112,7 @@ hdr_get_name(int fd,
*namep = NULL; */
DEBUG_ASSIGN_ERROR(err, NC_ENULLPAD)
if (repair) {
val_repair(fd, err_addr, (size_t)padding, (void*)nada);
val_repair(fd, (off_t)err_addr, (size_t)padding, (void*)nada);
if (verbose)
printf("\t%s \"%s\": name padding error has been **repaired**\n",loc,*namep);
}
@ -1335,12 +1335,12 @@ val_get_NC_attrV(int fd,
padding = attrp->xsz - nvalues;
pos_addr = (size_t) gbp->pos;
base_addr = (size_t) gbp->base;
bufremain = gbp->size - (pos_addr - base_addr);
bufremain = (long long)(gbp->size - (pos_addr - base_addr));
while (nvalues > 0) {
if (bufremain > 0) {
attcount = MIN(bufremain, nvalues);
(void) memcpy(value, gbp->pos, attcount);
(void) memcpy(value, gbp->pos, (size_t)attcount);
nvalues -= attcount;
gbp->pos = (void *)((char *)gbp->pos + attcount);
value = (void *)((char *)value + attcount);
@ -1353,19 +1353,19 @@ val_get_NC_attrV(int fd,
if (verbose) printf("\t%s: Failed to fetch next chunk into a buffer\n", loc);
return status;
}
bufremain = gbp->size;
bufremain = (long long)gbp->size;
}
}
if (padding > 0) {
memset(pad, 0, X_ALIGN-1);
if (memcmp(gbp->pos, pad, padding) != 0) {
if (memcmp(gbp->pos, pad, (size_t)padding) != 0) {
/* This is considered not a fatal error, we continue to validate */
if (verbose) printf("Error @ [0x%8.8zx]:\n", (size_t)ERR_ADDR);
if (verbose) printf("\t%s: value padding is non-null byte\n", loc);
DEBUG_ASSIGN_ERROR(status, NC_ENULLPAD)
if (repair) {
val_repair(fd, ERR_ADDR, (size_t)padding, (void*)nada);
val_repair(fd, (off_t)ERR_ADDR, (size_t)padding, (void*)nada);
if (verbose)
printf("\t%s: value padding has been **repaired**\n",loc);
}
@ -1720,7 +1720,7 @@ val_get_NC_var(int fd,
if (trace) printf("\t\tnumber of dimensions = %lld\n", ndims);
/* allocate variable object */
varp = val_new_NC_var(name, ndims);
varp = val_new_NC_var(name, (int)ndims);
if (varp == NULL) {
if (name != NULL) free(name);
DEBUG_RETURN_ERROR(NC_ENOMEM)

View File

@ -127,7 +127,7 @@ static OCerror printdata_indices(OClink, OCdatanode, NCbytes*,int);
static OCerror printdata_container(OClink, OCdatanode, NCbytes*,int);
static OCerror printdata_leaf(OClink, OCdatanode, NCbytes*,int);
static off_t odom_init(size_t rank, size_t* indices, size_t* dimsizes);
static size_t odom_init(size_t rank, size_t* indices, size_t* dimsizes);
static int odom_more(size_t rank, size_t* indices, size_t* dimsizes);
static void odom_next(size_t rank, size_t* indices, size_t* dimsizes);
@ -230,7 +230,7 @@ main(int argc, char **argv)
} break;
case 'X': {
int c0;
int so = (optarg == NULL ? 0 : strlen(optarg));
size_t so = (optarg == NULL ? 0 : strlen(optarg));
if(so == 0) usage("missing -X argument");
c0 = optarg[0];
switch (c0) {
@ -921,7 +921,7 @@ stringescape(char* s)
{
size_t len;
char* p;
int c;
char c;
char* escapedstring;
if(s == NULL) return NULL;
@ -948,7 +948,7 @@ static char*
idescape(char* id, char* escapeid, size_t esize)
{
char* p;
int c;
char c;
if(id == NULL) return NULL;
p = escapeid;
@ -1068,8 +1068,7 @@ dumpdatanode(OClink link, OCdatanode datanode, size_t count, void* memory, NCbyt
ncbytescat(buffer,tmp);
if(entry->rank > 0) {
if(ocopt.octest) { /* Match the octest output */
off_t xproduct;
xproduct = totaldimsize(entry->rank,entry->dimsizes);
size_t xproduct = totaldimsize(entry->rank,entry->dimsizes);
snprintf(tmp,sizeof(tmp),"[0..%lu]",(unsigned long)xproduct-1);
ncbytescat(buffer,tmp);
} else {
@ -1091,12 +1090,11 @@ dumpdatanode(OClink link, OCdatanode datanode, size_t count, void* memory, NCbyt
return OC_NOERR;
}
static off_t
static size_t
odom_init(size_t rank, size_t* indices, size_t* dimsizes)
{
int i;
off_t count;
for(count=1,i=0;i<rank;i++) {
size_t count = 1;
for(size_t i=0;i<rank;i++) {
indices[i] = 0;
count *= dimsizes[i];
}

View File

@ -29,7 +29,6 @@ main(int argc, char **argv)
int dimid, varid;
nc_type typeid;
char name_in[NC_MAX_NAME+1];
int i;
int var_dims[VAR6_RANK];
@ -139,7 +138,7 @@ main(int argc, char **argv)
val_in.attention_span != missing_val.attention_span ) ERR;
/* Read in each value and check */
for (i = 0; i < DIM6_LEN; i++) {
for (size_t i = 0; i < DIM6_LEN; i++) {
size_t index[VAR6_RANK];
index[0] = i;
if (nc_get_var1(ncid, varid, index, (void *) &val_in)) ERR;

View File

@ -30,7 +30,7 @@ main(int argc, char **argv)
int dimid, varid;
nc_type typeid;
char name_in[NC_MAX_NAME+1];
int i, j, k;
int i, j;
int var_dims[VAR_RANK];
@ -150,7 +150,7 @@ main(int argc, char **argv)
if (val_in.mon[i] != missing_val.mon[i]) ERR;
}
/* Read in each value and check */
for (k = 0; k < DIM_LEN; k++) {
for (size_t k = 0; k < DIM_LEN; k++) {
size_t index[VAR_RANK];
index[0] = k;
if (nc_get_var1(ncid, varid, index, (void *) &val_in)) ERR;

View File

@ -32,8 +32,6 @@ main(int argc, char **argv)
int class_in;
size_t size_in;
int i;
int var_dims[VAR3_RANK];
unsigned char sensor_data[DIM3_LEN][TYPE3_SIZE] = {
{1,2,3,4,5,6,7,8,9,10,11},
@ -90,7 +88,7 @@ main(int argc, char **argv)
if (nc_get_att(ncid, varid, ATT3_NAME, &val_in)) ERR;
if (memcmp(val_in, missing_val, TYPE3_SIZE) != 0) ERR;
for (i = 0; i < DIM3_LEN; i++) {
for (size_t i = 0; i < DIM3_LEN; i++) {
size_t index[VAR3_RANK];
index[0] = i;
if(nc_get_var1(ncid, varid, index, val_in)) ERR;

View File

@ -96,7 +96,7 @@ main(int argc, char **argv)
}
array[4][0] = missing_value; /* overwrite last row with missing for equality test */
for (i = 0; i < DIM5_LEN; i++) {
for (size_t i = 0; i < DIM5_LEN; i++) {
ragged_data[i].p = array[i];
ragged_data[i].len = NROWS - i;
}
@ -137,7 +137,7 @@ main(int argc, char **argv)
if (nc_free_vlen(&val_in)) ERR;
/* Read in each row, check its length and values */
for (i = 0; i < DIM5_LEN; i++) {
for (size_t i = 0; i < DIM5_LEN; i++) {
size_t index[VAR5_RANK];
float *fvals;
index[0] = i;

View File

@ -317,7 +317,7 @@ nc_inq_dimid2(int ncid, const char *dimname, int *dimidp) {
}
#ifdef USE_NETCDF4
else { /* Parse group name out and get dimid using that */
size_t grp_namelen = sp - dimname;
size_t grp_namelen = (size_t)(sp - dimname);
char *grpname = emalloc(grp_namelen+1);
int grpid;
@ -520,7 +520,7 @@ nc_inq_grpname_count(int ncid, int igrp, char **lgrps, idnode_t *grpids) {
/* Check if any group names specified with "-g grp1,...,grpn" are
* missing. Returns total number of matching groups if no missing
* groups detected, otherwise exits. */
int
size_t
grp_matches(int ncid, int nlgrps, char** lgrps, idnode_t *grpids) {
int ig;
size_t total = 0;
@ -883,7 +883,7 @@ nc_free_giter(ncgiter_t *iterp)
* for the group ids, then call again to get them.
*/
int
nc_inq_grps_full(int rootid, int *numgrps, int *grpids)
nc_inq_grps_full(int rootid, size_t *numgrps, int *grpids)
{
int stat = NC_NOERR;
ncgiter_t *giter; /* pointer to group iterator */

View File

@ -128,7 +128,7 @@ extern bool_t idmember ( const idnode_t* idlist, int id );
extern bool_t group_wanted ( int grpid, int nlgrps, const idnode_t* grpids );
/* Check group list for missing groups */
extern int grp_matches(int ncid, int nlgrps, char** lgrps, idnode_t *grpids);
extern size_t grp_matches(int ncid, int nlgrps, char** lgrps, idnode_t *grpids);
/* Returns 1 if string s1 ends with string s2, 0 otherwise. */
extern int strendswith(const char *s1, const char *s2);
@ -162,7 +162,7 @@ extern void freeidlist(idnode_t *idlist);
* loses information about subgroup relationships, just flattening all
* groups into a serial list.
*/
extern int nc_inq_grps_full(int ncid, int *numgrps, int *ncids);
extern int nc_inq_grps_full(int ncid, size_t *numgrps, int *ncids);
/*
* More complex iterator interface: get group iterator for start group

View File

@ -60,7 +60,7 @@ set_max_len(int len) {
*/
void
lput(const char *cp) {
size_t nn = strlen(cp);
int nn = (int)strlen(cp);
if (nn+linep > max_line_len && nn > 2) {
(void) fputs("\n", stdout);
@ -99,9 +99,9 @@ lput2(
* false=stay on same line */
)
{
static int linep; /* current line position (number of */
static size_t linep; /* current line position (number of */
/* chars); saved between calls */
int len_prefix = strlen (CDL_COMMENT_PREFIX);
size_t len_prefix = strlen (CDL_COMMENT_PREFIX);
bool_t make_newline;
size_t len1 = strlen(cp); /* length of input string */
@ -306,11 +306,11 @@ annotate(
/* C variable indices */
for (id = 0; id < vrank-1; id++)
printf("%lu,", (unsigned long) cor[id]);
printf("%lu", (unsigned long) cor[id] + iel);
printf("%lu", (unsigned long) cor[id] + (unsigned long) iel);
break;
case LANG_F:
/* Fortran variable indices */
printf("%lu", (unsigned long) cor[vrank-1] + iel + 1);
printf("%lu", (unsigned long) cor[vrank-1] + (unsigned long) iel + 1);
for (id = vrank-2; id >=0 ; id--) {
printf(",%lu", 1 + (unsigned long) cor[id]);
}
@ -342,7 +342,7 @@ pr_tvals(
len--;
for (iel = 0; iel < len; iel++) {
unsigned char uc;
switch (uc = *vals++ & 0377) {
switch (uc = (unsigned char)(*vals++ & 0377)) {
case '\b':
printf("\\b");
break;
@ -437,15 +437,11 @@ print_rows(
int rank = vp->ndims;
size_t ncols = rank > 0 ? vdims[rank - 1] : 1; /* number of values in a row */
int d0 = 0;
size_t inc = 1;
int i;
bool_t mark_record = (level > 0 && is_unlim_dim(ncid, vp->dims[level]));
safebuf_t *sb = sbuf_new();
if (rank > 0)
d0 = vdims[level];
for(i = level + 1; i < rank; i++) {
inc *= vdims[i];
}
d0 = (int)vdims[level];
if(mark_record) { /* the whole point of this recursion is printing these "{}" */
lput(LBRACE);
marks_pending++; /* matching "}"s to emit after last "row" */
@ -638,7 +634,7 @@ pr_tvalsx(
len--;
for (iel = 0; iel < len; iel++) {
unsigned char uc;
switch (uc = *vals++ & 0377) {
switch (uc = (unsigned char)(*vals++ & 0377)) {
case '\b':
printf("\\b");
break;

View File

@ -169,8 +169,7 @@ dumpgroup(Symbol* g)
if(debug <= 1) return;
fdebug("group %s {\n",(g==NULL?"null":g->name));
if(g != NULL && g->subnodes != NULL) {
int i;
for(i=0;i<listlength(g->subnodes);i++) {
for(size_t i=0;i<listlength(g->subnodes);i++) {
Symbol* sym = (Symbol*)listget(g->subnodes,i);
char* tname;
if(sym->objectclass == NC_PRIM
@ -178,7 +177,7 @@ dumpgroup(Symbol* g)
tname = nctypename(sym->subclass);
} else
tname = nctypename(sym->objectclass);
fdebug(" %3d: %s\t%s\t%s\n",
fdebug(" %3zu: %s\t%s\t%s\n",
i,
sym->name,
tname,