diff --git a/include/ncdap.h b/include/ncdap.h index 735d81810..27dd3450d 100644 --- a/include/ncdap.h +++ b/include/ncdap.h @@ -17,9 +17,9 @@ affect the operation of the system. */ typedef unsigned int NCFLAGS; -# define SETFLAG(controls,flag) (((controls).flags) |= (flag)) -# define CLRFLAG(controls,flag) (((controls).flags) &= ~(flag)) -# define FLAGSET(controls,flag) (((controls.flags) & (flag)) != 0) +#define SETFLAG(controls,flag) (((controls).flags) |= (NCFLAGS)(flag)) +#define CLRFLAG(controls,flag) (((controls).flags) &= ~(NCFLAGS)(flag)) +#define FLAGSET(controls,flag) ((((controls).flags) & (NCFLAGS)(flag)) != 0) /* Defined flags */ #define NCF_NC3 (0x0001) /* DAP->netcdf-3 */ diff --git a/libdap4/d4curlfunctions.c b/libdap4/d4curlfunctions.c index b1f949b9f..1519040c8 100644 --- a/libdap4/d4curlfunctions.c +++ b/libdap4/d4curlfunctions.c @@ -363,8 +363,8 @@ NCD4_get_rcproperties(NCD4INFO* state) unsigned long interval=0; if(sscanf(option,"%lu/%lu",&idle,&interval) != 2) fprintf(stderr,"Illegal KEEPALIVE VALUE: %s\n",option); - state->curl->keepalive.idle = idle; - state->curl->keepalive.interval = interval; + state->curl->keepalive.idle = (long)idle; + state->curl->keepalive.interval = (long)interval; state->curl->keepalive.active = 1; } } diff --git a/libdap4/d4data.c b/libdap4/d4data.c index d1e28b409..309ffa6a7 100644 --- a/libdap4/d4data.c +++ b/libdap4/d4data.c @@ -36,7 +36,7 @@ static unsigned NCD4_computeChecksum(NCD4meta* meta, NCD4node* topvar); /* Macro define procedures */ #ifdef D4DUMPCSUM -static unsigned int debugcrc32(unsigned int crc, const void *buf, size_t size) +static unsigned int debugcrc32(unsigned int crc, const void *buf, unsigned int size) { int i; fprintf(stderr,"crc32: "); @@ -309,7 +309,7 @@ fillopfixed(NCD4meta* meta, d4size_t opaquesize, NCD4offset* offset, void** dstp SKIPCOUNTER(offset); /* verify that it is the correct size */ actual = count; - delta = actual - opaquesize; + delta = (int)actual - (int)opaquesize; if(delta != 0) { #ifdef FIXEDOPAQUE nclog(NCLOGWARN,"opaque changed from %lu to %lu",actual,opaquesize); @@ -443,7 +443,7 @@ NCD4_computeChecksum(NCD4meta* meta, NCD4node* topvar) ASSERT((ISTOPLEVEL(topvar))); #ifndef HYRAXCHECKSUM - csum = CRC32(csum,topvar->data.dap4data.memory,topvar->data.dap4data.size); + csum = CRC32(csum,topvar->data.dap4data.memory, (unsigned int)topvar->data.dap4data.size); #else if(topvar->basetype->subsort != NC_STRING) { csum = CRC32(csum,topvar->data.dap4data.memory,topvar->data.dap4data.size); diff --git a/libdap4/d4file.c b/libdap4/d4file.c index e8ae665b1..03970ecad 100644 --- a/libdap4/d4file.c +++ b/libdap4/d4file.c @@ -161,7 +161,7 @@ NCD4_open(const char * path, int mode, {ret = NC_ENOMEM; goto done;} dmrresp->controller = d4info; - if((ret=NCD4_readDMR(d4info, d4info->controls.flags.flags, d4info->dmruri, dmrresp))) goto done; + if((ret=NCD4_readDMR(d4info, d4info->dmruri, dmrresp))) goto done; /* set serial.rawdata */ len = ncbyteslength(d4info->curl->packet); diff --git a/libdap4/d4fix.c b/libdap4/d4fix.c index af47ea88e..9cf1ba1cf 100644 --- a/libdap4/d4fix.c +++ b/libdap4/d4fix.c @@ -231,7 +231,6 @@ static int delimitAtomicVar(NCD4meta* compiler, NCD4node* var, NCD4offset* offset) { int ret = NC_NOERR; - int typesize; d4size_t i; d4size_t dimproduct; nc_type tid; @@ -249,7 +248,7 @@ delimitAtomicVar(NCD4meta* compiler, NCD4node* var, NCD4offset* offset) truetype = basetype->basetype; tid = truetype->subsort; - typesize = NCD4_typesize(tid); + size_t typesize = NCD4_typesize(tid); if(tid != NC_STRING) { INCR(offset,(typesize*dimproduct)); } else if(tid == NC_STRING) { /* walk the counts */ @@ -448,13 +447,13 @@ skipAtomicInstance(NCD4meta* compiler, NCD4node* type, NCD4offset* offset) { int ret = NC_NOERR; d4size_t count; - int typesize; + size_t typesize; switch (type->subsort) { default: /* fixed size atomic type */ typesize = NCD4_typesize(type->meta.id); - INCR(offset,typesize); - break; + INCR(offset,typesize); + break; case NC_STRING: /* Get string count */ count = GETCOUNTER(offset); diff --git a/libdap4/d4http.c b/libdap4/d4http.c index 13cb82a19..eb144c93b 100644 --- a/libdap4/d4http.c +++ b/libdap4/d4http.c @@ -70,7 +70,7 @@ NCD4_fetchurl(CURL* curl, const char* url, NCbytes* buf, long* filetime, int* ht if(cstat != CURLE_OK) goto done; httpcode = NCD4_fetchhttpcode(curl); - if(httpcodep) *httpcodep = httpcode; + if(httpcodep) *httpcodep = (int)httpcode; /* Get the last modified time */ if(filetime != NULL) diff --git a/libdap4/d4meta.c b/libdap4/d4meta.c index 57d030f77..6b84b8877 100644 --- a/libdap4/d4meta.c +++ b/libdap4/d4meta.c @@ -39,7 +39,7 @@ static int convertString(union ATOMICS* converter, NCD4node* type, const char* s static void* copyAtomic(union ATOMICS* converter, nc_type type, size_t len, void* dst, NClist* blobs); static int decodeEconst(NCD4meta* builder, NCD4node* enumtype, const char* nameorval, union ATOMICS* converter); static int downConvert(union ATOMICS* converter, NCD4node* type); -static void freeStringMemory(char** mem, int count); +static void freeStringMemory(char** mem, size_t count); static size_t getDimrefs(NCD4node* var, int* dimids); static size_t getDimsizes(NCD4node* var, int* dimsizes); static d4size_t getpadding(d4size_t offset, size_t alignment); @@ -255,7 +255,7 @@ buildDimension(NCD4meta* builder, NCD4node* dim) if(dim->dim.isunlimited) { NCCHECK((nc_def_dim(group->meta.id,dim->name,NC_UNLIMITED,&dim->meta.id))); } else { - NCCHECK((nc_def_dim(group->meta.id,dim->name,(size_t)dim->dim.size,&dim->meta.id))); + NCCHECK((nc_def_dim(group->meta.id,dim->name,dim->dim.size,&dim->meta.id))); } done: return THROW(ret); @@ -535,7 +535,7 @@ buildAtomicVar(NCD4meta* builder, NCD4node* var) #endif rank = getDimrefs(var,dimids); - NCCHECK((nc_def_var(group->meta.id,var->name,var->basetype->meta.id,rank,dimids,&var->meta.id))); + NCCHECK((nc_def_var(group->meta.id,var->name,var->basetype->meta.id,(int)rank,dimids,&var->meta.id))); /* Tag the var */ savevarbyid(group,var); @@ -705,11 +705,10 @@ getDimsizes(NCD4node* var, int* dimsizes) /* Utilities */ static void -freeStringMemory(char** mem, int count) +freeStringMemory(char** mem, size_t count) { - int i; if(mem == NULL) return; - for(i=0;irank <= NC_MAX_VAR_DIMS); for(i=0;irank;i++) { size_t istart,icount,istop,ideclsize; - ptrdiff_t istride; + size_t istride; istart = (start != NULL ? start[i] : 0); icount = (count != NULL ? count[i] : (size != NULL ? size[i] : 1)); istride = (size_t)(stride != NULL ? stride[i] : 1); @@ -98,14 +98,13 @@ d4odom_more(D4odometer* odom) d4size_t d4odom_next(D4odometer* odom) { - int i; /* do not make unsigned */ d4size_t count; if(odom->rank == 0) { /*scalar*/ odom->index[0]++; return 0; } count = d4odom_offset(odom); /* convenience */ - for(i=odom->rank-1;i>=0;i--) { + for(size_t i=odom->rank; i-- >0;) { odom->index[i] += odom->stride[i]; if(odom->index[i] < odom->stop[i]) break; if(i == 0) break; /* leave the 0th entry if it overflows*/ diff --git a/libdap4/d4odom.h b/libdap4/d4odom.h index ae37997e1..f0261b0df 100644 --- a/libdap4/d4odom.h +++ b/libdap4/d4odom.h @@ -7,7 +7,7 @@ #define D4ODOM_H 1 typedef struct D4odometer { - int rank; + size_t rank; size_t index[NC_MAX_VAR_DIMS]; size_t start[NC_MAX_VAR_DIMS]; #if 0 diff --git a/libdap4/d4parser.c b/libdap4/d4parser.c index 5deab64f8..a557ce117 100644 --- a/libdap4/d4parser.c +++ b/libdap4/d4parser.c @@ -288,7 +288,7 @@ parseDimensions(NCD4parser* parser, NCD4node* group, ncxml_t xml) if((ret = parseULL(sizestr,&size))) goto done; nullfree(sizestr); if((ret=makeNode(parser,group,x,NCD4_DIM,NC_NULL,&dimnode))) goto done; - dimnode->dim.size = (long long)size; + dimnode->dim.size = size; dimnode->dim.isunlimited = (unlimstr != NULL); nullfree(unlimstr); /* Process attributes */ @@ -881,7 +881,7 @@ getOpaque(NCD4parser* parser, ncxml_t varxml, NCD4node* group) { size_t i; int ret = NC_NOERR; - long long len; + size_t len; NCD4node* opaquetype = NULL; char* xattr; @@ -894,11 +894,11 @@ getOpaque(NCD4parser* parser, ncxml_t varxml, NCD4node* group) /* See if this var has UCARTAGOPAQUE attribute */ xattr = ncxml_attr(varxml,UCARTAGOPAQUE); if(xattr != NULL) { - long long tmp = 0; + long long tmp = 0; if((ret = parseLL(xattr,&tmp)) || (tmp < 0)) - FAIL(NC_EINVAL,"Illegal opaque len: %s",xattr); - len = tmp; - nullfree(xattr); + FAIL(NC_EINVAL,"Illegal opaque len: %s",xattr); + len = (size_t)tmp; + nullfree(xattr); } } #ifndef FIXEDOPAQUE @@ -920,7 +920,7 @@ getOpaque(NCD4parser* parser, ncxml_t varxml, NCD4node* group) if(opaquetype == NULL) {/* create it */ char name[NC_MAX_NAME+1]; /* Make name be "opaqueN" */ - snprintf(name,NC_MAX_NAME,"opaque%lld_t",len); + snprintf(name,NC_MAX_NAME,"opaque%zu_t",len); /* Opaque types are always created in the current group */ if((ret=makeNode(parser,group,NULL,NCD4_TYPE,NC_OPAQUE,&opaquetype))) goto done; @@ -1098,14 +1098,13 @@ lookupFQNList(NCD4parser* parser, NClist* fqn, NCD4sort sort, NCD4node** result) { int ret = NC_NOERR; size_t i; - int nsteps; NCD4node* current; char* name = NULL; NCD4node* node = NULL; /* Step 1: walk thru groups until can go no further */ current = parser->metadata->root; - nsteps = nclistlength(fqn); + size_t nsteps = nclistlength(fqn); for(i=1;isort)); name = (char*)nclistget(fqn,i); @@ -1282,17 +1281,17 @@ done: static NCD4node* lookupAtomicType(NClist* atomictypes, const char* name) { - int n = nclistlength(atomictypes); - int L = 0; - int R = (n - 1); - int m, cmp; + size_t n = nclistlength(atomictypes); + if (n == 0) return NULL; + size_t L = 0; + size_t R = n - 1; NCD4node* p; for(;;) { if(L > R) break; - m = (L + R) / 2; + size_t m = (L + R) / 2; p = (NCD4node*)nclistget(atomictypes,m); - cmp = strcasecmp(p->name,name); + int cmp = strcasecmp(p->name,name); if(cmp == 0) return p; if(cmp < 0) @@ -1370,7 +1369,7 @@ makeAnonDim(NCD4parser* parser, const char* sizestr) if(dim == NULL) {/* create it */ if((ret=makeNode(parser,root,NULL,NCD4_DIM,NC_NULL,&dim))) goto done; SETNAME(dim,name+1); /* leave out the '/' separator */ - dim->dim.size = (long long)size; + dim->dim.size = (size_t)size; dim->dim.isanonymous = 1; classify(root,dim); } diff --git a/libdap4/d4read.c b/libdap4/d4read.c index 3a24b08ff..7cc3ba070 100644 --- a/libdap4/d4read.c +++ b/libdap4/d4read.c @@ -37,7 +37,7 @@ deltatime(struct timeval time0,struct timeval time1) #endif int -NCD4_readDMR(NCD4INFO* state, int flags, NCURI* url, NCD4response* resp) +NCD4_readDMR(NCD4INFO* state, NCURI* url, NCD4response* resp) { int stat = NC_NOERR; ncbytesclear(state->curl->packet); @@ -46,7 +46,7 @@ NCD4_readDMR(NCD4INFO* state, int flags, NCURI* url, NCD4response* resp) } int -NCD4_readDAP(NCD4INFO* state, int flags, NCURI* url, NCD4response* resp) +NCD4_readDAP(NCD4INFO* state, NCURI* url, NCD4response* resp) { int stat = NC_NOERR; diff --git a/libdap4/d4swap.c b/libdap4/d4swap.c index 1d76a55b7..27d91f50b 100644 --- a/libdap4/d4swap.c +++ b/libdap4/d4swap.c @@ -7,6 +7,7 @@ #include #include #include "d4includes.h" +#include "d4util.h" /* The primary purpose of this code is to recursively traverse @@ -51,7 +52,7 @@ NCD4_swapdata(NCD4response* resp, NCD4node* var, int doswap) if((ret=walkSeqArray(resp,var,var,offset,doswap))) goto done; break; } - var->data.dap4data.size = DELTA(offset,var->data.dap4data.memory); + var->data.dap4data.size = (d4size_t)DELTA(offset,var->data.dap4data.memory); /* skip checksum, if there is one */ if(resp->inferredchecksumming) INCR(offset,CHECKSUMSIZE); @@ -77,8 +78,8 @@ walkAtomicVar(NCD4response* resp, NCD4node* topvar, NCD4node* var, NCD4offset* o subsort = var->basetype->basetype->subsort; /* Only need to swap multi-byte integers and floats */ if(subsort != NC_STRING) { - int typesize = NCD4_typesize(subsort); - d4size_t totalsize = typesize*dimproduct; + size_t typesize = NCD4_typesize(subsort); + d4size_t totalsize = typesize*dimproduct; if(typesize == 1) { INCR(offset,totalsize); } else { /*(typesize > 1)*/ diff --git a/libdap4/d4util.h b/libdap4/d4util.h index 38cda6a17..a094e68f8 100644 --- a/libdap4/d4util.h +++ b/libdap4/d4util.h @@ -23,7 +23,7 @@ typedef struct D4blob {d4size_t size; void* memory;} D4blob; /* Empty blob constant */ #define NULLBLOB(blob) {blob.size = 0; blob.memory = NULL;} -#define OFFSET2BLOB(blob,offset) do{(blob).size = ((offset)->limit - (offset)->base); (blob).memory = (offset)->base; }while(0) +#define OFFSET2BLOB(blob,offset) do{(blob).size = (d4size_t)((offset)->limit - (offset)->base); (blob).memory = (offset)->base; }while(0) #define BLOB2OFFSET(offset,blob) do{\ (offset)->base = (blob).memory; \ (offset)->limit = ((char*)(blob).memory) + (blob).size; \ diff --git a/libdap4/d4varx.c b/libdap4/d4varx.c index e42bd9855..12172c173 100644 --- a/libdap4/d4varx.c +++ b/libdap4/d4varx.c @@ -69,7 +69,7 @@ NCD4_get_vars(int gid, int varid, /* build size vector */ for(i=0;idims,i); - dimsizes[i] = (size_t)dim->dim.size; + dimsizes[i] = dim->dim.size; } /* Extract and desired subset of data */ @@ -195,7 +195,7 @@ getvarx(int gid, int varid, NCD4INFO** infop, NCD4node** varp, if((ret=NCD4_newResponse(info,&dapresp))) goto done; dapresp->mode = NCD4_DAP; nclistpush(info->responses,dapresp); - if((ret=NCD4_readDAP(info, info->controls.flags.flags, ceuri, dapresp))) goto done; + if((ret=NCD4_readDAP(info, ceuri, dapresp))) goto done; /* Extract DMR and dechunk the data part */ if((ret=NCD4_dechunk(dapresp))) goto done; diff --git a/libdap4/ncd4.h b/libdap4/ncd4.h index 286406d77..d72cef395 100644 --- a/libdap4/ncd4.h +++ b/libdap4/ncd4.h @@ -84,8 +84,8 @@ EXTERNL int NCD4_fetchlastmodified(CURL* curl, char* url, long* filetime); EXTERNL int NCD4_ping(const char* url); /* From d4read.c */ -EXTERNL int NCD4_readDMR(NCD4INFO* state, int flags, NCURI* url, NCD4response*); -EXTERNL int NCD4_readDAP(NCD4INFO* state, int flags, NCURI* ceuri, NCD4response*); +EXTERNL int NCD4_readDMR(NCD4INFO* state, NCURI* url, NCD4response*); +EXTERNL int NCD4_readDAP(NCD4INFO* state, NCURI* ceuri, NCD4response*); EXTERNL int NCD4_seterrormessage(NCD4response*, size_t len, char* msg); /* From d4parser.c */ diff --git a/libdap4/ncd4types.h b/libdap4/ncd4types.h index 7bed38a84..995ed56f6 100644 --- a/libdap4/ncd4types.h +++ b/libdap4/ncd4types.h @@ -13,6 +13,7 @@ are defined here. #undef COMPILEBYDEFAULT +#include "ncdap.h" #include "ncrc.h" #include "ncauth.h" @@ -206,10 +207,10 @@ struct NCD4node { NClist* values; } attr; struct { /* sort == NCD4_OPAQUE */ - long long size; /* 0 => var length */ + size_t size; /* 0 => var length */ } opaque; struct { /* sort == NCD4_DIMENSION */ - long long size; + size_t size; int isunlimited; int isanonymous; } dim;