From dd4881e39491a62e2977c873069fcd4532d597a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nico=20Schl=C3=B6mer?= Date: Wed, 11 Feb 2015 22:07:33 +0100 Subject: [PATCH 01/11] add basic travis support --- .travis.yml | 16 ++++++++++++++++ README.md | 2 ++ 2 files changed, 18 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..afa417ec6 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,16 @@ +language: c +compiler: + - gcc +# - clang + +before_install: + # Get CMake >=2.8.8, HDF5 >= 1.8.6 + - sudo add-apt-repository -y ppa:amcg/netcdf-parallel + - sudo apt-get update -qq + - sudo apt-get install -qq cmake libhdf5-openmpi-7 libhdf5-openmpi-dev + +before_script: + - cmake -DCMAKE_C_COMPILER=mpicc -DENABLE_PARALLEL:BOOL=ON . + +script: + - make && make test diff --git a/README.md b/README.md index 570ee5705..07f621064 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ Unidata NetCDF ============== +[![Build Status](https://travis-ci.org/nschloe/netcdf-c.png?branch=travis-ci)](https://travis-ci.org/nschloe/netcdf-c) + Coverity Scan Build Status From e8bea25d4e2bdb5089071cdc00d3879704fa1fb3 Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Wed, 18 Feb 2015 16:02:02 -0700 Subject: [PATCH 02/11] Converted the contributed travis.yml file to do a basic build, as we explore travis-ci. Will add more esoteric options/builds moving forward. --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index afa417ec6..4333b291f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,12 +5,12 @@ compiler: before_install: # Get CMake >=2.8.8, HDF5 >= 1.8.6 - - sudo add-apt-repository -y ppa:amcg/netcdf-parallel - sudo apt-get update -qq - - sudo apt-get install -qq cmake libhdf5-openmpi-7 libhdf5-openmpi-dev + - sudo apt-get install -qq cmake libhdf5-dev libhdf4-dev libcurl4-openssl-dev m4 before_script: - - cmake -DCMAKE_C_COMPILER=mpicc -DENABLE_PARALLEL:BOOL=ON . + - mkdir build && cd build + - cmake .. -DENABLE_EXTRA_TESTS=ON -DENABLE_HDF4=ON script: - make && make test From 738a6354902adf771b7b57f0e6cb3cba84605afc Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Wed, 18 Feb 2015 16:10:41 -0700 Subject: [PATCH 03/11] modified travis.yml --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4333b291f..700b833b8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,8 +5,9 @@ compiler: before_install: # Get CMake >=2.8.8, HDF5 >= 1.8.6 + - sudo add-apt-repository -y ppa:amcg/netcdf-parallel - sudo apt-get update -qq - - sudo apt-get install -qq cmake libhdf5-dev libhdf4-dev libcurl4-openssl-dev m4 + - sudo apt-get install -y -qq cmake libhdf5-dev libhdf4-dev libcurl4-openssl-dev m4 before_script: - mkdir build && cd build From 0f5624f247f364332724a5f2486cfcc9323dfec0 Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Wed, 18 Feb 2015 21:43:16 -0700 Subject: [PATCH 04/11] Modified .travis.yml to pull a pre-built hdf5-1.8.14 for the platform. --- .travis.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 700b833b8..8a3dd710d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,13 +5,18 @@ compiler: before_install: # Get CMake >=2.8.8, HDF5 >= 1.8.6 - - sudo add-apt-repository -y ppa:amcg/netcdf-parallel + # - sudo add-apt-repository -y ppa:amcg/netcdf-parallel - sudo apt-get update -qq - - sudo apt-get install -y -qq cmake libhdf5-dev libhdf4-dev libcurl4-openssl-dev m4 + - sudo apt-get install -y -qq libcurl4-openssl-dev m4 wget autoconf libtool + - wget http://www.unidata.ucar.edu/downloads/netcdf/ftp/hdf5-1.8.14.tar.bz2 + - sudo mv hdf5-1.8.14.tar.bz2 /usr/local + - pushd /usr/local + - sudo tar -jxf hdf5-1.8.14.bz2 + - popd before_script: - - mkdir build && cd build - - cmake .. -DENABLE_EXTRA_TESTS=ON -DENABLE_HDF4=ON + - autoreconf -if + - ./configure script: - - make && make test + - make && make check From 925102efc7c04b2a770091f53a1498431f512aaf Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Wed, 18 Feb 2015 21:45:34 -0700 Subject: [PATCH 05/11] Corrected typo in travis script. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8a3dd710d..ea5900dbf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ before_install: - wget http://www.unidata.ucar.edu/downloads/netcdf/ftp/hdf5-1.8.14.tar.bz2 - sudo mv hdf5-1.8.14.tar.bz2 /usr/local - pushd /usr/local - - sudo tar -jxf hdf5-1.8.14.bz2 + - sudo tar -jxf hdf5-1.8.14.tar.bz2 - popd before_script: From 255afffffa52dd9c4aa0d193f71bb3c6327805b4 Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Wed, 18 Feb 2015 21:48:56 -0700 Subject: [PATCH 06/11] Specified LD_LIBRARY_PATH in travis-ci script. --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ea5900dbf..f995ea3fb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,4 +19,5 @@ before_script: - ./configure script: - - make && make check + - make + - LD_LIBRARY_PATH=/usr/local/lib make check From 4fe5e8eaeb06c5ff99fc5eab72c6e3d15f850c53 Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Wed, 18 Feb 2015 21:55:30 -0700 Subject: [PATCH 07/11] Corrected travis-ci link in README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 07f621064..48f713cce 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Unidata NetCDF ============== -[![Build Status](https://travis-ci.org/nschloe/netcdf-c.png?branch=travis-ci)](https://travis-ci.org/nschloe/netcdf-c) +[![Build Status](https://travis-ci.org/Unidata/netcdf-c.svg?branch=master)](https://travis-ci.org/Unidata/netcdf-c) Coverity Scan Build Status Date: Mon, 23 Feb 2015 12:42:49 -0700 Subject: [PATCH 08/11] Added clang to list of compilers used by travis-ci. --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index f995ea3fb..2041e46d0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,13 @@ language: c compiler: - gcc -# - clang + - clang before_install: # Get CMake >=2.8.8, HDF5 >= 1.8.6 # - sudo add-apt-repository -y ppa:amcg/netcdf-parallel - sudo apt-get update -qq - - sudo apt-get install -y -qq libcurl4-openssl-dev m4 wget autoconf libtool + - sudo apt-get install -y -qq libcurl4-openssl-dev m4 wget autoconf libtool clang - wget http://www.unidata.ucar.edu/downloads/netcdf/ftp/hdf5-1.8.14.tar.bz2 - sudo mv hdf5-1.8.14.tar.bz2 /usr/local - pushd /usr/local From cc260fc9aa183090130e831ac592afc1ecca0070 Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Mon, 23 Feb 2015 13:25:35 -0700 Subject: [PATCH 09/11] Fixed a minor static-analysis reported warning. --- oc2/ocrc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oc2/ocrc.c b/oc2/ocrc.c index cf8b46bdb..f387f0f0a 100644 --- a/oc2/ocrc.c +++ b/oc2/ocrc.c @@ -123,7 +123,7 @@ static void rctrim(char* text) { char* p = text; - size_t len = strlen(text); + size_t len = 0; int i; /* locate first non-trimchar */ for(;*p;p++) { From a8494773f847671d7eaf633b990f04d6c17f18e3 Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Mon, 23 Feb 2015 13:38:18 -0700 Subject: [PATCH 10/11] Addressed an 'unallocated memory' warning generated by clang. --- libsrc/attr.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/libsrc/attr.c b/libsrc/attr.c index 96ecf9ca2..362ec5a13 100644 --- a/libsrc/attr.c +++ b/libsrc/attr.c @@ -115,7 +115,7 @@ new_NC_attr( free(name); if(strp == NULL) return NULL; - + attrp = new_x_NC_attr(strp, type, nelems); if(attrp == NULL) { @@ -134,7 +134,10 @@ dup_NC_attr(const NC_attr *rattrp) rattrp->type, rattrp->nelems); if(attrp == NULL) return NULL; - (void) memcpy(attrp->xvalue, rattrp->xvalue, rattrp->xsz); + if(attrp->xvalue == NULL) + attrp->xvalue = (void*)malloc(sizeof(void*)*rattrp->xsz); + + (void) memcpy(attrp->xvalue, rattrp->xvalue, rattrp->xsz); return attrp; } @@ -176,7 +179,7 @@ void free_NC_attrarrayV(NC_attrarray *ncap) { assert(ncap != NULL); - + if(ncap->nalloc == 0) return; @@ -265,7 +268,7 @@ incr_NC_attrarray(NC_attrarray *ncap, NC_attr *newelemp) (ncap->nalloc + NC_ARRAY_GROWBY) * sizeof(NC_attr *)); if(vp == NULL) return NC_ENOMEM; - + ncap->value = vp; ncap->nalloc += NC_ARRAY_GROWBY; } @@ -362,7 +365,7 @@ NC_findattr(const NC_attrarray *ncap, const char *uname) /* * Look up by ncid, varid and name, return NULL if not found */ -static int +static int NC_lookupattr(int ncid, int varid, const char *name, /* attribute name */ @@ -424,7 +427,7 @@ NC3_inq_attname(int ncid, int varid, int attnum, char *name) } -int +int NC3_inq_attid(int ncid, int varid, const char *name, int *attnump) { int status; @@ -441,7 +444,7 @@ NC3_inq_attid(int ncid, int varid, const char *name, int *attnump) ncap = NC_attrarray0(ncp, varid); if(ncap == NULL) return NC_ENOTVAR; - + attrpp = NC_findattr(ncap, name); if(attrpp == NULL) @@ -577,7 +580,7 @@ NC3_del_att(int ncid, int varid, const char *uname) char *name = (char *)utf8proc_NFC((const unsigned char *)uname); if(name == NULL) return NC_ENOMEM; - + /* sortof inline NC_findattr() */ slen = strlen(name); @@ -1399,10 +1402,10 @@ NC3_put_att( if(!NC_indef(ncp)) { const size_t xsz = ncx_len_NC_attrV(type, nelems); attrp = *attrpp; /* convenience */ - + if(xsz > attrp->xsz) return NC_ENOTINDEFINE; /* else, we can reuse existing without redef */ - + attrp->xsz = xsz; attrp->type = type; attrp->nelems = nelems; @@ -1411,7 +1414,7 @@ NC3_put_att( void *xp = attrp->xvalue; status = dispatchput(&xp, nelems, (const void*)value, type, memtype); } - + set_NC_hdirty(ncp); if(NC_doHsync(ncp)) { @@ -1512,4 +1515,3 @@ NC3_get_att( status = NC_EBADTYPE; return status; } - From 9c87a7466b67bdf874cc19924d67e270f5ac2925 Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Mon, 23 Feb 2015 15:58:30 -0700 Subject: [PATCH 11/11] Corrected a sloppy error on my part. --- CMakeLists.txt | 3 +- libsrc/attr.c | 345 +------------------------------------------------ libsrc/attr.m4 | 24 ++-- 3 files changed, 16 insertions(+), 356 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5dcabde7a..51b85ac92 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -987,7 +987,8 @@ IF(NOT MSVC) ENDIF(NOT MSVC) MACRO(GEN_m4 filename) - IF(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${filename}.c) +# IF(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${filename}.c) +IF(NC_M4) ADD_CUSTOM_COMMAND( OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${filename}.c COMMAND ${NC_M4} diff --git a/libsrc/attr.c b/libsrc/attr.c index 362ec5a13..573cd22ac 100644 --- a/libsrc/attr.c +++ b/libsrc/attr.c @@ -1,6 +1,4 @@ -#line 5 "../../libsrc/attr.m4" /* Do not edit this file. It is produced from the corresponding .m4 source */ -#line 7 /* * Copyright 1996, University Corporation for Atmospheric Research * See netcdf/COPYRIGHT file for copying and redistribution conditions. @@ -134,10 +132,8 @@ dup_NC_attr(const NC_attr *rattrp) rattrp->type, rattrp->nelems); if(attrp == NULL) return NULL; - if(attrp->xvalue == NULL) - attrp->xvalue = (void*)malloc(sizeof(void*)*rattrp->xsz); - - (void) memcpy(attrp->xvalue, rattrp->xvalue, rattrp->xsz); + if(attrp->xvalue != NULL && rattrp->xvalue != NULL) + (void) memcpy(attrp->xvalue, rattrp->xvalue, rattrp->xsz); return attrp; } @@ -615,704 +611,367 @@ NC3_del_att(int ncid, int varid, const char *uname) return NC_NOERR; } -#line 673 static int -#line 674 ncx_pad_putn_Iuchar(void **xpp, size_t nelems, const uchar *tp, nc_type type) -#line 674 { -#line 674 switch(type) { -#line 674 case NC_CHAR: -#line 674 return NC_ECHAR; -#line 674 case NC_BYTE: -#line 674 return ncx_pad_putn_schar_uchar(xpp, nelems, tp); -#line 674 case NC_SHORT: -#line 674 return ncx_pad_putn_short_uchar(xpp, nelems, tp); -#line 674 case NC_INT: -#line 674 return ncx_putn_int_uchar(xpp, nelems, tp); -#line 674 case NC_FLOAT: -#line 674 return ncx_putn_float_uchar(xpp, nelems, tp); -#line 674 case NC_DOUBLE: -#line 674 return ncx_putn_double_uchar(xpp, nelems, tp); -#line 674 default: -#line 674 assert("ncx_pad_putn_Iuchar invalid type" == 0); -#line 674 } -#line 674 return NC_EBADTYPE; -#line 674 } -#line 674 static int -#line 675 ncx_pad_getn_Iuchar(const void **xpp, size_t nelems, uchar *tp, nc_type type) -#line 675 { -#line 675 switch(type) { -#line 675 case NC_CHAR: -#line 675 return NC_ECHAR; -#line 675 case NC_BYTE: -#line 675 return ncx_pad_getn_schar_uchar(xpp, nelems, tp); -#line 675 case NC_SHORT: -#line 675 return ncx_pad_getn_short_uchar(xpp, nelems, tp); -#line 675 case NC_INT: -#line 675 return ncx_getn_int_uchar(xpp, nelems, tp); -#line 675 case NC_FLOAT: -#line 675 return ncx_getn_float_uchar(xpp, nelems, tp); -#line 675 case NC_DOUBLE: -#line 675 return ncx_getn_double_uchar(xpp, nelems, tp); -#line 675 default: -#line 675 assert("ncx_pad_getn_Iuchar invalid type" == 0); -#line 675 } -#line 675 return NC_EBADTYPE; -#line 675 } -#line 675 static int -#line 677 ncx_pad_putn_Ischar(void **xpp, size_t nelems, const schar *tp, nc_type type) -#line 677 { -#line 677 switch(type) { -#line 677 case NC_CHAR: -#line 677 return NC_ECHAR; -#line 677 case NC_BYTE: -#line 677 return ncx_pad_putn_schar_schar(xpp, nelems, tp); -#line 677 case NC_SHORT: -#line 677 return ncx_pad_putn_short_schar(xpp, nelems, tp); -#line 677 case NC_INT: -#line 677 return ncx_putn_int_schar(xpp, nelems, tp); -#line 677 case NC_FLOAT: -#line 677 return ncx_putn_float_schar(xpp, nelems, tp); -#line 677 case NC_DOUBLE: -#line 677 return ncx_putn_double_schar(xpp, nelems, tp); -#line 677 default: -#line 677 assert("ncx_pad_putn_Ischar invalid type" == 0); -#line 677 } -#line 677 return NC_EBADTYPE; -#line 677 } -#line 677 static int -#line 678 ncx_pad_getn_Ischar(const void **xpp, size_t nelems, schar *tp, nc_type type) -#line 678 { -#line 678 switch(type) { -#line 678 case NC_CHAR: -#line 678 return NC_ECHAR; -#line 678 case NC_BYTE: -#line 678 return ncx_pad_getn_schar_schar(xpp, nelems, tp); -#line 678 case NC_SHORT: -#line 678 return ncx_pad_getn_short_schar(xpp, nelems, tp); -#line 678 case NC_INT: -#line 678 return ncx_getn_int_schar(xpp, nelems, tp); -#line 678 case NC_FLOAT: -#line 678 return ncx_getn_float_schar(xpp, nelems, tp); -#line 678 case NC_DOUBLE: -#line 678 return ncx_getn_double_schar(xpp, nelems, tp); -#line 678 default: -#line 678 assert("ncx_pad_getn_Ischar invalid type" == 0); -#line 678 } -#line 678 return NC_EBADTYPE; -#line 678 } -#line 678 static int -#line 680 ncx_pad_putn_Ishort(void **xpp, size_t nelems, const short *tp, nc_type type) -#line 680 { -#line 680 switch(type) { -#line 680 case NC_CHAR: -#line 680 return NC_ECHAR; -#line 680 case NC_BYTE: -#line 680 return ncx_pad_putn_schar_short(xpp, nelems, tp); -#line 680 case NC_SHORT: -#line 680 return ncx_pad_putn_short_short(xpp, nelems, tp); -#line 680 case NC_INT: -#line 680 return ncx_putn_int_short(xpp, nelems, tp); -#line 680 case NC_FLOAT: -#line 680 return ncx_putn_float_short(xpp, nelems, tp); -#line 680 case NC_DOUBLE: -#line 680 return ncx_putn_double_short(xpp, nelems, tp); -#line 680 default: -#line 680 assert("ncx_pad_putn_Ishort invalid type" == 0); -#line 680 } -#line 680 return NC_EBADTYPE; -#line 680 } -#line 680 static int -#line 681 ncx_pad_getn_Ishort(const void **xpp, size_t nelems, short *tp, nc_type type) -#line 681 { -#line 681 switch(type) { -#line 681 case NC_CHAR: -#line 681 return NC_ECHAR; -#line 681 case NC_BYTE: -#line 681 return ncx_pad_getn_schar_short(xpp, nelems, tp); -#line 681 case NC_SHORT: -#line 681 return ncx_pad_getn_short_short(xpp, nelems, tp); -#line 681 case NC_INT: -#line 681 return ncx_getn_int_short(xpp, nelems, tp); -#line 681 case NC_FLOAT: -#line 681 return ncx_getn_float_short(xpp, nelems, tp); -#line 681 case NC_DOUBLE: -#line 681 return ncx_getn_double_short(xpp, nelems, tp); -#line 681 default: -#line 681 assert("ncx_pad_getn_Ishort invalid type" == 0); -#line 681 } -#line 681 return NC_EBADTYPE; -#line 681 } -#line 681 static int -#line 683 ncx_pad_putn_Iint(void **xpp, size_t nelems, const int *tp, nc_type type) -#line 683 { -#line 683 switch(type) { -#line 683 case NC_CHAR: -#line 683 return NC_ECHAR; -#line 683 case NC_BYTE: -#line 683 return ncx_pad_putn_schar_int(xpp, nelems, tp); -#line 683 case NC_SHORT: -#line 683 return ncx_pad_putn_short_int(xpp, nelems, tp); -#line 683 case NC_INT: -#line 683 return ncx_putn_int_int(xpp, nelems, tp); -#line 683 case NC_FLOAT: -#line 683 return ncx_putn_float_int(xpp, nelems, tp); -#line 683 case NC_DOUBLE: -#line 683 return ncx_putn_double_int(xpp, nelems, tp); -#line 683 default: -#line 683 assert("ncx_pad_putn_Iint invalid type" == 0); -#line 683 } -#line 683 return NC_EBADTYPE; -#line 683 } -#line 683 static int -#line 684 ncx_pad_getn_Iint(const void **xpp, size_t nelems, int *tp, nc_type type) -#line 684 { -#line 684 switch(type) { -#line 684 case NC_CHAR: -#line 684 return NC_ECHAR; -#line 684 case NC_BYTE: -#line 684 return ncx_pad_getn_schar_int(xpp, nelems, tp); -#line 684 case NC_SHORT: -#line 684 return ncx_pad_getn_short_int(xpp, nelems, tp); -#line 684 case NC_INT: -#line 684 return ncx_getn_int_int(xpp, nelems, tp); -#line 684 case NC_FLOAT: -#line 684 return ncx_getn_float_int(xpp, nelems, tp); -#line 684 case NC_DOUBLE: -#line 684 return ncx_getn_double_int(xpp, nelems, tp); -#line 684 default: -#line 684 assert("ncx_pad_getn_Iint invalid type" == 0); -#line 684 } -#line 684 return NC_EBADTYPE; -#line 684 } -#line 684 static int -#line 686 ncx_pad_putn_Ifloat(void **xpp, size_t nelems, const float *tp, nc_type type) -#line 686 { -#line 686 switch(type) { -#line 686 case NC_CHAR: -#line 686 return NC_ECHAR; -#line 686 case NC_BYTE: -#line 686 return ncx_pad_putn_schar_float(xpp, nelems, tp); -#line 686 case NC_SHORT: -#line 686 return ncx_pad_putn_short_float(xpp, nelems, tp); -#line 686 case NC_INT: -#line 686 return ncx_putn_int_float(xpp, nelems, tp); -#line 686 case NC_FLOAT: -#line 686 return ncx_putn_float_float(xpp, nelems, tp); -#line 686 case NC_DOUBLE: -#line 686 return ncx_putn_double_float(xpp, nelems, tp); -#line 686 default: -#line 686 assert("ncx_pad_putn_Ifloat invalid type" == 0); -#line 686 } -#line 686 return NC_EBADTYPE; -#line 686 } -#line 686 static int -#line 687 ncx_pad_getn_Ifloat(const void **xpp, size_t nelems, float *tp, nc_type type) -#line 687 { -#line 687 switch(type) { -#line 687 case NC_CHAR: -#line 687 return NC_ECHAR; -#line 687 case NC_BYTE: -#line 687 return ncx_pad_getn_schar_float(xpp, nelems, tp); -#line 687 case NC_SHORT: -#line 687 return ncx_pad_getn_short_float(xpp, nelems, tp); -#line 687 case NC_INT: -#line 687 return ncx_getn_int_float(xpp, nelems, tp); -#line 687 case NC_FLOAT: -#line 687 return ncx_getn_float_float(xpp, nelems, tp); -#line 687 case NC_DOUBLE: -#line 687 return ncx_getn_double_float(xpp, nelems, tp); -#line 687 default: -#line 687 assert("ncx_pad_getn_Ifloat invalid type" == 0); -#line 687 } -#line 687 return NC_EBADTYPE; -#line 687 } -#line 687 static int -#line 689 ncx_pad_putn_Idouble(void **xpp, size_t nelems, const double *tp, nc_type type) -#line 689 { -#line 689 switch(type) { -#line 689 case NC_CHAR: -#line 689 return NC_ECHAR; -#line 689 case NC_BYTE: -#line 689 return ncx_pad_putn_schar_double(xpp, nelems, tp); -#line 689 case NC_SHORT: -#line 689 return ncx_pad_putn_short_double(xpp, nelems, tp); -#line 689 case NC_INT: -#line 689 return ncx_putn_int_double(xpp, nelems, tp); -#line 689 case NC_FLOAT: -#line 689 return ncx_putn_float_double(xpp, nelems, tp); -#line 689 case NC_DOUBLE: -#line 689 return ncx_putn_double_double(xpp, nelems, tp); -#line 689 default: -#line 689 assert("ncx_pad_putn_Idouble invalid type" == 0); -#line 689 } -#line 689 return NC_EBADTYPE; -#line 689 } -#line 689 static int -#line 690 ncx_pad_getn_Idouble(const void **xpp, size_t nelems, double *tp, nc_type type) -#line 690 { -#line 690 switch(type) { -#line 690 case NC_CHAR: -#line 690 return NC_ECHAR; -#line 690 case NC_BYTE: -#line 690 return ncx_pad_getn_schar_double(xpp, nelems, tp); -#line 690 case NC_SHORT: -#line 690 return ncx_pad_getn_short_double(xpp, nelems, tp); -#line 690 case NC_INT: -#line 690 return ncx_getn_int_double(xpp, nelems, tp); -#line 690 case NC_FLOAT: -#line 690 return ncx_getn_float_double(xpp, nelems, tp); -#line 690 case NC_DOUBLE: -#line 690 return ncx_getn_double_double(xpp, nelems, tp); -#line 690 default: -#line 690 assert("ncx_pad_getn_Idouble invalid type" == 0); -#line 690 } -#line 690 return NC_EBADTYPE; -#line 690 } -#line 690 #ifdef IGNORE static int -#line 693 ncx_pad_putn_Ilong(void **xpp, size_t nelems, const long *tp, nc_type type) -#line 693 { -#line 693 switch(type) { -#line 693 case NC_CHAR: -#line 693 return NC_ECHAR; -#line 693 case NC_BYTE: -#line 693 return ncx_pad_putn_schar_long(xpp, nelems, tp); -#line 693 case NC_SHORT: -#line 693 return ncx_pad_putn_short_long(xpp, nelems, tp); -#line 693 case NC_INT: -#line 693 return ncx_putn_int_long(xpp, nelems, tp); -#line 693 case NC_FLOAT: -#line 693 return ncx_putn_float_long(xpp, nelems, tp); -#line 693 case NC_DOUBLE: -#line 693 return ncx_putn_double_long(xpp, nelems, tp); -#line 693 default: -#line 693 assert("ncx_pad_putn_Ilong invalid type" == 0); -#line 693 } -#line 693 return NC_EBADTYPE; -#line 693 } -#line 693 static int -#line 694 ncx_pad_getn_Ilong(const void **xpp, size_t nelems, long *tp, nc_type type) -#line 694 { -#line 694 switch(type) { -#line 694 case NC_CHAR: -#line 694 return NC_ECHAR; -#line 694 case NC_BYTE: -#line 694 return ncx_pad_getn_schar_long(xpp, nelems, tp); -#line 694 case NC_SHORT: -#line 694 return ncx_pad_getn_short_long(xpp, nelems, tp); -#line 694 case NC_INT: -#line 694 return ncx_getn_int_long(xpp, nelems, tp); -#line 694 case NC_FLOAT: -#line 694 return ncx_getn_float_long(xpp, nelems, tp); -#line 694 case NC_DOUBLE: -#line 694 return ncx_getn_double_long(xpp, nelems, tp); -#line 694 default: -#line 694 assert("ncx_pad_getn_Ilong invalid type" == 0); -#line 694 } -#line 694 return NC_EBADTYPE; -#line 694 } -#line 694 #endif static int -#line 697 ncx_pad_putn_Ilonglong(void **xpp, size_t nelems, const longlong *tp, nc_type type) -#line 697 { -#line 697 switch(type) { -#line 697 case NC_CHAR: -#line 697 return NC_ECHAR; -#line 697 case NC_BYTE: -#line 697 return ncx_pad_putn_schar_longlong(xpp, nelems, tp); -#line 697 case NC_SHORT: -#line 697 return ncx_pad_putn_short_longlong(xpp, nelems, tp); -#line 697 case NC_INT: -#line 697 return ncx_putn_int_longlong(xpp, nelems, tp); -#line 697 case NC_FLOAT: -#line 697 return ncx_putn_float_longlong(xpp, nelems, tp); -#line 697 case NC_DOUBLE: -#line 697 return ncx_putn_double_longlong(xpp, nelems, tp); -#line 697 default: -#line 697 assert("ncx_pad_putn_Ilonglong invalid type" == 0); -#line 697 } -#line 697 return NC_EBADTYPE; -#line 697 } -#line 697 static int -#line 698 ncx_pad_getn_Ilonglong(const void **xpp, size_t nelems, longlong *tp, nc_type type) -#line 698 { -#line 698 switch(type) { -#line 698 case NC_CHAR: -#line 698 return NC_ECHAR; -#line 698 case NC_BYTE: -#line 698 return ncx_pad_getn_schar_longlong(xpp, nelems, tp); -#line 698 case NC_SHORT: -#line 698 return ncx_pad_getn_short_longlong(xpp, nelems, tp); -#line 698 case NC_INT: -#line 698 return ncx_getn_int_longlong(xpp, nelems, tp); -#line 698 case NC_FLOAT: -#line 698 return ncx_getn_float_longlong(xpp, nelems, tp); -#line 698 case NC_DOUBLE: -#line 698 return ncx_getn_double_longlong(xpp, nelems, tp); -#line 698 default: -#line 698 assert("ncx_pad_getn_Ilonglong invalid type" == 0); -#line 698 } -#line 698 return NC_EBADTYPE; -#line 698 } -#line 698 diff --git a/libsrc/attr.m4 b/libsrc/attr.m4 index 50c2d80b6..b1edba472 100644 --- a/libsrc/attr.m4 +++ b/libsrc/attr.m4 @@ -118,7 +118,7 @@ new_NC_attr( free(name); if(strp == NULL) return NULL; - + attrp = new_x_NC_attr(strp, type, nelems); if(attrp == NULL) { @@ -137,7 +137,8 @@ dup_NC_attr(const NC_attr *rattrp) rattrp->type, rattrp->nelems); if(attrp == NULL) return NULL; - (void) memcpy(attrp->xvalue, rattrp->xvalue, rattrp->xsz); + if(attrp->xvalue != NULL && rattrp->xvalue != NULL) + (void) memcpy(attrp->xvalue, rattrp->xvalue, rattrp->xsz); return attrp; } @@ -179,7 +180,7 @@ void free_NC_attrarrayV(NC_attrarray *ncap) { assert(ncap != NULL); - + if(ncap->nalloc == 0) return; @@ -268,7 +269,7 @@ incr_NC_attrarray(NC_attrarray *ncap, NC_attr *newelemp) (ncap->nalloc + NC_ARRAY_GROWBY) * sizeof(NC_attr *)); if(vp == NULL) return NC_ENOMEM; - + ncap->value = vp; ncap->nalloc += NC_ARRAY_GROWBY; } @@ -365,7 +366,7 @@ NC_findattr(const NC_attrarray *ncap, const char *uname) /* * Look up by ncid, varid and name, return NULL if not found */ -static int +static int NC_lookupattr(int ncid, int varid, const char *name, /* attribute name */ @@ -427,7 +428,7 @@ NC3_inq_attname(int ncid, int varid, int attnum, char *name) } -int +int NC3_inq_attid(int ncid, int varid, const char *name, int *attnump) { int status; @@ -444,7 +445,7 @@ NC3_inq_attid(int ncid, int varid, const char *name, int *attnump) ncap = NC_attrarray0(ncp, varid); if(ncap == NULL) return NC_ENOTVAR; - + attrpp = NC_findattr(ncap, name); if(attrpp == NULL) @@ -580,7 +581,7 @@ NC3_del_att(int ncid, int varid, const char *uname) char *name = (char *)utf8proc_NFC((const unsigned char *)uname); if(name == NULL) return NC_ENOMEM; - + /* sortof inline NC_findattr() */ slen = strlen(name); @@ -784,10 +785,10 @@ NC3_put_att( if(!NC_indef(ncp)) { const size_t xsz = ncx_len_NC_attrV(type, nelems); attrp = *attrpp; /* convenience */ - + if(xsz > attrp->xsz) return NC_ENOTINDEFINE; /* else, we can reuse existing without redef */ - + attrp->xsz = xsz; attrp->type = type; attrp->nelems = nelems; @@ -796,7 +797,7 @@ NC3_put_att( void *xp = attrp->xvalue; status = dispatchput(&xp, nelems, (const void*)value, type, memtype); } - + set_NC_hdirty(ncp); if(NC_doHsync(ncp)) { @@ -897,4 +898,3 @@ NC3_get_att( status = NC_EBADTYPE; return status; } -