From 99f5ec3f24a6b2cec19695ba945b0c29effd3ba0 Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Mon, 27 Nov 2023 09:22:29 +0000 Subject: [PATCH 1/4] Include header for `size_t` in `nclist.h` --- include/nclist.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/nclist.h b/include/nclist.h index bad224ac2d..615b0c0da2 100644 --- a/include/nclist.h +++ b/include/nclist.h @@ -4,6 +4,7 @@ #define NCLIST_H 1 #include "ncexternl.h" +#include /* Define the type of the elements in the list*/ From 653e09fd6d5b65bad3ee748e3f54af720fd40b3e Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Mon, 27 Nov 2023 11:36:03 +0000 Subject: [PATCH 2/4] Try to more consistently use `size_t` for `nclistget` index argument --- libdap2/cache.c | 12 +++++---- libdap2/cdf.c | 27 +++++++++++---------- libdap2/constraints.c | 42 +++++++++++++++++--------------- libdap2/dapattr.c | 3 ++- libdap2/dapcvt.c | 7 +++--- libdap2/dapdump.c | 19 ++++++++------- libdap2/daputil.c | 7 +++--- libdap2/dceconstraints.c | 19 ++++++++------- libdap2/dceparse.c | 5 ++-- libdap2/getvara.c | 13 +++++----- libdap2/ncd2dispatch.c | 50 ++++++++++++++++++++------------------ libdap4/d4data.c | 15 +++++++----- libdap4/d4debug.c | 6 +++-- libdap4/d4dump.c | 3 ++- libdap4/d4file.c | 3 ++- libdap4/d4fix.c | 5 ++-- libdap4/d4meta.c | 51 +++++++++++++++++++++++---------------- libdap4/d4parser.c | 17 +++++++------ libdap4/d4printer.c | 20 +++++++-------- libdap4/d4swap.c | 3 ++- libdap4/d4util.c | 5 ++-- libdap4/d4varx.c | 14 +++++++---- libdap4/ncd4dispatch.c | 3 ++- libdispatch/dhttp.c | 3 ++- libdispatch/dinfermodel.c | 30 +++++++++++++---------- libdispatch/drc.c | 26 +++++++++++--------- libdispatch/ds3util.c | 3 ++- libdispatch/dutil.c | 5 ++-- libdispatch/nclist.c | 3 ++- libdispatch/ncuri.c | 27 +++++++++++---------- libhdf5/hdf5filter.c | 8 +++--- libhdf5/hdf5internal.c | 3 ++- libhdf5/hdf5open.c | 8 +++--- libhdf5/hdf5type.c | 5 ++-- libhdf5/nc4hdf.c | 7 +++--- libnczarr/zarr.c | 6 +++-- libnczarr/zfile.c | 3 ++- libnczarr/zfilter.c | 28 +++++++++++++-------- libnczarr/zmap.c | 3 ++- libnczarr/zmap_file.c | 6 +++-- libnczarr/zsync.c | 32 +++++++++++++++--------- libnczarr/ztype.c | 5 ++-- libnczarr/zutil.c | 6 +++-- libnczarr/zxcache.c | 9 ++++--- libsrc4/nc4internal.c | 7 +++--- libsrc4/nc4type.c | 19 ++++++++------- libsrc4/ncindex.c | 9 ++++--- ncdump/nc4printer.c | 9 ++++--- nczarr_test/ut_map.c | 8 +++--- nczarr_test/ut_mapapi.c | 9 ++++--- nczarr_test/zmapio.c | 15 ++++++------ oc2/dapparse.c | 3 ++- oc2/ocnode.c | 5 ++-- 53 files changed, 380 insertions(+), 279 deletions(-) diff --git a/libdap2/cache.c b/libdap2/cache.c index fb6afdfa7f..aa0ddd97d2 100644 --- a/libdap2/cache.c +++ b/libdap2/cache.c @@ -5,6 +5,7 @@ #include "dapincludes.h" #include "dapdump.h" +#include /* Grads servers always require a constraint, @@ -92,7 +93,7 @@ else NCerror prefetchdata(NCDAPCOMMON* nccomm) { - int i; + size_t i; NCFLAGS flags; NCerror ncstat = NC_NOERR; NClist* allvars = nccomm->cdf.ddsroot->tree->varnodes; @@ -341,7 +342,7 @@ fprintf(stderr,"freecachenode: %s\n", void freenccache(NCDAPCOMMON* nccomm, NCcache* cache) { - int i; + size_t i; if(cache == NULL) return; freenccachenode(nccomm,cache->prefetch); for(i=0;inodes);i++) { @@ -367,7 +368,8 @@ createnccache(void) static int iscacheableprojection(DCEprojection* proj) { - int i,cacheable; + size_t i; + int cacheable; if(proj->discrim != CES_VAR) return 0; cacheable = 1; /* assume so */ for(i=0;ivar->segments);i++) { @@ -380,7 +382,7 @@ iscacheableprojection(DCEprojection* proj) static int iscacheableconstraint(DCEconstraint* con) { - int i; + size_t i; if(con == NULL) return 1; if(con->selections != NULL && nclistlength(con->selections) > 0) return 0; /* can't deal with selections */ @@ -400,7 +402,7 @@ A variable is prefetchable if NCerror markprefetch(NCDAPCOMMON* nccomm) { - int i,j; + size_t i,j; NClist* allvars = nccomm->cdf.fullddsroot->tree->varnodes; assert(allvars != NULL); /* mark those variables of sufficiently small size */ diff --git a/libdap2/cdf.c b/libdap2/cdf.c index 4349dbe687..8db0bc845b 100644 --- a/libdap2/cdf.c +++ b/libdap2/cdf.c @@ -6,6 +6,7 @@ #include "dapincludes.h" #include "daputil.h" #include "dapdump.h" +#include #ifdef DAPDEBUG extern char* ocfqn(OCddsnode); @@ -433,7 +434,7 @@ we expected a grid. static int restructr(NCDAPCOMMON* ncc, CDFnode* dxdparent, CDFnode* patternparent, NClist* repairlist) { - int index, i, j, match; + size_t index, i, j, match; #ifdef DEBUG fprintf(stderr,"restruct: matched: %s -> %s\n", @@ -501,7 +502,7 @@ static NCerror repairgrids(NCDAPCOMMON* ncc, NClist* repairlist) { NCerror ncstat = NC_NOERR; - int i; + size_t i; assert(nclistlength(repairlist) % 2 == 0); for(i=0;isubnodes; for(i=0;icdf.ddsroot->tree->nodes; for(i=0;ibasenode; if(basenode == NULL) continue; @@ -689,7 +690,7 @@ dimimprint(NCDAPCOMMON* nccomm) if(noderank == 0) continue; ASSERT(noderank == baserank); #ifdef DEBUG -fprintf(stderr,"dimimprint %s/%d -> %s/%d\n", +fprintf(stderr,"dimimprint %s/%zu -> %s/%zu\n", makecdfpathstring(basenode,"."), noderank, makecdfpathstring(node,"."), @@ -725,7 +726,7 @@ static NClist* clonedimset(NCDAPCOMMON* nccomm, NClist* dimset, CDFnode* var) { NClist* result = NULL; - int i; + size_t i; for(i=0;iocname,(int)nclistlength(dimsetall)) static NCerror definetransdimset(NCDAPCOMMON* nccomm/*notused*/, CDFnode* node) { - int i; + size_t i; int ncstat = NC_NOERR; NClist* dimsettrans = NULL; @@ -842,7 +843,7 @@ Recursive helper for definedimsettrans3 static NCerror definedimsettransR(NCDAPCOMMON* nccomm, CDFnode* node) { - int i; + size_t i; int ncstat = NC_NOERR; definetransdimset(nccomm,node); @@ -882,7 +883,7 @@ Recursive helper static NCerror definedimsetsR(NCDAPCOMMON* nccomm, CDFnode* node) { - int i; + size_t i; int ncstat = NC_NOERR; definedimsetplus(nccomm,node); @@ -1057,7 +1058,7 @@ buildcdftreer(NCDAPCOMMON* nccomm, OCddsnode ocnode, CDFnode* container, void freecdfroot(CDFnode* root) { - int i; + size_t i; CDFtree* tree; NCDAPCOMMON* nccomm; if(root == NULL) return; @@ -1187,7 +1188,7 @@ fix1node(NCDAPCOMMON* nccomm, CDFnode* node) static NCerror fixnodes(NCDAPCOMMON* nccomm, NClist* cdfnodes) { - int i; + size_t i; for(i=0;i static void completesegments(NClist* fullpath, NClist* segments); static NCerror qualifyprojectionnames(DCEprojection* proj); @@ -338,7 +339,8 @@ fprintf(stderr,"matchpartialname: choice: %s %s for %s\n", static int matchsuffix(NClist* matchpath, NClist* segments) { - int i,pathstart; + size_t i; + int pathstart; int nsegs = nclistlength(segments); int pathlen = nclistlength(matchpath); int segmatch; @@ -356,7 +358,7 @@ matchsuffix(NClist* matchpath, NClist* segments) matching as we go */ for(i=0;irank; segmatch = 1; /* until proven otherwise */ @@ -386,12 +388,12 @@ dapbuildvaraprojection(CDFnode* var, const size_t* startp, const size_t* countp, const ptrdiff_t* stridep, DCEprojection** projectionp) { - int i,j; + size_t i,j; NCerror ncstat = NC_NOERR; DCEprojection* projection = NULL; NClist* path = nclistnew(); NClist* segments = NULL; - int dimindex; + size_t dimindex; /* Build a skeleton projection that has 1 segment for every cdfnode from root to the variable of interest. @@ -463,9 +465,10 @@ dapiswholeslice(DCEslice* slice, CDFnode* dim) int dapiswholesegment(DCEsegment* seg) { - int i,whole; + size_t i; + int whole; NClist* dimset = NULL; - unsigned int rank; + size_t rank; if(seg->rank == 0) return 1; if(!seg->slicesdefined) return 0; @@ -483,7 +486,8 @@ dapiswholesegment(DCEsegment* seg) int dapiswholeprojection(DCEprojection* proj) { - int i,whole; + size_t i; + int whole; ASSERT((proj->discrim == CES_VAR)); @@ -498,7 +502,7 @@ dapiswholeprojection(DCEprojection* proj) int dapiswholeconstraint(DCEconstraint* con) { - int i; + size_t i; if(con == NULL) return 1; if(con->projections != NULL) { for(i=0;iprojections);i++) { @@ -528,7 +532,7 @@ The term "expanded" means NCerror dapfixprojections(NClist* list) { - int i,j,k; + size_t i,j,k; NCerror ncstat = NC_NOERR; NClist* tmp = nclistnew(); /* misc. uses */ @@ -619,12 +623,12 @@ next: continue; } /*for(;;)*/ /* remove all NULL elements */ - for(i=nclistlength(list)-1;i>=0;i--) { - DCEprojection* target = (DCEprojection*)nclistget(list,i); + int n; + for(n=nclistlength(list)-1;n>=0;n--) { + DCEprojection* target = (DCEprojection*)nclistget(list,n); if(target == NULL) - nclistremove(list,i); + nclistremove(list,n); } - done: #ifdef DEBUG fprintf(stderr,"fixprojection: exploded = %s\n",dumpprojections(list)); @@ -661,7 +665,7 @@ projectify(CDFnode* field, DCEprojection* container) static int slicematch(NClist* seglist1, NClist* seglist2) { - int i,j; + size_t i,j; if((seglist1 == NULL || seglist2 == NULL) && seglist1 != seglist2) return 0; if(nclistlength(seglist1) != nclistlength(seglist2)) @@ -691,7 +695,7 @@ slicematch(NClist* seglist1, NClist* seglist2) int dapvar2projection(CDFnode* var, DCEprojection** projectionp) { - int i,j; + size_t i,j; int ncstat = NC_NOERR; NClist* path = nclistnew(); NClist* segments; @@ -707,7 +711,7 @@ dapvar2projection(CDFnode* var, DCEprojection** projectionp) for(i=0;iannotation = (void*)n; @@ -757,7 +761,7 @@ int daprestrictprojection(NClist* projections, DCEprojection* var, DCEprojection** resultp) { int ncstat = NC_NOERR; - int i; + size_t i; DCEprojection* result = NULL; #ifdef DEBUG1 fprintf(stderr,"restrictprojection.before: constraints=|%s| vara=|%s|\n", @@ -817,7 +821,7 @@ int dapshiftprojection(DCEprojection* projection) { int ncstat = NC_NOERR; - int i,j; + size_t i,j; NClist* segments; #ifdef DEBUG1 @@ -849,7 +853,7 @@ dapcomputeprojectedvars(NCDAPCOMMON* dapcomm, DCEconstraint* constraint) { NCerror ncstat = NC_NOERR; NClist* vars = NULL; - int i; + size_t i; vars = nclistnew(); diff --git a/libdap2/dapattr.c b/libdap2/dapattr.c index c0e37aa9a7..2ee46383eb 100644 --- a/libdap2/dapattr.c +++ b/libdap2/dapattr.c @@ -4,6 +4,7 @@ *********************************************************************/ #include "dapincludes.h" +#include #define OCCHECK(exp) if((ocstat = (exp))) {THROWCHK(ocstat); goto done;} @@ -18,7 +19,7 @@ and stuff from DODS_EXTRA. int dapmerge(NCDAPCOMMON* nccomm, CDFnode* ddsroot, OCddsnode dasroot) { - int i,j; + size_t i,j; NCerror ncstat = NC_NOERR; OCerror ocstat = OC_NOERR; NClist* allnodes; diff --git a/libdap2/dapcvt.c b/libdap2/dapcvt.c index 5979fb8227..72d305d87a 100644 --- a/libdap2/dapcvt.c +++ b/libdap2/dapcvt.c @@ -4,6 +4,7 @@ *********************************************************************/ #include "config.h" #include "dapincludes.h" +#include #ifdef _WIN32 #include @@ -215,10 +216,10 @@ If we need an int and the string value is out of range, return NC_ERANGE. NCerror dapcvtattrval(nc_type etype, void* dst, NClist* src, NCattribute* att) { - int i; + size_t i; NCerror ncstat = NC_NOERR; - unsigned int memsize = nctypesizeof(etype); - unsigned int nvalues = nclistlength(src); + size_t memsize = nctypesizeof(etype); + size_t nvalues = nclistlength(src); char* dstmem = (char*)dst; for(i=0;i #ifdef USE_PARALLEL #include "netcdf_par.h" #endif @@ -247,7 +248,7 @@ dumppath(CDFnode* leaf) NClist* path = nclistnew(); NCbytes* buf = ncbytesnew(); char* result; - int i; + size_t i; if(leaf == NULL) return nulldup(""); collectnodepath(leaf,path,!WITHDATASET); @@ -272,7 +273,7 @@ dumpindent(int indent, NCbytes* buf) static void dumptreer1(CDFnode* root, NCbytes* buf, int indent, char* tag, int visible) { - int i; + size_t i; dumpindent(indent,buf); ncbytescat(buf,tag); ncbytescat(buf," {\n"); @@ -300,7 +301,7 @@ dumptreer1(CDFnode* root, NCbytes* buf, int indent, char* tag, int visible) static void dumptreer(CDFnode* root, NCbytes* buf, int indent, int visible) { - int i; + size_t i; char* primtype = NULL; NClist* dimset = NULL; @@ -389,7 +390,7 @@ dumpnode(CDFnode* node) { NCbytes* buf = ncbytesnew(); char* result; - int i; + size_t i; char* nctype = NULL; char* primtype = NULL; char tmp[1024]; @@ -456,7 +457,7 @@ dumpnode(CDFnode* node) ncbytescat(buf,tmp); for(i=0;iarray.dimset0);i++) { CDFnode* dim = (CDFnode*)nclistget(node->array.dimset0,i); - snprintf(tmp,sizeof(tmp),"dims[%d]={\n",i); + snprintf(tmp,sizeof(tmp),"dims[%zu]={\n",i); ncbytescat(buf,tmp); snprintf(tmp,sizeof(tmp)," ocname=%s\n",dim->ocname); ncbytescat(buf,tmp); @@ -497,7 +498,7 @@ dumpcachenode(NCcachenode* node) { char* result = NULL; char tmp[8192]; - int i; + size_t i; NCbytes* buf; if(node == NULL) return strdup("cachenode{null}"); @@ -527,7 +528,7 @@ dumpcache(NCcache* cache) { char* result = NULL; char tmp[8192]; - int i; + size_t i; NCbytes* buf; if(cache == NULL) return strdup("cache{null}"); @@ -619,10 +620,10 @@ dumplistraw(NClist* l) void dumpstringlist(NClist* l) { - int i; + size_t i; for(i=0;i #ifdef HAVE_SYS_TIME_H #include @@ -312,7 +313,7 @@ collectocpath(OClink conn, OCddsnode node, NClist* path) char* makeocpathstring(OClink conn, OCddsnode node, const char* sep) { - int i,len,first; + size_t i,len,first; char* result; char* name; OCtype octype; @@ -353,7 +354,7 @@ makeocpathstring(OClink conn, OCddsnode node, const char* sep) char* makepathstring(NClist* path, const char* separator, int flags) { - int i,len,first; + size_t i,len,first; NCbytes* pathname = NULL; char* result; CDFnode* node; @@ -412,7 +413,7 @@ clonenodenamepath(CDFnode* node, NClist* path, int withdataset) char* simplepathstring(NClist* names, char* separator) { - int i; + size_t i; size_t len; char* result; if(nclistlength(names) == 0) return nulldup(""); diff --git a/libdap2/dceconstraints.c b/libdap2/dceconstraints.c index b4895768f8..2215542242 100644 --- a/libdap2/dceconstraints.c +++ b/libdap2/dceconstraints.c @@ -5,6 +5,7 @@ #include "config.h" +#include #include #include #include @@ -218,7 +219,7 @@ Dst will be modified. int dcemergeprojectionlists(NClist* dst, NClist* src) { - int i; + size_t i; NClist* cat = nclistnew(); int ncstat = NC_NOERR; @@ -272,7 +273,7 @@ int dcemergeprojections(DCEprojection* merged, DCEprojection* addition) { int ncstat = NC_NOERR; - int i,j; + size_t i,j; ASSERT((merged->discrim == CES_VAR && addition->discrim == CES_VAR)); ASSERT((nclistlength(merged->var->segments) == nclistlength(addition->var->segments))); @@ -432,7 +433,7 @@ dceclone(DCEnode* node) NClist* dceclonelist(NClist* list) { - int i; + size_t i; NClist* clone; if(list == NULL) return NULL; clone = nclistnew(); @@ -519,7 +520,7 @@ dcefree(DCEnode* node) void dcefreelist(NClist* list) { - int i; + size_t i; if(list == NULL) return; for(i=0;isort == which) @@ -920,8 +921,8 @@ dcemakewholeprojection(DCEprojection* p) int dcesamepath(NClist* list1, NClist* list2) { - int i; - int len = nclistlength(list1); + size_t i; + size_t len = nclistlength(list1); if(len != nclistlength(list2)) return 0; for(i=0;i #include #include #include @@ -91,7 +92,7 @@ segmentlist(DCEparsestate* state, Object var0, Object decl) Object segment(DCEparsestate* state, Object name, Object slices0) { - int i; + size_t i; DCEsegment* segment = (DCEsegment*)dcecreate(CES_SEGMENT); NClist* slices = (NClist*)slices0; segment->name = strdup((char*)name); @@ -222,7 +223,7 @@ array_indices(DCEparsestate* state, Object list0, Object indexno) Object indexer(DCEparsestate* state, Object name, Object indices) { - int i; + size_t i; NClist* list = (NClist*)indices; DCEsegment* seg = (DCEsegment*)dcecreate(CES_SEGMENT); seg->name = strdup((char*)name); diff --git a/libdap2/getvara.c b/libdap2/getvara.c index f3ab9259a3..32ac76e7bf 100644 --- a/libdap2/getvara.c +++ b/libdap2/getvara.c @@ -9,6 +9,7 @@ #include "dapdump.h" #include "ncd2dispatch.h" #include "ocx.h" +#include #define NEWVARM @@ -95,7 +96,7 @@ nc3d_getvarx(int ncid, int varid, { NCerror ncstat = NC_NOERR; OCerror ocstat = OC_NOERR; - int i; + size_t i; NC* drno; NC* substrate; NCDAPCOMMON* dapcomm; @@ -426,7 +427,7 @@ fprintf(stderr,"cache.datadds=%s\n",dumptree(cachenode->datadds)); static NCerror removepseudodims(DCEprojection* proj) { - int i; + size_t i; #ifdef DEBUG1 fprintf(stderr,"removesequencedims.before: %s\n",dumpprojection(proj)); #endif @@ -935,7 +936,7 @@ extractstring( { NCerror ncstat = NC_NOERR; OCerror ocstat = OC_NOERR; - int i; + size_t i; size_t rank0; NClist* strings = NULL; Dapodometer* odom = NULL; @@ -1056,9 +1057,9 @@ It is assumed that both trees have been re-struct'ed if necessary. */ static NCerror -attachr(CDFnode* xnode, NClist* patternpath, int depth) +attachr(CDFnode* xnode, NClist* patternpath, size_t depth) { - unsigned int i,plen,lastnode,gridable; + size_t i,plen,lastnode,gridable; NCerror ncstat = NC_NOERR; CDFnode* patternpathnode; CDFnode* patternpathnext; @@ -1129,7 +1130,7 @@ attachsubsetr(CDFnode* target, CDFnode* pattern) { unsigned int i; NCerror ncstat = NC_NOERR; - int fieldindex; + size_t fieldindex; #ifdef DEBUG2 fprintf(stderr,"attachsubsetr: attach: target=%s pattern=%s\n", diff --git a/libdap2/ncd2dispatch.c b/libdap2/ncd2dispatch.c index e8d433fd77..b60d2eca27 100644 --- a/libdap2/ncd2dispatch.c +++ b/libdap2/ncd2dispatch.c @@ -8,6 +8,7 @@ #include "ncrc.h" #include "ncoffsets.h" #include "netcdf_dispatch.h" +#include #ifdef DEBUG2 #include "dapdump.h" #endif @@ -728,7 +729,7 @@ fprintf(stderr,"define: dim: %s=%ld\n",dim->ncfullname,(long)dim->dim.declsize); static NCerror buildvars(NCDAPCOMMON* dapcomm) { - int i,j; + size_t i,j; NCerror ncstat = NC_NOERR; int varid; NClist* varnodes = dapcomm->cdf.ddsroot->tree->varnodes; @@ -738,7 +739,7 @@ buildvars(NCDAPCOMMON* dapcomm) for(i=0;iinvisible) continue; @@ -773,7 +774,7 @@ fprintf(stderr,"\n"); ncstat = nc_def_var(dapcomm->substrate.nc3id, definename, var->externaltype, - ncrank, + (int)ncrank, (ncrank==0?NULL:dimids), &varid); nullfree(definename); @@ -849,7 +850,7 @@ fprintf(stderr,"\n"); static NCerror buildglobalattrs(NCDAPCOMMON* dapcomm, CDFnode* root) { - int i; + size_t i; NCerror ncstat = NC_NOERR; const char* txt; char *nltxt, *p; @@ -930,9 +931,9 @@ buildglobalattrs(NCDAPCOMMON* dapcomm, CDFnode* root) static NCerror buildattribute(NCDAPCOMMON* dapcomm, CDFnode* var, NCattribute* att) { - int i; + size_t i; NCerror ncstat = NC_NOERR; - unsigned int nvalues = nclistlength(att->values); + size_t nvalues = nclistlength(att->values); int varid = (var == NULL ? NC_GLOBAL : var->ncid); void* mem = NULL; @@ -966,7 +967,7 @@ buildattribute(NCDAPCOMMON* dapcomm, CDFnode* var, NCattribute* att) if(ncstat) goto done; } else { nc_type atype; - unsigned int typesize; + size_t typesize; atype = nctypeconvert(dapcomm,att->etype); typesize = nctypesizeof(atype); if (nvalues > 0) { @@ -1040,7 +1041,7 @@ NCD2_inq_format_extended(int ncid, int* formatp, int* modep) NCerror computecdfdimnames(NCDAPCOMMON* nccomm) { - int i,j; + size_t i,j; char tmp[NC_MAX_NAME*2]; NClist* conflicts = nclistnew(); NClist* varnodes = nccomm->cdf.ddsroot->tree->varnodes; @@ -1116,7 +1117,7 @@ fprintf(stderr,"conflict: %s[%lu] %s[%lu]\n", /* Give all the conflicting dimensions an index */ for(j=0;jdim.index1 = j+1; + dim->dim.index1 = (int)j+1; } } nclistfree(conflicts); @@ -1240,7 +1241,8 @@ paramlookup(NCDAPCOMMON* state, const char* key) static NCerror applyclientparams(NCDAPCOMMON* nccomm) { - int i,len; + size_t i; + int len; int dfaltstrlen = DEFAULTSTRINGLENGTH; int dfaltseqlim = DEFAULTSEQLIMIT; const char* value; @@ -1364,12 +1366,12 @@ applyclientparams(NCDAPCOMMON* nccomm) static void computedimindexanon(CDFnode* dim, CDFnode* var) { - int i; + size_t i; NClist* dimset = var->array.dimsetall; for(i=0;idim.index1=i+1; + dim->dim.index1 = (int)i+1; return; } } @@ -1379,7 +1381,7 @@ computedimindexanon(CDFnode* dim, CDFnode* var) static void replacedims(NClist* dims) { - int i; + size_t i; for(i=0;idim.basedim; @@ -1407,7 +1409,7 @@ equivalentdim(CDFnode* basedim, CDFnode* dupdim) static void getalldimsa(NClist* dimset, NClist* alldims) { - int i; + size_t i; for(i=0;icdf.ddsroot->tree->varnodes; @@ -1450,7 +1452,7 @@ addstringdims(NCDAPCOMMON* dapcomm) in DODS{...} attribute set or defaulting to the variable name. All such dimensions are global. */ - int i; + size_t i; NClist* varnodes = dapcomm->cdf.ddsroot->tree->varnodes; CDFnode* globalsdim = NULL; char dimname[4096]; @@ -1514,7 +1516,7 @@ addstringdims(NCDAPCOMMON* dapcomm) static NCerror defrecorddim(NCDAPCOMMON* dapcomm) { - unsigned int i; + size_t i; NCerror ncstat = NC_NOERR; NClist* basedims; @@ -1590,7 +1592,7 @@ defseqdims(NCDAPCOMMON* dapcomm) static NCerror showprojection(NCDAPCOMMON* dapcomm, CDFnode* var) { - int i,rank; + size_t i,rank; NCerror ncstat = NC_NOERR; NCbytes* projection = ncbytesnew(); NClist* path = nclistnew(); @@ -1848,7 +1850,7 @@ make sure we always have a constraint. static NCerror computeseqcountconstraints(NCDAPCOMMON* dapcomm, CDFnode* seq, NCbytes* seqcountconstraints) { - int i,j; + size_t i,j; NClist* path = NULL; CDFnode* var = NULL; @@ -1875,7 +1877,7 @@ computeseqcountconstraints(NCDAPCOMMON* dapcomm, CDFnode* seq, NCbytes* seqcount ncbytescat(seqcountconstraints,tmp); } } else if(nclistlength(node->array.dimset0) > 0) { - int ndims = nclistlength(node->array.dimset0); + size_t ndims = nclistlength(node->array.dimset0); for(j=0;jarray.dimset0,j); if(DIMFLAG(dim,CDFDIMSTRING)) { @@ -1986,8 +1988,8 @@ cdftotalsize(NClist* dimensions) static void estimatevarsizes(NCDAPCOMMON* dapcomm) { - int ivar; - unsigned int rank; + size_t ivar; + size_t rank; size_t totalsize = 0; for(ivar=0;ivarcdf.ddsroot->tree->varnodes);ivar++) { @@ -2183,7 +2185,7 @@ make them invisible. static NCerror fixzerodims(NCDAPCOMMON* dapcomm) { - int i,j; + size_t i,j; for(i=0;icdf.ddsroot->tree->varnodes);i++) { CDFnode* var = (CDFnode*)nclistget(dapcomm->cdf.ddsroot->tree->varnodes,i); NClist* ncdims = var->array.dimsetplus; @@ -2249,7 +2251,7 @@ applyclientparamcontrols(NCDAPCOMMON* dapcomm) CLRFLAG(dapcomm->controls,NCF_FILLMISMATCH); if((value=dapparamvalue(dapcomm,"encode")) != NULL) { - int i; + size_t i; NClist* encode = nclistnew(); if(dapparamparselist(value,',',encode)) nclog(NCLOGERR,"Malformed encode parameter: %s",value); diff --git a/libdap4/d4data.c b/libdap4/d4data.c index eae5f32ed8..d1e28b4092 100644 --- a/libdap4/d4data.c +++ b/libdap4/d4data.c @@ -6,6 +6,7 @@ #include "d4includes.h" #include #include +#include #include "d4includes.h" #include "d4odom.h" #include "nccrc.h" @@ -58,7 +59,7 @@ int NCD4_parcelvars(NCD4meta* meta, NCD4response* resp) { int ret = NC_NOERR; - int i; + size_t i; NClist* toplevel = NULL; NCD4node* root = meta->root; NCD4offset* offset = NULL; @@ -88,7 +89,7 @@ int NCD4_processdata(NCD4meta* meta, NCD4response* resp) { int ret = NC_NOERR; - int i; + size_t i; NClist* toplevel = NULL; NCD4node* root = meta->root; NCD4offset* offset = NULL; @@ -203,7 +204,8 @@ NCD4_movetoinstance(NCD4meta* meta, NCD4node* type, NCD4offset* offset, void** d static int fillstruct(NCD4meta* meta, NCD4node* type, NCD4offset* offset, void** dstp, NClist* blobs) { - int i,ret = NC_NOERR; + size_t i; + int ret = NC_NOERR; void* dst = *dstp; #ifdef CLEARSTRUCT @@ -370,7 +372,7 @@ int NCD4_getToplevelVars(NCD4meta* meta, NCD4node* group, NClist* toplevel) { int ret = NC_NOERR; - int i; + size_t i; if(group == NULL) group = meta->root; @@ -397,7 +399,8 @@ int NCD4_inferChecksums(NCD4meta* meta, NCD4response* resp) { int ret = NC_NOERR; - int i, attrfound; + size_t i; + int attrfound; NClist* toplevel = NULL; /* Get the toplevel vars */ @@ -407,7 +410,7 @@ NCD4_inferChecksums(NCD4meta* meta, NCD4response* resp) /* First, look thru the DMR to see if there is a checksum attribute */ attrfound = 0; for(i=0;iattributes);a++) { NCD4node* attr = (NCD4node*)nclistget(node->attributes,a); diff --git a/libdap4/d4debug.c b/libdap4/d4debug.c index caed80027a..3074b80fe8 100644 --- a/libdap4/d4debug.c +++ b/libdap4/d4debug.c @@ -4,6 +4,7 @@ *********************************************************************/ #include "config.h" #include +#include #include #include "d4includes.h" @@ -96,7 +97,8 @@ bv inserting the data into the substrate and then writing it out. int NCD4_debugcopy(NCD4INFO* info) { - int i,ret=NC_NOERR; + size_t i; + int ret = NC_NOERR; NCD4meta* meta = info->dmrmetadata; NClist* topvars = nclistnew(); NC* ncp = info->controller; @@ -134,7 +136,7 @@ NCD4_debugcopy(NCD4INFO* info) */ { size_t edges[NC_MAX_VAR_DIMS]; - int d; + size_t d; for(d=0;ddims);d++) { NCD4node* dim = (NCD4node*)nclistget(var->dims,d); edges[d] = (size_t)dim->dim.size; diff --git a/libdap4/d4dump.c b/libdap4/d4dump.c index 2f3103a404..89bd9862ed 100644 --- a/libdap4/d4dump.c +++ b/libdap4/d4dump.c @@ -3,6 +3,7 @@ */ #include "d4includes.h" +#include /* Provide a simple dump of binary data @@ -87,7 +88,7 @@ NCD4_tagdump(size_t size, const void* data0, int swap, const char* tag) void NCD4_dumpvars(NCD4node* group) { - int i; + size_t i; fprintf(stderr,"%s.vars:\n",group->name); for(i=0;ivars);i++) { NCD4node* var = (NCD4node*)nclistget(group->vars,i); diff --git a/libdap4/d4file.c b/libdap4/d4file.c index 46c1a0fdbb..677844ab06 100644 --- a/libdap4/d4file.c +++ b/libdap4/d4file.c @@ -7,6 +7,7 @@ #include "ncd4dispatch.h" #include "d4includes.h" #include "d4curlfunctions.h" +#include #ifdef _MSC_VER #include @@ -678,7 +679,7 @@ NCD4_newMeta(NCD4INFO* info, NCD4meta** metap) void NCD4_reclaimMeta(NCD4meta* dataset) { - int i; + size_t i; if(dataset == NULL) return; for(i=0;iallnodes);i++) { diff --git a/libdap4/d4fix.c b/libdap4/d4fix.c index b76a52d28b..af47ea88e3 100644 --- a/libdap4/d4fix.c +++ b/libdap4/d4fix.c @@ -5,6 +5,7 @@ #include #include +#include #include "d4includes.h" @@ -120,7 +121,7 @@ Do depth first search static void walk(NCD4node* node, NClist* sorted) { - int i; + size_t i; if(node->visited) return; node->visited = 1; @@ -310,7 +311,7 @@ static int delimitStruct(NCD4meta* compiler, NCD4node* basetype, NCD4offset* offset) { int ret = NC_NOERR; - int i; + size_t i; /* The fields are associated with the basetype struct */ for(i=0;ivars);i++) { diff --git a/libdap4/d4meta.c b/libdap4/d4meta.c index 1cea62f613..049469ad36 100644 --- a/libdap4/d4meta.c +++ b/libdap4/d4meta.c @@ -5,6 +5,7 @@ #include "d4includes.h" #include +#include #include "nc4internal.h" #include "ncoffsets.h" @@ -58,7 +59,7 @@ int NCD4_metabuild(NCD4meta* metadata, int ncid) { int ret = NC_NOERR; - int i; + size_t i; metadata->ncid = ncid; metadata->root->meta.id = ncid; @@ -119,7 +120,8 @@ reclaimNode(NCD4node* node) static int build(NCD4meta* builder, NCD4node* root) { - int i,ret = NC_NOERR; + size_t i; + int ret = NC_NOERR; size_t len = nclistlength(builder->allnodes); /* Tag the root group */ @@ -223,7 +225,8 @@ build(NCD4meta* builder, NCD4node* root) static int buildGroups(NCD4meta* builder, NCD4node* parent) { - int i,ret=NC_NOERR; + size_t i; + int ret = NC_NOERR; #ifdef D4DEBUG fprintf(stderr,"build group: %s\n",parent->name); #endif @@ -261,7 +264,8 @@ buildDimension(NCD4meta* builder, NCD4node* dim) static int buildEnumeration(NCD4meta* builder, NCD4node* en) { - int i,ret = NC_NOERR; + size_t i; + int ret = NC_NOERR; NCD4node* group = NCD4_groupFor(en); NCCHECK((nc_def_enum(group->meta.id,en->basetype->meta.id,en->name,&en->meta.id))); for(i=0;ien.econsts);i++) { @@ -342,7 +346,8 @@ buildMetaData(NCD4meta* builder, NCD4node* var) static int buildMaps(NCD4meta* builder, NCD4node* var) { - int i,ret = NC_NOERR; + size_t i; + int ret = NC_NOERR; size_t count = nclistlength(var->maps); char** memory = NULL; char** p; @@ -372,7 +377,8 @@ buildMaps(NCD4meta* builder, NCD4node* var) static int buildAttributes(NCD4meta* builder, NCD4node* varorgroup) { - int i,ret = NC_NOERR; + size_t i; + int ret = NC_NOERR; NClist* blobs = NULL; for(i=0;iattributes);i++) { @@ -479,7 +485,8 @@ buildVlenType(NCD4meta* builder, NCD4node* vlentype) static int buildCompound(NCD4meta* builder, NCD4node* cmpdtype, NCD4node* group, char* name) { - int i,ret = NC_NOERR; + size_t i; + int ret = NC_NOERR; /* Step 1: compute field offsets */ computeOffsets(builder,cmpdtype); @@ -613,7 +620,7 @@ savevarbyid(NCD4node* group, NCD4node* var) char* NCD4_getVarFQN(NCD4node* var, const char* tail) { - int i; + size_t i; NCD4node* x = NULL; NClist* path = NULL; NCbytes* fqn = NULL; @@ -646,7 +653,7 @@ NCD4_getVarFQN(NCD4node* var, const char* tail) static char* getFieldFQN(NCD4node* field, const char* tail) { - int i; + size_t i; NCD4node* x = NULL; NClist* path = NULL; NCbytes* fqn = NULL; @@ -676,8 +683,8 @@ getFieldFQN(NCD4node* field, const char* tail) static size_t getDimrefs(NCD4node* var, int* dimids) { - int i; - int rank = nclistlength(var->dims); + size_t i; + size_t rank = nclistlength(var->dims); for(i=0;idims,i); dimids[i] = dim->meta.id; @@ -688,8 +695,8 @@ getDimrefs(NCD4node* var, int* dimids) static size_t getDimsizes(NCD4node* var, int* dimsizes) { - int i; - int rank = nclistlength(var->dims); + size_t i; + size_t rank = nclistlength(var->dims); for(i=0;idims,i); dimsizes[i] = (int)dim->dim.size; @@ -720,7 +727,8 @@ to nc_put_att(). static int compileAttrValues(NCD4meta* builder, NCD4node* attr, void** memoryp, NClist* blobs) { - int i,ret = NC_NOERR; + size_t i; + int ret = NC_NOERR; unsigned char* memory = NULL; unsigned char* p; size_t size; @@ -730,7 +738,7 @@ compileAttrValues(NCD4meta* builder, NCD4node* attr, void** memoryp, NClist* blo NCD4node* container = attr->container; NCD4node* basetype = attr->basetype; NClist* values = attr->attr.values; - int count = nclistlength(values); + size_t count = nclistlength(values); memset((void*)&converter,0,sizeof(converter)); @@ -887,7 +895,8 @@ Note: this will work if the econst string is a number or a econst name static int decodeEconst(NCD4meta* builder, NCD4node* enumtype, const char* nameorval, union ATOMICS* converter) { - int i,ret=NC_NOERR; + size_t i; + int ret = NC_NOERR; union ATOMICS number; NCD4node* match = NULL; @@ -949,7 +958,7 @@ backslashEscape(const char* s) static int markfixedsize(NCD4meta* meta) { - int i,j; + size_t i,j; for(i=0;iallnodes);i++) { int fixed = 1; NCD4node* n = (NCD4node*)nclistget(meta->allnodes,i); @@ -979,7 +988,7 @@ markfixedsize(NCD4meta* meta) static void computeOffsets(NCD4meta* builder, NCD4node* cmpd) { - int i; + size_t i; d4size_t offset = 0; d4size_t largestalign = 1; d4size_t size = 0; @@ -1103,7 +1112,7 @@ getpadding(d4size_t offset, size_t alignment) static int markdapsize(NCD4meta* meta) { - int i,j; + size_t i,j; for(i=0;iallnodes);i++) { NCD4node* type = (NCD4node*)nclistget(meta->allnodes,i); size_t totalsize; @@ -1161,10 +1170,10 @@ NCD4_findvar(NC* ncp, int gid, int varid, NCD4node** varp, NCD4node** grpp) return THROW(NC_EBADID); /* Locate var node via (grpid,varid) */ grp_id = GROUPIDPART(gid); - group = nclistget(meta->groupbyid,grp_id); + group = nclistget(meta->groupbyid, (size_t)grp_id); if(group == NULL) return THROW(NC_EBADID); - var = nclistget(group->group.varbyid,varid); + var = nclistget(group->group.varbyid, (size_t)varid); if(var == NULL) return THROW(NC_EBADID); if(varp) *varp = var; diff --git a/libdap4/d4parser.c b/libdap4/d4parser.c index 2948f80672..895e88e2a0 100644 --- a/libdap4/d4parser.c +++ b/libdap4/d4parser.c @@ -6,6 +6,7 @@ #include "d4includes.h" #include #include +#include #include "ncxml.h" /** @@ -878,7 +879,8 @@ Find or create an opaque type static NCD4node* getOpaque(NCD4parser* parser, ncxml_t varxml, NCD4node* group) { - int i, ret = NC_NOERR; + size_t i; + int ret = NC_NOERR; long long len; NCD4node* opaquetype = NULL; char* xattr; @@ -1024,7 +1026,7 @@ splitOrigType(NCD4parser* parser, const char* fqn, NCD4node* type) NCD4node* NCD4_findAttr(NCD4node* container, const char* attrname) { - int i; + size_t i; /* Look directly under this xml for */ for(i=0;iattributes);i++) { NCD4node* attr = (NCD4node*)nclistget(container->attributes,i); @@ -1095,7 +1097,8 @@ static int lookupFQNList(NCD4parser* parser, NClist* fqn, NCD4sort sort, NCD4node** result) { int ret = NC_NOERR; - int i,nsteps; + size_t i; + int nsteps; NCD4node* current; char* name = NULL; NCD4node* node = NULL; @@ -1139,7 +1142,7 @@ lookupFQNList(NCD4parser* parser, NClist* fqn, NCD4sort sort, NCD4node** result) assert (i < (nsteps - 1)); i++; /* skip variable name */ for(;;i++) { - int j; + size_t j; name = (char*)nclistget(fqn,i); assert(ISTYPE(current->sort) && ISCMPD(current->subsort)); for(node=NULL,j=0;jvars);j++) { @@ -1166,7 +1169,7 @@ lookupFQNList(NCD4parser* parser, NClist* fqn, NCD4sort sort, NCD4node** result) static NCD4node* lookFor(NClist* elems, const char* name, NCD4sort sort) { - int n,i; + size_t n,i; if(elems == NULL || nclistlength(elems) == 0) return NULL; n = nclistlength(elems); for(i=0;igroup.elements; if(elems == NULL || nclistlength(elems) == 0) return; @@ -1646,7 +1649,7 @@ static int parseForwards(NCD4parser* parser, NCD4node* root) { int ret = NC_NOERR; - int i,j; + size_t i,j; /* process all vars */ for(i=0;ivars);i++) { diff --git a/libdap4/d4printer.c b/libdap4/d4printer.c index 88b1392d24..81183efba1 100644 --- a/libdap4/d4printer.c +++ b/libdap4/d4printer.c @@ -4,6 +4,7 @@ *********************************************************************/ #include "d4includes.h" +#include /** This provides a simple dap4 metadata -> xml printer. @@ -87,7 +88,7 @@ static int printNode(D4printer* out, NCD4node* node, int depth) { int ret = NC_NOERR; - int i; + size_t i; char* fqn = NULL; switch (node->sort) { @@ -297,13 +298,12 @@ static int printGroupBody(D4printer* out, NCD4node* node, int depth) { int ret = NC_NOERR; - int i,ngroups,nvars,ntypes,ndims,nattrs; - - ngroups = nclistlength(node->groups); - nvars = nclistlength(node->vars); - ntypes = nclistlength(node->types); - ndims = nclistlength(node->dims); - nattrs = nclistlength(node->attributes); + size_t i; + size_t ngroups = nclistlength(node->groups); + size_t nvars = nclistlength(node->vars); + size_t ntypes = nclistlength(node->types); + size_t ndims = nclistlength(node->dims); + size_t nattrs = nclistlength(node->attributes); if(ndims > 0) { INDENT(depth); @@ -371,7 +371,7 @@ static int printMetaData(D4printer* out, NCD4node* node, int depth) { int ret = NC_NOERR; - int i; + size_t i; if(nclistlength(node->dims) > 0) { for(i=0;idims);i++) { @@ -456,7 +456,7 @@ static int printAttribute(D4printer* out, NCD4node* attr, int depth) { int ret = NC_NOERR; - int i = 0; + size_t i = 0; char* fqn = NULL; INDENT(depth); CAT(" +#include #include "d4includes.h" /* @@ -151,7 +152,7 @@ static int walkStruct(NCD4response* resp, NCD4node* topvar, NCD4node* structtype, NCD4offset* offset, int doswap) { int ret = NC_NOERR; - int i; + size_t i; for(i=0;ivars);i++) { NCD4node* field = (NCD4node*)nclistget(structtype->vars,i); diff --git a/libdap4/d4util.c b/libdap4/d4util.c index d1ba7f5828..8e422b5cad 100644 --- a/libdap4/d4util.c +++ b/libdap4/d4util.c @@ -4,6 +4,7 @@ *********************************************************************/ #include "d4includes.h" +#include #ifdef HAVE_SYS_STAT_H #include #endif @@ -92,7 +93,7 @@ NCD4_typesize(nc_type tid) d4size_t NCD4_dimproduct(NCD4node* node) { - int i; + size_t i; d4size_t product = 1; for(i=0;idims);i++) { NCD4node* dim = (NCD4node*)nclistget(node->dims,i); @@ -156,7 +157,7 @@ create the last part of the fqn char* NCD4_makeName(NCD4node* elem, const char* sep) { - int i; + size_t i; size_t estimate = 0; NCD4node* n; NClist* path = nclistnew(); diff --git a/libdap4/d4varx.c b/libdap4/d4varx.c index b098855f83..e42bd98558 100644 --- a/libdap4/d4varx.c +++ b/libdap4/d4varx.c @@ -9,6 +9,7 @@ #include "nc4internal.h" #include "d4includes.h" #include "d4odom.h" +#include /* Forward */ static int getvarx(int gid, int varid, NCD4INFO**, NCD4node** varp, nc_type* xtypep, size_t*, nc_type* nc4typep, size_t*); @@ -31,7 +32,8 @@ NCD4_get_vars(int gid, int varid, const size_t *start, const size_t *edges, const ptrdiff_t* stride, void *memoryin, nc_type xtype) { - int i,ret; + size_t i; + int ret; NCD4INFO* info; NCD4meta* meta; NCD4node* ncvar; @@ -41,7 +43,7 @@ NCD4_get_vars(int gid, int varid, size_t nc4size, xsize, dapsize; void* instance = NULL; /* Staging area in case we have to convert */ NClist* blobs = NULL; - int rank; + size_t rank; size_t dimsizes[NC_MAX_VAR_DIMS]; d4size_t dimproduct; size_t dstpos; @@ -246,7 +248,8 @@ findbyname(const char* name, NClist* nodes) static int matchvar(NCD4meta* dmrmeta, NCD4node* dapvar, NCD4node** dmrvarp) { - int i,ret = NC_NOERR; + size_t i; + int ret = NC_NOERR; NCD4node* x = NULL; NClist* dappath = nclistnew(); NClist* dmrpath = nclistnew(); /* compute path for this dmr var */ @@ -259,7 +262,7 @@ matchvar(NCD4meta* dmrmeta, NCD4node* dapvar, NCD4node** dmrvarp) for(i=0;iallnodes);i++) { NCD4node* node = (NCD4node*)nclistget(dmrmeta->allnodes,i); if(ISVAR(node->sort) && strcmp(node->name,dapvar->name)==0) { /* possible candidate */ - int j; + size_t j; found = 0; nclistclear(dmrpath); for(x=node;x != NULL;x=x->container) nclistinsert(dmrpath,0,x); @@ -292,7 +295,8 @@ toplevel dmr var and transfer necessary info; static int mapvars(NCD4meta* dapmeta, NCD4meta* dmrmeta, int inferredchecksumming) { - int i, ret = NC_NOERR; + size_t i; + int ret = NC_NOERR; NCD4node* daproot = dapmeta->root; NClist* daptop = NULL; /* top variables in dap tree */ diff --git a/libdap4/ncd4dispatch.c b/libdap4/ncd4dispatch.c index e7eefb40a4..37e134b55a 100644 --- a/libdap4/ncd4dispatch.c +++ b/libdap4/ncd4dispatch.c @@ -3,6 +3,7 @@ * See netcdf/COPYRIGHT file for copying and redistribution conditions. *********************************************************************/ +#include #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -841,7 +842,7 @@ NCD4_inq_dim(int ncid, int dimid, char* name, size_t* lenp) NC* ncp; NCD4INFO* info; NCD4meta* meta; - int i; + size_t i; NCD4node* dim = NULL; if((ret = NC_check_id(ncid, (NC**)&ncp)) != NC_NOERR) diff --git a/libdispatch/dhttp.c b/libdispatch/dhttp.c index 6f12e561fa..1008ff62f2 100644 --- a/libdispatch/dhttp.c +++ b/libdispatch/dhttp.c @@ -8,6 +8,7 @@ */ #include "config.h" +#include #include #include #include @@ -715,7 +716,7 @@ headersoff(NC_HTTP_STATE* state) static int lookupheader(NC_HTTP_STATE* state, const char* key, const char** valuep) { - int i; + size_t i; const char* value = NULL; /* Get the content length header */ for(i=0;icurl.response.headers);i+=2) { diff --git a/libdispatch/dinfermodel.c b/libdispatch/dinfermodel.c index 6f5e4a846c..b1c838b24f 100644 --- a/libdispatch/dinfermodel.c +++ b/libdispatch/dinfermodel.c @@ -9,6 +9,7 @@ */ #include "config.h" +#include #include #ifdef HAVE_UNISTD_H #include @@ -399,7 +400,7 @@ parseonchar(const char* s, int ch, NClist* segments) static char* envvlist2string(NClist* envv, const char* delim) { - int i; + size_t i; NCbytes* buf = NULL; char* result = NULL; @@ -441,7 +442,8 @@ processmodearg(const char* arg, NCmodel* model) static int processmacros(NClist* fraglenv, NClist* expanded) { - int i, stat = NC_NOERR; + size_t i; + int stat = NC_NOERR; const struct MACRODEF* macros = NULL; for(i=0;i #ifdef HAVE_UNISTD_H #include #endif @@ -204,7 +205,7 @@ rcfreeentry(NCRCentry* t) static void rcfreeentries(NClist* rc) { - int i; + size_t i; for(i=0;ircinfo; NCRCentry* entry = NULL; @@ -612,7 +614,7 @@ rclocatepos(const char* key, const char* hostport, const char* urlpath) for(i=0;iy static int awsparse(const char* text, NClist* profiles) { - int i,stat = NC_NOERR; + size_t i; + int stat = NC_NOERR; size_t len; AWSparser* parser = NULL; struct AWSprofile* profile = NULL; @@ -1095,7 +1098,7 @@ static void freeprofile(struct AWSprofile* profile) { if(profile) { - int i; + size_t i; #ifdef AWSDEBUG fprintf(stderr,">>> freeprofile: %s\n",profile->name); #endif @@ -1113,7 +1116,7 @@ static void freeprofilelist(NClist* profiles) { if(profiles) { - int i; + size_t i; for(i=0;ircinfo->s3profiles);i++) { @@ -1231,7 +1234,8 @@ NC_authgets3profile(const char* profilename, struct AWSprofile** profilep) int NC_s3profilelookup(const char* profile, const char* key, const char** valuep) { - int i,stat = NC_NOERR; + size_t i; + int stat = NC_NOERR; struct AWSprofile* awsprof = NULL; const char* value = NULL; diff --git a/libdispatch/ds3util.c b/libdispatch/ds3util.c index 5091b1a24e..b447a64350 100644 --- a/libdispatch/ds3util.c +++ b/libdispatch/ds3util.c @@ -52,7 +52,8 @@ if provided, otherwise us-east-1. int NC_s3urlrebuild(NCURI* url, NCS3INFO* s3, NCURI** newurlp) { - int i,stat = NC_NOERR; + size_t i; + int stat = NC_NOERR; NClist* hostsegments = NULL; NClist* pathsegments = NULL; NCbytes* buf = ncbytesnew(); diff --git a/libdispatch/dutil.c b/libdispatch/dutil.c index 83b20dfb69..d60c8e1767 100644 --- a/libdispatch/dutil.c +++ b/libdispatch/dutil.c @@ -4,6 +4,7 @@ *********************************************************************/ #include "config.h" +#include #include #include #include @@ -378,7 +379,7 @@ NC_testmode(NCURI* uri, const char* tag) { int stat = NC_NOERR; int found = 0; - int i; + size_t i; const char* modestr = NULL; NClist* modelist = NULL; @@ -467,7 +468,7 @@ int NC_join(NClist* segments, char** pathp) { int stat = NC_NOERR; - int i; + size_t i; NCbytes* buf = NULL; if(segments == NULL) diff --git a/libdispatch/nclist.c b/libdispatch/nclist.c index f2c3f4d47b..ae4177bcd1 100644 --- a/libdispatch/nclist.c +++ b/libdispatch/nclist.c @@ -1,5 +1,6 @@ /* Copyright 2018, UCAR/Unidata and OPeNDAP, Inc. See the COPYRIGHT file for more information. */ +#include #include #include #include @@ -270,7 +271,7 @@ nclistclone(const NClist* l, int deep) nclistsetlength(clone,l->length); memcpy((void*)clone->content,(void*)l->content,sizeof(void*)*l->length); } else { /*deep*/ - int i; + size_t i; for(i=0;i #include #include #include @@ -431,7 +432,7 @@ static void freestringlist(NClist* list) { if(list != NULL) { - int i; + size_t i; for(i=0;ifraglist,key); nclistpush(duri->fraglist,value); } else { - nullfree(nclistget(duri->fraglist,pos+1)); - nclistset(duri->fraglist,pos+1,strdup(value)); + nullfree(nclistget(duri->fraglist,(size_t)pos+1)); + nclistset(duri->fraglist,(size_t)pos+1,strdup(value)); } /* Rebuild the fragment */ nullfree(duri->fragment); duri->fragment = NULL; @@ -576,8 +577,8 @@ ncuriappendfragmentkey(NCURI* duri,const char* key, const char* value) nclistpush((NClist*)duri->fraglist,strdup(key)); nclistpush((NClist*)duri->fraglist,nulldup(value)); } else { - nullfree(nclistget(duri->fraglist,pos+1)); - nclistset(duri->fraglist,pos+1,nulldup(value)); + nullfree(nclistget(duri->fraglist,(size_t)pos+1)); + nclistset(duri->fraglist,(size_t)pos+1,nulldup(value)); } /* Rebuild the fragment */ nullfree(duri->fraglist); duri->fraglist = NULL; @@ -600,8 +601,8 @@ ncurisetquerykey(NCURI* duri,const char* key, const char* value) nclistpush(duri->querylist,key); nclistpush(duri->querylist,value); } else { - nullfree(nclistget(duri->querylist,pos+1)); - nclistset(duri->querylist,pos+1,strdup(value)); + nullfree(nclistget(duri->querylist,(size_t)pos+1)); + nclistset(duri->querylist,(size_t)pos+1,strdup(value)); } /* Rebuild the query */ nullfree(duri->query); duri->query = NULL; @@ -623,8 +624,8 @@ ncuriappendquerykey(NCURI* duri,const char* key, const char* value) nclistpush((NClist*)duri->querylist,strdup(key)); nclistpush((NClist*)duri->querylist,nulldup(value)); } else { - nullfree(nclistget(duri->querylist,pos+1)); - nclistset(duri->querylist,pos+1,nulldup(value)); + nullfree(nclistget(duri->querylist,(size_t)pos+1)); + nclistset(duri->querylist,(size_t)pos+1,nulldup(value)); } /* Rebuild the query */ nullfree(duri->querylist); duri->querylist = NULL; @@ -768,7 +769,7 @@ ncurifragmentlookup(NCURI* uri, const char* key) if(ensurefraglist(uri)) return NULL; i = ncfind(uri->fraglist,key); if(i < 0) return NULL; - value = nclistget(uri->fraglist,i+1); + value = nclistget(uri->fraglist,(size_t)i+1); return value; } @@ -781,7 +782,7 @@ ncuriquerylookup(NCURI* uri, const char* key) if(ensurequerylist(uri)) return NULL; i = ncfind(uri->querylist,key); if(i < 0) return NULL; - value = nclistget(uri->querylist,i+1); + value = nclistget(uri->querylist,(size_t)i+1); return value; } @@ -832,7 +833,7 @@ ncfind(NClist* params, const char* key) if(key == NULL) return -1; if(params == NULL) return -1; for(i=0;i #include #include "hdf5internal.h" #include "hdf5debug.h" @@ -335,7 +336,7 @@ fprintf(stderr,"\tid=%s\n",id); int NC4_hdf5_filter_lookup(NC_VAR_INFO_T* var, unsigned int id, struct NC_HDF5_Filter** specp) { - int i; + size_t i; NClist* flist = (NClist*)var->filters; if(flist == NULL) { @@ -520,7 +521,7 @@ NC4_hdf5_inq_var_filter_ids(int ncid, int varid, size_t* nfiltersp, unsigned int nfilters = nclistlength(flist); if(nfilters > 0 && ids != NULL) { - int k; + size_t k; for(k=0;kfilterid; @@ -569,7 +570,8 @@ NC4_hdf5_inq_var_filter_info(int ncid, int varid, unsigned int id, size_t* npara int NC4_hdf5_find_missing_filter(NC_VAR_INFO_T* var, unsigned int* idp) { - int i,stat = NC_NOERR; + size_t i; + int stat = NC_NOERR; NClist* flist = (NClist*)var->filters; int id = 0; diff --git a/libhdf5/hdf5internal.c b/libhdf5/hdf5internal.c index 5532ed0c1d..43a8e27c1d 100644 --- a/libhdf5/hdf5internal.c +++ b/libhdf5/hdf5internal.c @@ -17,6 +17,7 @@ #include "config.h" #include "hdf5internal.h" #include "hdf5err.h" /* For BAIL2 */ +#include #ifdef _WIN32 #include #endif @@ -205,7 +206,7 @@ nc4_rec_find_hdf_type(NC_FILE_INFO_T *h5, hid_t target_hdf_typeid) { NC_TYPE_INFO_T *type; htri_t equal; - int i; + size_t i; assert(h5); diff --git a/libhdf5/hdf5open.c b/libhdf5/hdf5open.c index 0c2f5b5234..dec1bff4f2 100644 --- a/libhdf5/hdf5open.c +++ b/libhdf5/hdf5open.c @@ -18,6 +18,7 @@ #include "ncauth.h" #include "ncmodel.h" #include "ncpathmgr.h" +#include #ifdef ENABLE_BYTERANGE #include "H5FDhttp.h" @@ -2088,7 +2089,7 @@ read_type(NC_GRP_INFO_T *grp, hid_t hdf_typeid, char *type_name) return NC_EHDFERR; LOG((5, "compound type has %d members", nmembers)); type->u.c.field = nclistnew(); - nclistsetalloc(type->u.c.field,nmembers); + nclistsetalloc(type->u.c.field, (size_t)nmembers); for (m = 0; m < nmembers; m++) { @@ -2253,7 +2254,7 @@ read_type(NC_GRP_INFO_T *grp, hid_t hdf_typeid, char *type_name) if ((nmembers = H5Tget_nmembers(hdf_typeid)) < 0) return NC_EHDFERR; type->u.e.enum_member = nclistnew(); - nclistsetalloc(type->u.e.enum_member,nmembers); + nclistsetalloc(type->u.e.enum_member, (size_t)nmembers); /* Allocate space for one value. */ if (!(value = calloc(1, type_size))) @@ -2816,7 +2817,8 @@ rec_read_metadata(NC_GRP_INFO_T *grp) hid_t pid = -1; unsigned crt_order_flags = 0; H5_index_t iter_index; - int i, retval = NC_NOERR; + size_t i; + int retval = NC_NOERR; assert(grp && grp->hdr.name && grp->format_grp_info); LOG((3, "%s: grp->hdr.name %s", __func__, grp->hdr.name)); diff --git a/libhdf5/hdf5type.c b/libhdf5/hdf5type.c index 7d971dfcd5..ddd10f5381 100644 --- a/libhdf5/hdf5type.c +++ b/libhdf5/hdf5type.c @@ -14,6 +14,7 @@ #include "config.h" #include "hdf5internal.h" +#include /** * @internal Determine if two types are equal. @@ -69,11 +70,11 @@ NC4_inq_type_equal(int ncid1, nc_type typeid1, int ncid2, /* Not atomic types - so find type1 and type2 information. */ if ((retval = nc4_find_nc4_grp(ncid1, &grpone))) return retval; - if (!(type1 = nclistget(grpone->nc4_info->alltypes, typeid1))) + if (!(type1 = nclistget(grpone->nc4_info->alltypes, (size_t)typeid1))) return NC_EBADTYPE; if ((retval = nc4_find_nc4_grp(ncid2, &grptwo))) return retval; - if (!(type2 = nclistget(grptwo->nc4_info->alltypes, typeid2))) + if (!(type2 = nclistget(grptwo->nc4_info->alltypes, (size_t)typeid2))) return NC_EBADTYPE; /* Are the two types equal? */ diff --git a/libhdf5/nc4hdf.c b/libhdf5/nc4hdf.c index a84abd0223..b589872fdb 100644 --- a/libhdf5/nc4hdf.c +++ b/libhdf5/nc4hdf.c @@ -22,6 +22,7 @@ #include "hdf5err.h" /* For BAIL2 */ #include "hdf5debug.h" #include +#include #ifdef HAVE_INTTYPES_H #define __STDC_FORMAT_MACROS @@ -886,7 +887,7 @@ var_create_dataset(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var, nc_bool_t write_dimid * nc_def_var_filter(). If the user * has specified a filter, it will be applied here. */ if(var->filters != NULL) { - int j; + size_t j; NClist* filters = (NClist*)var->filters; for(j=0;jhdf_typeid = H5Tcreate(H5T_COMPOUND, type->size)) < 0) return NC_EHDFERR; @@ -1255,7 +1256,7 @@ commit_type(NC_GRP_INFO_T *grp, NC_TYPE_INFO_T *type) else if (type->nc_type_class == NC_ENUM) { NC_ENUM_MEMBER_INFO_T *enum_m; - int i; + size_t i; if (nclistlength(type->u.e.enum_member) == 0) return NC_EINVAL; diff --git a/libnczarr/zarr.c b/libnczarr/zarr.c index 9e22f73d42..832b0d7c40 100644 --- a/libnczarr/zarr.c +++ b/libnczarr/zarr.c @@ -4,6 +4,7 @@ *********************************************************************/ #include "zincludes.h" +#include /**************************************************/ /* Forwards */ @@ -296,7 +297,7 @@ ncz_open_rootgroup(NC_FILE_INFO_T* dataset) static const char* controllookup(NClist* controls, const char* key) { - int i; + size_t i; for(i=0;i /* Forward */ static int NCZ_enddef(NC_FILE_INFO_T* h5); @@ -103,7 +104,7 @@ static int NCZ_enddef(NC_FILE_INFO_T* h5) { NC_VAR_INFO_T *var; - int i,j; + size_t i,j; int stat = NC_NOERR; ZTRACE(1,"h5=%s",h5->hdr.name); diff --git a/libnczarr/zfilter.c b/libnczarr/zfilter.c index e3896bf9a4..07e6d7d3bf 100644 --- a/libnczarr/zfilter.c +++ b/libnczarr/zfilter.c @@ -30,6 +30,7 @@ */ #include "config.h" +#include #include #ifdef HAVE_SYS_STAT_H @@ -287,7 +288,8 @@ static int pluginnamecheck(const char* name); int NCZ_filter_freelists(NC_VAR_INFO_T* var) { - int i, stat=NC_NOERR; + size_t i; + int stat=NC_NOERR; NClist* filters = NULL; NCZ_VAR_INFO_T* zvar = (NCZ_VAR_INFO_T*)var->format_var_info; @@ -444,7 +446,7 @@ NCZ_filter_remove(NC_VAR_INFO_T* var, unsigned int id) static int NCZ_filter_lookup(NC_VAR_INFO_T* var, unsigned int id, struct NCZ_Filter** specp) { - int i; + size_t i; NClist* flist = (NClist*)var->filters; ZTRACE(6,"var=%s id=%u",var->hdr.name,id); @@ -652,7 +654,7 @@ NCZ_inq_var_filter_ids(int ncid, int varid, size_t* nfiltersp, unsigned int* ids nfilters = nclistlength(flist); /* including incomplets */ if(nfilters > 0 && ids != NULL) { - int k; + size_t k; for(k=0;khdf5.id; @@ -842,7 +844,8 @@ NCZ_plugin_loaded(int filterid, NCZ_Plugin** pp) int NCZ_applyfilterchain(const NC_FILE_INFO_T* file, NC_VAR_INFO_T* var, NClist* chain, size_t inlen, void* indata, size_t* outlenp, void** outdatap, int encode) { - int i, stat = NC_NOERR; + size_t i; + int stat = NC_NOERR; void* lastbuffer = NULL; /* if not null, then last allocated buffer */ ZTRACE(6,"|chain|=%u inlen=%u indata=%p encode=%d", (unsigned)nclistlength(chain), (unsigned)inlen, indata, encode); @@ -893,8 +896,9 @@ fprintf(stderr,">>> next: alloc=%u used=%u buf=%p\n",(unsigned)next_alloc,(unsig } } else { /* Apply in reverse order */ - for(i=nclistlength(chain)-1;i>=0;i--) { - f = (struct NCZ_Filter*)nclistget(chain,i); + int k; + for(k=(int)nclistlength(chain)-1;k>=0;k--) { + f = (struct NCZ_Filter*)nclistget(chain,(size_t)k); if(f->flags & FLAG_SUPPRESS) continue; /* this filter should not be applied */ ff = f->plugin->hdf5.filter; /* code can be simplified */ @@ -1151,7 +1155,8 @@ getentries(const char* path, NClist* contents) static int NCZ_load_all_plugins(void) { - int i,j,ret = NC_NOERR; + size_t i,j; + int ret = NC_NOERR; char* pluginroots = NULL; struct stat buf; NClist* dirs = nclistnew(); @@ -1330,7 +1335,8 @@ NCZ_split_plugin_path(const char* path0, NClist* list) static int NCZ_load_plugin_dir(const char* path) { - int i,stat = NC_NOERR; + size_t i; + int stat = NC_NOERR; size_t pathlen; NClist* contents = nclistnew(); char* file = NULL; @@ -1605,7 +1611,8 @@ pluginnamecheck(const char* name) int NCZ_codec_attr(const NC_VAR_INFO_T* var, size_t* lenp, void* data) { - int i,stat = NC_NOERR; + size_t i; + int stat = NC_NOERR; size_t len; char* contents = NULL; NCbytes* buf = NULL; @@ -1761,7 +1768,8 @@ rebuild_visible(const NC_VAR_INFO_T* var, NCZ_Filter* filter) int NCZ_filter_setup(NC_VAR_INFO_T* var) { - int i,stat = NC_NOERR; + size_t i; + int stat = NC_NOERR; NClist* filters = NULL; ZTRACE(6,"var=%s",var->hdr.name); diff --git a/libnczarr/zmap.c b/libnczarr/zmap.c index eb808d431d..611b2fbb49 100644 --- a/libnczarr/zmap.c +++ b/libnczarr/zmap.c @@ -5,6 +5,7 @@ #include "zincludes.h" #include +#include #include "ncpathmgr.h" /**************************************************/ @@ -217,7 +218,7 @@ int nczm_join(NClist* segments, char** pathp) { int stat = NC_NOERR; - int i; + size_t i; NCbytes* buf = NULL; if(segments == NULL) diff --git a/libnczarr/zmap_file.c b/libnczarr/zmap_file.c index 4884e3eec8..4f798c4fde 100755 --- a/libnczarr/zmap_file.c +++ b/libnczarr/zmap_file.c @@ -3,6 +3,7 @@ * See netcdf/COPYRIGHT file for copying and redistribution conditions. */ +#include #undef DEBUG /* Not sure this has any effect */ @@ -529,7 +530,8 @@ static int zfcreategroup(ZFMAP* zfmap, const char* key, int nskip) { int stat = NC_NOERR; - int i, len; + size_t i; + int len; char* fullpath = NULL; NCbytes* path = ncbytesnew(); NClist* segments = nclistnew(); @@ -948,7 +950,7 @@ static int platformdeleter(NCbytes* canonpath, int depth) { int ret = NC_NOERR; - int i; + size_t i; NClist* subfiles = nclistnew(); size_t tpathlen = ncbyteslength(canonpath); char* local = NULL; diff --git a/libnczarr/zsync.c b/libnczarr/zsync.c index 8a14cdc694..2407d1f2b5 100644 --- a/libnczarr/zsync.c +++ b/libnczarr/zsync.c @@ -5,6 +5,7 @@ #include "zincludes.h" #include "zfilter.h" +#include #ifndef nulldup #define nulldup(x) ((x)?strdup(x):(x)) @@ -277,7 +278,8 @@ ncz_sync_grp(NC_FILE_INFO_T* file, NC_GRP_INFO_T* grp, int isclose) static int ncz_sync_var_meta(NC_FILE_INFO_T* file, NC_VAR_INFO_T* var, int isclose) { - int i,stat = NC_NOERR; + size_t i; + int stat = NC_NOERR; NCZ_FILE_INFO_T* zinfo = NULL; char number[1024]; NCZMAP* map = NULL; @@ -435,7 +437,7 @@ ncz_sync_var_meta(NC_FILE_INFO_T* file, NC_VAR_INFO_T* var, int isclose) if((stat = NCJaddstring(jvar,NCJ_STRING,"filters"))) goto done; #ifdef ENABLE_NCZARR_FILTERS if(nclistlength(filterchain) > 1) { - int k; + size_t k; /* jtmp holds the array of filters */ if((stat = NCJnew(NCJ_ARRAY,&jtmp))) goto done; for(k=0;kcontroller->path,grp->hdr.name,nclistlength(diminfo)); @@ -1447,7 +1450,7 @@ static int define_vars(NC_FILE_INFO_T* file, NC_GRP_INFO_T* grp, NClist* varnames) { int stat = NC_NOERR; - int i,j; + size_t i,j; NCZ_FILE_INFO_T* zinfo = NULL; NCZMAP* map = NULL; int purezarr = 0; @@ -1823,7 +1826,8 @@ define_vars(NC_FILE_INFO_T* file, NC_GRP_INFO_T* grp, NClist* varnames) static int define_subgrps(NC_FILE_INFO_T* file, NC_GRP_INFO_T* grp, NClist* subgrpnames) { - int i,stat = NC_NOERR; + size_t i; + int stat = NC_NOERR; ZTRACE(3,"file=%s grp=%s |subgrpnames|=%u",file->controller->path,grp->hdr.name,nclistlength(subgrpnames)); @@ -2059,7 +2063,8 @@ parse_var_dims_pure(NCZ_FILE_INFO_T* zinfo, NC_GRP_INFO_T* grp, NC_VAR_INFO_T* static int searchvars(NCZ_FILE_INFO_T* zfile, NC_GRP_INFO_T* grp, NClist* varnames) { - int i,stat = NC_NOERR; + size_t i; + int stat = NC_NOERR; char* grpkey = NULL; char* varkey = NULL; char* zarray = NULL; @@ -2093,7 +2098,8 @@ searchvars(NCZ_FILE_INFO_T* zfile, NC_GRP_INFO_T* grp, NClist* varnames) static int searchsubgrps(NCZ_FILE_INFO_T* zfile, NC_GRP_INFO_T* grp, NClist* subgrpnames) { - int i,stat = NC_NOERR; + size_t i; + int stat = NC_NOERR; char* grpkey = NULL; char* subkey = NULL; char* zgroup = NULL; @@ -2177,7 +2183,8 @@ Given a list of segments, find corresponding group. static int locategroup(NC_FILE_INFO_T* file, size_t nsegs, NClist* segments, NC_GRP_INFO_T** grpp) { - int i, j, found, stat = NC_NOERR; + size_t i, j; + int found, stat = NC_NOERR; NC_GRP_INFO_T* grp = NULL; grp = file->root_grp; @@ -2206,13 +2213,14 @@ locategroup(NC_FILE_INFO_T* file, size_t nsegs, NClist* segments, NC_GRP_INFO_T* static int parsedimrefs(NC_FILE_INFO_T* file, NClist* dimnames, size64_t* shape, NC_DIM_INFO_T** dims, int create) { - int i, stat = NC_NOERR; + size_t i; + int stat = NC_NOERR; NClist* segments = NULL; for(i=0;i we need to create the dims in root if they do not already exist */ NCZ_FILE_INFO_T* zfile = (NCZ_FILE_INFO_T*)file->format_file_info; NCZ_VAR_INFO_T* zvar = (NCZ_VAR_INFO_T*)(var->format_var_info); diff --git a/libnczarr/ztype.c b/libnczarr/ztype.c index 7c8ecec8da..dd1bb57fa9 100644 --- a/libnczarr/ztype.c +++ b/libnczarr/ztype.c @@ -14,6 +14,7 @@ */ #include "zincludes.h" +#include /** * @internal Determine if two types are equal. @@ -69,11 +70,11 @@ NCZ_inq_type_equal(int ncid1, nc_type typeid1, int ncid2, /* Not atomic types - so find type1 and type2 information. */ if ((retval = nc4_find_nc4_grp(ncid1, &grpone))) return retval; - if (!(type1 = nclistget(grpone->nc4_info->alltypes, typeid1))) + if (!(type1 = nclistget(grpone->nc4_info->alltypes, (size_t)typeid1))) return NC_EBADTYPE; if ((retval = nc4_find_nc4_grp(ncid2, &grptwo))) return retval; - if (!(type2 = nclistget(grptwo->nc4_info->alltypes, typeid2))) + if (!(type2 = nclistget(grptwo->nc4_info->alltypes, (size_t)typeid2))) return NC_EBADTYPE; #ifdef LOOK diff --git a/libnczarr/zutil.c b/libnczarr/zutil.c index 5e10ffaf91..bca5cafeac 100644 --- a/libnczarr/zutil.c +++ b/libnczarr/zutil.c @@ -11,6 +11,7 @@ */ #include "zincludes.h" +#include #undef DEBUG @@ -125,7 +126,7 @@ NCZ_grpkey(const NC_GRP_INFO_T* grp, char** pathp) NClist* segments = nclistnew(); NCbytes* path = NULL; NC_GRP_INFO_T* parent = NULL; - int i; + size_t i; nclistinsert(segments,0,(void*)grp); parent = grp->parent; @@ -475,7 +476,8 @@ Note: need to test with "/", "", and with and without trailing "/". int NCZ_subobjects(NCZMAP* map, const char* prefix, const char* tag, char dimsep, NClist* objlist) { - int i,stat=NC_NOERR; + size_t i; + int stat = NC_NOERR; NClist* matches = nclistnew(); NCbytes* path = ncbytesnew(); diff --git a/libnczarr/zxcache.c b/libnczarr/zxcache.c index 7a469587a3..f997a14791 100644 --- a/libnczarr/zxcache.c +++ b/libnczarr/zxcache.c @@ -14,6 +14,7 @@ #include "zcache.h" #include "ncxcache.h" #include "zfilter.h" +#include #undef DEBUG @@ -423,7 +424,7 @@ constraincache(NCZChunkCache* cache, size64_t needed) /* Flush from LRU end if we are at capacity */ while(nclistlength(cache->mru) > cache->params.nelems || cache->used > final_size) { - int i; + size_t i; void* ptr; NCZCacheEntry* e = ncxcachelast(cache->xcache); /* last entry is the least recently used */ if(e == NULL) break; @@ -773,7 +774,7 @@ get_chunk(NCZChunkCache* cache, NCZCacheEntry* entry) case NC_EEMPTY: empty = 1; stat = NC_NOERR;break; default: goto done; } - entry->isfiltered = FILTERED(cache); /* Is the data being read filtered? */ + entry->isfiltered = (int)FILTERED(cache); /* Is the data being read filtered? */ if(tid == NC_STRING) entry->isfixedstring = 1; /* fill cache is in char[maxstrlen] format */ } @@ -890,7 +891,7 @@ NCZ_printxcache(NCZChunkCache* cache) static char xs[20000]; NCbytes* buf = ncbytesnew(); char s[8192]; - int i; + size_t i; ncbytescat(buf,"NCZChunkCache:\n"); snprintf(s,sizeof(s),"\tvar=%s\n\tndims=%u\n\tchunksize=%u\n\tchunkcount=%u\n\tfillchunk=%p\n", @@ -916,7 +917,7 @@ NCZ_printxcache(NCZChunkCache* cache) ncbytescat(buf,"\t\t\n"); for(i=0;imru);i++) { NCZCacheEntry* e = (NCZCacheEntry*)nclistget(cache->mru,i); - snprintf(s,sizeof(s),"\t\t[%d] ",i); + snprintf(s,sizeof(s),"\t\t[%zu] ", i); ncbytescat(buf,s); if(e == NULL) ncbytescat(buf,""); diff --git a/libsrc4/nc4internal.c b/libsrc4/nc4internal.c index 2c6e64d1b3..c07bae8123 100644 --- a/libsrc4/nc4internal.c +++ b/libsrc4/nc4internal.c @@ -24,6 +24,7 @@ #include "ncdispatch.h" /* from libdispatch */ #include "ncutf8.h" #include +#include #include "ncrc.h" /** @internal Number of reserved attributes. These attributes are @@ -507,7 +508,7 @@ nc4_find_dim(NC_GRP_INFO_T *grp, int dimid, NC_DIM_INFO_T **dim, LOG((4, "%s: dimid %d", __func__, dimid)); /* Find the dim info. */ - if (!((*dim) = nclistget(grp->nc4_info->alldims, dimid))) + if (!((*dim) = nclistget(grp->nc4_info->alldims, (size_t)dimid))) return NC_EBADDIM; /* Give the caller the group the dimension is in. */ @@ -597,7 +598,7 @@ nc4_find_type(const NC_FILE_INFO_T *h5, nc_type typeid, NC_TYPE_INFO_T **type) return NC_NOERR; /* Find the type. */ - if (!(*type = nclistget(h5->alltypes,typeid))) + if (!(*type = nclistget(h5->alltypes, (size_t)typeid))) return NC_EBADTYPID; return NC_NOERR; @@ -1252,7 +1253,7 @@ field_free(NC_FIELD_INFO_T *field) int nc4_type_free(NC_TYPE_INFO_T *type) { - int i; + size_t i; assert(type && type->rc && type->hdr.name); diff --git a/libsrc4/nc4type.c b/libsrc4/nc4type.c index 1aef7ea0e7..b0361a55a5 100644 --- a/libsrc4/nc4type.c +++ b/libsrc4/nc4type.c @@ -13,6 +13,7 @@ */ #include "nc4internal.h" #include "nc4dispatch.h" +#include #if 0 #ifdef ENABLE_DAP4 @@ -187,7 +188,7 @@ NC4_inq_type(int ncid, nc_type typeid1, char *name, size_t *size) return retval; /* Find this type. */ - if (!(type = nclistget(grp->nc4_info->alltypes, typeid1))) + if (!(type = nclistget(grp->nc4_info->alltypes, (size_t)typeid1))) return NC_EBADTYPE; if (name) @@ -237,7 +238,7 @@ NC4_inq_user_type(int ncid, nc_type typeid1, char *name, size_t *size, return retval; /* Find this type. */ - if (!(type = nclistget(grp->nc4_info->alltypes, typeid1))) + if (!(type = nclistget(grp->nc4_info->alltypes, (size_t)typeid1))) return NC_EBADTYPE; /* Count the number of fields. */ @@ -316,11 +317,11 @@ NC4_inq_compound_field(int ncid, nc_type typeid1, int fieldid, char *name, return retval; /* Find this type. */ - if (!(type = nclistget(grp->nc4_info->alltypes, typeid1))) + if (!(type = nclistget(grp->nc4_info->alltypes, (size_t)typeid1))) return NC_EBADTYPE; /* Find the field. */ - if (!(field = nclistget(type->u.c.field,fieldid))) + if (!(field = nclistget(type->u.c.field, (size_t)fieldid))) return NC_EBADFIELD; if (name) @@ -360,7 +361,7 @@ NC4_inq_compound_fieldindex(int ncid, nc_type typeid1, const char *name, int *fi NC_FIELD_INFO_T *field; char norm_name[NC_MAX_NAME + 1]; int retval; - int i; + size_t i; LOG((2, "nc_inq_compound_fieldindex: ncid 0x%x typeid %d name %s", ncid, typeid1, name)); @@ -422,7 +423,7 @@ NC4_inq_enum_ident(int ncid, nc_type xtype, long long value, char *identifier) NC_TYPE_INFO_T *type; NC_ENUM_MEMBER_INFO_T *enum_member; long long ll_val; - int i; + size_t i; int retval; int found; @@ -433,7 +434,7 @@ NC4_inq_enum_ident(int ncid, nc_type xtype, long long value, char *identifier) return retval; /* Find this type. */ - if (!(type = nclistget(grp->nc4_info->alltypes, xtype))) + if (!(type = nclistget(grp->nc4_info->alltypes, (size_t)xtype))) return NC_EBADTYPE; /* Complain if they are confused about the type. */ @@ -525,7 +526,7 @@ NC4_inq_enum_member(int ncid, nc_type typeid1, int idx, char *identifier, return retval; /* Find this type. */ - if (!(type = nclistget(grp->nc4_info->alltypes, typeid1))) + if (!(type = nclistget(grp->nc4_info->alltypes, (size_t)typeid1))) return NC_EBADTYPE; /* Complain if they are confused about the type. */ @@ -533,7 +534,7 @@ NC4_inq_enum_member(int ncid, nc_type typeid1, int idx, char *identifier, return NC_EBADTYPE; /* Move to the desired enum member in the list. */ - if (!(enum_member = nclistget(type->u.e.enum_member, idx))) + if (!(enum_member = nclistget(type->u.e.enum_member, (size_t)idx))) return NC_EINVAL; /* Give the people what they want. */ diff --git a/libsrc4/ncindex.c b/libsrc4/ncindex.c index 8f1aa5cfd8..250aa6c5ab 100644 --- a/libsrc4/ncindex.c +++ b/libsrc4/ncindex.c @@ -14,6 +14,7 @@ */ /* Define this for debug so that table sizes are small */ +#include #undef SMALLTABLE #undef NCNOHASH @@ -369,7 +370,7 @@ sortname(NC_SORT sort) void printindexlist(NClist* lm) { - int i; + size_t i; if(lm == NULL) { fprintf(stderr,"\n"); return; @@ -377,10 +378,10 @@ printindexlist(NClist* lm) for(i=0;i\n",(unsigned long)i); + fprintf(stderr,"[%zu] \n",i); else - fprintf(stderr,"[%ld] sort=%s name=|%s| id=%lu\n", - (unsigned long)i,sortname(o->sort),o->name,(unsigned long)o->id); + fprintf(stderr,"[%zu] sort=%s name=|%s| id=%lu\n", + i,sortname(o->sort),o->name,(unsigned long)o->id); } } diff --git a/ncdump/nc4printer.c b/ncdump/nc4printer.c index 10de3e7856..1569788e76 100644 --- a/ncdump/nc4printer.c +++ b/ncdump/nc4printer.c @@ -10,6 +10,7 @@ */ #include "config.h" +#include #include #include #include @@ -146,7 +147,7 @@ NC4print(NCbytes* buf, int ncid) static void freeNC4Printer(NC4printer* out) { - int i; + size_t i; if(out == NULL) return; @@ -612,17 +613,17 @@ getNumericValue(union NUMVALUE numvalue, nc_type base) static NCID* findType(NC4printer* out, nc_type t) { - int len = nclistlength(out->types); + size_t len = nclistlength(out->types); if(t >= len) abort(); - return (NCID*)nclistget(out->types,t); + return (NCID*)nclistget(out->types, (size_t)t); } static NCID* findDim(NC4printer* out, int dimid) { if(nclistlength(out->dims) <= dimid) abort(); - return (NCID*)nclistget(out->dims,dimid); + return (NCID*)nclistget(out->dims, (size_t)dimid); } static void diff --git a/nczarr_test/ut_map.c b/nczarr_test/ut_map.c index 005cd59c39..6bee606aff 100644 --- a/nczarr_test/ut_map.c +++ b/nczarr_test/ut_map.c @@ -322,7 +322,8 @@ readdata(void) static int searchR(NCZMAP* map, int depth, const char* prefix0, NClist* objects) { - int i,stat = NC_NOERR; + size_t i; + int stat = NC_NOERR; NClist* matches = nclistnew(); char prefix[4096]; /* only ok because we know testdata */ size_t prefixlen; @@ -360,7 +361,8 @@ searchR(NCZMAP* map, int depth, const char* prefix0, NClist* objects) static int search(void) { - int i,stat = NC_NOERR; + size_t i; + int stat = NC_NOERR; NCZMAP* map = NULL; NClist* objects = nclistnew(); @@ -375,7 +377,7 @@ search(void) /* Print out the list */ for(i=0;i #undef DEBUG @@ -342,7 +343,8 @@ simpledata(void) static int searchR(NCZMAP* map, int depth, const char* prefix0, NClist* objects) { - int i,stat = NC_NOERR; + size_t i; + int stat = NC_NOERR; NClist* matches = nclistnew(); char prefix[4096]; /* only ok because we know testdata */ size_t prefixlen; @@ -382,7 +384,8 @@ searchR(NCZMAP* map, int depth, const char* prefix0, NClist* objects) static int search(void) { - int i,stat = NC_NOERR; + size_t i; + int stat = NC_NOERR; NCZMAP* map = NULL; NClist* objects = nclistnew(); @@ -398,7 +401,7 @@ search(void) /* Print out the list */ for(i=0;i #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -249,7 +250,7 @@ implfor(const char* path) NCURI* uri = NULL; const char* mode = NULL; NClist* segments = nclistnew(); - int i; + size_t i; NCZM_IMPL impl = NCZM_UNDEF; ncuriparse(path,&uri); @@ -318,7 +319,7 @@ objdump(void) NClist* stack = nclistnew(); char* obj = NULL; char* content = NULL; - int depth; + size_t depth; if((stat=nczmap_open(dumpoptions.impl, dumpoptions.infile, NC_NOCLOBBER, 0, NULL, &map))) goto done; @@ -327,10 +328,10 @@ objdump(void) if((stat = breadthfirst(map,"/",stack))) goto done; if(dumpoptions.debug) { - int i; + size_t i; fprintf(stderr,"stack:\n"); for(i=0;itypesize); } - printf("[%d] %s : (%llu)",depth,obj,len); + printf("[%zu] %s : (%llu)",depth,obj,len); if(kind == OK_CHUNK && dumpoptions.nctype->nctype != NC_STRING) printf(" (%s)",dumpoptions.nctype->typename); printf(" |"); @@ -378,10 +379,10 @@ objdump(void) } printf("|\n"); } else { - printf("[%d] %s : (%llu) ||\n",depth,obj,len); + printf("[%zu] %s : (%llu) ||\n",depth,obj,len); } } else { - printf("[%d] %s\n",depth,obj); + printf("[%zu] %s\n",depth,obj); } } done: diff --git a/oc2/dapparse.c b/oc2/dapparse.c index 8d039ad557..446045a812 100644 --- a/oc2/dapparse.c +++ b/oc2/dapparse.c @@ -5,6 +5,7 @@ #include "config.h" #include "dapparselex.h" #include "dapy.h" +#include /* Forward */ @@ -403,7 +404,7 @@ static NClist* scopeduplicates(NClist* list) { unsigned int i,j; - unsigned int len = nclistlength(list); + size_t len = nclistlength(list); NClist* dups = NULL; for(i=0;i static OCerror mergedas1(OCnode* dds, OCnode* das); static OCerror mergedods1(OCnode* dds, OCnode* das); @@ -417,7 +418,7 @@ static OCerror mergeother(OCnode* ddsroot, NClist* dasnodes) { OCerror stat = OC_NOERR; - int i; + size_t i; for(i=0;ifullname,das->etype,das->att.values); nclistpush(root->attributes,(void*)att); } else if(das->octype == OC_Attributeset) { - int i; + size_t i; /* Recurse */ for(i=0;isubnodes);i++) { OCnode* sub = (OCnode*)nclistget(das->subnodes,i); From b05b9be9a196ca3be267cd565e36ac249862b24a Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Mon, 27 Nov 2023 14:59:48 +0000 Subject: [PATCH 3/4] Try to more consistently use `size_t` for argument of `nclistlength` --- libdap2/cache.c | 4 +++- libdap2/cdf.c | 2 +- libdap2/constraints.c | 2 +- libdap2/daputil.c | 3 ++- libdap4/d4meta.c | 17 +++++++---------- oc2/dapparse.c | 4 ++-- oc2/ocnode.c | 8 ++++---- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/libdap2/cache.c b/libdap2/cache.c index aa0ddd97d2..d481704e45 100644 --- a/libdap2/cache.c +++ b/libdap2/cache.c @@ -25,7 +25,9 @@ static int iscacheableconstraint(DCEconstraint* con); int iscached(NCDAPCOMMON* nccomm, CDFnode* target, NCcachenode** cachenodep) { - int i,j,found,index; + int i, found; + size_t j; + size_t index; NCcache* cache; NCcachenode* cachenode; diff --git a/libdap2/cdf.c b/libdap2/cdf.c index 8db0bc845b..f1bb335213 100644 --- a/libdap2/cdf.c +++ b/libdap2/cdf.c @@ -71,7 +71,7 @@ computecdfnodesets(NCDAPCOMMON* nccomm, CDFtree* tree) NCerror computevarnodes(NCDAPCOMMON* nccomm, NClist* allnodes, NClist* varnodes) { - unsigned int i,len; + size_t i, len; NClist* allvarnodes = nclistnew(); for(i=0;incfullname,dumpsegments(segments)); break; default: { CDFnode* minnode = NULL; - int minpath = 0; + size_t minpath = 0; int nmin = 0; /* to catch multiple ones with same short path */ /* ok, see if one of the matches has a path that is shorter then all the others */ diff --git a/libdap2/daputil.c b/libdap2/daputil.c index 74c1791766..d679408334 100644 --- a/libdap2/daputil.c +++ b/libdap2/daputil.c @@ -255,7 +255,8 @@ nclistconcat(NClist* l1, NClist* l2) int nclistminus(NClist* l1, NClist* l2) { - unsigned int i,len,found; + size_t i, len; + int found; len = nclistlength(l2); found = 0; for(i=0;ivars);i++) { - int rank; int dimsizes[NC_MAX_VAR_DIMS]; NCD4node* field = (NCD4node*)nclistget(cmpdtype->vars,i); - rank = nclistlength(field->dims); + size_t rank = nclistlength(field->dims); if(rank == 0) { /* scalar */ NCCHECK((nc_insert_compound(group->meta.id, cmpdtype->meta.id, field->name, field->meta.offset, field->basetype->meta.id))); - } else if(rank > 0) { /* array */ + } else { /* array */ int idimsizes[NC_MAX_VAR_DIMS]; int j; getDimsizes(field,dimsizes); @@ -513,7 +512,7 @@ buildCompound(NCD4meta* builder, NCD4node* cmpdtype, NCD4node* group, char* name NCCHECK((nc_insert_array_compound(group->meta.id, cmpdtype->meta.id, field->name, field->meta.offset, field->basetype->meta.id, - rank, idimsizes))); + (int)rank, idimsizes))); } } @@ -551,14 +550,13 @@ buildStructure(NCD4meta* builder, NCD4node* structvar) { int ret = NC_NOERR; NCD4node* group; - int rank; int dimids[NC_MAX_VAR_DIMS]; /* Step 1: define the variable */ - rank = nclistlength(structvar->dims); + size_t rank = nclistlength(structvar->dims); getDimrefs(structvar,dimids); group = NCD4_groupFor(structvar); - NCCHECK((nc_def_var(group->meta.id,structvar->name,structvar->basetype->meta.id,rank,dimids,&structvar->meta.id))); + NCCHECK((nc_def_var(group->meta.id,structvar->name,structvar->basetype->meta.id,(int)rank,dimids,&structvar->meta.id))); /* Tag the var */ savevarbyid(group,structvar); @@ -575,13 +573,12 @@ buildSequence(NCD4meta* builder, NCD4node* seq) int ret = NC_NOERR; NCD4node* group; - int rank; int dimids[NC_MAX_VAR_DIMS]; - rank = nclistlength(seq->dims); + size_t rank = nclistlength(seq->dims); getDimrefs(seq,dimids); group = NCD4_groupFor(seq); - NCCHECK((nc_def_var(group->meta.id,seq->name,seq->basetype->meta.id,rank,dimids,&seq->meta.id))); + NCCHECK((nc_def_var(group->meta.id,seq->name,seq->basetype->meta.id,(int)rank,dimids,&seq->meta.id))); savevarbyid(group,seq); /* Build attributes and map attributes WRT the variable */ diff --git a/oc2/dapparse.c b/oc2/dapparse.c index 446045a812..3612b6616a 100644 --- a/oc2/dapparse.c +++ b/oc2/dapparse.c @@ -236,8 +236,8 @@ isnumber(const char* text) static void dimension(OCnode* node, NClist* dimensions) { - unsigned int i; - unsigned int rank = nclistlength(dimensions); + size_t i; + size_t rank = nclistlength(dimensions); node->array.dimensions = (NClist*)dimensions; node->array.rank = rank; for(i=0;icontainer == NULL || node->name == NULL) continue; slen += strlen(node->name); } slen += ((len-1)*strlen(separator)); slen += 1; /* for null terminator*/ - pathname = (char*)ocmalloc((size_t)slen); + pathname = (char*)ocmalloc(slen); MEMCHECK(pathname,NULL); pathname[0] = '\0'; for(i=0;icontainer == NULL || node->name == NULL) continue; if(strlen(pathname) > 0) strcat(pathname,separator); strcat(pathname,node->name); From 4e1ff160e10bd3336b8ae54ebad98be2615564b2 Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Tue, 28 Nov 2023 16:27:40 +0000 Subject: [PATCH 4/4] Change signature of `nczm_sortenvv` to take `size_t` Always called with a `size_t` and passes `n` to `qsort` which expects a `size_t` anyway --- libnczarr/zmap.c | 2 +- libnczarr/zmap.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/libnczarr/zmap.c b/libnczarr/zmap.c index 611b2fbb49..337a47f3e7 100644 --- a/libnczarr/zmap.c +++ b/libnczarr/zmap.c @@ -518,7 +518,7 @@ nczm_compare(const void* arg1, const void* arg2) /* quick sort a list of strings */ void -nczm_sortenvv(int n, char** envv) +nczm_sortenvv(size_t n, char** envv) { if(n <= 1) return; qsort(envv, n, sizeof(char*), nczm_compare); diff --git a/libnczarr/zmap.h b/libnczarr/zmap.h index 451959bcbf..c8e022c31f 100644 --- a/libnczarr/zmap.h +++ b/libnczarr/zmap.h @@ -136,6 +136,7 @@ of the implementation. #define ZMAP_H #include "ncexternl.h" +#include #define NCZM_SEP "/" @@ -369,7 +370,7 @@ EXTERNL int nczm_lastsegment(const char* path, char** lastp); /* bubble sorts (note arguments) */ EXTERNL void nczm_sortlist(struct NClist* l); -EXTERNL void nczm_sortenvv(int n, char** envv); +EXTERNL void nczm_sortenvv(size_t n, char** envv); EXTERNL void NCZ_freeenvv(int n, char** envv); #ifdef __cplusplus