From eda449b9473728d5d0d9fc782abafb4e85500aba Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 16 Jan 2019 15:51:22 -0500 Subject: [PATCH 01/11] ncconfigure: add NC_UNUSED macro This should be used to indicate that a variable is unused in a codeblock. --- include/ncconfigure.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/ncconfigure.h b/include/ncconfigure.h index 42085dc88..3495e3751 100644 --- a/include/ncconfigure.h +++ b/include/ncconfigure.h @@ -85,4 +85,8 @@ typedef unsigned short ushort; typedef unsigned int uint; #endif +#ifndef NC_UNUSED +#define NC_UNUSED(var) (void)var +#endif + #endif /* NCCONFIGURE_H */ From a747216c33d1e9744f6a13d2a9a8064f6529ad93 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 11 Jan 2019 10:45:42 -0500 Subject: [PATCH 02/11] warnings: mark conditionally used parameters --- libdispatch/dparallel.c | 23 +++++++++++++++++++++++ libsrc/posixio.c | 6 ++++++ libsrc4/nc4var.c | 3 +++ 3 files changed, 32 insertions(+) diff --git a/libdispatch/dparallel.c b/libdispatch/dparallel.c index a62351435..78a1adec8 100644 --- a/libdispatch/dparallel.c +++ b/libdispatch/dparallel.c @@ -98,6 +98,11 @@ int nc_create_par(const char *path, int cmode, MPI_Comm comm, MPI_Info info, int *ncidp) { #ifndef USE_PARALLEL + NC_UNUSED(path); + NC_UNUSED(cmode); + NC_UNUSED(comm); + NC_UNUSED(info); + NC_UNUSED(ncidp); return NC_ENOPAR; #else NC_MPI_INFO data; @@ -197,6 +202,11 @@ nc_open_par(const char *path, int omode, MPI_Comm comm, MPI_Info info, int *ncidp) { #ifndef USE_PARALLEL + NC_UNUSED(path); + NC_UNUSED(omode); + NC_UNUSED(comm); + NC_UNUSED(info); + NC_UNUSED(ncidp); return NC_ENOPAR; #else NC_MPI_INFO mpi_data; @@ -245,6 +255,11 @@ nc_open_par_fortran(const char *path, int omode, int comm, int info, int *ncidp) { #ifndef USE_PARALLEL + NC_UNUSED(path); + NC_UNUSED(omode); + NC_UNUSED(comm); + NC_UNUSED(info); + NC_UNUSED(ncidp); return NC_ENOPAR; #else MPI_Comm comm_c; @@ -344,6 +359,9 @@ int nc_var_par_access(int ncid, int varid, int par_access) { #ifndef USE_PARALLEL + NC_UNUSED(ncid); + NC_UNUSED(varid); + NC_UNUSED(par_access); return NC_ENOPAR; #else int stat = NC_NOERR; @@ -399,6 +417,11 @@ nc_create_par_fortran(const char *path, int cmode, int comm, int info, int *ncidp) { #ifndef USE_PARALLEL + NC_UNUSED(path); + NC_UNUSED(cmode); + NC_UNUSED(comm); + NC_UNUSED(info); + NC_UNUSED(ncidp); return NC_ENOPAR; #else MPI_Comm comm_c; diff --git a/libsrc/posixio.c b/libsrc/posixio.c index 328b13aaf..71a91aff1 100644 --- a/libsrc/posixio.c +++ b/libsrc/posixio.c @@ -184,7 +184,11 @@ blksize(int fd) return 8192; } /* else, silent in the face of error */ +#else + NC_UNUSED(fd); #endif +#else + NC_UNUSED(fd); #endif return (size_t) 2 * pagesize(); } @@ -445,6 +449,7 @@ px_rel(ncio_px *const pxp, off_t offset, int rflags) && offset < pxp->bf_offset + (off_t) pxp->bf_extent); assert(pIf(fIsSet(rflags, RGN_MODIFIED), fIsSet(pxp->bf_rflags, RGN_WRITE))); + NC_UNUSED(offset); if(fIsSet(rflags, RGN_MODIFIED)) { @@ -1152,6 +1157,7 @@ ncio_spx_rel(ncio *const nciop, off_t offset, int rflags) assert(offset < pxp->bf_offset + X_ALIGN); assert(pxp->bf_cnt % X_ALIGN == 0 ); #endif + NC_UNUSED(offset); if(fIsSet(rflags, RGN_MODIFIED)) { diff --git a/libsrc4/nc4var.c b/libsrc4/nc4var.c index 7c9b55c53..a60c1a184 100644 --- a/libsrc4/nc4var.c +++ b/libsrc4/nc4var.c @@ -390,6 +390,9 @@ int NC4_var_par_access(int ncid, int varid, int par_access) { #ifndef USE_PARALLEL4 + NC_UNUSED(ncid); + NC_UNUSED(varid); + NC_UNUSED(par_access); return NC_ENOPAR; #else NC *nc; From eb0b9b8bbd54e6989f3ea53e346258a8cd659ec5 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 11 Jan 2019 10:46:05 -0500 Subject: [PATCH 03/11] ncuri: check the right preprocessor definition --- libdispatch/ncuri.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdispatch/ncuri.c b/libdispatch/ncuri.c index 03a741965..26aa02a9d 100644 --- a/libdispatch/ncuri.c +++ b/libdispatch/ncuri.c @@ -67,7 +67,7 @@ static char* queryallow = static char* userpwdallow = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!$&'()*+,-.;=_~?#/"; -#ifndef HAVE_STRNCMP +#ifndef HAVE_STRNDUP #define strndup ncstrndup /* Not all systems have strndup, so provide one*/ char* From b3f34432a352712e687e641a58652eba6abe6948 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 11 Jan 2019 10:46:25 -0500 Subject: [PATCH 04/11] warnings: mark unused parameters --- libdispatch/nclog.c | 1 + libdispatch/nctime.c | 2 ++ libsrc/posixio.c | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/libdispatch/nclog.c b/libdispatch/nclog.c index 4e0adbfd8..1289772d2 100644 --- a/libdispatch/nclog.c +++ b/libdispatch/nclog.c @@ -212,6 +212,7 @@ Each line will be sent using nclog with the specified tag. void nclogtextn(int tag, const char* text, size_t count) { + NC_UNUSED(tag); if(!nclogging || nclogstream == NULL) return; fwrite(text,1,count,nclogstream); fflush(nclogstream); diff --git a/libdispatch/nctime.c b/libdispatch/nctime.c index aed5ac984..909f3cfbe 100644 --- a/libdispatch/nctime.c +++ b/libdispatch/nctime.c @@ -23,6 +23,7 @@ #include #include #include +#include "ncconfigure.h" #include "nctime.h" static int cuErrOpts; /* Error options */ @@ -659,6 +660,7 @@ Cdh2e(CdTime *htime, double *etime) static int cdValidateTime(cdCalenType timetype, cdCompTime comptime) { + NC_UNUSED(timetype); if(comptime.month<1 || comptime.month>12){ cdError("Error on time conversion: invalid month = %hd\n",comptime.month); return 1; diff --git a/libsrc/posixio.c b/libsrc/posixio.c index 71a91aff1..ed7993b22 100644 --- a/libsrc/posixio.c +++ b/libsrc/posixio.c @@ -802,6 +802,7 @@ px_double_buffer(ncio *const nciop, off_t to, off_t from, int status = NC_NOERR; void *src; void *dest; + NC_UNUSED(rflags); #if INSTRUMENT fprintf(stderr, "\tdouble_buffr %ld %ld %ld\n", @@ -1406,6 +1407,7 @@ ncio_spx_move(ncio *const nciop, off_t to, off_t from, static int ncio_spx_sync(ncio *const nciop) { + NC_UNUSED(nciop); /* NOOP */ return NC_NOERR; } @@ -1598,6 +1600,7 @@ posixio_create(const char *path, int ioflags, int oflags = (O_RDWR|O_CREAT); int fd; int status; + NC_UNUSED(parameters); if(initialsz < (size_t)igeto + igetsz) initialsz = (size_t)igeto + igetsz; @@ -1742,6 +1745,7 @@ posixio_open(const char *path, int oflags = fIsSet(ioflags, NC_WRITE) ? O_RDWR : O_RDONLY; int fd = -1; int status = 0; + NC_UNUSED(parameters); if(path == NULL || *path == 0) return EINVAL; From 94a0259f0e205b78887c2f72f4669243da18e625 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 11 Jan 2019 10:47:03 -0500 Subject: [PATCH 05/11] NC_mktmp: pass the remaining space to strncat This could overflow if `tmp` only had a few bytes left in its space given its current contents. --- libdispatch/dutil.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdispatch/dutil.c b/libdispatch/dutil.c index f79575ef3..843d90550 100644 --- a/libdispatch/dutil.c +++ b/libdispatch/dutil.c @@ -208,7 +208,7 @@ NC_mktmp(const char* base) char spid[7]; if(rno < 0) rno = -rno; snprintf(spid,sizeof(spid),"%06d",rno); - strncat(tmp,spid,sizeof(tmp)); + strncat(tmp,spid,sizeof(tmp) - strlen(tmp) - 1); } #endif /* HAVE_MKTEMP */ #ifdef _MSC_VER From 8c331222ecbdfeb399d41f78f303ffe6de51e9cb Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 11 Jan 2019 13:41:09 -0500 Subject: [PATCH 06/11] warnings: store sizes in size_t --- libdispatch/drc.c | 4 ++-- libdispatch/ncuri.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libdispatch/drc.c b/libdispatch/drc.c index 2ad784472..318b42ec9 100644 --- a/libdispatch/drc.c +++ b/libdispatch/drc.c @@ -396,8 +396,8 @@ rcsearch(const char* prefix, const char* rcname, char** pathp) { char* path = NULL; FILE* f = NULL; - int plen = strlen(prefix); - int rclen = strlen(rcname); + size_t plen = strlen(prefix); + size_t rclen = strlen(rcname); int ret = NC_NOERR; size_t pathlen = plen+rclen+1; /*+1 for '/' */ diff --git a/libdispatch/ncuri.c b/libdispatch/ncuri.c index 26aa02a9d..a023cf673 100644 --- a/libdispatch/ncuri.c +++ b/libdispatch/ncuri.c @@ -258,7 +258,7 @@ ncuriparse(const char* uri0, NCURI** durip) isfile = (strcmp(tmp.protocol,"file")==0); if(isfile) { - int l = strlen(p); /* to test if we have enough characters */ + size_t l = strlen(p); /* to test if we have enough characters */ hashost = 0; /* always */ if(l >= 2 && p[1] == ':' && strchr(DRIVELETTERS,p[0]) != NULL) { /* case 1 */ ; /* p points to the start of the path */ From 82d72dfa47e6eaca929c6abfb67f2736765a0b27 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 11 Jan 2019 13:41:19 -0500 Subject: [PATCH 07/11] nctime: expand basetime's size It ends up being `basetime_1 + basetime_2` with a space in between. Make enough room to ensure that it is not truncated. --- libdispatch/nctime.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdispatch/nctime.c b/libdispatch/nctime.c index 909f3cfbe..08df27bb1 100644 --- a/libdispatch/nctime.c +++ b/libdispatch/nctime.c @@ -310,7 +310,7 @@ cdParseRelunits(cdCalenType timetype, char* relunits, cdUnitTime* unit, cdCompTi char charunits[CD_MAX_RELUNITS]; char basetime_1[CD_MAX_CHARTIME]; char basetime_2[CD_MAX_CHARTIME]; - char basetime[CD_MAX_CHARTIME]; + char basetime[2 * CD_MAX_CHARTIME + 1]; int nconv1, nconv2, nconv; /* Parse the relunits */ From 766d2acfc30be4609adcefe5ffac2e7c6a35b240 Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Fri, 25 Jan 2019 11:26:26 -0700 Subject: [PATCH 08/11] Update CmakeLists.txt in support of https://github.com/Unidata/netcdf-c/issues/1295 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d9d7e561..0a77fde27 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,7 +82,7 @@ IF(MSVC) ENDIF() #Add custom CMake Module -SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/" +SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/" CACHE INTERNAL "Location of our custom CMake modules.") # auto-configure style checks, other CMake modules. From 455bf1352959c8db0b392d6caf877d03510af3e7 Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Tue, 5 Feb 2019 12:57:27 -0700 Subject: [PATCH 09/11] Some housekeeping. Next big push may be to clean up older files. --- CMakeInstallation.cmake | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CMakeInstallation.cmake b/CMakeInstallation.cmake index 80714b8b1..82b051084 100644 --- a/CMakeInstallation.cmake +++ b/CMakeInstallation.cmake @@ -38,6 +38,7 @@ SET(CPACK_SOURCE_IGNORE_FILES "${CPACK_SOURCE_IGNORE_FILES}" "/obsolete/" "/unknown/" ".*~" + ".git/" ) ### @@ -56,9 +57,9 @@ IF(WIN32) SET(CPACK_NSIS_CONTACT "support-netcdf@unidata.ucar.edu") SET(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON) SET(CPACK_NSIS_MENU_LINKS - "http://www.unidata.ucar.edu/netcdf" "Unidata Website" - "http://www.unidata.ucar.edu/netcdf/docs" "NetCDF Stable Documentation" - "http://www.unidata.ucar.edu/netcdf/docs_rc" "NetCDF Unstable Documentation") + "http://www.unidata.ucar.edu/software/netcdf" "Unidata Website" + "http://www.unidata.ucar.edu/software/netcdf/docs" "NetCDF Stable Documentation" + "http://www.unidata.ucar.edu/software/netcdf/docs_rc" "NetCDF Unstable Documentation") ENDIF() From 5fca0edf73b219331e24c710573c8727c4e15a2e Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Tue, 5 Feb 2019 13:08:30 -0700 Subject: [PATCH 10/11] Move away from deprecated PackageManager to the productbuild generator. --- CMakeInstallation.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeInstallation.cmake b/CMakeInstallation.cmake index 82b051084..18be367f7 100644 --- a/CMakeInstallation.cmake +++ b/CMakeInstallation.cmake @@ -104,7 +104,7 @@ ENDIF() IF(APPLE) SET(CPACK_SOURCE_GENERATOR "TGZ") - SET(CPACK_GENERATOR "PackageMaker" "STGZ" "TBZ2" "TGZ" "ZIP") + SET(CPACK_GENERATOR "productbuild" "STGZ" "TBZ2" "TGZ" "ZIP") ENDIF() ## From 6511599a6d1679db18c0e58a2a9f326d8237f246 Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Thu, 7 Feb 2019 12:43:07 -0700 Subject: [PATCH 11/11] Corrected issue in support of https://github.com/Unidata/netcdf-c/issues/1310 --- nc_test4/Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nc_test4/Makefile.am b/nc_test4/Makefile.am index 4988be622..613427dcb 100644 --- a/nc_test4/Makefile.am +++ b/nc_test4/Makefile.am @@ -144,10 +144,10 @@ tst_floats2_*.cdl tst_ints2_*.cdl tst_shorts2_*.cdl tst_elena_*.cdl \ tst_simple*.cdl tst_chunks.cdl pr_A1.* tauu_A1.* usi_01.* thetau_01.* \ tst_*.h5 tst_grp_rename.cdl tst_grp_rename.dmp ref_grp_rename.cdl \ foo1.nc tst_*.h4 test.nc testszip.nc test.h5 szip_dump.cdl \ -perftest.txt bigmeta.nc bigvars.nc run_par_test.sh *.gz MSGCPP_*.nc \ +perftest.txt bigmeta.nc bigvars.nc *.gz MSGCPP_*.nc \ floats*.nc floats*.cdl shorts*.nc shorts*.cdl ints*.nc ints*.cdl -DISTCLEANFILES = findplugin.sh +DISTCLEANFILES = findplugin.sh run_par_test.sh # If valgrind is present, add valgrind targets. @VALGRIND_CHECK_RULES@