From c72511404ebfe858bdbc0c548fc036885eafbb98 Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Fri, 2 Feb 2024 10:59:55 +0000 Subject: [PATCH] Fix conversion warnings in libdispatch --- libdispatch/dauth.c | 4 ++-- libdispatch/daux.c | 4 +--- libdispatch/dhttp.c | 2 +- libdispatch/dinfermodel.c | 12 ++++++------ libdispatch/dinstance.c | 22 ++++++++++++---------- libdispatch/dinstance_intern.c | 6 +++--- libdispatch/dpathmgr.c | 4 ++-- libdispatch/ds3util.c | 29 ++++++++++++----------------- libdispatch/dutf8.c | 2 +- libdispatch/dutil.c | 7 +++---- libdispatch/dv2i.c | 2 +- libdispatch/dvar.c | 4 +--- libdispatch/ncbytes.c | 2 +- libdispatch/ncexhash.c | 17 ++++++++--------- libdispatch/nchashmap.c | 20 ++++++++++---------- libdispatch/ncjson.c | 27 +++++++++++++-------------- libdispatch/ncuri.c | 6 +++--- libdispatch/ncxcache.c | 2 +- libsrc4/nc4var.c | 8 ++++---- 19 files changed, 85 insertions(+), 95 deletions(-) diff --git a/libdispatch/dauth.c b/libdispatch/dauth.c index 9cd335eeba..6e12ee3c72 100644 --- a/libdispatch/dauth.c +++ b/libdispatch/dauth.c @@ -281,7 +281,7 @@ setauthfield(NCauth* auth, const char* flag, const char* value) } if(strcmp(flag,"HTTP.SSL.VERIFYPEER")==0) { int v; - if((v = atol(value))) { + if((v = atoi(value))) { auth->ssl.verifypeer = v; #ifdef DEBUG nclog(NCLOGNOTE,"HTTP.SSL.VERIFYPEER: %d", v); @@ -290,7 +290,7 @@ setauthfield(NCauth* auth, const char* flag, const char* value) } if(strcmp(flag,"HTTP.SSL.VERIFYHOST")==0) { int v; - if((v = atol(value))) { + if((v = atoi(value))) { auth->ssl.verifyhost = v; #ifdef DEBUG nclog(NCLOGNOTE,"HTTP.SSL.VERIFYHOST: %d", v); diff --git a/libdispatch/daux.c b/libdispatch/daux.c index 538403533e..77fddaffef 100644 --- a/libdispatch/daux.c +++ b/libdispatch/daux.c @@ -311,11 +311,9 @@ computefieldinfo(struct NCAUX_CMPD* cmpd) #define LBRACK '[' #define RBRACK ']' -static int gettype(int q0, int q1, int* unsignedp); - /* Look at q0 and q1) to determine type */ static int -gettype(const int q0, const int q1, int* isunsignedp) +gettype(const char q0, const char q1, int* isunsignedp) { int type = 0; int isunsigned = 0; diff --git a/libdispatch/dhttp.c b/libdispatch/dhttp.c index db82c5e00f..45f93828f6 100644 --- a/libdispatch/dhttp.c +++ b/libdispatch/dhttp.c @@ -774,7 +774,7 @@ void dump(const char *text, FILE *stream, unsigned char *ptr, size_t size) /* show data on the right */ for(c = 0; (c < width) && (i+c < size); c++) { - char x = (ptr[i+c] >= 0x20 && ptr[i+c] < 0x80) ? ptr[i+c] : '.'; + const int x = (ptr[i+c] >= 0x20 && ptr[i+c] < 0x80) ? ptr[i+c] : '.'; fputc(x, stream); } diff --git a/libdispatch/dinfermodel.c b/libdispatch/dinfermodel.c index 44352c1573..7bb2eaddda 100644 --- a/libdispatch/dinfermodel.c +++ b/libdispatch/dinfermodel.c @@ -213,7 +213,7 @@ static int parseonchar(const char* s, int ch, NClist* segments); static int mergelist(NClist** valuesp); static int openmagic(struct MagicFile* file); -static int readmagic(struct MagicFile* file, long pos, char* magic); +static int readmagic(struct MagicFile* file, size_t pos, char* magic); static int closemagic(struct MagicFile* file); static int NC_interpret_magic_number(char* magic, NCmodel* model); #ifdef DEBUG @@ -1288,7 +1288,7 @@ check_file_type(const char *path, int omode, int use_parallel, search forward at starting at 512 and doubling to see if we have HDF5 magic number */ { - long pos = 512L; + size_t pos = 512L; for(;;) { if((pos+MAGIC_NUMBER_LEN) > magicinfo.filelen) {status = NC_ENOTNC; goto done;} @@ -1395,7 +1395,7 @@ openmagic(struct MagicFile* file) } static int -readmagic(struct MagicFile* file, long pos, char* magic) +readmagic(struct MagicFile* file, size_t pos, char* magic) { int status = NC_NOERR; NCbytes* buf = ncbytesnew(); @@ -1413,8 +1413,8 @@ readmagic(struct MagicFile* file, long pos, char* magic) #endif } else if(file->uri != NULL) { #ifdef NETCDF_ENABLE_BYTERANGE - fileoffset_t start = (size_t)pos; - fileoffset_t count = MAGIC_NUMBER_LEN; + size64_t start = (size64_t)pos; + size64_t count = MAGIC_NUMBER_LEN; status = nc_http_read(file->state, start, count, buf); if (status == NC_NOERR) { if (ncbyteslength(buf) != count) @@ -1436,7 +1436,7 @@ readmagic(struct MagicFile* file, long pos, char* magic) #endif /* USE_PARALLEL */ { /* Ordinary read */ long i; - i = fseek(file->fp, pos, SEEK_SET); + i = fseek(file->fp, (long)pos, SEEK_SET); if (i < 0) { status = errno; goto done; } ncbytessetlength(buf, 0); if ((status = NC_readfileF(file->fp, buf, MAGIC_NUMBER_LEN))) goto done; diff --git a/libdispatch/dinstance.c b/libdispatch/dinstance.c index 38d5217cb4..52b1d21bb0 100644 --- a/libdispatch/dinstance.c +++ b/libdispatch/dinstance.c @@ -12,6 +12,8 @@ Currently two operations are defined: */ #include "config.h" +#include +#include #include #include #include @@ -411,7 +413,7 @@ dump_datar(int ncid, nc_type xtype, Position* offset, NCbytes* buf) break; } if(xtype <= NC_MAX_ATOMIC_TYPE) - offset->offset += xsize; + offset->offset += (ptrdiff_t)xsize; done: return stat; @@ -440,12 +442,12 @@ dump_vlen(int ncid, nc_type xtype, nc_type basetype, Position* offset, NCbytes* voffset.offset = 0; for(i=0;ilen;i++) { if(i > 0) ncbytescat(buf," "); - voffset.offset = NC_read_align(voffset.offset,alignment); + voffset.offset = (ptrdiff_t)NC_read_align((uintptr_t)voffset.offset, alignment); if((stat = dump_datar(ncid,basetype,&voffset,buf))) goto done; } } ncbytescat(buf,")}"); - offset->offset += sizeof(nc_vlen_t); + offset->offset += (ptrdiff_t)sizeof(nc_vlen_t); done: return stat; @@ -469,12 +471,12 @@ dump_opaque(int ncid, nc_type xtype, size_t size, Position* offset, NCbytes* buf /* basically a fixed size sequence of bytes */ ncbytescat(buf,"|"); for(i=0;imemory+offset->offset+i); + unsigned char x = (unsigned char)*(offset->memory+offset->offset+i); snprintf(sx,sizeof(sx),"%2x",x); ncbytescat(buf,sx); } ncbytescat(buf,"|"); - offset->offset += size; + offset->offset += (ptrdiff_t)size; return NC_NOERR; } @@ -482,7 +484,7 @@ static int dump_compound(int ncid, nc_type xtype, size_t size, size_t nfields, Position* offset, NCbytes* buf) { int stat = NC_NOERR; - size_t fid, i, arraycount; + size_t i; ptrdiff_t saveoffset; int ndims; int dimsizes[NC_MAX_VAR_DIMS]; @@ -492,7 +494,7 @@ dump_compound(int ncid, nc_type xtype, size_t size, size_t nfields, Position* of ncbytescat(buf,"<"); /* Get info about each field in turn and dump it */ - for(fid=0;fidoffset = saveoffset + fieldalignment; + offset->offset = saveoffset + (ptrdiff_t)fieldalignment; /* compute the total number of elements in the field array */ - arraycount = 1; + int arraycount = 1; for(i=0;i 0) ncbytescat(buf," "); @@ -525,7 +527,7 @@ dump_compound(int ncid, nc_type xtype, size_t size, size_t nfields, Position* of ncbytescat(buf,">"); /* Return to beginning of the compound and move |compound| */ offset->offset = saveoffset; - offset->offset += size; + offset->offset += (ptrdiff_t)size; done: return stat; diff --git a/libdispatch/dinstance_intern.c b/libdispatch/dinstance_intern.c index b4b1b41f64..f1dac8eda6 100644 --- a/libdispatch/dinstance_intern.c +++ b/libdispatch/dinstance_intern.c @@ -133,7 +133,7 @@ reclaim_datar(NC_FILE_INFO_T* file, NC_TYPE_INFO_T* utype, Position instance) NC_TYPE_INFO_T* basetype = NULL; size_t nfields; nc_vlen_t* vlen; - size_t fid, arraycount; + size_t fid; int ndims; int dimsizes[NC_MAX_VAR_DIMS]; size_t alignment = 0; @@ -184,7 +184,7 @@ reclaim_datar(NC_FILE_INFO_T* file, NC_TYPE_INFO_T* utype, Position instance) /* Get field's dimension sizes */ field = (NC_FIELD_INFO_T*)nclistget(utype->u.c.field,fid); ndims = field->ndims; - arraycount = 1; + int arraycount = 1; for(i=0;idim_size[i]; arraycount *= dimsizes[i];} if(field->ndims == 0) {ndims=1; dimsizes[0]=1;} /* fake the scalar case */ @@ -423,7 +423,7 @@ copy_datar(NC_FILE_INFO_T* file, NC_TYPE_INFO_T* utype, Position src, Position d field = (NC_FIELD_INFO_T*)nclistget(utype->u.c.field,fid); ndims = field->ndims; arraycount = 1; - for(i=0;idim_size[i]; arraycount *= dimsizes[i];} + for(i=0;idim_size[i]; arraycount *= (size_t)dimsizes[i];} if(field->ndims == 0) {ndims=1; dimsizes[0]=1;} /* fake the scalar case */ /* "move" to this field */ diff --git a/libdispatch/dpathmgr.c b/libdispatch/dpathmgr.c index dca9f7f80f..7e67fbbeb5 100644 --- a/libdispatch/dpathmgr.c +++ b/libdispatch/dpathmgr.c @@ -85,7 +85,7 @@ static const char* cygwinspecial[] = static const struct Path { int kind; - int drive; + char drive; char* path; } empty = {NCPD_UNKNOWN,0,NULL}; @@ -896,7 +896,7 @@ unparsepath(struct Path* xp, char** pathp, int target) char sdrive[4] = "\0\0\0\0"; char* p = NULL; int cygspecial = 0; - int drive = 0; + char drive = 0; /* Short circuit a relative path */ if(xp->kind == NCPD_REL) { diff --git a/libdispatch/ds3util.c b/libdispatch/ds3util.c index 75c7851a96..8db08d2e82 100644 --- a/libdispatch/ds3util.c +++ b/libdispatch/ds3util.c @@ -282,11 +282,10 @@ NC_s3urlrebuild(NCURI* url, NCS3INFO* s3, NCURI** newurlp) static int endswith(const char* s, const char* suffix) { - ssize_t ls, lsf, delta; if(s == NULL || suffix == NULL) return 0; - ls = strlen(s); - lsf = strlen(suffix); - delta = (ls - lsf); + size_t ls = strlen(s); + size_t lsf = strlen(suffix); + ssize_t delta = (ssize_t)(ls - lsf); if(delta < 0) return 0; if(memcmp(s+delta,suffix,lsf)!=0) return 0; return 1; @@ -404,11 +403,10 @@ static void freeprofile(struct AWSprofile* profile) { if(profile) { - int i; #ifdef AWSDEBUG fprintf(stderr,">>> freeprofile: %s\n",profile->name); #endif - for(i=0;ientries);i++) { + for(size_t i=0;ientries);i++) { struct AWSentry* e = (struct AWSentry*)nclistget(profile->entries,i); freeentry(e); } @@ -422,8 +420,7 @@ void NC_s3freeprofilelist(NClist* profiles) { if(profiles) { - int i; - for(i=0;ircinfo->s3profiles);i++) { + for(size_t i=0;ircinfo->s3profiles);i++) { struct AWSprofile* profile = (struct AWSprofile*)nclistget(gstate->rcinfo->s3profiles,i); if(strcmp(profilename,profile->name)==0) {if(profilep) {*profilep = profile; goto done;}} @@ -572,13 +568,13 @@ 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; + int stat = NC_NOERR; struct AWSprofile* awsprof = NULL; const char* value = NULL; if(profile == NULL) return NC_ES3; if((stat=NC_authgets3profile(profile,&awsprof))==NC_NOERR && awsprof != NULL) { - for(i=0;ientries);i++) { + for(size_t i=0;ientries);i++) { struct AWSentry* entry = (struct AWSentry*)nclistget(awsprof->entries,i); if(strcasecmp(entry->key,key)==0) { value = entry->value; @@ -735,7 +731,6 @@ typedef struct AWSparser { static int awslex(AWSparser* parser) { - int c; int token = 0; char* start; size_t count; @@ -751,7 +746,7 @@ awslex(AWSparser* parser) } while(token == 0) { /* avoid need to goto when retrying */ - c = *parser->pos; + char c = *parser->pos; if(c == '\0') { token = AWS_EOF; } else if(c == '\n') { @@ -785,7 +780,7 @@ awslex(AWSparser* parser) } /* Pushback last char */ parser->pos--; - count = ((parser->pos) - start); + count = (size_t)(parser->pos - start); ncbytesappendn(parser->yytext,start,count); ncbytesnull(parser->yytext); token = AWS_WORD; @@ -811,7 +806,7 @@ fprintf(stderr,"%s(%d): |%s|\n",tokenname(token),token,ncbytescontents(parser->y static int awsparse(const char* text, NClist* profiles) { - int i,stat = NC_NOERR; + int stat = NC_NOERR; size_t len; AWSparser* parser = NULL; struct AWSprofile* profile = NULL; @@ -891,7 +886,7 @@ fprintf(stderr,">>> parse: entry=(%s,%s)\n",entry->key,entry->value); } /* If this profile already exists, then replace old one */ - for(i=0;iname,profile->name)==0) { nclistset(profiles,i,profile); diff --git a/libdispatch/dutf8.c b/libdispatch/dutf8.c index f8e0d6b9a0..86f917d207 100644 --- a/libdispatch/dutf8.c +++ b/libdispatch/dutf8.c @@ -153,7 +153,7 @@ int nc_utf8_to_utf16(const unsigned char* s8, unsigned short** utf16p, size_t* l goto done; } else { /* move to next char */ /* Complain if top 16 bits not zero */ - if((codepoint & 0xFFFF0000) != 0) { + if((codepoint & (nc_utf8proc_int32_t)0xFFFF0000) != 0) { ncstat = NC_EBADNAME; goto done; } diff --git a/libdispatch/dutil.c b/libdispatch/dutil.c index 47e1ead503..f6f0eecc34 100644 --- a/libdispatch/dutil.c +++ b/libdispatch/dutil.c @@ -282,7 +282,7 @@ NC_readfileF(FILE* stream, NCbytes* content, long long amount) { #define READ_BLOCK_SIZE 4194304 int ret = NC_NOERR; - long long red = 0; + size_t red = 0; char *part = (char*) malloc(READ_BLOCK_SIZE); while(amount < 0 || red < amount) { @@ -294,7 +294,7 @@ NC_readfileF(FILE* stream, NCbytes* content, long long amount) } /* Keep only amount */ if(amount >= 0) { - if(red > amount) ncbytessetlength(content,amount); /* read too much */ + if(red > amount) ncbytessetlength(content, (unsigned long)amount); /* read too much */ if(red < amount) ret = NC_ETRUNC; /* |file| < amount */ } ncbytesnull(content); @@ -405,7 +405,6 @@ NC_addmodetag(NCURI* uri, const char* tag) { int stat = NC_NOERR; int found = 0; - int i; const char* modestr = NULL; char* modevalue = NULL; NClist* modelist = NULL; @@ -417,7 +416,7 @@ NC_addmodetag(NCURI* uri, const char* tag) } else modelist = nclistnew(); /* Search for tag */ - for(i=0;ilength <= pos) return ncbytesfail(); if(pos < (bb->length - 1)) { - int copylen = (bb->length - pos) - 1; + size_t copylen = (bb->length - pos) - 1; memmove(bb->content+pos,bb->content+pos+1,copylen); } bb->length--; diff --git a/libdispatch/ncexhash.c b/libdispatch/ncexhash.c index 0d3d9dc212..8a65841e15 100644 --- a/libdispatch/ncexhash.c +++ b/libdispatch/ncexhash.c @@ -736,7 +736,7 @@ ncexhashiterate(NCexhashmap* map, ncexhashkey_t* keyp, uintptr_t* datap) void ncexhashprint(NCexhashmap* hm) { - int dirindex,index; + int index; if(hm == NULL) {fprintf(stderr,"NULL"); fflush(stderr); return;} fprintf(stderr,"{depth=%u leaflen=%u",hm->depth,hm->leaflen); @@ -745,9 +745,9 @@ ncexhashprint(NCexhashmap* hm) hm->iterator.leaf,hm->iterator.index); } fprintf(stderr,"\n"); - for(dirindex=0;dirindex<(1<depth);dirindex++) { + for(size_t dirindex=0;dirindex<(1<depth);dirindex++) { NCexleaf* leaf = hm->directory[dirindex]; - fprintf(stderr,"\tdirectory[%03d|%sb]=(%04x)[(%u)^%d|%d|", + fprintf(stderr,"\tdirectory[%03zu|%sb]=(%04x)[(%u)^%d|%d|", dirindex,ncexbinstr(dirindex,hm->depth), leaf->active, (unsigned)(0xffff & (uintptr_t)leaf), @@ -776,10 +776,9 @@ ncexhashprint(NCexhashmap* hm) void ncexhashprintdir(NCexhashmap* map, NCexleaf** dir) { - int dirindex; - for(dirindex=0;dirindex<(1<depth);dirindex++) { + for(unsigned long long dirindex=0;dirindex<(1<depth);dirindex++) { NCexleaf* leaf = dir[dirindex]; - fprintf(stderr,"\tdirectory[%03d|%sb]=%d/%p\n", + fprintf(stderr,"\tdirectory[%03llu|%sb]=%d/%p\n", dirindex,ncexbinstr(dirindex,map->depth),leaf->uid,leaf); } fflush(stderr); @@ -831,14 +830,14 @@ ncexbinstr(ncexhashkey_t hkey, int depth) void ncexhashprintstats(NCexhashmap* map) { - int nactive, nleaves; + int nactive; NCexleaf* leaf = NULL; double leafavg = 0.0; double leafload = 0.0; unsigned long long dirsize, leafsize, total; nactive = 0; - nleaves = 0; + unsigned long long nleaves = 0; for(leaf=map->leaves;leaf;leaf=leaf->next) { nleaves++; nactive += leaf->active; @@ -850,7 +849,7 @@ ncexhashprintstats(NCexhashmap* map) if(nactive != map->nactive) { fprintf(stderr,"nactive mismatch: map->active=%d actual=%d\n",map->nactive,nactive); } - fprintf(stderr,"|directory|=%llu nleaves=%d nactive=%d", + fprintf(stderr,"|directory|=%llu nleaves=%llu nactive=%d", (unsigned long long)(1<<(map->depth)),nleaves,nactive); fprintf(stderr," |leaf|=%d nactive/nleaves=%g", map->leaflen, leafavg); fprintf(stderr," load=%g",leafload); diff --git a/libdispatch/nchashmap.c b/libdispatch/nchashmap.c index af08aac027..0e438bca86 100644 --- a/libdispatch/nchashmap.c +++ b/libdispatch/nchashmap.c @@ -71,7 +71,7 @@ extern nchashkey_t hash_fast(const char*, size_t length); /* Forward */ static const unsigned int NC_nprimes; static const unsigned int NC_primes[16386]; -static unsigned int findPrimeGreaterThan(size_t val); +static size_t findPrimeGreaterThan(size_t val); extern void printhashmapstats(NC_hashmap* hm); extern void printhashmap(NC_hashmap* hm); @@ -160,7 +160,7 @@ locate(NC_hashmap* hash, nchashkey_t hashkey, const char* key, size_t keysize, s nchashkey_t NC_hashmapkey(const char* key, size_t size) { - return NC_crc64(0,(void*)key,(unsigned int)size); + return (nchashkey_t)NC_crc64(0,(void*)key,(unsigned int)size); } NC_hashmap* @@ -399,7 +399,7 @@ static int isPrime(size_t n) } /* Function to return the smallest prime number greater than N */ -static int nextPrime(size_t val) +static size_t nextPrime(size_t val) { if (val <= 1) return 2; @@ -424,18 +424,18 @@ Binary search prime table for first prime just greater than or equal to val */ -static unsigned int +static size_t findPrimeGreaterThan(size_t val) { - int n = NC_nprimes; - int L = 1; /* skip leading flag number */ - int R = (n - 2); /* skip trailing flag */ - unsigned int v = 0; - int m; + size_t n = NC_nprimes; + size_t L = 1; /* skip leading flag number */ + size_t R = (n - 2); /* skip trailing flag */ + size_t v = 0; + size_t m; if(val >= 0xFFFFFFFF) return 0; /* Too big */ - v = (unsigned int)val; + v = val; if (v > NC_primes[n - 2]) { /* diff --git a/libdispatch/ncjson.c b/libdispatch/ncjson.c index 1a574a9b80..363b24ffef 100644 --- a/libdispatch/ncjson.c +++ b/libdispatch/ncjson.c @@ -71,7 +71,7 @@ typedef struct NCJparser { } NCJparser; typedef struct NCJbuf { - int len; /* |text|; does not include nul terminator */ + size_t len; /* |text|; does not include nul terminator */ char* text; /* NULL || nul terminated */ } NCJbuf; @@ -109,7 +109,7 @@ static int NCJyytext(NCJparser*, char* start, size_t pdlen); static void NCJreclaimArray(struct NCjlist*); static void NCJreclaimDict(struct NCjlist*); static int NCJunescape(NCJparser* parser); -static int unescape1(int c); +static char unescape1(char c); static int listappend(struct NCjlist* list, NCjson* element); static int NCJcloneArray(const NCjson* array, NCjson** clonep); @@ -368,13 +368,12 @@ NCJparseDict(NCJparser* parser, struct NCjlist* dictp) static int NCJlex(NCJparser* parser) { - int c; int token = NCJ_UNDEF; char* start; size_t count; while(token == 0) { /* avoid need to goto when retrying */ - c = *parser->pos; + char c = *parser->pos; if(c == '\0') { token = NCJ_EOF; } else if(c <= ' ' || c == '\177') {/* ignore whitespace */ @@ -393,7 +392,7 @@ NCJlex(NCJparser* parser) } /* Pushback c */ parser->pos--; - count = ((parser->pos) - start); + count = (size_t)((parser->pos) - start); if(NCJyytext(parser,start,count)) goto done; /* Discriminate the word string to get the proper sort */ if(testbool(parser->yytext) == NCJ_OK) @@ -420,7 +419,7 @@ NCJlex(NCJparser* parser) token = NCJ_UNDEF; goto done; } - count = ((parser->pos) - start) - 1; /* -1 for trailing quote */ + count = (size_t)((parser->pos) - start) - 1; /* -1 for trailing quote */ if(NCJyytext(parser,start,count)==NCJ_ERR) goto done; if(NCJunescape(parser)==NCJ_ERR) goto done; token = NCJ_STRING; @@ -641,7 +640,7 @@ NCJunescape(NCJparser* parser) { char* p = parser->yytext; char* q = p; - int c; + char c; for(;(c=*p++);) { if(c == NCJ_ESCAPE) { c = *p++; @@ -651,9 +650,9 @@ NCJunescape(NCJparser* parser) case 'n': c = '\n'; break; case 'r': c = '\r'; break; case 't': c = '\t'; break; - case NCJ_QUOTE: c = c; break; - case NCJ_ESCAPE: c = c; break; - default: c = c; break;/* technically not Json conformant */ + case NCJ_QUOTE: break; + case NCJ_ESCAPE: break; + default: break;/* technically not Json conformant */ } } *q++ = c; @@ -663,8 +662,8 @@ NCJunescape(NCJparser* parser) } /* Unescape a single character */ -static int -unescape1(int c) +static char +unescape1(char c) { switch (c) { case 'b': c = '\b'; break; @@ -672,7 +671,7 @@ unescape1(int c) case 'n': c = '\n'; break; case 'r': c = '\r'; break; case 't': c = '\t'; break; - default: c = c; break;/* technically not Json conformant */ + default: break;/* technically not Json conformant */ } return c; } @@ -1007,7 +1006,7 @@ static int escape(const char* text, NCJbuf* buf) { const char* p = text; - int c; + char c; for(;(c=*p++);) { char replace = 0; switch (c) { diff --git a/libdispatch/ncuri.c b/libdispatch/ncuri.c index 01e48151ef..e5be032e46 100644 --- a/libdispatch/ncuri.c +++ b/libdispatch/ncuri.c @@ -143,7 +143,7 @@ ncuriparse(const char* uri0, NCURI** durip) NClist* params = nclistnew(); NClist* querylist = nclistnew(); size_t len0; - int pathchar; + char pathchar; if(uri0 == NULL) {THROW(NC_EURL);} @@ -899,7 +899,7 @@ ncrshift1(char* p) static const char* hexchars = "0123456789abcdefABCDEF"; static void -toHex(unsigned int b, char hex[2]) +toHex(char b, char hex[2]) { hex[0] = hexchars[(b >> 4) & 0xf]; hex[1] = hexchars[(b) & 0xf]; @@ -943,7 +943,7 @@ ncuriencodeonly(const char* s, const char* allowable) encoded = (char*)malloc((3*slen) + 1); /* max possible size */ for(inptr=s,outptr=encoded;*inptr;) { - int c = *inptr++; + char c = *inptr++; { /* search allowable */ char* p = strchr(allowable,c); diff --git a/libdispatch/ncxcache.c b/libdispatch/ncxcache.c index 40b82f81c4..11a8248c61 100644 --- a/libdispatch/ncxcache.c +++ b/libdispatch/ncxcache.c @@ -230,7 +230,7 @@ ncxcachenew(size_t leaflen, NCxcache** cachep) cache = calloc(1,sizeof(NCxcache)); if(cache == NULL) {stat = NC_ENOMEM; goto done;} - cache->map = ncexhashnew(leaflen); + cache->map = ncexhashnew((int)leaflen); if(cache->map == NULL) {stat = NC_ENOMEM; goto done;} cache->lru.next = &cache->lru; diff --git a/libsrc4/nc4var.c b/libsrc4/nc4var.c index d3d7c0048a..9da3a03ec9 100644 --- a/libsrc4/nc4var.c +++ b/libsrc4/nc4var.c @@ -1763,8 +1763,8 @@ nc4_find_default_chunksizes2(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var) LOG((4, "%s: name %s dim %d DEFAULT_CHUNK_SIZE %d num_values %f type_size %d " "chunksize %ld", __func__, var->hdr.name, d, DEFAULT_CHUNK_SIZE, num_values, type_size, var->chunksizes[0])); } - if (var->ndims > 1 && var->ndims == num_unlim) { /* all dims unlimited */ - suggested_size = pow((double)DEFAULT_CHUNK_SIZE/type_size, 1.0/(double)(var->ndims)); + if (var->ndims > 1 && (float)var->ndims == num_unlim) { /* all dims unlimited */ + suggested_size = (size_t)pow((double)DEFAULT_CHUNK_SIZE/(double)type_size, 1.0/(double)(var->ndims)); for (d = 0; d < var->ndims; d++) { var->chunksizes[d] = suggested_size ? suggested_size : 1; @@ -1778,8 +1778,8 @@ nc4_find_default_chunksizes2(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var) for (d = 0; d < var->ndims; d++) if (!var->chunksizes[d]) { - suggested_size = (pow((double)DEFAULT_CHUNK_SIZE/(num_values * type_size), - 1.0/(double)(var->ndims - num_unlim)) * var->dim[d]->len - .5); + suggested_size = (size_t)(pow((double)DEFAULT_CHUNK_SIZE/(num_values * (double)type_size), + 1.0/(double)((double)var->ndims - num_unlim)) * (double)var->dim[d]->len - .5); if (suggested_size > var->dim[d]->len) suggested_size = var->dim[d]->len; var->chunksizes[d] = suggested_size ? suggested_size : 1;