1. Any test that references nctestserver/NC_findtestserver

should be under ENABLE_DAP_REMOTE_TESTS.
   Fixed to make sure that this is so.
   Also attempted to fix ncdap_test/CMakeLists.txt,
   but probably got it wrong.
   HT to Nico Schlomer.
2. Attempted to reduce the number of conversion errors
   when -Wconversion is set. Fixed oc2, but
   rest of netcdf remains to be done.
   HT to Nico Schlomer.
3. When doing #2, I discovered an error in ncgen.y
   that has remained hidden. This required some other
   test case fixes.
This commit is contained in:
dmh 2014-03-08 20:41:30 -07:00
parent baade3e4fc
commit a189b98b0b
42 changed files with 386 additions and 282 deletions

4
cf
View File

@ -16,6 +16,10 @@ DAP=1
#M32=1
#M64=1
CFLAGS=""
#CFLAGS="-Wall -Wno-unused-variable -Wno-unused-parameter -Wconversion ${CFLAGS}"
#CFLAGS="-Wall -Wno-unused-variable -Wno-unused-parameter ${CFLAGS}"
FORCE="-i"
#INSTALL=1

View File

@ -65,6 +65,7 @@ const char*
NC_findtestserver(const char* path)
{
#ifdef USE_DAP
#ifdef ENABLE_DAP_REMOTE_TESTS
/* NCDAP_ping is defined in libdap2/ncdap3.c */
const char** svc;
if(path == NULL) path = "";
@ -79,6 +80,7 @@ NC_findtestserver(const char* path)
if(stat == NC_NOERR)
return *svc;
}
#endif
#endif
return NULL;
}

View File

@ -50,7 +50,7 @@ cdTrim(char* s, int n)
if(s==NULL)
return;
for(c=s; *c && c<s+n-1 && !isspace(*c); c++);
for(c=s; *c && c<s+n-1 && !isspace((int)*c); c++);
*c='\0';
return;
}

View File

@ -12,8 +12,10 @@ FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.sh)
FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/ FILE_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE)
ADD_EXECUTABLE(nctestserver nctestserver.c)
TARGET_LINK_LIBRARIES(nctestserver netcdf ${ALL_TLL_LIBS})
IF(ENABLE_DAP_REMOTE_TESTS)
ADD_EXECUTABLE(nctestserver nctestserver.c)
TARGET_LINK_LIBRARIES(nctestserver netcdf ${ALL_TLL_LIBS})
ENDIF()
IF(ENABLE_TESTS)
# Base tests
@ -24,29 +26,26 @@ IF(ENABLE_TESTS)
add_sh_test(ncdap tst_ncdap3)
IF(ENABLE_DAP_REMOTE_TESTS)
add_sh_test(ncdap tst_remote3)
add_sh_test(ncdap tst_formatx)
ENDIF()
IF(ENABLE_DAP_LONG_TESTS)
add_sh_test(ncdap tst_longremote3)
ENDIF()
IF(NOT MSVC)
add_bin_env_test(ncdap t_dap3a)
add_bin_env_test(ncdap test_cvt)
add_bin_env_test(ncdap test_vara)
ENDIF()
add_bin_test(ncdap test_nstride_cached)
add_bin_test(ncdap test_partvar)
add_bin_test(ncdap t_misc)
IF(ENABLE_DAP_AUTH_TESTS)
add_bin_test(ncdap t_auth)
ENDIF()
IF(ENABLE_DAP_REMOTE_TESTS)
add_sh_test(ncdap tst_remote3)
add_sh_test(ncdap tst_formatx)
add_bin_test(ncdap test_partvar)
IF(ENABLE_DAP_LONG_TESTS)
add_sh_test(ncdap tst_longremote3)
ENDIF()
add_bin_test(ncdap test_nstride_cached)
add_bin_test(ncdap t_misc)
IF(ENABLE_DAP_AUTH_TESTS)
add_bin_test(ncdap t_auth)
ENDIF()
# test_varm3 did not survive the transition
# to remotetest.unidata.ucar.edu; the
@ -55,6 +54,8 @@ IF(ENABLE_TESTS)
# and put it in testdods directory on remotetest.
# add_bin_test(ncdap test_varm3)
ENDIF()
ENDIF()
ADD_SUBDIRECTORY(testdata3)
ADD_SUBDIRECTORY(expected3)

View File

@ -14,38 +14,40 @@ check_PROGRAMS =
TESTS =
TESTS_ENVIRONMENT=TOPSRCDIR=${abs_top_srcdir}
# Make nctestserver be the first test to be built
check_PROGRAMS += nctestserver
nctestserver_SOURCES = nctestserver.c
TESTS += tst_ncdap3.sh
t_dap3a_SOURCES = t_dap3a.c
test_cvt3_SOURCES = test_cvt.c
test_vara_SOURCES = test_vara.c
check_PROGRAMS += t_dap3a test_cvt3 test_vara
TESTS += t_dap3a test_cvt3 test_vara
# remote tests are optional
# because the server may be down or inaccessible
if ENABLE_DAP_REMOTE_TESTS
TESTS += tst_remote3.sh tst_formatx.sh
# Make nctestserver be the first test to be built
check_PROGRAMS += nctestserver
nctestserver_SOURCES = nctestserver.c
TESTS += tst_remote3.sh tst_formatx.sh test_partvar
if ENABLE_DAP_LONG_TESTS
TESTS += tst_longremote3.sh
endif
test_cvt3_SOURCES = test_cvt.c
test_vara_SOURCES = test_vara.c
test_partvar_SOURCES = test_partvar.c
t_dap3a_SOURCES = t_dap3a.c
test_nstride_cached_SOURCE = test_nstride_cached.c
t_auth_SOURCES = t_auth.c
t_misc_SOURCES = t_misc.c
TESTS += t_dap3a test_cvt3 test_vara test_partvar
TESTS += t_dap3a
TESTS += test_nstride_cached
TESTS += t_misc
check_PROGRAMS += t_dap3a test_cvt3 test_vara test_partvar
check_PROGRAMS += t_dap3a
check_PROGRAMS += test_partvar
check_PROGRAMS += test_nstride_cached
check_PROGRAMS += t_misc

View File

@ -36,8 +36,10 @@ ADD_EXECUTABLE(nccopy ${nccopy_FILES})
TARGET_LINK_LIBRARIES(ncdump netcdf ${ALL_TLL_LIBS})
TARGET_LINK_LIBRARIES(nccopy netcdf ${ALL_TLL_LIBS})
ADD_EXECUTABLE(bom bom.c)
IF(ENABLE_TESTS)
ADD_EXECUTABLE(rewrite-scalar rewrite-scalar.c bom.c)
ADD_EXECUTABLE(rewrite-scalar rewrite-scalar.c)
TARGET_LINK_LIBRARIES(rewrite-scalar netcdf)
# Base tests
# The tests are set up as a combination of shell scripts and executables that

View File

