Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Rebase #2812 #2844

Merged
merged 5 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/nclist.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#define NCLIST_H 1

#include "ncexternl.h"
#include <stddef.h>

/* Define the type of the elements in the list*/

Expand Down
16 changes: 10 additions & 6 deletions libdap2/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "dapincludes.h"
#include "dapdump.h"
#include <stddef.h>

/*
Grads servers always require a constraint,
Expand All @@ -24,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;

Expand Down Expand Up @@ -92,7 +95,7 @@ else
NCerror
prefetchdata(NCDAPCOMMON* nccomm)
{
int i;
size_t i;
NCFLAGS flags;
NCerror ncstat = NC_NOERR;
NClist* allvars = nccomm->cdf.ddsroot->tree->varnodes;
Expand Down Expand Up @@ -341,7 +344,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;i<nclistlength(cache->nodes);i++) {
Expand All @@ -367,7 +370,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;i<nclistlength(proj->var->segments);i++) {
Expand All @@ -380,7 +384,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 */
Expand All @@ -400,7 +404,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 */
Expand Down
29 changes: 15 additions & 14 deletions libdap2/cdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "dapincludes.h"
#include "daputil.h"
#include "dapdump.h"
#include <stddef.h>

#ifdef DAPDEBUG
extern char* ocfqn(OCddsnode);
Expand Down Expand Up @@ -70,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;i<nclistlength(allnodes);i++) {
CDFnode* node = (CDFnode*)nclistget(allnodes,i);
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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;i<nclistlength(repairlist);i+=2) {
CDFnode* node = (CDFnode*)nclistget(repairlist,i);
Expand Down Expand Up @@ -541,7 +542,7 @@ structwrap(NCDAPCOMMON* ncc, CDFnode* node, CDFnode* parent, int parentindex,
static int
findin(CDFnode* parent, CDFnode* child)
{
int i;
size_t i;
NClist* subnodes = parent->subnodes;
for(i=0;i<nclistlength(subnodes);i++) {
if(nclistget(subnodes,i) == child)
Expand Down Expand Up @@ -674,13 +675,13 @@ dimimprint(NCDAPCOMMON* nccomm)
{
NCerror ncstat = NC_NOERR;
NClist* allnodes;
int i,j;
size_t i,j;
CDFnode* basenode;

allnodes = nccomm->cdf.ddsroot->tree->nodes;
for(i=0;i<nclistlength(allnodes);i++) {
CDFnode* node = (CDFnode*)nclistget(allnodes,i);
int noderank, baserank;
size_t noderank, baserank;
/* Do dimension imprinting */
basenode = node->basenode;
if(basenode == NULL) continue;
Expand All @@ -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,"."),
Expand Down Expand Up @@ -725,7 +726,7 @@ static NClist*
clonedimset(NCDAPCOMMON* nccomm, NClist* dimset, CDFnode* var)
{
NClist* result = NULL;
int i;
size_t i;

for(i=0;i<nclistlength(dimset);i++) {
CDFnode *dim = NULL;
Expand Down Expand Up @@ -768,7 +769,7 @@ definedimsetplus(NCDAPCOMMON* nccomm/*notused*/, CDFnode* node)
static NCerror
definedimsetall(NCDAPCOMMON* nccomm/*notused*/, CDFnode* node)
{
int i;
size_t i;
int ncstat = NC_NOERR;
NClist* dimsetall = NULL;

Expand All @@ -795,7 +796,7 @@ fprintf(stderr,"dimsetall: |%s|=%d\n",node->ocname,(int)nclistlength(dimsetall))
static NCerror
definetransdimset(NCDAPCOMMON* nccomm/*notused*/, CDFnode* node)
{
int i;
size_t i;
int ncstat = NC_NOERR;
NClist* dimsettrans = NULL;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<nclistlength(cdfnodes);i++) {
CDFnode* node = (CDFnode*)nclistget(cdfnodes,i);
NCerror err = fix1node(nccomm,node);
Expand Down
44 changes: 24 additions & 20 deletions libdap2/constraints.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "dceparselex.h"
#include "dceconstraints.h"
#include "dapdump.h"
#include <stddef.h>

static void completesegments(NClist* fullpath, NClist* segments);
static NCerror qualifyprojectionnames(DCEprojection* proj);
Expand Down Expand Up @@ -295,7 +296,7 @@ matchnode->ncfullname,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 */
Expand Down Expand Up @@ -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;
Expand All @@ -356,7 +358,7 @@ matchsuffix(NClist* matchpath, NClist* segments)
matching as we go
*/
for(i=0;i<nsegs;i++) {
CDFnode* node = (CDFnode*)nclistget(matchpath,pathstart+i);
CDFnode* node = (CDFnode*)nclistget(matchpath, (size_t)pathstart+i);
DCEsegment* seg = (DCEsegment*)nclistget(segments,i);
int rank = seg->rank;
segmatch = 1; /* until proven otherwise */
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand All @@ -483,7 +486,8 @@ dapiswholesegment(DCEsegment* seg)
int
dapiswholeprojection(DCEprojection* proj)
{
int i,whole;
size_t i;
int whole;

ASSERT((proj->discrim == CES_VAR));

Expand All @@ -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;i<nclistlength(con->projections);i++) {
Expand Down Expand Up @@ -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 */

Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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;
Expand All @@ -707,7 +711,7 @@ dapvar2projection(CDFnode* var, DCEprojection** projectionp)
for(i=0;i<nclistlength(path);i++) {
DCEsegment* segment = (DCEsegment*)dcecreate(CES_SEGMENT);
CDFnode* n = (CDFnode*)nclistget(path,i);
int localrank;
size_t localrank;
NClist* dimset;

segment->annotation = (void*)n;
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -817,7 +821,7 @@ int
dapshiftprojection(DCEprojection* projection)
{
int ncstat = NC_NOERR;
int i,j;
size_t i,j;
NClist* segments;

#ifdef DEBUG1
Expand Down Expand Up @@ -849,7 +853,7 @@ dapcomputeprojectedvars(NCDAPCOMMON* dapcomm, DCEconstraint* constraint)
{
NCerror ncstat = NC_NOERR;
NClist* vars = NULL;
int i;
size_t i;

vars = nclistnew();

Expand Down
3 changes: 2 additions & 1 deletion libdap2/dapattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*********************************************************************/

#include "dapincludes.h"
#include <stddef.h>

#define OCCHECK(exp) if((ocstat = (exp))) {THROWCHK(ocstat); goto done;}

Expand All @@ -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;
Expand Down
Loading
Loading