mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-03-25 17:40:27 +08:00
1. Attempted to reduce the number of conversion errors
when -Wconversion is set. Fixed libdispatch, but rest of netcdf remains to be done.
This commit is contained in:
parent
2bc36f2bc1
commit
1b941d342d
1
cf
1
cf
@ -19,6 +19,7 @@ DAP=1
|
||||
CFLAGS=""
|
||||
#CFLAGS="-Wall -Wno-unused-variable -Wno-unused-parameter -Wconversion ${CFLAGS}"
|
||||
#CFLAGS="-Wall -Wno-unused-variable -Wno-unused-parameter ${CFLAGS}"
|
||||
CFLAGS="-Wconversion"
|
||||
|
||||
FORCE="-i"
|
||||
|
||||
|
@ -633,15 +633,13 @@ AC_ARG_ENABLE([diskless],
|
||||
[AS_HELP_STRING([--disable-diskless],
|
||||
[disable support for in-memory (NC_DISKLESS) files])])
|
||||
test "x$enable_diskless" = xno || enable_diskless=yes
|
||||
AC_MSG_RESULT($enable_diskless)
|
||||
|
||||
if test "x$enable_dap" = "xyes" -o "x$enable_cdmremote" = "xyes" -o "x$enable_rpc" = "xyes" ; then
|
||||
enable_diskless=yes
|
||||
AC_MSG_NOTICE([--enable-dap requires --enable-diskless])
|
||||
fi
|
||||
|
||||
AC_MSG_RESULT($enable_diskless)
|
||||
|
||||
|
||||
# check for useful, but not essential, memio support
|
||||
AC_CHECK_FUNCS([memmove getpagesize sysconf])
|
||||
|
||||
|
@ -6,8 +6,8 @@
|
||||
|
||||
typedef struct NCbytes {
|
||||
int nonextendible; /* 1 => fail if an attempt is made to extend this buffer*/
|
||||
unsigned long alloc;
|
||||
unsigned long length;
|
||||
size_t alloc;
|
||||
size_t length;
|
||||
char* content;
|
||||
} NCbytes;
|
||||
|
||||
@ -19,8 +19,8 @@ typedef struct NCbytes {
|
||||
|
||||
EXTERNC NCbytes* ncbytesnew(void);
|
||||
EXTERNC void ncbytesfree(NCbytes*);
|
||||
EXTERNC int ncbytessetalloc(NCbytes*,unsigned long);
|
||||
EXTERNC int ncbytessetlength(NCbytes*,unsigned long);
|
||||
EXTERNC int ncbytessetalloc(NCbytes*,size_t);
|
||||
EXTERNC int ncbytessetlength(NCbytes*,size_t);
|
||||
EXTERNC int ncbytesfill(NCbytes*, char fill);
|
||||
|
||||
/* Produce a duplicate of the contents*/
|
||||
@ -29,14 +29,14 @@ EXTERNC char* ncbytesdup(NCbytes*);
|
||||
EXTERNC char* ncbytesextract(NCbytes*);
|
||||
|
||||
/* Return the ith byte; -1 if no such index */
|
||||
EXTERNC int ncbytesget(NCbytes*,unsigned long);
|
||||
EXTERNC int ncbytesget(NCbytes*,size_t);
|
||||
/* Set the ith byte */
|
||||
EXTERNC int ncbytesset(NCbytes*,unsigned long,char);
|
||||
EXTERNC int ncbytesset(NCbytes*,size_t,char);
|
||||
|
||||
/* Append one byte */
|
||||
EXTERNC int ncbytesappend(NCbytes*,char); /* Add at Tail */
|
||||
EXTERNC int ncbytesappend(NCbytes*,int); /* Add at Tail */
|
||||
/* Append n bytes */
|
||||
EXTERNC int ncbytesappendn(NCbytes*,const void*,unsigned long); /* Add at Tail */
|
||||
EXTERNC int ncbytesappendn(NCbytes*,const void*,size_t); /* Add at Tail */
|
||||
|
||||
/* Null terminate the byte string without extending its length (for debugging) */
|
||||
EXTERNC int ncbytesnull(NCbytes*);
|
||||
@ -45,7 +45,7 @@ EXTERNC int ncbytesnull(NCbytes*);
|
||||
EXTERNC int ncbytescat(NCbytes*,const char*);
|
||||
|
||||
/* Set the contents of the buffer; mark the buffer as non-extendible */
|
||||
EXTERNC int ncbytessetcontents(NCbytes*, char*, unsigned long);
|
||||
EXTERNC int ncbytessetcontents(NCbytes*, char*, size_t);
|
||||
|
||||
/* Following are always "in-lined"*/
|
||||
#define ncbyteslength(bb) ((bb)!=NULL?(bb)->length:0)
|
||||
|
@ -358,7 +358,7 @@ extern int NCDAP_ping(const char*);
|
||||
|
||||
/* Misc */
|
||||
|
||||
extern int NC_getshape(int ncid, int varid, int ndims, size_t* shape);
|
||||
extern int NC_getshape(int ncid, int varid, size_t ndims, size_t* shape);
|
||||
extern int NC_is_recvar(int ncid, int varid, size_t* nrecs);
|
||||
|
||||
#define nullstring(s) (s==NULL?"(null)":s)
|
||||
|
@ -48,7 +48,7 @@ externC int nchashremove(NChashmap*, nchashid nchash);
|
||||
|
||||
/* Return the ith pair; order is completely arbitrary*/
|
||||
/* Can be expensive*/
|
||||
externC int nchashith(NChashmap*, int i, nchashid*, void**);
|
||||
externC int nchashith(NChashmap*, size_t i, nchashid*, void**);
|
||||
|
||||
externC int nchashkeys(NChashmap* hm, nchashid** keylist);
|
||||
|
||||
|
@ -547,7 +547,7 @@ ssize_t utf8proc_map(
|
||||
}
|
||||
{
|
||||
int32_t *newptr;
|
||||
newptr = realloc(buffer, result+1);
|
||||
newptr = realloc(buffer, (size_t)result+1);
|
||||
if (newptr) buffer = newptr;
|
||||
}
|
||||
*dstptr = (uint8_t *)buffer;
|
||||
|
@ -964,7 +964,7 @@ ncattput(
|
||||
const void* value
|
||||
)
|
||||
{
|
||||
const int status = nc_put_att(ncid, varid, name, datatype, len, value);
|
||||
const int status = nc_put_att(ncid, varid, name, datatype, (size_t)len, value);
|
||||
if(status != NC_NOERR)
|
||||
{
|
||||
nc_advise("ncattput", status, "ncid %d", ncid);
|
||||
|
@ -423,7 +423,7 @@ NC_atomictypename(nc_type xtype)
|
||||
Get the shape of a variable.
|
||||
*/
|
||||
int
|
||||
NC_getshape(int ncid, int varid, int ndims, size_t* shape)
|
||||
NC_getshape(int ncid, int varid, size_t ndims, size_t* shape)
|
||||
{
|
||||
int dimids[NC_MAX_VAR_DIMS];
|
||||
int i;
|
||||
|
@ -73,7 +73,7 @@ NC_get_vara(int ncid, int varid,
|
||||
#endif
|
||||
if(edges == NULL) {
|
||||
size_t shape[NC_MAX_VAR_DIMS];
|
||||
int ndims;
|
||||
size_t ndims;
|
||||
stat = nc_inq_varndims(ncid, varid, &ndims);
|
||||
if(stat != NC_NOERR) return stat;
|
||||
stat = NC_getshape(ncid,varid,ndims,shape);
|
||||
@ -89,7 +89,7 @@ NC_get_vara(int ncid, int varid,
|
||||
static int
|
||||
NC_get_var(int ncid, int varid, void *value, nc_type memtype)
|
||||
{
|
||||
int ndims;
|
||||
size_t ndims;
|
||||
size_t shape[NC_MAX_VAR_DIMS];
|
||||
int stat = nc_inq_varndims(ncid,varid, &ndims);
|
||||
if(stat) return stat;
|
||||
@ -117,7 +117,8 @@ NCDEFAULT_get_vars(int ncid, int varid, const size_t * start,
|
||||
/* Rebuilt get_vars code to simplify and avoid use of get_varm */
|
||||
|
||||
int status = NC_NOERR;
|
||||
int i,simplestride,rank,isrecvar;
|
||||
int i,simplestride,isrecvar;
|
||||
size_t rank;
|
||||
struct GETodometer odom;
|
||||
nc_type vartype = NC_NAT;
|
||||
NC* ncp;
|
||||
@ -256,7 +257,7 @@ NCDEFAULT_get_varm(int ncid, int varid, const size_t *start,
|
||||
{
|
||||
int status = NC_NOERR;
|
||||
nc_type vartype = NC_NAT;
|
||||
int varndims,maxidim;
|
||||
size_t varndims,maxidim;
|
||||
NC* ncp;
|
||||
size_t memtypelen;
|
||||
ptrdiff_t cvtmap[NC_MAX_VAR_DIMS];
|
||||
|
@ -69,7 +69,7 @@ NC_put_vara(int ncid, int varid, const size_t *start,
|
||||
if(stat != NC_NOERR) return stat;
|
||||
if(edges == NULL) {
|
||||
size_t shape[NC_MAX_VAR_DIMS];
|
||||
int ndims;
|
||||
size_t ndims;
|
||||
stat = nc_inq_varndims(ncid, varid, &ndims);
|
||||
if(stat != NC_NOERR) return stat;
|
||||
stat = NC_getshape(ncid, varid, ndims, shape);
|
||||
@ -85,7 +85,7 @@ NC_put_vara(int ncid, int varid, const size_t *start,
|
||||
static int
|
||||
NC_put_var(int ncid, int varid, const void *value, nc_type memtype)
|
||||
{
|
||||
int ndims;
|
||||
size_t ndims;
|
||||
size_t shape[NC_MAX_VAR_DIMS];
|
||||
int stat = nc_inq_varndims(ncid,varid, &ndims);
|
||||
if(stat) return stat;
|
||||
@ -122,7 +122,8 @@ NCDEFAULT_put_vars(int ncid, int varid, const size_t * start,
|
||||
/* Rebuilt put_vars code to simplify and avoid use of put_varm */
|
||||
|
||||
int status = NC_NOERR;
|
||||
int i,simplestride,rank,isrecvar;
|
||||
int i,simplestride,isrecvar;
|
||||
size_t rank;
|
||||
struct PUTodometer odom;
|
||||
nc_type vartype = NC_NAT;
|
||||
NC* ncp;
|
||||
@ -264,8 +265,8 @@ NCDEFAULT_put_varm(
|
||||
{
|
||||
int status = NC_NOERR;
|
||||
nc_type vartype = NC_NAT;
|
||||
int varndims = 0;
|
||||
int maxidim = 0;
|
||||
size_t varndims = 0;
|
||||
size_t maxidim = 0;
|
||||
NC* ncp;
|
||||
size_t memtypelen;
|
||||
ptrdiff_t cvtmap[NC_MAX_VAR_DIMS];
|
||||
|
@ -318,7 +318,7 @@ nctypealignment(nc_type nctype)
|
||||
}
|
||||
|
||||
static int
|
||||
getpadding(int offset, int alignment)
|
||||
getpadding(size_t offset, size_t alignment)
|
||||
{
|
||||
int rem = (alignment==0?0:(offset % alignment));
|
||||
int pad = (rem==0?0:(alignment - rem));
|
||||
@ -360,7 +360,7 @@ computefieldinfo(struct NCAUX_CMPD* cmpd)
|
||||
|
||||
for(offset=0,i=0;i<cmpd->nfields;i++) {
|
||||
struct NCAUX_FIELD* field = &cmpd->fields[i];
|
||||
int alignment = 0;
|
||||
size_t alignment = 0;
|
||||
nc_type firsttype = findfirstfield(cmpd->ncid,field->fieldtype);
|
||||
|
||||
/* only support 'c' alignment for now*/
|
||||
|
@ -42,7 +42,7 @@ ncbytesnew(void)
|
||||
}
|
||||
|
||||
int
|
||||
ncbytessetalloc(NCbytes* bb, unsigned long sz)
|
||||
ncbytessetalloc(NCbytes* bb, size_t sz)
|
||||
{
|
||||
char* newcontent;
|
||||
if(bb == NULL) return ncbytesfail();
|
||||
@ -69,7 +69,7 @@ ncbytesfree(NCbytes* bb)
|
||||
}
|
||||
|
||||
int
|
||||
ncbytessetlength(NCbytes* bb, unsigned long sz)
|
||||
ncbytessetlength(NCbytes* bb, size_t sz)
|
||||
{
|
||||
if(bb == NULL) return ncbytesfail();
|
||||
if(bb->length < sz) {
|
||||
@ -82,14 +82,14 @@ ncbytessetlength(NCbytes* bb, unsigned long sz)
|
||||
int
|
||||
ncbytesfill(NCbytes* bb, char fill)
|
||||
{
|
||||
unsigned long i;
|
||||
size_t i;
|
||||
if(bb == NULL) return ncbytesfail();
|
||||
for(i=0;i<bb->length;i++) bb->content[i] = fill;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int
|
||||
ncbytesget(NCbytes* bb, unsigned long index)
|
||||
ncbytesget(NCbytes* bb, size_t index)
|
||||
{
|
||||
if(bb == NULL) return -1;
|
||||
if(index >= bb->length) return -1;
|
||||
@ -97,7 +97,7 @@ ncbytesget(NCbytes* bb, unsigned long index)
|
||||
}
|
||||
|
||||
int
|
||||
ncbytesset(NCbytes* bb, unsigned long index, char elem)
|
||||
ncbytesset(NCbytes* bb, size_t index, char elem)
|
||||
{
|
||||
if(bb == NULL) return ncbytesfail();
|
||||
if(index >= bb->length) return ncbytesfail();
|
||||
@ -106,14 +106,14 @@ ncbytesset(NCbytes* bb, unsigned long index, char elem)
|
||||
}
|
||||
|
||||
int
|
||||
ncbytesappend(NCbytes* bb, char elem)
|
||||
ncbytesappend(NCbytes* bb, int elem)
|
||||
{
|
||||
if(bb == NULL) return ncbytesfail();
|
||||
/* We need space for the char + null */
|
||||
while(bb->length+1 >= bb->alloc) {
|
||||
if(!ncbytessetalloc(bb,0)) return ncbytesfail();
|
||||
}
|
||||
bb->content[bb->length] = elem;
|
||||
bb->content[bb->length] = (elem & 0xFF);
|
||||
bb->length++;
|
||||
bb->content[bb->length] = '\0';
|
||||
return TRUE;
|
||||
@ -134,7 +134,7 @@ ncbytescat(NCbytes* bb, const char* s)
|
||||
}
|
||||
|
||||
int
|
||||
ncbytesappendn(NCbytes* bb, const void* elem, unsigned long n)
|
||||
ncbytesappendn(NCbytes* bb, const void* elem, size_t n)
|
||||
{
|
||||
if(bb == NULL || elem == NULL) return ncbytesfail();
|
||||
if(n == 0) {n = strlen((char*)elem);}
|
||||
@ -180,7 +180,7 @@ ncbytesextract(NCbytes* bb)
|
||||
}
|
||||
|
||||
int
|
||||
ncbytessetcontents(NCbytes* bb, char* contents, unsigned long alloc)
|
||||
ncbytessetcontents(NCbytes* bb, char* contents, size_t alloc)
|
||||
{
|
||||
if(bb == NULL) return ncbytesfail();
|
||||
ncbytesclear(bb);
|
||||
@ -197,7 +197,7 @@ ncbytessetcontents(NCbytes* bb, char* contents, unsigned long alloc)
|
||||
int
|
||||
ncbytesnull(NCbytes* bb)
|
||||
{
|
||||
ncbytesappend(bb,'\0');
|
||||
ncbytesappend(bb,(int)'\0');
|
||||
bb->length--;
|
||||
return 1;
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ nchashreplace(NChashmap* hm, nchashid hash, void* value)
|
||||
int
|
||||
nchashremove(NChashmap* hm, nchashid hash)
|
||||
{
|
||||
int i,offset,len;
|
||||
size_t i,offset,len;
|
||||
NClist* seq;
|
||||
void** list;
|
||||
|
||||
@ -158,13 +158,13 @@ nchashlookup(NChashmap* hm, nchashid hash, void** valuep)
|
||||
/* Return the ith pair; order is completely arbitrary*/
|
||||
/* Can be expensive*/
|
||||
int
|
||||
nchashith(NChashmap* hm, int index, nchashid* hashp, void** elemp)
|
||||
nchashith(NChashmap* hm, size_t index, nchashid* hashp, void** elemp)
|
||||
{
|
||||
int i;
|
||||
size_t i;
|
||||
if(hm == NULL) return FALSE;
|
||||
for(i=0;i<hm->alloc;i++) {
|
||||
NClist* seq = hm->table[i];
|
||||
int len = nclistlength(seq) / 2;
|
||||
size_t len = nclistlength(seq) / 2;
|
||||
if(len == 0) continue;
|
||||
if((index - len) < 0) {
|
||||
if(hashp) *hashp = (nchashid)nclistget(seq,index*2);
|
||||
@ -181,7 +181,7 @@ nchashith(NChashmap* hm, int index, nchashid* hashp, void** elemp)
|
||||
int
|
||||
nchashkeys(NChashmap* hm, nchashid** keylist)
|
||||
{
|
||||
int i,j,index;
|
||||
size_t i,j,index;
|
||||
nchashid* keys;
|
||||
if(hm == NULL) return FALSE;
|
||||
if(hm->size == 0) {
|
||||
|
@ -316,9 +316,9 @@ ncuriparse(const char* uri0, NCURI** durip)
|
||||
|
||||
/* concat suffix and prefix params */
|
||||
if(prefixparams != NULL || suffixparams != NULL) {
|
||||
int plen = prefixparams ? strlen(prefixparams) : 0;
|
||||
int slen = suffixparams ? strlen(suffixparams) : 0;
|
||||
int space = plen + slen + 1;
|
||||
size_t plen = prefixparams ? strlen(prefixparams) : 0;
|
||||
size_t slen = suffixparams ? strlen(suffixparams) : 0;
|
||||
size_t space = plen + slen + 1;
|
||||
/* add 1 for an extra ampersand if both are defined */
|
||||
space++;
|
||||
duri->params = (char*)malloc(space);
|
||||
@ -721,7 +721,7 @@ ncrshift1(char* p)
|
||||
static char* hexchars = "0123456789abcdefABCDEF";
|
||||
|
||||
static void
|
||||
toHex(unsigned int b, char hex[2])
|
||||
toHex(int b, char hex[2])
|
||||
{
|
||||
hex[0] = hexchars[(b >> 4) & 0xff];
|
||||
hex[1] = hexchars[(b) & 0xff];
|
||||
@ -734,7 +734,7 @@ fromHex(int c)
|
||||
if(c >= '0' && c <= '9') return (c - '0');
|
||||
if(c >= 'a' && c <= 'f') return (10 + (c - 'a'));
|
||||
if(c >= 'A' && c <= 'F') return (10 + (c - 'A'));
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
1333
ncdump/ctest.c
1333
ncdump/ctest.c
File diff suppressed because it is too large
Load Diff
1333
ncdump/ctest64.c
1333
ncdump/ctest64.c
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user