@ -6,6 +6,7 @@
#include <config.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
/* BOM Sequences */
static char* U8 = "\xEF\xBB\xBF"; /* UTF-8 */
@ -18,7 +19,7 @@ int
main(int argc, char** argv)
{
char* bom = U8;
int bomlen = 3;
size_t bomlen = 3;
if(argc > 1 && strlen(argv[1]) > 0) {
char* which = argv[1];
switch (which[0]) {
@ -30,4 +31,3 @@ main(int argc, char** argv)
fwrite(bom,1,bomlen,stdout);
exit(0);
}

View File

@ -1944,7 +1944,7 @@ main(int argc, char *argv[])
break;
case 'b': /* brief comments in data section */
formatting_specs.brief_data_cmnts = true;
switch (tolower(optarg[0])) {
switch (tolower((int)optarg[0])) {
case 'c':
formatting_specs.data_lang = LANG_C;
break;
@ -1957,7 +1957,7 @@ main(int argc, char *argv[])
break;
case 'f': /* full comments in data section */
formatting_specs.full_data_cmnts = true;
switch (tolower(optarg[0])) {
switch (tolower((int)optarg[0])) {
case 'c':
formatting_specs.data_lang = LANG_C;
break;

View File

@ -45,7 +45,7 @@ if ../ncgen/ncgen -k1 -o tst_bom16.nc tst_bom16.cdl ; then
echo 'BOM Big Endian 16 succeeded, but should not'
exit 1
else
echo '***XFAIL: BOM Big Endian 16'
echo '***XFAIL : BOM Big Endian 16'
fi
# Cleanup

View File

@ -81,14 +81,14 @@ else # Non-MINGW Platforms
diff -b tst_compounds4.cdl $srcdir/ref_tst_compounds4.cdl
# Exercise Jira NCF-213 bug fix
rm -f tst_ncf213.cdl tst_ncf213.nc
# rm -f tst_ncf213.cdl tst_ncf213.nc
../ncgen/ncgen -b -o tst_ncf213.nc $srcdir/ref_tst_ncf213.cdl
./ncdump -s -h tst_ncf213.nc >tst_ncf213.cdl
# Now compare
ok=1;
if diff -b $srcdir/ref_tst_ncf213.cdl tst_ncf213.cdl ; then ok=1; else ok=0; fi
# cleanup
rm -f tst_ncf213.cdl tst_ncf213.nc
# rm -f tst_ncf213.cdl tst_ncf213.nc
if test $ok = 0 ; then
echo "*** FAIL: NCF-213 Bug Fix test"
exit 1

View File

@ -83,8 +83,8 @@ escaped_name(const char* cp) {
*sp++ = '\\';
}
for (; *cp; cp++) {
if (isascii(*cp)) {
if(iscntrl(*cp)) { /* render control chars as two hex digits, \%xx */
if (isascii((int)*cp)) {
if(iscntrl((int)*cp)) { /* render control chars as two hex digits, \%xx */
snprintf(sp, 4,"\\%%%.2x", *cp);
sp += 4;
} else {

View File

@ -173,6 +173,24 @@ gen_netcdf(const char *filename)
}
#ifdef USE_NETCDF4
#if 0
Turn off for now.
static void
genbin_defineglobalspecials(void)
{
int stat = NC_NOERR;
const char* format = NULL;
if(usingclassic) return;
if(!/*Main.*/format_attribute) return;
/* Watch out, this is a global Attribute */
format = kind_string(/*Main.*/format_flag);
stat = nc_put_att_text(rootgroup->ncid,NC_GLOBAL,"_Format",strlen(format),format);
check_err(stat,__LINE__,__FILE__);
}
#endif /*0*/
static void
genbin_definespecialattributes(Symbol* var)
{
@ -356,7 +374,7 @@ genbin_write(Generator* generator, Symbol* sym, Bytebuffer* memory,
else if(sym->objectclass == NC_VAR)
return genbin_writevar(generator,sym,memory,rank,start,count);
else
PANIC("illegal symbol for genc_write");
PANIC("illegal symbol for genbin_write");
return NC_EINVAL;
}

View File

@ -22,6 +22,7 @@ static const char* dimncid(Symbol*);
static void definectype(Symbol*);
static void genc_deftype(Symbol*);
static void genc_definespecialattributes(Symbol* vsym);
static void genc_defineglobalspecials(void);
#endif
static void genc_defineattr(Symbol* asym);
@ -252,6 +253,10 @@ gen_ncc(const char *filename)
codelined(1,"check_err(stat,__LINE__,__FILE__);");
codeflush();
#ifdef USE_NETCDF4
genc_defineglobalspecials();
#endif /*USE_NETCDF4*/
#ifdef USE_NETCDF4
/* Define the group structure */
/* ncid created above is also root group*/
@ -401,6 +406,22 @@ gen_ncc(const char *filename)
}
#ifdef USE_NETCDF4
static void
genc_defineglobalspecials(void)
{
const char* format = NULL;
if(usingclassic) return;
if(!/*Main.*/format_attribute) return;
/* Watch out, this is a global Attribute */
format = kind_string(/*Main.*/format_flag);
bbprintf0(stmt,"%sstat = nc_put_att_text(ncid, NC_GLOBAL, \"_Format\", 1, \"%s\");\n",
indented(1),
format);
codedump(stmt);
codelined(1,"check_err(stat,__LINE__,__FILE__);");
}
static void
genc_definespecialattributes(Symbol* vsym)
{

View File

@ -157,6 +157,7 @@ extern void jflush(void);
/* from: main.c */
extern int format_flag; /* _Format attribute value (same range as -k flag) */
extern int format_attribute; /* 1 if format came from _FORMAT attribute */
extern int enhanced_flag; /* 1 => netcdf-4 constructs appear in the parse */
extern int specials_flag; /* 1 => special attributes are present */
extern int usingclassic; /* 1 => k_flag == 1|2 */

View File

@ -39,6 +39,7 @@ int header_only;
/* flags for tracking what output format to use */
int k_flag; /* > 0 => -k was specified on command line*/
int format_flag; /* _Format attribute value (same range as -k flag) */
int format_attribute; /* 1=>format came from format attribute */
int enhanced_flag; /* 1 => netcdf-4 constructs appear in the parse */
int specials_flag; /* 1=> special attributes are present */
int usingclassic;
@ -192,6 +193,7 @@ main(
k_flag = 0;
format_flag = 0;
format_attribute = 0;
enhanced_flag = 0;
specials_flag = 0;

View File

@ -418,11 +418,13 @@ NIL|nil|Nil {
case -1: token = INT64_CONST; break;
case 1:
/* if value is too big, complain */
/* cannot actually test this.
if(uint64_val > NC_MAX_INT64) {
sprintf(errstr,"32 bit integer constant out of range: %s",(char*)yytext);
sprintf(errstr,"64 bit integer constant out of range: %s",(char*)yytext);
yyerror(errstr);
}
int64_val = (long long)(uint64_val & 0x7fffffffffffffff);
*/
int64_val = (long long)(uint64_val & 0x7fffffffffffffffLL);
token = INT64_CONST;
break;
}

View File

@ -1177,7 +1177,7 @@ makespecial(int tag, Symbol* vsym, Symbol* tsym, void* data, int isconst)
char* sdata = NULL;
int idata = -1;
if(tag == _FORMAT) {
if(tag == _FORMAT_FLAG) {
if(vsym != NULL) {
derror("_Format: must be global attribute");
vsym = NULL;
@ -1189,7 +1189,8 @@ makespecial(int tag, Symbol* vsym, Symbol* tsym, void* data, int isconst)
}
}
specials_flag += (tag == _FILLVALUE_FLAG ? 0 : 1);
if(tag != _FILLVALUE_FLAG && tag != _FORMAT_FLAG)
/*Main.*/specials_flag++;
if(isconst) {
con = (NCConstant*)data;
@ -1234,25 +1235,26 @@ makespecial(int tag, Symbol* vsym, Symbol* tsym, void* data, int isconst)
}
if(tag == _FORMAT_FLAG) {
/* Watch out: this is a global attribute */
struct Kvalues* kvalue;
int found = 0;
/* Use the table in main.c */
for(kvalue = legalkinds; kvalue->name; kvalue++) {
if(strcmp(sdata, kvalue->name) == 0) {
format_flag = kvalue->k_flag;
/*Main.*/format_flag = kvalue->k_flag;
found = 1;
break;
}
}
if(!found)
derror("_Format: illegal value: %s",sdata);
/*Main.*/format_attribute = 1;
} else {
Specialdata* special;
/* Set up special info */
special = &vsym->var.special;
special->flags = 0;
if(tag == _FILLVALUE_FLAG) {
special->_Fillvalue = list;
@ -1272,8 +1274,9 @@ makespecial(int tag, Symbol* vsym, Symbol* tsym, void* data, int isconst)
else if(vsym->typ.basetype != tsym) {
derror("_FillValue attribute type does not match variable type: %s",vsym->name);
}
attr=makeattribute(install("_FillValue"),vsym,tsym,list,ATTRVAR);
attr = makeattribute(install("_FillValue"),vsym,tsym,list,ATTRVAR);
} else switch (tag) {
// These will be output as attributes later
case _STORAGE_FLAG:
if(strcmp(sdata,"contiguous") == 0)
special->_Storage = NC_CONTIGUOUS;
@ -1329,7 +1332,7 @@ makespecial(int tag, Symbol* vsym, Symbol* tsym, void* data, int isconst)
} break;
default: PANIC1("makespecial: illegal token: %d",tag);
}
}
return attr;
}

View File

@ -3150,15 +3150,25 @@ makespecial(int tag, Symbol* vsym, Symbol* tsym, void* data, int isconst)
Symbol* attr = NULL;
Datalist* list;
NCConstant* con;
Specialdata* special = (Specialdata*)malloc(sizeof(Specialdata));
NCConstant iconst;
int tf = 0;
char* sdata = NULL;
int idata = -1;
special->flags = 0;
if(tag == _FORMAT_FLAG) {
if(vsym != NULL) {
derror("_Format: must be global attribute");
vsym = NULL;
}
} else {
if(vsym == NULL) {
derror("%s: must have non-NULL vsym", specialname(tag));
return NULL;
}
}
specials_flag += (tag == _FILLVALUE_FLAG ? 0 : 1);
if(tag != _FILLVALUE_FLAG && tag != _FORMAT_FLAG)
/*Main.*/specials_flag++;
if(isconst) {
con = (NCConstant*)data;
@ -3169,11 +3179,6 @@ makespecial(int tag, Symbol* vsym, Symbol* tsym, void* data, int isconst)
con = (NCConstant*)list->data;
}
if(tag == _FORMAT && vsym != NULL) {
derror("_Format: must be global attribute");
vsym = NULL;
}
switch (tag) {
case _FLETCHER32_FLAG:
case _SHUFFLE_FLAG:
@ -3207,95 +3212,105 @@ makespecial(int tag, Symbol* vsym, Symbol* tsym, void* data, int isconst)
default: PANIC1("unexpected special tag: %d",tag);
}
if(vsym != NULL) special = &vsym->var.special;
if(tag == _FORMAT_FLAG) {
/* Watch out: this is a global attribute */
struct Kvalues* kvalue;
int found;
found = 0;
int found = 0;
/* Use the table in main.c */
for(kvalue=legalkinds;kvalue->name;kvalue++) {
if(strcmp(sdata,kvalue->name) == 0) {
format_flag = kvalue->k_flag;
for(kvalue = legalkinds; kvalue->name; kvalue++) {
if(strcmp(sdata, kvalue->name) == 0) {
/*Main.*/format_flag = kvalue->k_flag;
found = 1;
break;
}
}
if(!found)
derror("_Format: illegal value: %s",sdata);
} else if(tag == _FILLVALUE_FLAG) {
special->_Fillvalue = list;
/* fillvalue must be a single value*/
if(list->length != 1)
derror("_FillValue: must be a single (possibly compound) value",
vsym->name);
/* check that the attribute value contains no fill values*/
if(containsfills(list)) {
derror("Attribute data may not contain fill values (i.e. _ )");
}
/* _FillValue is also a real attribute*/
if(vsym->objectclass != NC_VAR) {
derror("_FillValue attribute not associated with variable: %s",vsym->name);
}
if(tsym == NULL) tsym = vsym->typ.basetype;
else if(vsym->typ.basetype != tsym) {
derror("_FillValue attribute type does not match variable type: %s",vsym->name);
}
attr=makeattribute(install("_FillValue"),vsym,tsym,list,ATTRVAR);
} else switch (tag) {
case _STORAGE_FLAG:
if(strcmp(sdata,"contiguous") == 0)
special->_Storage = NC_CONTIGUOUS;
else if(strcmp(sdata,"chunked") == 0)
special->_Storage = NC_CHUNKED;
else
derror("_Storage: illegal value: %s",sdata);
special->flags |= _STORAGE_FLAG;
break;
case _FLETCHER32_FLAG:
special->_Fletcher32 = tf;
special->flags |= _FLETCHER32_FLAG;
break;
case _DEFLATE_FLAG:
special->_DeflateLevel = idata;
special->flags |= _DEFLATE_FLAG;
break;
case _SHUFFLE_FLAG:
special->_Shuffle = tf;
special->flags |= _SHUFFLE_FLAG;
break;
case _ENDIAN_FLAG:
if(strcmp(sdata,"little") == 0)
special->_Endianness = 1;
else if(strcmp(sdata,"big") == 0)
special->_Endianness = 2;
else
derror("_Endianness: illegal value: %s",sdata);
special->flags |= _ENDIAN_FLAG;
break;
case _NOFILL_FLAG:
special->_Fill = (1 - tf); /* negate */
special->flags |= _NOFILL_FLAG;
break;
case _CHUNKSIZES_FLAG: {
int i;
special->nchunks = list->length;
special->_ChunkSizes = (size_t*)emalloc(sizeof(size_t)*special->nchunks);
for(i=0;i<special->nchunks;i++) {
iconst.nctype = NC_INT;
convert1(&list->data[i],&iconst);
if(iconst.nctype == NC_INT) {
special->_ChunkSizes[i] = (size_t)iconst.value.int32v;
} else
derror("%s: illegal value",specialname(tag));
}
special->flags |= _CHUNKSIZES_FLAG;
/* Chunksizes => storage == chunked */
special->flags |= _STORAGE_FLAG;
special->_Storage = NC_CHUNKED;
} break;
default: PANIC1("makespecial: illegal token: %d",tag);
}
/*Main.*/format_attribute = 1;
} else {
Specialdata* special;
/* Set up special info */
special = &vsym->var.special;
if(tag == _FILLVALUE_FLAG) {
special->_Fillvalue = list;
/* fillvalue must be a single value*/
if(list->length != 1)
derror("_FillValue: must be a single (possibly compound) value",
vsym->name);
/* check that the attribute value contains no fill values*/
if(containsfills(list)) {
derror("Attribute data may not contain fill values (i.e. _ )");
}
/* _FillValue is also a real attribute*/
if(vsym->objectclass != NC_VAR) {
derror("_FillValue attribute not associated with variable: %s",vsym->name);
}
if(tsym == NULL) tsym = vsym->typ.basetype;
else if(vsym->typ.basetype != tsym) {
derror("_FillValue attribute type does not match variable type: %s",vsym->name);
}
attr = makeattribute(install("_FillValue"),vsym,tsym,list,ATTRVAR);
} else switch (tag) {
// These will be output as attributes later
case _STORAGE_FLAG:
if(strcmp(sdata,"contiguous") == 0)
special->_Storage = NC_CONTIGUOUS;
else if(strcmp(sdata,"chunked") == 0)
special->_Storage = NC_CHUNKED;
else
derror("_Storage: illegal value: %s",sdata);
special->flags |= _STORAGE_FLAG;
break;
case _FLETCHER32_FLAG:
special->_Fletcher32 = tf;
special->flags |= _FLETCHER32_FLAG;
break;
case _DEFLATE_FLAG:
special->_DeflateLevel = idata;
special->flags |= _DEFLATE_FLAG;
break;
case _SHUFFLE_FLAG:
special->_Shuffle = tf;
special->flags |= _SHUFFLE_FLAG;
break;
case _ENDIAN_FLAG:
if(strcmp(sdata,"little") == 0)
special->_Endianness = 1;
else if(strcmp(sdata,"big") == 0)
special->_Endianness = 2;
else
derror("_Endianness: illegal value: %s",sdata);
special->flags |= _ENDIAN_FLAG;
break;
case _NOFILL_FLAG:
special->_Fill = (1 - tf); /* negate */
special->flags |= _NOFILL_FLAG;
break;
case _CHUNKSIZES_FLAG: {
int i;
special->nchunks = list->length;
special->_ChunkSizes = (size_t*)emalloc(sizeof(size_t)*special->nchunks);
for(i=0;i<special->nchunks;i++) {
iconst.nctype = NC_INT;
convert1(&list->data[i],&iconst);
if(iconst.nctype == NC_INT) {
special->_ChunkSizes[i] = (size_t)iconst.value.int32v;
} else {
efree(special->_ChunkSizes);
derror("%s: illegal value",specialname(tag));
}
}
special->flags |= _CHUNKSIZES_FLAG;
/* Chunksizes => storage == chunked */
special->flags |= _STORAGE_FLAG;
special->_Storage = NC_CHUNKED;
} break;
default: PANIC1("makespecial: illegal token: %d",tag);
}
}
return attr;
}
@ -3381,11 +3396,10 @@ be returned.
static NCConstant
evaluate(Symbol* fcn, Datalist* arglist)
{
NCConstant result;
NCConstant result = nullconstant;
/* prepare the result */
result.lineno = fcn->lineno;
result.filled = 0;
if(strcasecmp(fcn->name,"time") == 0) {
char* timekind = NULL;

View File

@ -1325,7 +1325,7 @@ static int input (void );
/* This used to be an fputs(), but since the string might contain NUL's,
* we now use fwrite().
*/
#define ECHO do { if (fwrite( ncgtext, ncgleng, 1, ncgout )) {} } while (0)
#define ECHO fwrite( ncgtext, ncgleng, 1, ncgout )
#endif
/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
@ -1336,7 +1336,7 @@ static int input (void );
if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
{ \
int c = '*'; \
unsigned n; \
int n; \
for ( n = 0; n < max_size && \
(c = getc( ncgin )) != EOF && c != '\n'; ++n ) \
buf[n] = (char) c; \
@ -1829,12 +1829,14 @@ YY_RULE_SETUP
int32_val = (int)uint64_val;
return lexdebug(INT_CONST);
#endif
default:
yyerror("Unknown integer size");
}
}
YY_BREAK
case 36:
YY_RULE_SETUP
#line 375 "ncgen.l"
#line 377 "ncgen.l"
{ /* The number may be signed or unsigned (signed has priority) */
int slen = strlen(ncgtext);
int tag = ncgtext[slen-1];
@ -1879,11 +1881,13 @@ YY_RULE_SETUP
case -1: token = INT64_CONST; break;
case 1:
/* if value is too big, complain */
/* cannot actually test this.
if(uint64_val > NC_MAX_INT64) {
sprintf(errstr,"32 bit integer constant out of range: %s",(char*)ncgtext);
sprintf(errstr,"64 bit integer constant out of range: %s",(char*)ncgtext);
yyerror(errstr);
}
int64_val = (long long)(uint64_val & 0x7fffffffffffffff);
*/
int64_val = (long long)(uint64_val & 0x7fffffffffffffffLL);
token = INT64_CONST;
break;
}
@ -1897,7 +1901,7 @@ YY_RULE_SETUP
YY_BREAK
case 37:
YY_RULE_SETUP
#line 435 "ncgen.l"
#line 439 "ncgen.l"
{
int slen = strlen(ncgtext);
int tag = ncgtext[slen-1];
@ -1940,7 +1944,7 @@ YY_RULE_SETUP
YY_BREAK
case 38:
YY_RULE_SETUP
#line 474 "ncgen.l"
#line 478 "ncgen.l"
{
int c;
int token = 0;
@ -1978,7 +1982,7 @@ YY_RULE_SETUP
YY_BREAK
case 39:
YY_RULE_SETUP
#line 508 "ncgen.l"
#line 512 "ncgen.l"
{
if (sscanf((char*)ncgtext, "%le", &double_val) != 1) {
sprintf(errstr,"bad long or double constant: %s",(char*)ncgtext);
@ -1989,7 +1993,7 @@ YY_RULE_SETUP
YY_BREAK
case 40:
YY_RULE_SETUP
#line 515 "ncgen.l"
#line 519 "ncgen.l"
{
if (sscanf((char*)ncgtext, "%e", &float_val) != 1) {
sprintf(errstr,"bad float constant: %s",(char*)ncgtext);
@ -2001,7 +2005,7 @@ YY_RULE_SETUP
case 41:
/* rule 41 can match eol */
YY_RULE_SETUP
#line 522 "ncgen.l"
#line 526 "ncgen.l"
{
(void) sscanf((char*)&ncgtext[1],"%c",&byte_val);
return lexdebug(BYTE_CONST);
@ -2009,7 +2013,7 @@ YY_RULE_SETUP
YY_BREAK
case 42:
YY_RULE_SETUP
#line 526 "ncgen.l"
#line 530 "ncgen.l"
{
int oct = unescapeoct(&ncgtext[2]);
if(oct < 0) {
@ -2022,7 +2026,7 @@ YY_RULE_SETUP
YY_BREAK
case 43:
YY_RULE_SETUP
#line 535 "ncgen.l"
#line 539 "ncgen.l"
{
int hex = unescapehex(&ncgtext[3]);
if(byte_val < 0) {
@ -2035,7 +2039,7 @@ YY_RULE_SETUP
YY_BREAK
case 44:
YY_RULE_SETUP
#line 544 "ncgen.l"
#line 548 "ncgen.l"
{
switch ((char)ncgtext[2]) {
case 'a': byte_val = '\007'; break; /* not everyone under-
@ -2057,7 +2061,7 @@ YY_RULE_SETUP
case 45:
/* rule 45 can match eol */
YY_RULE_SETUP
#line 562 "ncgen.l"
#line 566 "ncgen.l"
{
lineno++ ;
break;
@ -2065,7 +2069,7 @@ YY_RULE_SETUP
YY_BREAK
case 46:
YY_RULE_SETUP
#line 567 "ncgen.l"
#line 571 "ncgen.l"
{/*initial*/
BEGIN(ST_C_COMMENT);
break;
@ -2074,21 +2078,21 @@ YY_RULE_SETUP
case 47:
/* rule 47 can match eol */
YY_RULE_SETUP
#line 572 "ncgen.l"
#line 576 "ncgen.l"
{/* continuation */
break;
}
YY_BREAK
case 48:
YY_RULE_SETUP
#line 576 "ncgen.l"
#line 580 "ncgen.l"
{/* final */
BEGIN(INITIAL);
break;
}
YY_BREAK
case YY_STATE_EOF(ST_C_COMMENT):
#line 581 "ncgen.l"
#line 585 "ncgen.l"
{/* final, error */
fprintf(stderr,"unterminated /**/ comment");
BEGIN(INITIAL);
@ -2097,17 +2101,17 @@ case YY_STATE_EOF(ST_C_COMMENT):
YY_BREAK
case 49:
YY_RULE_SETUP
#line 587 "ncgen.l"
#line 591 "ncgen.l"
{/* Note: this next rule will not work for UTF8 characters */
return lexdebug(ncgtext[0]) ;
}
YY_BREAK
case 50:
YY_RULE_SETUP
#line 590 "ncgen.l"
#line 594 "ncgen.l"
ECHO;
YY_BREAK
#line 2111 "ncgenyy.c"
#line 2115 "ncgenyy.c"
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(TEXT):
yyterminate();
@ -3106,7 +3110,7 @@ void ncgfree (void * ptr )
#define YYTABLES_NAME "yytables"
#line 590 "ncgen.l"
#line 594 "ncgen.l"
static int

View File

@ -654,4 +654,19 @@ findlastunlimited(Dimset* dimset)
return -1;
}
/* Return standard format string */
const char *
kind_string(int kind)
{
static char text[1024];
switch (kind) {
case 1: return "classic";
case 2: return "64-bit offset";
case 3: return "netCDF-4";
case 4: return "netCDF-4 classic model";
default:
derror("Unknown format index: %d\n",kind);
}
return NULL;
}

View File

@ -58,5 +58,6 @@ extern NCConstant builddatasublist(Datalist* dl);
extern void dlextend(Datalist* dl);
extern void dlsetalloc(Datalist* dl, size_t newalloc);
extern void check_err(const int stat, const int line, const char* file);
extern const char* kind_string(int kind);
#endif /*NCGEN_UTIL_H*/

View File

@ -250,7 +250,7 @@ daplex(YYSTYPE* lvalp, DAPparsestate* state)
static void
dapaddyytext(DAPlexstate* lex, int c)
{
ocbytesappend(lex->yytext,(char)c);
ocbytesappend(lex->yytext,c);
}
#ifndef DAP2ENCODE

View File

@ -215,8 +215,8 @@ isglobalname(const char* name)
static int
isdodsname(const char* name)
{
int len = strlen(name);
int glen = strlen("DODS");
size_t len = strlen(name);
size_t glen = strlen("DODS");
if(len < glen) return 0;
if(ocstrncmp(name,"DODS",glen) != 0)
return 0;
@ -337,7 +337,7 @@ addedges(OCnode* node)
static void
setroot(OCnode* root, OClist* ocnodes)
{
int i;
size_t i;
for(i=0;i<oclistlength(ocnodes);i++) {
OCnode* node = (OCnode*)oclistget(ocnodes,i);
node->root = root;
@ -359,7 +359,7 @@ dapsemanticerror(DAPparsestate* state, OCerror err, const char* msg)
}
static char*
flatten(char* s, char* tmp, int tlen)
flatten(char* s, char* tmp, size_t tlen)
{
int c;
char* p,*q;

View File

@ -697,7 +697,7 @@ oc_dds_dimensionsizes(OCobject link, OCobject ddsnode, size_t* dimsizes)
if(node->array.rank == 0) return OCTHROW(OCTHROW(OC_ESCALAR));
if(dimsizes != NULL) {
int i;
size_t i;
for(i=0;i<node->array.rank;i++) {
OCnode* dim = (OCnode*)oclistget(node->array.dimensions,i);
dimsizes[i] = dim->dim.declsize;
@ -1654,7 +1654,7 @@ Non-atomic types (e.g. OC_Structure) return zero.
size_t
oc_typesize(OCtype etype)
{
return OCTHROW(octypesize(etype));
return octypesize(etype);
}
/*!

View File

@ -42,7 +42,7 @@ ocbytesnew(void)
}
int
ocbytessetalloc(OCbytes* bb, unsigned long sz)
ocbytessetalloc(OCbytes* bb, size_t sz)
{
char* newcontent;
if(bb == NULL) return ocbytesfail();
@ -69,7 +69,7 @@ ocbytesfree(OCbytes* bb)
}
int
ocbytessetlength(OCbytes* bb, unsigned long sz)
ocbytessetlength(OCbytes* bb, size_t sz)
{
if(bb == NULL) return ocbytesfail();
if(bb->length < sz) {
@ -82,14 +82,14 @@ ocbytessetlength(OCbytes* bb, unsigned long sz)
int
ocbytesfill(OCbytes* bb, char fill)
{
unsigned long i;
size_t i;
if(bb == NULL) return ocbytesfail();
for(i=0;i<bb->length;i++) bb->content[i] = fill;
return TRUE;
}
int
ocbytesget(OCbytes* bb, unsigned long index)
ocbytesget(OCbytes* bb, size_t index)
{
if(bb == NULL) return -1;
if(index >= bb->length) return -1;
@ -97,7 +97,7 @@ ocbytesget(OCbytes* bb, unsigned long index)
}
int
ocbytesset(OCbytes* bb, unsigned long index, char elem)
ocbytesset(OCbytes* bb, size_t index, char elem)
{
if(bb == NULL) return ocbytesfail();
if(index >= bb->length) return ocbytesfail();
@ -106,14 +106,14 @@ ocbytesset(OCbytes* bb, unsigned long index, char elem)
}
int
ocbytesappend(OCbytes* bb, char elem)
ocbytesappend(OCbytes* bb, int elem)
{
if(bb == NULL) return ocbytesfail();
/* We need space for the char + null */
while(bb->length+1 >= bb->alloc) {
if(!ocbytessetalloc(bb,0)) return ocbytesfail();
}
bb->content[bb->length] = elem;
bb->content[bb->length] = (char)elem;
bb->length++;
bb->content[bb->length] = '\0';
return TRUE;
@ -131,7 +131,7 @@ ocbytescat(OCbytes* bb, const char* s)
}
int
ocbytesappendn(OCbytes* bb, const void* elem, unsigned long n)
ocbytesappendn(OCbytes* bb, const void* elem, size_t n)
{
if(bb == NULL || elem == NULL) return ocbytesfail();
if(n == 0) {n = strlen((char*)elem);}
@ -177,7 +177,7 @@ ocbytesextract(OCbytes* bb)
}
int
ocbytessetcontents(OCbytes* bb, char* contents, unsigned long alloc)
ocbytessetcontents(OCbytes* bb, char* contents, size_t alloc)
{
if(bb == NULL) return ocbytesfail();
ocbytesclear(bb);

View File

@ -6,8 +6,8 @@
typedef struct OCbytes {
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;
} OCbytes;
@ -19,8 +19,8 @@ typedef struct OCbytes {
EXTERNC OCbytes* ocbytesnew(void);
EXTERNC void ocbytesfree(OCbytes*);
EXTERNC int ocbytessetalloc(OCbytes*,unsigned long);
EXTERNC int ocbytessetlength(OCbytes*,unsigned long);
EXTERNC int ocbytessetalloc(OCbytes*,size_t);
EXTERNC int ocbytessetlength(OCbytes*,size_t);
EXTERNC int ocbytesfill(OCbytes*, char fill);
/* Produce a duplicate of the contents*/
@ -29,14 +29,14 @@ EXTERNC char* ocbytesdup(OCbytes*);
EXTERNC char* ocbytesextract(OCbytes*);
/* Return the ith byte; -1 if no such index */
EXTERNC int ocbytesget(OCbytes*,unsigned long);
EXTERNC int ocbytesget(OCbytes*,size_t);
/* Set the ith byte */
EXTERNC int ocbytesset(OCbytes*,unsigned long,char);
EXTERNC int ocbytesset(OCbytes*,size_t,char);
/* Append one byte */
EXTERNC int ocbytesappend(OCbytes*,char); /* Add at Tail */
EXTERNC int ocbytesappend(OCbytes*,int); /* Add at Tail */
/* Append n bytes */
EXTERNC int ocbytesappendn(OCbytes*,const void*,unsigned long); /* Add at Tail */
EXTERNC int ocbytesappendn(OCbytes*,const void*,size_t); /* Add at Tail */
/* Null terminate the byte string without extending its length (for debugging) */
EXTERNC int ocbytesnull(OCbytes*);
@ -45,7 +45,7 @@ EXTERNC int ocbytesnull(OCbytes*);
EXTERNC int ocbytescat(OCbytes*,const char*);
/* Set the contents of the buffer; mark the buffer as non-extendible */
EXTERNC int ocbytessetcontents(OCbytes*, char*, unsigned long);
EXTERNC int ocbytessetcontents(OCbytes*, char*, size_t);
/* Following are always "in-lined"*/
#define ocbyteslength(bb) ((bb)!=NULL?(bb)->length:0)

View File

@ -74,7 +74,7 @@ static OCerror
occompile1(OCstate* state, OCnode* xnode, XXDR* xxdrs, OCdata** datap)
{
OCerror ocstat = OC_NOERR;
int i;
size_t i;
OCdata* data = NULL;
size_t nelements = 0;
OClist* records = NULL;
@ -144,7 +144,7 @@ occompile1(OCstate* state, OCnode* xnode, XXDR* xxdrs, OCdata** datap)
/* pick up the sequence record begin marker*/
char tmp[sizeof(unsigned int)];
/* extract the tag byte*/
if(!xxdr_opaque(xxdrs,tmp,sizeof(tmp)))
if(!xxdr_opaque(xxdrs,tmp,(off_t)sizeof(tmp)))
{ocstat = OC_EXDR; goto fail;}
if(tmp[0] == StartOfSequence) {
/* Allocate a record instance */
@ -224,7 +224,7 @@ occompilerecord(OCstate* state, OCnode* xnode, XXDR* xxdrs, OCdata** recordp)
static OCerror
occompilefields(OCstate* state, OCdata* data, XXDR* xxdrs, int istoplevel)
{
int i;
size_t i;
OCerror ocstat = OC_NOERR;
size_t nelements;
OCnode* xnode = data->template;
@ -276,7 +276,7 @@ occompileatomic(OCstate* state, OCdata* data, XXDR* xxdrs)
{
OCerror ocstat = OC_NOERR;
int i;
size_t nelements,xdrsize;
off_t nelements,xdrsize;
unsigned int xxdrcount;
OCnode* xnode = data->template;
int scalar = (xnode->array.rank == 0);
@ -333,12 +333,14 @@ occompileatomic(OCstate* state, OCdata* data, XXDR* xxdrs)
/* We need to walk each string, get size, then skip */
for(i=0;i<data->nstrings;i++) {
unsigned int len;
off_t lenz;
data->strings[i] = xxdr_getpos(xxdrs);
/* get exact string length */
if(!xxdr_uint(xxdrs,&len)) {ocstat = OC_EXDR; goto fail;}
len = RNDUP(len);
lenz = (off_t)len;
lenz = RNDUP(lenz);
/* Skip the data */
xxdr_skip(xxdrs,len);
xxdr_skip(xxdrs,lenz);
}
break;
@ -435,8 +437,8 @@ ocerrorstring(XXDR* xdrs)
{
/* Check to see if the xdrs contains "Error {\n'; assume it is at the beginning of data */
off_t avail = xxdr_getavail(xdrs);
char* data = (char*)malloc(avail);
if(!xxdr_setpos(xdrs,0)) return 0;
char* data = (char*)malloc((size_t)avail);
if(!xxdr_setpos(xdrs,(off_t)0)) return 0;
if(!xxdr_opaque(xdrs,data,avail)) return 0;
/* check for error tag at front */
if(ocstrncmp(data,tag,sizeof(tag))==0) {

View File

@ -195,7 +195,10 @@ ocdata_position(OCstate* state, OCdata* data, size_t* indices)
indices[0] = data->index;
else if(fisset(data->datamode,OCDT_ELEMENT)) {
/* Transform the linearized array index into a set of indices */
ocarrayindices(data->index,template->array.rank,template->array.sizes,indices);
ocarrayindices(data->index,
template->array.rank,
template->array.sizes,
indices);
} else
return OCTHROW(OC_EBADTYPE);
return OCTHROW(OC_NOERR);
@ -363,7 +366,7 @@ ocread(OCdata* data, XXDR* xdrs, char* memory, size_t memsize, size_t start, siz
unsigned short* sp = (unsigned short*)memory;
for(i=0;i<count;i++,sp++) {
unsigned int tmp;
if(!xxdr_getbytes(xdrs,(char*)&tmp,XDRUNIT))
if(!xxdr_getbytes(xdrs,(char*)&tmp,(off_t)XDRUNIT))
{OCTHROW(OC_EDATADDS); goto xdrfail;}
/* convert from network order if necessary */
if(!xxdr_network_order)
@ -398,7 +401,7 @@ ocread(OCdata* data, XXDR* xdrs, char* memory, size_t memsize, size_t start, siz
return OCTHROW(OC_EDATADDS);
for(i=0;i<count;i++,sp++) {
off_t len;
size_t offset = data->strings[start+i];
off_t offset = data->strings[start+i];
xxdr_setpos(xdrs,offset);
/* get the string */
if(!xxdr_string(xdrs,sp,&len))

View File

@ -23,7 +23,7 @@ struct OCdata {
OCdata** instances; /* vector of instances; if rank > 0, then
it captures the array elements, else
it captures the field instances. */
off_t nstrings;
size_t nstrings;
off_t* strings;
};

View File

@ -75,12 +75,12 @@ extern void ocfree(void*);
#define MEMGOTO(var,label) {if((var)==NULL) goto label;}
#ifdef OCCATCHERROR
extern int ocbreakpoint(int err);
extern int octhrow(int err);
/* Place breakpoint on ocbreakpoint to catch errors close to where they occur*/
#define OCTHROW(e) octhrow(e)
#define OCTHROWCHK(e) (void)octhrow(e)
#define OCGOTO(label) {ocbreakpoint(-1); goto label;}
extern int ocbreakpoint(int err);
extern int octhrow(int err);
#else
#define OCTHROW(e) (e)
#define OCTHROWCHK(e)

View File

@ -54,7 +54,7 @@ tabto(int pos, OCbytes* buffer)
len = ocbyteslength(buffer);
/* find preceding newline */
for(bol=len-1;;bol--) {
int c = ocbytesget(buffer,bol);
int c = ocbytesget(buffer,(size_t)bol);
if(c < 0) break;
if(c == '\n') {bol++; break;}
}
@ -172,7 +172,7 @@ dumpocnode1(OCnode* node, int depth)
if(att->nvalues == 1) {
dumpattvalue(att->etype,att->values,0);
} else {
unsigned int j;
int j;
fprintf(stdout,"{");
for(j=0;j<att->nvalues;j++) {
if(j>0) fprintf(stdout,", ");
@ -252,7 +252,7 @@ addfield(char* field, char* line, int align)
}
static void
dumpfield(int index, char* n8, int isxdr)
dumpfield(size_t index, char* n8, int isxdr)
{
char line[1024];
char tmp[32];
@ -315,7 +315,7 @@ dumpfield(int index, char* n8, int isxdr)
addfield(tmp,line,16);
/* double */
memcpy(dform.cv,n8,2*XDRUNIT);
memcpy(dform.cv,n8,(size_t)(2*XDRUNIT));
if(isxdr) xxdrntohdouble(dform.cv,&dform.d);
sprintf(tmp,"%#g",dform.d);
addfield(tmp,line,12);
@ -419,17 +419,17 @@ ocdumpmemory(char* memory, size_t len, int xdrencoded, int level)
}
static int
ocreadfile(FILE* file, int datastart, char** memp, size_t* lenp)
ocreadfile(FILE* file, off_t datastart, char** memp, size_t* lenp)
{
char* mem;
size_t len;
size_t red;
long red;
struct stat stats;
ssize_t pos;
long pos;
pos = ftell(file);
fseek(file,0,SEEK_SET);
fseek(file,datastart,SEEK_SET);
fseek(file,(long)datastart,SEEK_SET);
fstat(fileno(file),&stats);
len = stats.st_size;
@ -456,7 +456,10 @@ ocdd(OCstate* state, OCnode* root, int xdrencoded, int level)
char* mem;
size_t len;
if(root->tree->data.file != NULL) {
if(!ocreadfile(root->tree->data.file,root->tree->data.bod,&mem,&len)) {
if(!ocreadfile(root->tree->data.file,
root->tree->data.bod,
&mem,
&len)) {
fprintf(stderr,"ocdd could not read data file\n");
return;
}

View File

@ -499,7 +499,7 @@ fprintf(stderr,"missing bod: ddslen=%lu bod=%lu\n",
} else
tree->text = NULL;
/* reset the position of the tmp file*/
fseek(tree->data.file,tree->data.bod,SEEK_SET);
fseek(tree->data.file,(long)tree->data.bod,SEEK_SET);
if(tree->text == NULL) stat = OC_EDATADDS;
return OCTHROW(stat);
}
@ -655,7 +655,8 @@ dataError(XXDR* xdrs, OCstate* state)
{
int depth=0;
int errfound = 0;
off_t ckp=0,avail=0,i=0;
off_t ckp=0,avail=0;
int i=0;
char* errmsg = NULL;
char errortext[16]; /* bigger thant |ERROR_TAG|*/
avail = xxdr_getavail(xdrs);
@ -670,17 +671,17 @@ dataError(XXDR* xdrs, OCstate* state)
/* Try to locate the whole error body */
xxdr_setpos(xdrs,ckp);
for(depth=0,i=0;i<avail;i++) {
xxdr_getbytes(xdrs,errortext,1);
xxdr_getbytes(xdrs,errortext,(off_t)1);
if(errortext[0] == CLBRACE) depth++;
else if(errortext[0] == CRBRACE) {
depth--;
if(depth == 0) {i++; break;}
}
}
errmsg = (char*)malloc(i+1);
errmsg = (char*)malloc((size_t)i+1);
if(errmsg == NULL) {errfound = 1; goto done;}
xxdr_setpos(xdrs,ckp);
xxdr_getbytes(xdrs,errmsg,i);
xxdr_getbytes(xdrs,errmsg,(off_t)i);
errmsg[i] = '\0';
state->error.message = errmsg;
state->error.code = strdup("?");

View File

@ -48,7 +48,7 @@ oclistfree(OClist* l)
}
int
oclistsetalloc(OClist* l, unsigned long sz)
oclistsetalloc(OClist* l, size_t sz)
{
void** newcontent;
if(l == NULL) return FALSE;
@ -65,7 +65,7 @@ oclistsetalloc(OClist* l, unsigned long sz)
}
int
oclistsetlength(OClist* l, unsigned long sz)
oclistsetlength(OClist* l, size_t sz)
{
if(l == NULL) return FALSE;
if(sz > l->alloc && !oclistsetalloc(l,sz)) return FALSE;
@ -74,7 +74,7 @@ oclistsetlength(OClist* l, unsigned long sz)
}
void*
oclistget(OClist* l, unsigned long index)
oclistget(OClist* l, size_t index)
{
if(l == NULL || l->length == 0) return NULL;
if(index >= l->length) return NULL;
@ -82,7 +82,7 @@ oclistget(OClist* l, unsigned long index)
}
int
oclistset(OClist* l, unsigned long index, void* elem)
oclistset(OClist* l, size_t index, void* elem)
{
if(l == NULL) return FALSE;
if(index >= l->length) return FALSE;
@ -92,7 +92,7 @@ oclistset(OClist* l, unsigned long index, void* elem)
/* Insert at position i of l; will push up elements i..|seq|. */
int
oclistinsert(OClist* l, unsigned long index, void* elem)
oclistinsert(OClist* l, size_t index, void* elem)
{
int i; /* do not make unsigned */
if(l == NULL) return FALSE;
@ -130,9 +130,9 @@ oclisttop(OClist* l)
}
void*
oclistremove(OClist* l, unsigned long i)
oclistremove(OClist* l, size_t i)
{
unsigned long len;
size_t len;
void* elem;
if(l == NULL || (len=l->length) == 0) return NULL;
if(i >= len) return NULL;
@ -155,7 +155,7 @@ oclistdup(OClist* l)
int
oclistcontains(OClist* l, void* elem)
{
unsigned long i;
size_t i;
for(i=0;i<oclistlength(l);i++) {
if(elem == oclistget(l,i)) return 1;
}
@ -166,8 +166,8 @@ oclistcontains(OClist* l, void* elem)
int
oclistelemremove(OClist* l, void* elem)
{
unsigned long len;
unsigned long i;
size_t len;
size_t i;
int found = 0;
if(l == NULL || (len=l->length) == 0) return 0;
for(i=0;i<oclistlength(l);i++) {
@ -193,7 +193,7 @@ oclistelemremove(OClist* l, void* elem)
int
oclistunique(OClist* l)
{
unsigned long i,j,k,len;
size_t i,j,k,len;
void** content;
if(l == NULL || l->length == 0) return 1;
len = l->length;

View File

@ -14,24 +14,24 @@
EXTERNC int oclistnull(void*);
typedef struct OClist {
unsigned long alloc;
unsigned long length;
size_t alloc;
size_t length;
void** content;
} OClist;
EXTERNC OClist* oclistnew(void);
EXTERNC int oclistfree(OClist*);
EXTERNC int oclistsetalloc(OClist*,unsigned long);
EXTERNC int oclistsetlength(OClist*,unsigned long);
EXTERNC int oclistsetalloc(OClist*,size_t);
EXTERNC int oclistsetlength(OClist*,size_t);
/* Set the ith element */
EXTERNC int oclistset(OClist*,unsigned long,void*);
EXTERNC int oclistset(OClist*,size_t,void*);
/* Get value at position i */
EXTERNC void* oclistget(OClist*,unsigned long);/* Return the ith element of l */
EXTERNC void* oclistget(OClist*,size_t);/* Return the ith element of l */
/* Insert at position i; will push up elements i..|seq|. */
EXTERNC int oclistinsert(OClist*,unsigned long,void*);
EXTERNC int oclistinsert(OClist*,size_t,void*);
/* Remove element at position i; will move higher elements down */
EXTERNC void* oclistremove(OClist* l, unsigned long i);
EXTERNC void* oclistremove(OClist* l, size_t i);
/* Tail operations */
EXTERNC int oclistpush(OClist*,void*); /* Add at Tail */

View File

@ -80,17 +80,17 @@ pathtostring(OClist* path, char* separator, int usecdfname)
char* pathname;
if(path == NULL || (len = oclistlength(path))==0) return NULL;
for(slen=0,i=0;i<len;i++) {
OCnode* node = (OCnode*)oclistget(path,i);
OCnode* node = (OCnode*)oclistget(path,(size_t)i);
if(node->container == NULL || node->name == NULL) continue;
slen += strlen(node->name);
}
slen += ((len-1)*strlen(separator));
slen += 1; /* for null terminator*/
pathname = (char*)ocmalloc(slen);
pathname = (char*)ocmalloc((size_t)slen);
MEMCHECK(pathname,NULL);
pathname[0] = '\0';
for(i=0;i<len;i++) {
OCnode* node = (OCnode*)oclistget(path,i);
OCnode* node = (OCnode*)oclistget(path,(size_t)i);
if(node->container == NULL || node->name == NULL) continue;
if(strlen(pathname) > 0) strcat(pathname,separator);
strcat(pathname,node->name);
@ -135,7 +135,7 @@ makeattribute(char* name, OCtype ptype, OClist* values)
int i;
att->values = (char**)ocmalloc(sizeof(char*)*att->nvalues);
for(i=0;i<att->nvalues;i++)
att->values[i] = nulldup((char*)oclistget(values,i));
att->values[i] = nulldup((char*)oclistget(values,(size_t)i));
}
return att;
}
@ -163,9 +163,9 @@ ocroot_free(OCnode* root)
ocdata_free(state,tree->data.data);
for(i=0;i<oclistlength(state->trees);i++) {
OCnode* node = (OCnode*)oclistget(state->trees,i);
OCnode* node = (OCnode*)oclistget(state->trees,(size_t)i);
if(root == node)
oclistremove(state->trees,i);
oclistremove(state->trees,(size_t)i);
}
/* Note: it is ok if state->trees does not contain this root */
octree_free(tree);
@ -529,9 +529,9 @@ occorrelater(OCnode* dds, OCnode* dxd)
case OC_Sequence:
/* Remember: there may be fewer datadds fields than dds fields */
for(i=0;i<oclistlength(dxd->subnodes);i++) {
OCnode* dxd1 = (OCnode*)oclistget(dxd->subnodes,i);
OCnode* dxd1 = (OCnode*)oclistget(dxd->subnodes,(size_t)i);
for(j=0;j<oclistlength(dds->subnodes);j++) {
OCnode* dds1 = (OCnode*)oclistget(dds->subnodes,j);
OCnode* dds1 = (OCnode*)oclistget(dds->subnodes,(size_t)j);
if(strcmp(dxd1->name,dds1->name) == 0) {
ocstat = occorrelater(dds1,dxd1);
if(ocstat != OC_NOERR) {OCTHROWCHK(ocstat); goto fail;}
@ -548,8 +548,8 @@ occorrelater(OCnode* dds, OCnode* dxd)
/* Correlate the dimensions */
if(dds->array.rank > 0) {
for(i=0;i<oclistlength(dxd->subnodes);i++) {
OCnode* ddsdim = (OCnode*)oclistget(dds->array.dimensions,i);
OCnode* dxddim = (OCnode*)oclistget(dxd->array.dimensions,i);
OCnode* ddsdim = (OCnode*)oclistget(dds->array.dimensions,(size_t)i);
OCnode* dxddim = (OCnode*)oclistget(dxd->array.dimensions,(size_t)i);
ocstat = occorrelater(ddsdim,dxddim);
if(!ocstat) goto fail;
}
@ -582,7 +582,7 @@ ocmarkcacheable(OCstate* state, OCnode* ddsroot)
OClist* treenodes = ddsroot->tree->nodes;
OClist* path = oclistnew();
for(i=0;i<oclistlength(treenodes);i++) {
OCnode* node = (OCnode*)oclistget(treenodes,i);
OCnode* node = (OCnode*)oclistget(treenodes,(size_t)i);
if(node->octype != OC_Atomic) continue;
if(node->etype != OC_String && node->etype != OC_URL) continue;
/* collect node path */
@ -592,7 +592,7 @@ ocmarkcacheable(OCstate* state, OCnode* ddsroot)
ok = 1;
#endif
for(j=1;j<oclistlength(path)-1;j++) {/* skip top level dataset and node itself*/
OCnode* pathnode = (OCnode*)oclistget(path,j);
OCnode* pathnode = (OCnode*)oclistget(path,(size_t)j);
if(pathnode->octype != OC_Structure
|| pathnode->array.rank > 0) {
#if 0

View File

@ -56,10 +56,10 @@ ocextract_credentials(const char *url, char **name, char **pw, char **result_url
char *pos;
char *end;
char *middle;
int up_len = 0;
int mid_len = 0;
int midpas_len = 0;
int url_len = 0;
size_t up_len = 0;
size_t mid_len = 0;
size_t midpas_len = 0;
size_t url_len = 0;
if (strchr(url, '@')) {
pos = strstr(url, "http://");
@ -87,7 +87,7 @@ ocextract_credentials(const char *url, char **name, char **pw, char **result_url
if (!result_url)
return OC_ENOMEM;
strncpy(*result_url, url, pos - url);
strncpy(*result_url, url, (size_t)(pos - url));
strncpy(*result_url + (pos - url), end + 1, url_len - (pos - url));
#if 0
@ -167,7 +167,7 @@ parseproxy(OCstate* state, char* v)
host_pos = v;
port_pos = strchr(host_pos, ':');
if (port_pos) {
int host_len;
size_t host_len;
char *port_sep = port_pos;
port_pos++;
*port_sep = '\0';
@ -181,7 +181,7 @@ parseproxy(OCstate* state, char* v)
state->proxy.port = atoi(port_pos);
} else {
int host_len = strlen(host_pos);
size_t host_len = strlen(host_pos);
state->proxy.host = malloc(sizeof(char) * host_len + 1);
if (!state->proxy.host)
return OC_ENOMEM;
@ -487,7 +487,7 @@ ocdodsrc_lookup(char* key, char* url)
if(url == NULL) url = "";
/* Assume that the triple store has been properly sorted */
for(found=0,i=0;i<ocdodsrc->ntriples;i++,triple++) {
int triplelen = strlen(triple->url);
size_t triplelen = strlen(triple->url);
int t;
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)*/

View File

@ -233,14 +233,14 @@ readfile(const char* path, const char* suffix, OCbytes* packet)
return OCTHROW(OC_EOPEN);
}
/* Get the file size */
filesize = lseek(fd,0,SEEK_END);
filesize = lseek(fd,(off_t)0,SEEK_END);
if(filesize < 0) {
stat = OC_EIO;
oclog(OCLOGERR,"lseek failed: %s",filename);
goto done;
}
/* Move file pointer back to the beginning of the file */
(void)lseek(fd,0,SEEK_SET);
(void)lseek(fd,(off_t)0,SEEK_SET);
stat = OC_NOERR;
for(totalread=0;;) {
off_t count = (off_t)read(fd,buf,sizeof(buf));

View File

@ -319,9 +319,9 @@ ocuriparse(const char* uri0, OCURI** 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 comma if both are defined */
space++;
duri->params = (char*)malloc(space);
@ -720,14 +720,14 @@ ocrshift1(char* p)
static char* hexchars = "0123456789abcdefABCDEF";
static void
toHex(unsigned int b, char hex[2])
toHex(int b, char* hex)
{
hex[0] = hexchars[(b >> 4) & 0xff];
hex[1] = hexchars[(b) & 0xff];
}
static unsigned int
static int
fromHex(int c)
{
if(c >= '0' && c <= '9') return (c - '0');

View File

@ -141,7 +141,7 @@ ocfindbod(OCbytes* buffer, size_t* bodp, size_t* ddslenp)
for(marks = DDSdatamarks;*marks;marks++) {
char* mark = *marks;
int tlen = strlen(mark);
size_t tlen = strlen(mark);
for(i=0;i<len;i++) {
if((i+tlen) <= len
&& (ocstrncmp(content+i,mark,tlen)==0)) {
@ -422,7 +422,8 @@ ocdataddsmsg(OCstate* state, OCtree* tree)
#define ERRCHUNK 1024
#define ERRFILL ' '
#define ERRTAG "Error {"
unsigned int i,j,len;
int i,j;
size_t len;
XXDR* xdrs;
char* contents;
off_t ckp;
@ -434,10 +435,10 @@ ocdataddsmsg(OCstate* state, OCtree* tree)
if(len < strlen(ERRTAG))
return; /* no room */
ckp = xxdr_getpos(xdrs);
xxdr_setpos(xdrs,0);
xxdr_setpos(xdrs,(off_t)0);
/* read the whole thing */
contents = (char*)malloc(len+1);
(void)xxdr_getbytes(xdrs,contents,len);
(void)xxdr_getbytes(xdrs,contents,(off_t)len);
contents[len] = '\0';
/* Look for error tag */
for(i=0;i<len;i++) {
@ -477,7 +478,7 @@ ocarrayoffset(size_t rank, size_t* sizes, size_t* indices)
/* Inverse of ocarrayoffset: convert linear index to a set of indices */
void
ocarrayindices(size_t index, int rank, size_t* sizes, size_t* indices)
ocarrayindices(size_t index, size_t rank, size_t* sizes, size_t* indices)
{
int i;
for(i=rank-1;i>=0;i--) {

View File

@ -28,7 +28,7 @@ extern int oc_ispacked(OCnode* node);
extern size_t octotaldimsize(size_t,size_t*);
extern size_t ocarrayoffset(size_t rank, size_t*, size_t*);
extern void ocarrayindices(size_t index, int rank, size_t*, size_t*);
extern void ocarrayindices(size_t index, size_t rank, size_t*, size_t*);
extern size_t ocedgeoffset(size_t rank, size_t*, size_t*);
extern int ocvalidateindices(size_t rank, size_t*, size_t*);

View File

@ -96,7 +96,7 @@ xxdr_uchar(XXDR* xdr, unsigned char* ip)
{
unsigned int ii;
if(!ip) return 0;
if(!xdr->getbytes(xdr,(char*)&ii,sizeof(unsigned int)))
if(!xdr->getbytes(xdr,(char*)&ii,(off_t)sizeof(unsigned int)))
return 0;
/*convert from network order*/
if(!xxdr_network_order) {
@ -112,7 +112,7 @@ xxdr_ushort(XXDR* xdr, unsigned short* ip)
{
unsigned int ii;
if(!ip) return 0;
if(!xdr->getbytes(xdr,(char*)&ii,sizeof(unsigned int)))
if(!xdr->getbytes(xdr,(char*)&ii,(off_t)sizeof(unsigned int)))
return 0;
/*convert from network order*/
if(!xxdr_network_order) {
@ -127,7 +127,7 @@ int
xxdr_uint(XXDR* xdr, unsigned int* ip)
{
if(!ip) return 0;
if(!xdr->getbytes(xdr,(char*)ip,sizeof(*ip)))
if(!xdr->getbytes(xdr,(char*)ip,(off_t)sizeof(*ip)))
return 0;
/*convert from network order*/
if(!xxdr_network_order) {
@ -142,7 +142,7 @@ xxdr_ulonglong(XXDR* xdr, unsigned long* llp)
{
/* Pull two units */
if(!llp) return 0;
if(!xdr->getbytes(xdr,(char*)llp,sizeof(*llp)))
if(!xdr->getbytes(xdr,(char*)llp,(off_t)sizeof(*llp)))
return 0;
/* Convert to signed/unsigned */
/*convert from network order*/
@ -172,9 +172,9 @@ xxdr_string(XXDR* xdrs, char** sp, off_t* lenp)
char* s;
unsigned int len;
if(!xxdr_uint(xdrs,&len)) return 0;
s = (char*)malloc((off_t)len+1);
s = (char*)malloc((size_t)len+1);
if(s == NULL) return 0;
if(!xxdr_opaque(xdrs,s,len)) {
if(!xxdr_opaque(xdrs,s,(off_t)len)) {
free((void*)s);
return 0;
}
@ -219,7 +219,7 @@ xxdr_free(XXDR* xdr)
int
xxdr_skip(XXDR* xdrs, off_t len)
{
unsigned int pos;
off_t pos;
pos = xxdr_getpos(xdrs);
pos = (pos + len);
// Removed the following; pos is unsigned. jhrg 9/30/13
@ -233,9 +233,11 @@ xxdr_skip_strings(XXDR* xdrs, off_t n)
{
while(n-- > 0) {
unsigned int slen;
off_t slenz;
if(!xxdr_uint(xdrs,&slen)) return 0;
slen = RNDUP(slen);
if(xxdr_skip(xdrs,slen)) return 0;
slenz = (off_t)slen;
slenz = RNDUP(slenz);
if(xxdr_skip(xdrs,slenz)) return 0;
}
return 1;
}
@ -281,7 +283,7 @@ xxdrtrace(xdrs,"getbytes",len);
if(len < 0) len = 0;
if(!xdrs->valid)
{
if(fseek((FILE *)xdrs->data, xdrs->pos + xdrs->base, 0) != 0) {
if(fseek((FILE *)xdrs->data, (long)(xdrs->pos + xdrs->base), 0) != 0) {
ok=0;
goto done;
}
@ -290,7 +292,7 @@ xxdrtrace(xdrs,"getbytes",len);
if(xdrs->pos + len > xdrs->length)
return 0;
if(len > 0) {
count = fread(addr, len, 1, (FILE*)xdrs->data);
count = fread(addr, (size_t)len, (size_t)1, (FILE*)xdrs->data);
if(count <= 0) {
ok=0;
goto done;
@ -383,7 +385,7 @@ xxdrtrace(xdrs,"getbytes",len);
if(len < 0) len = 0;
if(xdrs->pos+len > xdrs->length) {ok=0; goto done;}
if(len > 0) {
memcpy(addr,(char*)xdrs->data+xdrs->base+xdrs->pos, len);
memcpy(addr,(char*)xdrs->data+xdrs->base+xdrs->pos, (size_t)len);
}
xdrs->pos += len;
done:
@ -471,7 +473,7 @@ xxdr_double(XXDR* xdr, double* dp)
int status = 0;
char data[2*XDRUNIT];
/* Pull two units */
status = xxdr_opaque(xdr,data,2*XDRUNIT);
status = xxdr_opaque(xdr,data,(off_t)2*XDRUNIT);
if(status && dp) {
xxdrntohdouble(data,dp);
}
@ -483,7 +485,7 @@ void
xxdrntohdouble(char* c8, double* dp)
{
unsigned int ii[2];
memcpy(ii,c8,2*XDRUNIT);
memcpy(ii,c8,(size_t)2*XDRUNIT);
if(!xxdr_big_endian) {
unsigned int tmp;
/* reverse byte order */

View File

@ -49,10 +49,10 @@
#if 1
/* faster version when XDRUNIT is a power of two */
# define RNDUP(x) (((x) + XDRUNIT - 1) & ~(XDRUNIT - 1))
# define RNDUP(x) ((off_t)(((x) + XDRUNIT - 1) & ~(XDRUNIT - 1)))
#else /* old version */
#define RNDUP(x) ((((x) + XDRUNIT - 1) / XDRUNIT) \
* XDRUNIT)
#define RNDUP(x) ((off_t)((((x) + XDRUNIT - 1) / XDRUNIT) \
* XDRUNIT))
#endif
/* signature: void swapinline16(unsigned short* sp) */