diff --git a/ncdump/chunkspec.c b/ncdump/chunkspec.c index 909e3ee07f..d3fca875f1 100644 --- a/ncdump/chunkspec.c +++ b/ncdump/chunkspec.c @@ -196,7 +196,7 @@ dimchunkspec_size(int indimid) { /* Return number of dimensions for which chunking was specified in * chunkspec string on command line, 0 if no chunkspec string was * specified. */ -int +size_t dimchunkspec_ndims(void) { return dimchunkspecs.ndims; } @@ -337,8 +337,7 @@ varchunkspec_parse(int igrp, const char *spec0) int varchunkspec_kind(int grpid, int varid) { - int i; - for(i=0;iigrpid == grpid && spec->ivarid == varid) return spec->kind; @@ -349,8 +348,7 @@ varchunkspec_kind(int grpid, int varid) bool_t varchunkspec_exists(int igrpid, int ivarid) { - int i; - for(i=0;iigrpid == igrpid && spec->ivarid == ivarid) return true; @@ -361,8 +359,7 @@ varchunkspec_exists(int igrpid, int ivarid) bool_t varchunkspec_omit(int igrpid, int ivarid) { - int i; - for(i=0;iigrpid == igrpid && spec->ivarid == ivarid) return spec->omit; @@ -373,8 +370,7 @@ varchunkspec_omit(int igrpid, int ivarid) size_t* varchunkspec_chunksizes(int igrpid, int ivarid) { - int i; - for(i=0;iigrpid == igrpid && spec->ivarid == ivarid) return spec->chunksizes; @@ -385,8 +381,7 @@ varchunkspec_chunksizes(int igrpid, int ivarid) size_t varchunkspec_rank(int igrpid, int ivarid) { - int i; - for(i=0;iigrpid == igrpid && spec->ivarid == ivarid) return spec->rank; diff --git a/ncdump/chunkspec.h b/ncdump/chunkspec.h index 8e2f9f06c8..06ab65a869 100644 --- a/ncdump/chunkspec.h +++ b/ncdump/chunkspec.h @@ -6,6 +6,9 @@ #ifndef _CHUNKSPEC_H_ #define _CHUNKSPEC_H_ +#include +#include "utils.h" + /* Parse chunkspec string and convert into internal data structure, * associating dimids from open file or group specified by ncid with * corresponding chunk sizes */ @@ -25,7 +28,7 @@ dimchunkspec_exists(int indimid); /* Return number of dimensions for which chunking was specified in * chunkspec string on command line, 0 if no chunkspec string was * specified. */ -extern int +extern size_t dimchunkspec_ndims(void); /* Return whether chunking should be omitted, due to explicit diff --git a/ncdump/dumplib.c b/ncdump/dumplib.c index 07090d17d5..0df8763f25 100644 --- a/ncdump/dumplib.c +++ b/ncdump/dumplib.c @@ -861,7 +861,7 @@ int ncstring_typ_tostring(const nctype_t *typ, safebuf_t *sfbf, const void *valp sp = sout; *sp++ = '"' ; while(*cp) { - switch (uc = *cp++ & 0377) { + switch (uc = (unsigned char)*cp++ & 0377) { case '\b': *sp++ = '\\'; *sp++ = 'b' ; @@ -904,7 +904,7 @@ int ncstring_typ_tostring(const nctype_t *typ, safebuf_t *sfbf, const void *valp sp += 4; } else - *sp++ = uc; + *sp++ = (char)uc; break; } } @@ -1045,7 +1045,7 @@ chars_tostring( len--; for (iel = 0; iel < len; iel++) { unsigned char uc; - switch (uc = *vals++ & 0377) { + switch (uc = (unsigned char)(*vals++ & 0377)) { case '\b': case '\f': case '\n': @@ -1062,7 +1062,7 @@ chars_tostring( if (isprint(uc)) *cp++ = *(char *)&uc; /* just copy, even if char is signed */ else { - size_t remaining = sout_size - (cp - sout); + size_t remaining = sout_size - (size_t)(cp - sout); snprintf(cp,remaining,"\\%.3o",uc); cp += 4; } @@ -1806,10 +1806,8 @@ print_type_name(int locid, int typeid) { static int init_is_unlim(int ncid, int **is_unlim_p) { - int num_grps; /* total number of groups */ - int num_dims = 0; /* total number of dimensions in all groups */ + size_t num_grps; /* total number of groups */ int max_dimid = -1; /* maximum dimid across whole dataset */ - int num_undims = 0; /* total number of unlimited dimensions in all groups */ int *grpids = NULL; /* temporary list of all grpids */ int igrp; int grpid; @@ -1824,7 +1822,7 @@ init_is_unlim(int ncid, int **is_unlim_p) return NC_EBADGRPID; /* Now ncid is root group. Get total number of groups and their ids */ NC_CHECK( nc_inq_grps_full(ncid, &num_grps, NULL) ); - grpids = emalloc((size_t)(num_grps + 1) * sizeof(int)); + grpids = emalloc((num_grps + 1) * sizeof(int)); NC_CHECK( nc_inq_grps_full(ncid, &num_grps, grpids) ); #define DONT_INCLUDE_PARENTS 0 /* Get all dimensions in groups and info about which ones are unlimited */ @@ -1836,7 +1834,6 @@ init_is_unlim(int ncid, int **is_unlim_p) int* dimids = NULL; grpid = grpids[igrp]; NC_CHECK( nc_inq_dimids(grpid, &ndims, NULL, DONT_INCLUDE_PARENTS) ); - num_dims += ndims; dimids = (int*)emalloc((size_t)ndims*sizeof(int)); NC_CHECK( nc_inq_dimids(grpid, &ndims, dimids, DONT_INCLUDE_PARENTS) ); for(i=0;i max_dimid) max_dimid = dimids[i];} @@ -1863,7 +1860,6 @@ init_is_unlim(int ncid, int **is_unlim_p) int* isunlim = *is_unlim_p; int did = dimids[idim]; isunlim[did] = 1; - num_undims++; } if(dimids) free(dimids); diff --git a/ncdump/list.c b/ncdump/list.c index f2f7031d3a..7ade711aa0 100644 --- a/ncdump/list.c +++ b/ncdump/list.c @@ -40,8 +40,7 @@ int listfreeall(List* l) { if(l) { - int i; - for(i=0;i\n"); depth++; for(i=0;iid,i,name,&numvalue))) FAIL; - value = getNumericValue(numvalue,node->base->id); + long long value = (long long)getNumericValue(numvalue,node->base->id); INDENT(depth); CAT("\n"); if((ret=readAttributeValues(attr,&values))) FAIL; depth++; - for(i=0;isize;i++) { + for(size_t i=0;isize;i++) { void* value = computeOffset(attr->base,values,i); if((ret=printValue(out,attr->base,value,depth))) FAIL; } @@ -696,7 +694,7 @@ entityEscape(NCbytes* escaped, const char* s) const char* p; ncbytesclear(escaped); for(p=s;*p;p++) { - int c = *p; + char c = *p; switch (c) { case '&': ncbytescat(escaped,"&"); break; case '<': ncbytescat(escaped,"<"); break; @@ -735,7 +733,7 @@ printString(NCbytes* out, const char* s, int quotes) if(quotes) ncbytesappend(out,'"'); if(s == NULL) s = ""; for(p=s;*p;p++) { - int c = *p; + char c = *p; if(c == '\\') ncbytescat(out,"\\\\"); else if(c == '"') ncbytescat(out,"\\\""); else ncbytesappend(out,c); diff --git a/ncdump/nccopy.c b/ncdump/nccopy.c index 190696d72a..a369f3bdfc 100644 --- a/ncdump/nccopy.c +++ b/ncdump/nccopy.c @@ -288,7 +288,6 @@ parsefilterspec(const char* optarg0, List* speclist) char* p = NULL; char* remainder = NULL; List* vlist = NULL; - int i; int isnone = 0; size_t nfilters = 0; NC_H5_Filterspec** filters = NULL; @@ -325,7 +324,7 @@ parsefilterspec(const char* optarg0, List* speclist) } /* Construct a spec entry for each element in vlist */ - for(i=0;ifqn[0] = '\0'; /* for strlcat */ if(strcmp(var,"*") != 0 && var[0] != '/') strlcat(filtopt->fqn,"/",vlen+2); strlcat(filtopt->fqn,var,vlen+2); - if(isnone) + if(isnone) { filtopt->nofilter = 1; - else { + } else { filtopt->pfs = *nsf; if(nsf->nparams != 0) { /* Duplicate the params */ @@ -369,11 +368,10 @@ parsefilterspec(const char* optarg0, List* speclist) static int varfiltersactive(const char* ofqn) { - int i; int hasnone = 0; int hasactive = 0; /* See which output filter options are defined for this output variable */ - for(i=0;ifqn,"*")==0 || strcmp(opt->fqn,ofqn)==0) {if(opt->nofilter) hasnone = 1;} else {hasactive = 1;} @@ -385,10 +383,9 @@ varfiltersactive(const char* ofqn) static int varfilterssuppress(const char* ofqn) { - int i; int hasnone = 0; /* See which output filter options are defined for this output variable */ - for(i=0;ifqn,"*")==0 || strcmp(opt->fqn,ofqn)==0) {if(opt->nofilter) hasnone = 1;} @@ -400,11 +397,10 @@ varfilterssuppress(const char* ofqn) static List* filteroptsforvar(const char* ofqn) { - int i; List* list = listnew(); /* See which output filter options are defined for this output variable; both active and none. */ - for(i=0;ifqn,"*")==0 || strcmp(opt->fqn,ofqn)==0) { if(!opt->nofilter) /* Add to the list */ @@ -461,7 +457,6 @@ inq_var_chunking_params(int igrp, int ivarid, int ogrp, int ovarid, int stat = NC_NOERR; int ndims; size_t *ichunksizes, *ochunksizes; - int dim; int icontig = NC_CONTIGUOUS, ocontig = NC_CONTIGUOUS; nc_type vartype; size_t value_size; @@ -497,7 +492,7 @@ inq_var_chunking_params(int igrp, int ivarid, int ogrp, int ovarid, if(icontig != NC_CHUNKED) { /* if input contiguous|compact, treat as if chunked on * first dimension */ ichunksizes[0] = 1; - for(dim = 1; dim < ndims; dim++) { + for(size_t dim = 1; dim < ndims; dim++) { ichunksizes[dim] = dim; } } else { @@ -510,7 +505,7 @@ inq_var_chunking_params(int igrp, int ivarid, int ogrp, int ovarid, nelems = 1; oprod = value_size; - for(dim = 0; dim < ndims; dim++) { + for(size_t dim = 0; dim < ndims; dim++) { nelems += 1 + (ichunksizes[dim] - 1) / ochunksizes[dim]; iprod *= ichunksizes[dim]; oprod *= ochunksizes[dim]; @@ -681,14 +676,14 @@ static int copy_groups(int iroot, int oroot) { int stat = NC_NOERR; - int numgrps; + size_t numgrps; int *grpids; int i; /* get total number of groups and their ids, including all descendants */ NC_CHECK(nc_inq_grps_full(iroot, &numgrps, NULL)); if(numgrps > 1) { /* there's always 1 root group */ - grpids = emalloc((size_t)numgrps * sizeof(int)); + grpids = emalloc(numgrps * sizeof(int)); NC_CHECK(nc_inq_grps_full(iroot, NULL, grpids)); /* create corresponding new groups in ogrp, except for root group */ for(i = 1; i < numgrps; i++) { @@ -879,8 +874,7 @@ copy_var_filter(int igrp, int varid, int ogrp, int o_varid, int inkind, int outk /* Apply actual filter spec if any */ if(!unfiltered) { /* add all the actual filters */ - int k; - for(k=0;kpfs.filterid, @@ -956,7 +950,7 @@ copy_chunking(int igrp, int i_varid, int ogrp, int o_varid, int ndims, int inkin /* Figure out the chunking even if we do not decide to do so*/ if(varchunkspec_exists(igrp,i_varid) && varchunkspec_kind(igrp,i_varid) == NC_CHUNKED) - memcpy(ochunkp,varchunkspec_chunksizes(igrp,i_varid),ndims*sizeof(size_t)); + memcpy(ochunkp,varchunkspec_chunksizes(igrp,i_varid),(size_t)ndims*sizeof(size_t)); /* If any kind of output filter was specified, then not contiguous */ ovid.grpid = ogrp; @@ -1566,12 +1560,12 @@ copy_schema(int igrp, int ogrp) /* Return number of values for a variable varid in a group igrp */ static int -inq_nvals(int igrp, int varid, long long *nvalsp) { +inq_nvals(int igrp, int varid, size_t *nvalsp) { int stat = NC_NOERR; int ndims; int *dimids; int dim; - long long nvals = 1; + size_t nvals = 1; NC_CHECK(nc_inq_varndims(igrp, varid, &ndims)); dimids = (int *) emalloc((size_t)(ndims + 1) * sizeof(int)); @@ -1594,7 +1588,7 @@ copy_var_data(int igrp, int varid, int ogrp) { int stat = NC_NOERR; nc_type vartype; - long long nvalues; /* number of values for this variable */ + size_t nvalues; /* number of values for this variable */ size_t ntoget; /* number of values to access this iteration */ size_t value_size; /* size of a single value of this variable */ static void *buf = 0; /* buffer for the variable values */ @@ -1898,7 +1892,6 @@ copy_fixed_size_data(int igrp, int ogrp, size_t nfixed_vars, int *fixed_varids) static int copy_rec_var_data(int ncid, /* input */ int ogrp, /* output */ - int irec, /* record number */ int varid, /* input variable id */ int ovarid, /* output variable id */ size_t *start, /* start indices for record data */ @@ -1970,7 +1963,7 @@ copy_record_data(int ncid, int ogrp, size_t nrec_vars, int *rec_varids) { varid = rec_varids[ivar]; ovarid = rec_ovarids[ivar]; start[ivar][0] = irec; - NC_CHECK(copy_rec_var_data(ncid, ogrp, irec, varid, ovarid, + NC_CHECK(copy_rec_var_data(ncid, ogrp, varid, ovarid, start[ivar], count[ivar], buf[ivar])); } } @@ -2044,10 +2037,9 @@ copy(char* infile, char* outfile) #ifdef USE_NETCDF4 if(listlength(option_chunkspecs) > 0) { - int i; /* Now that input is open, can parse option_chunkspecs into binary * structure. */ - for(i=0;i 9) { error("invalid deflation level: %d", option_deflate_level); } @@ -2395,9 +2387,9 @@ main(int argc, char**argv) case 'M': /* set min chunk size */ #ifdef USE_NETCDF4 if(optarg == NULL) - option_min_chunk_bytes = 0; + option_min_chunk_bytes = 0; else - option_min_chunk_bytes = atol(optarg); + option_min_chunk_bytes = (size_t)atol(optarg); break; #else error("-M requires netcdf-4"); @@ -2459,8 +2451,7 @@ main(int argc, char**argv) static void freefilteroptlist(List* specs) { - int i; - for(i=0;ifqn) free(spec->fqn); nullfree(spec->pfs.params); diff --git a/ncdump/ncdump.c b/ncdump/ncdump.c index c86ecb824c..a47884ced1 100644 --- a/ncdump/ncdump.c +++ b/ncdump/ncdump.c @@ -5,6 +5,7 @@ Research/Unidata. See \ref copyright file for more info. */ #include "config.h" #include +#include #include #ifdef HAVE_GETOPT_H #include @@ -429,7 +430,7 @@ pr_att_string( while (len != 0 && *sp-- == '\0') len--; for (iel = 0; iel < len; iel++) - switch (uc = *cp++ & 0377) { + switch (uc = (unsigned char)(*cp++ & 0377)) { case '\b': printf ("\\b"); break; @@ -500,7 +501,7 @@ pr_attx_string( while (len != 0 && *sp-- == '\0') len--; for (iel = 0; iel < len; iel++) - switch (uc = *cp++ & 0377) { + switch (uc = (unsigned char)*cp++ & 0377) { case '\"': printf ("""); break; @@ -908,7 +909,7 @@ pr_att( value = *((int64_t *)data + i); break; case NC_UINT64: - value = *((uint64_t *)data + i); + value = (int64_t)*((uint64_t *)data + i); break; default: error("enum must have an integer base type: %d", base_nc_type); @@ -1395,7 +1396,7 @@ print_enum_type(int ncid, nc_type typeid) { memval = *(int64_t *)raw; break; case NC_UINT64: - memval = *(uint64_t *)raw; + memval = (int64_t)*(uint64_t *)raw; break; default: error("Bad base type for enum!"); @@ -2567,7 +2568,7 @@ searchgrouptreedim(int ncid, int dimid, int* parentidp) int gid; uintptr_t id; - id = ncid; + id = (uintptr_t)ncid; nclistpush(queue,(void*)id); /* prime the queue */ while(nclistlength(queue) > 0) { id = (uintptr_t)nclistremove(queue,0); @@ -2589,7 +2590,7 @@ searchgrouptreedim(int ncid, int dimid, int* parentidp) goto done; /* push onto the end of the queue */ for(i=0;idimsizes; iter->rank = rank; @@ -184,7 +184,6 @@ nc_get_iter(int ncid, size_t value_size = 0; /* size in bytes of each variable element */ int ndims; /* number of dimensions for variable */ int *dimids; - long long nvalues = 1; int dim; int chunked = 0; @@ -203,7 +202,6 @@ nc_get_iter(int ncid, for(dim = 0; dim < ndims; dim++) { size_t len; NC_CHECK(nc_inq_dimlen(ncid, dimids[dim], &len)); - nvalues *= len; iterp->dimsizes[dim] = len; } NC_CHECK(nc_inq_vartype(ncid, varid, &vartype)); diff --git a/ncdump/nctime0.c b/ncdump/nctime0.c index f7b3d24788..e47a14f4d4 100644 --- a/ncdump/nctime0.c +++ b/ncdump/nctime0.c @@ -24,6 +24,7 @@ #include #include #include +#include "nctime.h" #include "utils.h" #include "nccomps.h" #include "dumplib.h" /* for sbuf_... prototypes */ @@ -55,12 +56,11 @@ bounds_add(char *bounds_name, int ncid, int varid) { * calendar type, if present. */ cdCalenType calendar_type(int ncid, int varid) { - int ctype; int stat; ncatt_t catt; static struct { char* attname; - int type; + cdCalenType type; } calmap[] = { {"gregorian", cdMixed}, {"standard", cdMixed}, /* synonym */ @@ -77,7 +77,7 @@ calendar_type(int ncid, int varid) { }; #define CF_CAL_ATT_NAME "calendar" int ncals = (sizeof calmap)/(sizeof calmap[0]); - ctype = cdMixed; /* default mixed Gregorian/Julian ala udunits */ + cdCalenType ctype = cdMixed; /* default mixed Gregorian/Julian ala udunits */ stat = nc_inq_att(ncid, varid, CF_CAL_ATT_NAME, &catt.type, &catt.len); if(stat == NC_NOERR && (catt.type == NC_CHAR || catt.type == NC_STRING) && catt.len > 0) { char *calstr; @@ -88,7 +88,7 @@ calendar_type(int ncid, int varid) { nc_get_att_single_string(ncid, varid, &catt, &calstr); int itype; - int calstr_len = strlen(calstr); + size_t calstr_len = strlen(calstr); for(itype = 0; itype < ncals; itype++) { if(strncasecmp(calstr, calmap[itype].attname, calstr_len) == 0) { ctype = calmap[itype].type; diff --git a/ncdump/ncvalidator.c b/ncdump/ncvalidator.c index 7e86fb64d3..852cbd2824 100644 --- a/ncdump/ncvalidator.c +++ b/ncdump/ncvalidator.c @@ -115,7 +115,7 @@ static const char nada[4] = {0, 0, 0, 0}; /* useful for aligning memory */ #define _RNDUP(x, unit) ((((x) + (unit) - 1) / (unit)) * (unit)) -#define ERR_ADDR (((size_t) gbp->pos - (size_t) gbp->base) + gbp->offset - gbp->size) +#define ERR_ADDR (((size_t) gbp->pos - (size_t) gbp->base) + (size_t) gbp->offset - gbp->size) #define IS_RECVAR(vp) ((vp)->shape != NULL ? (*(vp)->shape == NC_UNLIMITED) : 0 ) @@ -425,7 +425,7 @@ hdr_len_NC_name(size_t nchars, long long sz = sizeof_t; /* nelems */ if (nchars != 0) /* namestring */ - sz += _RNDUP(nchars, X_ALIGN); + sz += _RNDUP((long long)nchars, X_ALIGN); return sz; } @@ -951,7 +951,7 @@ val_fetch(int fd, bufferinfo *gbp) { fprintf(stderr,"Error at line %d: read %s\n",__LINE__,strerror(errno)); return -1; } - gbp->offset += (gbp->size - slack); + gbp->offset += (off_t)(gbp->size - (size_t)slack); return NC_NOERR; } @@ -962,7 +962,7 @@ val_fetch(int fd, bufferinfo *gbp) { static int val_check_buffer(int fd, bufferinfo *gbp, - long long nextread) + size_t nextread) { size_t pos_addr, base_addr; @@ -1014,12 +1014,12 @@ hdr_get_NON_NEG(int fd, bufferinfo *gbp, long long *sp) * NON_NEG = | // CDF-1 and CDF-2 * // CDF-5 */ - int sizeof_NON_NEG, status; + int status; - sizeof_NON_NEG = (gbp->version < 5) ? 4 : 8; + size_t sizeof_NON_NEG = (gbp->version < 5) ? 4 : 8; status = val_check_buffer(fd, gbp, sizeof_NON_NEG); if (status != NC_NOERR) { - if (verbose) printf("%d-byte size is expected for ", sizeof_NON_NEG); + if (verbose) printf("%zu-byte size is expected for ", sizeof_NON_NEG); return status; } if (gbp->version < 5) @@ -1070,13 +1070,13 @@ hdr_get_name(int fd, padding = _RNDUP(nchars, X_ALIGN) - nchars; pos_addr = (size_t) gbp->pos; base_addr = (size_t) gbp->base; - bufremain = gbp->size - (pos_addr - base_addr); + bufremain = (long long)(gbp->size - (pos_addr - base_addr)); cpos = *namep; while (nchars > 0) { if (bufremain > 0) { strcount = MIN(bufremain, nchars); - (void) memcpy(cpos, gbp->pos, strcount); + (void) memcpy(cpos, gbp->pos, (size_t)strcount); nchars -= strcount; gbp->pos = (void *)((char *)gbp->pos + strcount); cpos += strcount; @@ -1091,20 +1091,20 @@ hdr_get_name(int fd, *namep = NULL; return err; } - bufremain = gbp->size; + bufremain = (long long)gbp->size; } } if (padding > 0) { err_addr = ERR_ADDR; - err = val_check_buffer(fd, gbp, padding); + err = val_check_buffer(fd, gbp, (size_t)padding); if (err != NC_NOERR) { if (verbose) printf("Error @ [0x%8.8zx]:\n", err_addr); if (verbose) printf("\t%s - fetching name string padding\n", loc); return err; } memset(pad, 0, X_ALIGN-1); - if (memcmp(gbp->pos, pad, padding) != 0) { + if (memcmp(gbp->pos, pad, (size_t)padding) != 0) { /* This is considered not a fatal error, we continue to validate */ if (verbose) printf("Error @ [0x%8.8zx]:\n", err_addr); if (verbose) printf("\t%s \"%s\": name padding is non-null byte\n", loc, *namep); @@ -1112,7 +1112,7 @@ hdr_get_name(int fd, *namep = NULL; */ DEBUG_ASSIGN_ERROR(err, NC_ENULLPAD) if (repair) { - val_repair(fd, err_addr, (size_t)padding, (void*)nada); + val_repair(fd, (off_t)err_addr, (size_t)padding, (void*)nada); if (verbose) printf("\t%s \"%s\": name padding error has been **repaired**\n",loc,*namep); } @@ -1335,12 +1335,12 @@ val_get_NC_attrV(int fd, padding = attrp->xsz - nvalues; pos_addr = (size_t) gbp->pos; base_addr = (size_t) gbp->base; - bufremain = gbp->size - (pos_addr - base_addr); + bufremain = (long long)(gbp->size - (pos_addr - base_addr)); while (nvalues > 0) { if (bufremain > 0) { attcount = MIN(bufremain, nvalues); - (void) memcpy(value, gbp->pos, attcount); + (void) memcpy(value, gbp->pos, (size_t)attcount); nvalues -= attcount; gbp->pos = (void *)((char *)gbp->pos + attcount); value = (void *)((char *)value + attcount); @@ -1353,19 +1353,19 @@ val_get_NC_attrV(int fd, if (verbose) printf("\t%s: Failed to fetch next chunk into a buffer\n", loc); return status; } - bufremain = gbp->size; + bufremain = (long long)gbp->size; } } if (padding > 0) { memset(pad, 0, X_ALIGN-1); - if (memcmp(gbp->pos, pad, padding) != 0) { + if (memcmp(gbp->pos, pad, (size_t)padding) != 0) { /* This is considered not a fatal error, we continue to validate */ if (verbose) printf("Error @ [0x%8.8zx]:\n", (size_t)ERR_ADDR); if (verbose) printf("\t%s: value padding is non-null byte\n", loc); DEBUG_ASSIGN_ERROR(status, NC_ENULLPAD) if (repair) { - val_repair(fd, ERR_ADDR, (size_t)padding, (void*)nada); + val_repair(fd, (off_t)ERR_ADDR, (size_t)padding, (void*)nada); if (verbose) printf("\t%s: value padding has been **repaired**\n",loc); } @@ -1720,7 +1720,7 @@ val_get_NC_var(int fd, if (trace) printf("\t\tnumber of dimensions = %lld\n", ndims); /* allocate variable object */ - varp = val_new_NC_var(name, ndims); + varp = val_new_NC_var(name, (int)ndims); if (varp == NULL) { if (name != NULL) free(name); DEBUG_RETURN_ERROR(NC_ENOMEM) diff --git a/ncdump/ocprint.c b/ncdump/ocprint.c index 7c0abc47d9..e75d153a04 100644 --- a/ncdump/ocprint.c +++ b/ncdump/ocprint.c @@ -127,7 +127,7 @@ static OCerror printdata_indices(OClink, OCdatanode, NCbytes*,int); static OCerror printdata_container(OClink, OCdatanode, NCbytes*,int); static OCerror printdata_leaf(OClink, OCdatanode, NCbytes*,int); -static off_t odom_init(size_t rank, size_t* indices, size_t* dimsizes); +static size_t odom_init(size_t rank, size_t* indices, size_t* dimsizes); static int odom_more(size_t rank, size_t* indices, size_t* dimsizes); static void odom_next(size_t rank, size_t* indices, size_t* dimsizes); @@ -230,7 +230,7 @@ main(int argc, char **argv) } break; case 'X': { int c0; - int so = (optarg == NULL ? 0 : strlen(optarg)); + size_t so = (optarg == NULL ? 0 : strlen(optarg)); if(so == 0) usage("missing -X argument"); c0 = optarg[0]; switch (c0) { @@ -921,7 +921,7 @@ stringescape(char* s) { size_t len; char* p; - int c; + char c; char* escapedstring; if(s == NULL) return NULL; @@ -948,7 +948,7 @@ static char* idescape(char* id, char* escapeid, size_t esize) { char* p; - int c; + char c; if(id == NULL) return NULL; p = escapeid; @@ -1068,8 +1068,7 @@ dumpdatanode(OClink link, OCdatanode datanode, size_t count, void* memory, NCbyt ncbytescat(buffer,tmp); if(entry->rank > 0) { if(ocopt.octest) { /* Match the octest output */ - off_t xproduct; - xproduct = totaldimsize(entry->rank,entry->dimsizes); + size_t xproduct = totaldimsize(entry->rank,entry->dimsizes); snprintf(tmp,sizeof(tmp),"[0..%lu]",(unsigned long)xproduct-1); ncbytescat(buffer,tmp); } else { @@ -1091,12 +1090,11 @@ dumpdatanode(OClink link, OCdatanode datanode, size_t count, void* memory, NCbyt return OC_NOERR; } -static off_t +static size_t odom_init(size_t rank, size_t* indices, size_t* dimsizes) { - int i; - off_t count; - for(count=1,i=0;i max_line_len && nn > 2) { (void) fputs("\n", stdout); @@ -99,9 +99,9 @@ lput2( * false=stay on same line */ ) { - static int linep; /* current line position (number of */ + static size_t linep; /* current line position (number of */ /* chars); saved between calls */ - int len_prefix = strlen (CDL_COMMENT_PREFIX); + size_t len_prefix = strlen (CDL_COMMENT_PREFIX); bool_t make_newline; size_t len1 = strlen(cp); /* length of input string */ @@ -306,11 +306,11 @@ annotate( /* C variable indices */ for (id = 0; id < vrank-1; id++) printf("%lu,", (unsigned long) cor[id]); - printf("%lu", (unsigned long) cor[id] + iel); + printf("%lu", (unsigned long) cor[id] + (unsigned long) iel); break; case LANG_F: /* Fortran variable indices */ - printf("%lu", (unsigned long) cor[vrank-1] + iel + 1); + printf("%lu", (unsigned long) cor[vrank-1] + (unsigned long) iel + 1); for (id = vrank-2; id >=0 ; id--) { printf(",%lu", 1 + (unsigned long) cor[id]); } @@ -342,7 +342,7 @@ pr_tvals( len--; for (iel = 0; iel < len; iel++) { unsigned char uc; - switch (uc = *vals++ & 0377) { + switch (uc = (unsigned char)(*vals++ & 0377)) { case '\b': printf("\\b"); break; @@ -437,15 +437,11 @@ print_rows( int rank = vp->ndims; size_t ncols = rank > 0 ? vdims[rank - 1] : 1; /* number of values in a row */ int d0 = 0; - size_t inc = 1; int i; bool_t mark_record = (level > 0 && is_unlim_dim(ncid, vp->dims[level])); safebuf_t *sb = sbuf_new(); if (rank > 0) - d0 = vdims[level]; - for(i = level + 1; i < rank; i++) { - inc *= vdims[i]; - } + d0 = (int)vdims[level]; if(mark_record) { /* the whole point of this recursion is printing these "{}" */ lput(LBRACE); marks_pending++; /* matching "}"s to emit after last "row" */ @@ -638,7 +634,7 @@ pr_tvalsx( len--; for (iel = 0; iel < len; iel++) { unsigned char uc; - switch (uc = *vals++ & 0377) { + switch (uc = (unsigned char)(*vals++ & 0377)) { case '\b': printf("\\b"); break; diff --git a/ncgen/dump.c b/ncgen/dump.c index 024f92c41d..004009840c 100644 --- a/ncgen/dump.c +++ b/ncgen/dump.c @@ -169,8 +169,7 @@ dumpgroup(Symbol* g) if(debug <= 1) return; fdebug("group %s {\n",(g==NULL?"null":g->name)); if(g != NULL && g->subnodes != NULL) { - int i; - for(i=0;isubnodes);i++) { + for(size_t i=0;isubnodes);i++) { Symbol* sym = (Symbol*)listget(g->subnodes,i); char* tname; if(sym->objectclass == NC_PRIM @@ -178,7 +177,7 @@ dumpgroup(Symbol* g) tname = nctypename(sym->subclass); } else tname = nctypename(sym->objectclass); - fdebug(" %3d: %s\t%s\t%s\n", + fdebug(" %3zu: %s\t%s\t%s\n", i, sym->name, tname,