mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-01-30 16:10:44 +08:00
Merge branch 'main' into silence-ncgen-warnings
* main: Set flags to avoid warning messages if curl isn't found. Use modern cmake nomenclature for curl. Skip checking for duplicates if only one element in list Change format of backwards-loops
This commit is contained in:
commit
03db612ef1
@ -218,25 +218,27 @@ endif(USE_HDF5)
|
||||
################################
|
||||
# See if we have libcurl
|
||||
find_package(CURL)
|
||||
target_compile_options(netcdf
|
||||
PRIVATE
|
||||
-DCURL_STATICLIB=1
|
||||
)
|
||||
target_include_directories(netcdf
|
||||
PRIVATE
|
||||
${CURL_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
|
||||
|
||||
MESSAGE(STATUS "Found CURL_INCLUDE_DIRS: ${CURL_INCLUDE_DIRS}")
|
||||
# Define a test flag for have curl library
|
||||
if(CURL_LIBRARIES OR CURL_LIBRARY)
|
||||
#target_compile_options(netcdf
|
||||
# PRIVATE
|
||||
# -DCURL_STATICLIB=1
|
||||
#)
|
||||
#target_include_directories(netcdf
|
||||
# PRIVATE
|
||||
# ${CURL_INCLUDE_DIRS}
|
||||
#)
|
||||
if(CURL_FOUND)
|
||||
set(FOUND_CURL TRUE)
|
||||
target_link_libraries(netcdf
|
||||
PRIVATE
|
||||
CURL::libcurl
|
||||
)
|
||||
else()
|
||||
set(FOUND_CURL FALSE)
|
||||
endif()
|
||||
set(FOUND_CURL ${FOUND_CURL} TRUE )
|
||||
set(NETCDF_ENABLE_DAP2 OFF)
|
||||
set(NETCDF_ENABLE_DAP4 OFF)
|
||||
set(NETCDF_ENABLE_BYTERANGE OFF)
|
||||
set(NETCDF_ENABLE_S3 OFF)
|
||||
endif(CURL_FOUND)
|
||||
|
||||
# Start disabling if curl not found
|
||||
if(NOT FOUND_CURL)
|
||||
|
@ -27,7 +27,7 @@ set_property(SOURCE ncd2dispatch.c
|
||||
add_library(dap2 OBJECT ${dap2_SOURCES})
|
||||
|
||||
|
||||
target_link_libraries(dap2 PUBLIC ${CURL_LIBRARIES})
|
||||
target_link_libraries(dap2 PUBLIC CURL::libcurl ${CURL_LIBRARIES})
|
||||
target_include_directories(dap2 PUBLIC ${CURL_INCLUDE_DIRS})
|
||||
target_compile_options(dap2
|
||||
PRIVATE
|
||||
|
@ -25,7 +25,7 @@ static int iscacheableconstraint(DCEconstraint* con);
|
||||
int
|
||||
iscached(NCDAPCOMMON* nccomm, CDFnode* target, NCcachenode** cachenodep)
|
||||
{
|
||||
int i, found;
|
||||
int found;
|
||||
size_t j;
|
||||
size_t index;
|
||||
NCcache* cache;
|
||||
@ -39,7 +39,8 @@ iscached(NCDAPCOMMON* nccomm, CDFnode* target, NCcachenode** cachenodep)
|
||||
cache = nccomm->cdf.cache;
|
||||
cachenode = cache->prefetch;
|
||||
if(cachenode!= NULL) {
|
||||
for(found=0,i=0;i<nclistlength(cachenode->vars);i++) {
|
||||
found = 0;
|
||||
for(size_t i=0;i<nclistlength(cachenode->vars);i++) {
|
||||
CDFnode* var = (CDFnode*)nclistget(cachenode->vars,i);
|
||||
if(var == target) {
|
||||
if(cachenodep) *cachenodep = cachenode;
|
||||
@ -51,7 +52,7 @@ iscached(NCDAPCOMMON* nccomm, CDFnode* target, NCcachenode** cachenodep)
|
||||
|
||||
/*search other cache nodes starting at latest first */
|
||||
index = 0;
|
||||
for(i=nclistlength(cache->nodes)-1;i>=0;i--) {
|
||||
for(size_t i = nclistlength(cache->nodes); i-->0;) {
|
||||
cachenode = (NCcachenode*)nclistget(cache->nodes,i);
|
||||
/* We currently do not try to match constraints;
|
||||
If the cachenode is constrained by more than
|
||||
|
@ -623,11 +623,10 @@ next: continue;
|
||||
} /*for(;;)*/
|
||||
|
||||
/* remove all NULL elements */
|
||||
int n;
|
||||
for(n=nclistlength(list)-1;n>=0;n--) {
|
||||
for(size_t n = nclistlength(list); n-->0;) {
|
||||
DCEprojection* target = (DCEprojection*)nclistget(list,n);
|
||||
if(target == NULL)
|
||||
nclistremove(list,n);
|
||||
if(target == NULL)
|
||||
nclistremove(list,n);
|
||||
}
|
||||
done:
|
||||
#ifdef DEBUG
|
||||
|
@ -114,9 +114,8 @@ dapodom_count(Dapodometer* odom)
|
||||
int
|
||||
dapodom_next(Dapodometer* odom)
|
||||
{
|
||||
int i; /* do not make unsigned */
|
||||
if(odom->rank == 0) return 0;
|
||||
for(i=odom->rank-1;i>=0;i--) {
|
||||
for(size_t i = odom->rank; i-->0;) {
|
||||
odom->index[i] += odom->stride[i];
|
||||
if(odom->index[i] < odom->stop[i]) break;
|
||||
if(i == 0) return 0; /* leave the 0th entry if it overflows*/
|
||||
|
@ -268,11 +268,8 @@ nclistminus(NClist* l1, NClist* l2)
|
||||
int
|
||||
nclistdeleteall(NClist* l, void* elem)
|
||||
{
|
||||
int i; /* do not make unsigned */
|
||||
unsigned int len,found;
|
||||
found = 0;
|
||||
len = nclistlength(l);
|
||||
for(i=len-1;i>=0;i--) {
|
||||
int found = 0;
|
||||
for(size_t i = nclistlength(l); i-->0;) {
|
||||
void* test = nclistget(l,i);
|
||||
if(test==elem) {
|
||||
nclistremove(l,i);
|
||||
|
@ -2146,14 +2146,14 @@ fail:
|
||||
static NCerror
|
||||
suppressunusablevars(NCDAPCOMMON* dapcomm)
|
||||
{
|
||||
int i,j;
|
||||
size_t i,j;
|
||||
int found = 1;
|
||||
NClist* path = nclistnew();
|
||||
|
||||
while(found) {
|
||||
found = 0;
|
||||
/* Walk backwards to aid removal semantics */
|
||||
for(i=nclistlength(dapcomm->cdf.ddsroot->tree->varnodes)-1;i>=0;i--) {
|
||||
for(i = nclistlength(dapcomm->cdf.ddsroot->tree->varnodes); i-->0;) {
|
||||
CDFnode* var = (CDFnode*)nclistget(dapcomm->cdf.ddsroot->tree->varnodes,i);
|
||||
/* See if this var is under an unusable sequence */
|
||||
nclistclear(path);
|
||||
|
@ -20,7 +20,7 @@ set_property(SOURCE d4meta.c
|
||||
SKIP_UNITY_BUILD_INCLUSION ON)
|
||||
|
||||
add_library(dap4 OBJECT ${dap4_SOURCES})
|
||||
target_link_libraries(dap4 PUBLIC ${CURL_LIBRARIES})
|
||||
target_link_libraries(dap4 PUBLIC CURL::libcurl ${CURL_LIBRARIES})
|
||||
target_include_directories(dap4 PUBLIC ${CURL_INCLUDE_DIRS})
|
||||
target_compile_options(dap4
|
||||
PRIVATE
|
||||
|
@ -557,10 +557,9 @@ negateone(const char* mode, NClist* newmodes)
|
||||
const struct MODEINFER* tests = modenegations;
|
||||
int changed = 0;
|
||||
for(;tests->key;tests++) {
|
||||
int i;
|
||||
if(strcasecmp(tests->key,mode)==0) {
|
||||
/* Find and remove all instances of the inference value */
|
||||
for(i=nclistlength(newmodes)-1;i>=0;i--) {
|
||||
for(size_t i = nclistlength(newmodes); i-- > 0;) {
|
||||
char* candidate = nclistget(newmodes,i);
|
||||
if(strcasecmp(candidate,tests->inference)==0) {
|
||||
nclistremove(newmodes,i);
|
||||
@ -1188,25 +1187,25 @@ cleancommalist(const char* commalist, int caseinsensitive)
|
||||
static void
|
||||
cleanstringlist(NClist* strs, int caseinsensitive)
|
||||
{
|
||||
int i,j;
|
||||
if(nclistlength(strs) == 0) return;
|
||||
/* Remove nulls */
|
||||
for(i=nclistlength(strs)-1;i>=0;i--) {
|
||||
for(size_t i = nclistlength(strs); i-->0;) {
|
||||
if(nclistget(strs,i)==NULL) nclistremove(strs,i);
|
||||
}
|
||||
if(nclistlength(strs) <= 1) return;
|
||||
/* Remove duplicates*/
|
||||
for(i=0;i<nclistlength(strs);i++) {
|
||||
for(size_t i=0;i<nclistlength(strs);i++) {
|
||||
const char* value = nclistget(strs,i);
|
||||
/* look ahead for duplicates */
|
||||
for(j=nclistlength(strs)-1;j>i;j--) {
|
||||
int match;
|
||||
/* look ahead for duplicates */
|
||||
for(size_t j=nclistlength(strs)-1;j>i;j--) {
|
||||
int match;
|
||||
const char* candidate = nclistget(strs,j);
|
||||
if(caseinsensitive)
|
||||
match = (strcasecmp(value,candidate) == 0);
|
||||
else
|
||||
match = (strcmp(value,candidate) == 0);
|
||||
if(match) {char* dup = nclistremove(strs,j); nullfree(dup);}
|
||||
}
|
||||
match = (strcasecmp(value,candidate) == 0);
|
||||
else
|
||||
match = (strcmp(value,candidate) == 0);
|
||||
if(match) {char* dup = nclistremove(strs,j); nullfree(dup);}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -362,7 +362,6 @@ rctrim(char* text)
|
||||
char* p;
|
||||
char* q;
|
||||
size_t len = 0;
|
||||
int i;
|
||||
|
||||
if(text == NULL || *text == '\0') return;
|
||||
|
||||
@ -375,7 +374,7 @@ rctrim(char* text)
|
||||
len = strlen(p);
|
||||
/* locate last non-trimchar */
|
||||
if(len > 0) {
|
||||
for(i=(len-1);i>=0;i--) {
|
||||
for(size_t i = len; i-->0;) {
|
||||
p = &text[i];
|
||||
if(*p != ' ' && *p != '\t' && *p != '\r') {break;}
|
||||
*p = '\0'; /* elide trailing trimchars */
|
||||
|
@ -224,13 +224,13 @@ printfilterlist(NC_VAR_INFO_T* var, const char* tag, int line)
|
||||
int
|
||||
NC4_hdf5_filter_freelist(NC_VAR_INFO_T* var)
|
||||
{
|
||||
int i, stat=NC_NOERR;
|
||||
int stat=NC_NOERR;
|
||||
NClist* filters = (NClist*)var->filters;
|
||||
|
||||
if(filters == NULL) goto done;
|
||||
PRINTFILTERLIST(var,"free: before");
|
||||
/* Free the filter list backward */
|
||||
for(i=nclistlength(filters)-1;i>=0;i--) {
|
||||
for(size_t i = nclistlength(filters);i-->0;) {
|
||||
struct NC_HDF5_Filter* spec = (struct NC_HDF5_Filter*)nclistremove(filters,i);
|
||||
if(spec->nparams > 0) nullfree(spec->params);
|
||||
nullfree(spec);
|
||||
@ -312,11 +312,10 @@ done:
|
||||
int
|
||||
NC4_hdf5_filter_remove(NC_VAR_INFO_T* var, unsigned int id)
|
||||
{
|
||||
int k;
|
||||
NClist* flist = (NClist*)var->filters;
|
||||
|
||||
/* Walk backwards */
|
||||
for(k=nclistlength(flist)-1;k>=0;k--) {
|
||||
for(size_t k = nclistlength(flist); k-->0;) {
|
||||
struct NC_HDF5_Filter* f = (struct NC_HDF5_Filter*)nclistget(flist,k);
|
||||
if(f->filterid == id) {
|
||||
/* Remove from variable */
|
||||
|
@ -42,6 +42,10 @@ if(USE_HDF4)
|
||||
)
|
||||
endif()
|
||||
|
||||
if(FOUND_CURL)
|
||||
target_link_libraries(netcdf PRIVATE CURL::libcurl)
|
||||
endif()
|
||||
|
||||
if(NETCDF_ENABLE_DAP2)
|
||||
target_sources(netcdf
|
||||
PRIVATE
|
||||
@ -144,7 +148,7 @@ if(USE_HDF5)
|
||||
endif()
|
||||
|
||||
if(FOUND_CURL)
|
||||
set(TLL_LIBS ${TLL_LIBS} ${CURL_LIBRARIES})
|
||||
set(TLL_LIBS ${TLL_LIBS} CURL::libcurl ${CURL_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(USE_HDF4)
|
||||
|
@ -96,8 +96,7 @@ NCZ_compute_projections(struct Common* common, int r, size64_t chunkindex, cons
|
||||
projection = &projections[n];
|
||||
if(n > 0) {
|
||||
/* Find last non-skipped projection */
|
||||
int i;
|
||||
for(i=n-1;i>=0;i--) { /* walk backward */
|
||||
for(size_t i=n;i-->0;) { /* walk backward */
|
||||
if(!projections[i].skip) {
|
||||
prev = &projections[i];
|
||||
break;
|
||||
|
@ -423,12 +423,12 @@ done:
|
||||
int
|
||||
NCZ_filter_remove(NC_VAR_INFO_T* var, unsigned int id)
|
||||
{
|
||||
int k, stat = NC_NOERR;
|
||||
int stat = NC_NOERR;
|
||||
NClist* flist = (NClist*)var->filters;
|
||||
|
||||
ZTRACE(6,"var=%s id=%u",var->hdr.name,id);
|
||||
/* Walk backwards */
|
||||
for(k=nclistlength(flist)-1;k>=0;k--) {
|
||||
for(size_t k = nclistlength(flist); k-->0;) {
|
||||
struct NCZ_Filter* f = (struct NCZ_Filter*)nclistget(flist,k);
|
||||
if(f->hdf5.id == id) {
|
||||
/* Remove from variable */
|
||||
@ -896,9 +896,8 @@ fprintf(stderr,">>> next: alloc=%u used=%u buf=%p\n",(unsigned)next_alloc,(unsig
|
||||
}
|
||||
} else {
|
||||
/* Apply in reverse order */
|
||||
int k;
|
||||
for(k=(int)nclistlength(chain)-1;k>=0;k--) {
|
||||
f = (struct NCZ_Filter*)nclistget(chain,(size_t)k);
|
||||
for(size_t k=nclistlength(chain); k-->0;) {
|
||||
f = (struct NCZ_Filter*)nclistget(chain, k);
|
||||
if(f->flags & FLAG_SUPPRESS) continue; /* this filter should not be applied */
|
||||
ff = f->plugin->hdf5.filter;
|
||||
/* code can be simplified */
|
||||
|
@ -42,6 +42,7 @@ ENDif (USE_FFIO)
|
||||
|
||||
if (NETCDF_ENABLE_BYTERANGE)
|
||||
list(APPEND libsrc_SOURCES httpio.c)
|
||||
|
||||
if (NETCDF_ENABLE_S3)
|
||||
list(APPEND libsrc_SOURCES s3io.c)
|
||||
endif(NETCDF_ENABLE_S3)
|
||||
@ -55,6 +56,7 @@ endif()
|
||||
|
||||
if (NETCDF_ENABLE_BYTERANGE)
|
||||
target_include_directories(netcdf3 PUBLIC ${CURL_INCLUDE_DIRS})
|
||||
target_link_libraries(netcdf3 PUBLIC CURL::libcurl)
|
||||
target_compile_options(netcdf3
|
||||
PRIVATE
|
||||
-DCURL_STATICLIB=1
|
||||
|
@ -1104,11 +1104,10 @@ odom_init(size_t rank, size_t* indices, size_t* dimsizes)
|
||||
static void
|
||||
odom_next(size_t rank, size_t* indices, size_t* dimsizes)
|
||||
{
|
||||
int i;
|
||||
for(i=rank-1;i>=0;i--) {
|
||||
indices[i]++;
|
||||
if(indices[i] < dimsizes[i]) break;
|
||||
if(i > 0) indices[i] = 0;
|
||||
for(size_t i = rank; i-->0;) {
|
||||
indices[i]++;
|
||||
if(indices[i] < dimsizes[i]) break;
|
||||
if(i > 0) indices[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ endif()
|
||||
if(STATUS_PARALLEL)
|
||||
target_link_libraries(oc2 PUBLIC MPI::MPI_C)
|
||||
endif(STATUS_PARALLEL)
|
||||
target_link_libraries(oc2 PUBLIC ${CURL_LIBRARIES})
|
||||
target_link_libraries(oc2 PUBLIC CURL::libcurl ${CURL_LIBRARIES})
|
||||
target_include_directories(oc2 PUBLIC ${CURL_INCLUDE_DIRS})
|
||||
target_compile_options(oc2
|
||||
PRIVATE
|
||||
|
@ -490,10 +490,9 @@ ocarrayoffset(size_t rank, size_t* sizes, const size_t* indices)
|
||||
void
|
||||
ocarrayindices(size_t index, size_t rank, size_t* sizes, size_t* indices)
|
||||
{
|
||||
int i;
|
||||
for(i=rank-1;i>=0;i--) {
|
||||
indices[i] = index % sizes[i];
|
||||
index = (index - indices[i]) / sizes[i];
|
||||
for(size_t i = rank; i-->0;) {
|
||||
indices[i] = index % sizes[i];
|
||||
index = (index - indices[i]) / sizes[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user