diff --git a/libdap4/d4includes.h b/libdap4/d4includes.h index 9187bb01a..6979e7876 100644 --- a/libdap4/d4includes.h +++ b/libdap4/d4includes.h @@ -10,6 +10,7 @@ #include #include #include +#include #include #ifdef HAVE_UNISTD_H #include diff --git a/libdap4/d4parser.c b/libdap4/d4parser.c index dc5656824..40cb7141e 100644 --- a/libdap4/d4parser.c +++ b/libdap4/d4parser.c @@ -1133,11 +1133,13 @@ keyword(const char* name) int n = sizeof(keywordmap)/sizeof(KEYWORDINFO); int L = 0; int R = (n - 1); + int m, cmp; + struct KEYWORDINFO* p; for(;;) { if(L > R) break; - int m = (L + R) / 2; - struct KEYWORDINFO* p = &keywordmap[m]; - int cmp = strcasecmp(p->tag,name); + m = (L + R) / 2; + p = &keywordmap[m]; + cmp = strcasecmp(p->tag,name); if(cmp == 0) return p; if(cmp < 0) L = (m + 1); @@ -1196,13 +1198,14 @@ lookupAtomictype(NCD4parser* parser, const char* name) int n = nclistlength(parser->atomictypes); int L = 0; int R = (n - 1); + int m, cmp; NCD4node* p; for(;;) { if(L > R) break; - int m = (L + R) / 2; + m = (L + R) / 2; p = (NCD4node*)nclistget(parser->atomictypes,m); - int cmp = strcasecmp(p->name,name); + cmp = strcasecmp(p->name,name); if(cmp == 0) return p; if(cmp < 0) L = (m + 1); diff --git a/libdap4/d4util.c b/libdap4/d4util.c index 91992ac8d..f95355f27 100644 --- a/libdap4/d4util.c +++ b/libdap4/d4util.c @@ -102,6 +102,7 @@ char* NCD4_makeFQN(NCD4node* node) { char* fqn = NULL; + char* escaped; int i; NCD4node* g = node; NClist* path = nclistnew(); @@ -121,7 +122,7 @@ NCD4_makeFQN(NCD4node* node) NCD4node* elem = (NCD4node*)nclistget(path,i); if(elem->sort != NCD4_GROUP) break; /* Add in the group name */ - char* escaped = backslashEscape(elem->name); + escaped = backslashEscape(elem->name); if(escaped == NULL) {free(fqn); fqn = NULL; goto done;} strcat(fqn,"/"); strcat(fqn,escaped); @@ -342,8 +343,8 @@ NCD4_saveblob(NCD4meta* meta, void* mem) int NCD4_error(int code, const int line, const char* file, const char* fmt, ...) { - fprintf(stderr,"(%s:%d) ",file,line); va_list argv; + fprintf(stderr,"(%s:%d) ",file,line); va_start(argv,fmt); vfprintf(stderr,fmt,argv); fprintf(stderr,"\n"); diff --git a/libdispatch/dauth.c b/libdispatch/dauth.c index 4884278b4..484c87df3 100644 --- a/libdispatch/dauth.c +++ b/libdispatch/dauth.c @@ -66,6 +66,7 @@ NC_combinehostport(NCURI* uri) size_t len; char* host = NULL; char* port = NULL; + char* hp = NULL; if(uri == NULL) return NULL; host = uri->host; port = uri->port; @@ -73,7 +74,7 @@ NC_combinehostport(NCURI* uri) if(port != NULL && strlen(port) == 0) port = NULL; len = strlen(host); if(port != NULL) len += (1+strlen(port)); - char* hp = (char*)malloc(len+1); + hp = (char*)malloc(len+1); if(hp == NULL) return NULL; strncpy(hp,host,len); if(port != NULL) { diff --git a/libdispatch/drc.c b/libdispatch/drc.c index c7e5e8f51..374ffcd70 100644 --- a/libdispatch/drc.c +++ b/libdispatch/drc.c @@ -338,7 +338,8 @@ done: static struct NCTriple* rclocate(const char* key, const char* hostport) { - int i,found; + int i, found, t; + size_t hplen; NClist* rc = ncrc_globalstate.rcinfo.triples; NCTriple* triple = NULL; @@ -350,8 +351,7 @@ rclocate(const char* key, const char* hostport) for(found=0,i=0;ihost); - int t; + hplen = strlen(triple->host); if(strcmp(key,triple->key) != 0) continue; /* keys do not match */ /* If the triple entry has no url, then use it (because we have checked all other cases)*/ diff --git a/libdispatch/utf8proc.c b/libdispatch/utf8proc.c index 1ecbb1db1..c680678cf 100644 --- a/libdispatch/utf8proc.c +++ b/libdispatch/utf8proc.c @@ -289,9 +289,10 @@ static nc_utf8proc_bool nc_grapheme_break_simple(int lbc, int tbc) { static nc_utf8proc_bool nc_grapheme_break_extended(int lbc, int tbc, nc_utf8proc_int32_t *state) { int lbc_override = lbc; + nc_utf8proc_bool break_permitted; if (state && *state != UTF8PROC_BOUNDCLASS_START) lbc_override = *state; - nc_utf8proc_bool break_permitted = nc_grapheme_break_simple(lbc_override, tbc); + break_permitted = nc_grapheme_break_simple(lbc_override, tbc); if (state) { // Special support for GB 12/13 made possible by GB999. After two RI // class codepoints we want to force a break. Do this by resetting the diff --git a/libsrc/nc3internal.c b/libsrc/nc3internal.c index da58f353e..c6e983a14 100644 --- a/libsrc/nc3internal.c +++ b/libsrc/nc3internal.c @@ -1778,11 +1778,12 @@ NC3_inq_var_fill(const NC_var *varp, void *fill_value) */ attrpp = NC_findattr(&varp->attrs, _FillValue); if ( attrpp != NULL ) { + const void *xp; /* User defined fill value */ if ( (*attrpp)->type != varp->type || (*attrpp)->nelems != 1 ) return NC_EBADTYPE; - const void *xp = (*attrpp)->xvalue; + xp = (*attrpp)->xvalue; /* value stored in xvalue is in external representation, may need byte-swap */ switch(varp->type) { case NC_CHAR: return ncx_getn_text (&xp, 1, (char*)fill_value); diff --git a/libsrc/ncx.h b/libsrc/ncx.h index 6b8ddcf21..a9ffcdc63 100644 --- a/libsrc/ncx.h +++ b/libsrc/ncx.h @@ -45,6 +45,17 @@ #define CRAYFLOAT 1 /* CRAY Floating point */ #endif +#ifndef __cplusplus + #if __STDC_VERSION__ == 199901L /* C99 */ + /* "inline" is a keyword */ + #elif _MSC_VER >= 1500 /* MSVC 9 or newer */ + #define inline __inline + #elif __GNUC__ >= 3 /* GCC 3 or newer */ + #define inline __inline + #else /* Unknown or ancient */ + #define inline + #endif +#endif /* * External sizes of the primitive elements. diff --git a/libsrc/ncx.m4 b/libsrc/ncx.m4 index 96ad9210b..9dc0edf2b 100644 --- a/libsrc/ncx.m4 +++ b/libsrc/ncx.m4 @@ -2267,6 +2267,9 @@ APIPrefix`x_get_size_t'(const void **xpp, size_t *ulp) int APIPrefix`x_put_off_t'(void **xpp, const off_t *lp, size_t sizeof_off_t) { + /* similar to put_ix_int() */ + uchar *cp = (uchar *) *xpp; + /* No negative offsets stored in netcdf */ if (*lp < 0) { /* Assume this is an overflow of a 32-bit int... */ @@ -2275,9 +2278,6 @@ APIPrefix`x_put_off_t'(void **xpp, const off_t *lp, size_t sizeof_off_t) assert(sizeof_off_t == 4 || sizeof_off_t == 8); - /* similar to put_ix_int() */ - uchar *cp = (uchar *) *xpp; - if (sizeof_off_t == 4) { *cp++ = (uchar) ((*lp) >> 24); *cp++ = (uchar)(((*lp) & 0x00ff0000) >> 16); diff --git a/nc_test/test_put.m4 b/nc_test/test_put.m4 index d586b9175..0d6705ed0 100644 --- a/nc_test/test_put.m4 +++ b/nc_test/test_put.m4 @@ -1382,6 +1382,7 @@ int TestFunc(att)_text(AttVarArgs) { int i, j, err, ncid, nok=0; + double dtmp; IntType k, ndx[1]; text value[MAX_NELS]; @@ -1426,7 +1427,7 @@ TestFunc(att)_text(AttVarArgs) for (k = 0; k < ATT_LEN(i,j); k++) { ndx[0] = k; - double dtmp = hash(ATT_TYPE(i,j), -1, ndx); + dtmp = hash(ATT_TYPE(i,j), -1, ndx); value[k] = (text)dtmp; } err = PutAtt(text)(ncid, i, ATT_NAME(i,j), ATT_LEN(i,j), value); diff --git a/nc_test/test_write.m4 b/nc_test/test_write.m4 index 034d55888..936d99b7f 100644 --- a/nc_test/test_write.m4 +++ b/nc_test/test_write.m4 @@ -2504,7 +2504,7 @@ TestFunc(set_default_format)(void) int TestFunc(delete)(void) { - int err, nok=0;; + int err, nok=0; int ncid; err = FileCreate(scratch, NC_CLOBBER, &ncid); diff --git a/nc_test4/tst_enums.c b/nc_test4/tst_enums.c index 96a4e3136..34c2021c2 100644 --- a/nc_test4/tst_enums.c +++ b/nc_test4/tst_enums.c @@ -284,6 +284,7 @@ main(int argc, char **argv) SUMMARIZE_ERR; printf("*** testing enum interuptus..."); { + unsigned char ubyte_value = 42; #define GEEKY_NAME "Galadriel" /* Create a file. */ @@ -304,7 +305,6 @@ main(int argc, char **argv) /* Close the file. */ if (nc_close(ncid) != NC_EINVAL) ERR; - unsigned char ubyte_value = 42; if (nc_redef(ncid)) ERR; if (nc_insert_enum(ncid, typeid, "name", &ubyte_value)) ERR; if (nc_close(ncid)) ERR; diff --git a/oc2/ocinternal.c b/oc2/ocinternal.c index 850fa91db..55acde17b 100644 --- a/oc2/ocinternal.c +++ b/oc2/ocinternal.c @@ -54,6 +54,7 @@ OCerror ocinternalinitialize(void) { int stat = OC_NOERR; + CURLcode cstat = CURLE_OK; if(ocinitialized) return OC_NOERR; ocinitialized = 1; @@ -68,7 +69,6 @@ ocinternalinitialize(void) } #endif - CURLcode cstat = CURLE_OK; cstat = curl_global_init(CURL_GLOBAL_ALL); if(cstat != CURLE_OK) fprintf(stderr,"curl_global_init failed!\n"); diff --git a/oc2/ocnode.c b/oc2/ocnode.c index e4f0e8f52..f5ae9e2b9 100644 --- a/oc2/ocnode.c +++ b/oc2/ocnode.c @@ -365,14 +365,15 @@ mergedas1(OCnode* dds, OCnode* das) for(i=0;isubnodes);i++) { OCnode* attnode = (OCnode*)nclistget(das->subnodes,i); if(attnode->octype == OC_Attribute) { + OCattribute* att; if(dds->octype == OC_Atomic || dds->octype == OC_Sequence || dds->octype == OC_Structure || dds->octype == OC_Grid) attnode->att.var = dds; - OCattribute* att = makeattribute(attnode->name, - attnode->etype, - attnode->att.values); + att = makeattribute(attnode->name, + attnode->etype, + attnode->att.values); nclistpush(dds->attributes,(void*)att); } }