Merged changes from netcdf-branch.

o Changed variable names 'typeid' to 'typeid1' to avoid a namespace conflict
in visual studio.
o Cleaned up a handful of warnings in Visual Studio.
o Addressed a few Coverity-discovered issuesl
o Made changes to CMake-based builds.
This commit is contained in:
Ward Fisher 2012-12-13 22:09:41 +00:00
parent 635a03f2f7
commit 7b91248723
8 changed files with 118 additions and 102 deletions

View File

@ -57,11 +57,15 @@ INCLUDE (${CMAKE_ROOT}/Modules/GetPrerequisites.cmake)
# Only necessary for Windows
IF(MSVC)
INCLUDE (${CMAKE_SOURCE_DIR}/cmake/modules/windows/FindHDF5.cmake)
ENDIF()
# Supress some warnings on Windows
IF(MSVC)
# Supress some warnings on Windows
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
ENDIF()
ENDIF()
IF (NOT CMAKE_BUILD_TYPE)
SET (CMAKE_BUILD_TYPE DEBUG CACHE STRING "Choose the type of build, options are: None, Debug, Release."
FORCE)
ENDIF()
#####
# Some utility macros/scripts.
@ -116,6 +120,7 @@ MACRO(print_conf_summary)
MESSAGE("")
MESSAGE(STATUS "CMake Summary:")
MESSAGE("")
MESSAGE(STATUS "\tBuild Type:\t\t\t" ${CMAKE_BUILD_TYPE})
MESSAGE(STATUS "\tBuilding Shared Libraries:\t" ${BUILD_SHARED_LIBS})
MESSAGE(STATUS "\tBuilding NetCDF-4:\t\t" ${ENABLE_NETCDF_4})
MESSAGE(STATUS "\tBuilding DAP Support:\t\t" ${ENABLE_DAP})
@ -585,7 +590,6 @@ INSTALL(FILES ${NetCDF_SOURCE_DIR}/include/netcdf.h
# Install the dependencies.
IF(MSVC)
INSTALL(DIRECTORY ${CMAKE_PREFIX_PATH} DESTINATION "deps" COMPONENT dependencies)
ENDIF()

View File

@ -334,7 +334,7 @@ NC_GRP_INFO_T *nc4_rec_find_grp(NC_GRP_INFO_T *start_grp, int target_nc_grpid);
NC *nc4_find_nc_file(int ncid, NC_HDF5_FILE_INFO_T**);
int nc4_find_dim(NC_GRP_INFO_T *grp, int dimid, NC_DIM_INFO_T **dim, NC_GRP_INFO_T **dim_grp);
int nc4_find_dim_len(NC_GRP_INFO_T *grp, int dimid, size_t **len);
int nc4_find_type(NC_HDF5_FILE_INFO_T *h5, int typeid, NC_TYPE_INFO_T **type);
int nc4_find_type(NC_HDF5_FILE_INFO_T *h5, int typeid1, NC_TYPE_INFO_T **type);
NC_TYPE_INFO_T *nc4_rec_find_nc_type(NC_GRP_INFO_T *start_grp, hid_t target_nc_typeid);
NC_TYPE_INFO_T *nc4_rec_find_hdf_type(NC_GRP_INFO_T *start_grp, hid_t target_hdf_typeid);
NC_TYPE_INFO_T *nc4_rec_find_named_type(NC_GRP_INFO_T *start_grp, char *name);

View File

@ -47,7 +47,7 @@ EXTERNL int
nc_inq_dimids_f(int ncid, int *ndims, int *fdimids, int parent);
EXTERNL int
nc_insert_array_compound_f(int ncid, int typeid, char *name,
nc_insert_array_compound_f(int ncid, int typeid1, char *name,
size_t offset, nc_type field_typeid,
int ndims, int *dim_sizesp);

View File

@ -347,7 +347,11 @@ ncuriparse(const char* uri0, NCURI** durip)
fprintf(stderr,"\n");
}
#endif
if(durip != NULL) *durip = duri;
if(durip != NULL)
*durip = duri;
else
ncurifree(duri);
return 1;
fail:

View File

@ -18,106 +18,113 @@
extern "C" {
#endif
extern int
/* We use EXTERNL instead of extern.
On Windows system, EXTERNL has been defined (see netcdf.h) such
that symbols are properly exported/imported between
libraries and executables. On non-windows systems,
EXTERNL is defined as extern. */
EXTERNL int
NC4_create(const char *path, int cmode,
size_t initialsz, int basepe, size_t *chunksizehintp,
int useparallel, void* parameters,
NC_Dispatch*, NC*);
extern int
EXTERNL int
NC4_open(const char *path, int mode,
int basepe, size_t *chunksizehintp,
int use_parallel, void* parameters,
NC_Dispatch*, NC*);
extern int
EXTERNL int
NC4_redef(int ncid);
extern int
EXTERNL int
NC4__enddef(int ncid, size_t h_minfree, size_t v_align,
size_t v_minfree, size_t r_align);
extern int
EXTERNL int
NC4_sync(int ncid);
extern int
EXTERNL int
NC4_abort(int ncid);
extern int
EXTERNL int
NC4_close(int ncid);
extern int
EXTERNL int
NC4_set_fill(int ncid, int fillmode, int *old_modep);
extern int
EXTERNL int
NC4_set_base_pe(int ncid, int pe);
extern int
EXTERNL int
NC4_inq_base_pe(int ncid, int *pe);
extern int
EXTERNL int
NC4_inq_format(int ncid, int *formatp);
extern int
EXTERNL int
NC4_inq(int ncid, int *ndimsp, int *nvarsp, int *nattsp, int *unlimdimidp);
extern int
EXTERNL int
NC4_inq_type(int, nc_type, char *, size_t *);
/* Begin _dim */
extern int
EXTERNL int
NC4_def_dim(int ncid, const char *name, size_t len, int *idp);
extern int
EXTERNL int
NC4_inq_dimid(int ncid, const char *name, int *idp);
extern int
EXTERNL int
NC4_inq_dim(int ncid, int dimid, char *name, size_t *lenp);
extern int
EXTERNL int
NC4_inq_unlimdim(int ncid, int *unlimdimidp);
extern int
EXTERNL int
NC4_rename_dim(int ncid, int dimid, const char *name);
/* End _dim */
/* Begin _att */
extern int
EXTERNL int
NC4_inq_att(int ncid, int varid, const char *name,
nc_type *xtypep, size_t *lenp);
extern int
EXTERNL int
NC4_inq_attid(int ncid, int varid, const char *name, int *idp);
extern int
EXTERNL int
NC4_inq_attname(int ncid, int varid, int attnum, char *name);
extern int
EXTERNL int
NC4_rename_att(int ncid, int varid, const char *name, const char *newname);
extern int
EXTERNL int
NC4_del_att(int ncid, int varid, const char*);
/* End _att */
/* Begin {put,get}_att */
extern int
EXTERNL int
NC4_get_att(int ncid, int varid, const char *name, void *value, nc_type);
extern int
EXTERNL int
NC4_put_att(int ncid, int varid, const char *name, nc_type datatype,
size_t len, const void *value, nc_type);
/* End {put,get}_att */
/* Begin _var */
extern int
EXTERNL int
NC4_def_var(int ncid, const char *name,
nc_type xtype, int ndims, const int *dimidsp, int *varidp);
extern int
EXTERNL int
NC4_inq_var_all(int ncid, int varid, char *name, nc_type *xtypep,
int *ndimsp, int *dimidsp, int *nattsp,
int *shufflep, int *deflatep, int *deflate_levelp,
@ -125,18 +132,18 @@ NC4_inq_var_all(int ncid, int varid, char *name, nc_type *xtypep,
int *no_fill, void *fill_valuep, int *endiannessp,
int *options_maskp, int *pixels_per_blockp);
extern int
EXTERNL int
NC4_inq_varid(int ncid, const char *name, int *varidp);
extern int
EXTERNL int
NC4_rename_var(int ncid, int varid, const char *name);
extern int
EXTERNL int
NC4_put_vara(int ncid, int varid,
const size_t *start, const size_t *count,
const void *value, nc_type);
extern int
EXTERNL int
NC4_get_vara(int ncid, int varid,
const size_t *start, const size_t *count,
void *value, nc_type);
@ -144,115 +151,115 @@ NC4_get_vara(int ncid, int varid,
/* End _var */
/* netCDF4 API only */
extern int
EXTERNL int
NC4_var_par_access(int, int, int);
extern int
EXTERNL int
NC4_inq_ncid(int, const char *, int *);
extern int
EXTERNL int
NC4_inq_grps(int, int *, int *);
extern int
EXTERNL int
NC4_inq_grpname(int, char *);
extern int
EXTERNL int
NC4_inq_grpname_full(int, size_t *, char *);
extern int
EXTERNL int
NC4_inq_grp_parent(int, int *);
extern int
EXTERNL int
NC4_inq_grp_full_ncid(int, const char *, int *);
extern int
EXTERNL int
NC4_inq_varids(int, int * nvars, int *);
extern int
EXTERNL int
NC4_inq_dimids(int, int * ndims, int *, int);
extern int
EXTERNL int
NC4_inq_typeids(int, int * ntypes, int *);
extern int
EXTERNL int
NC4_inq_type_equal(int, nc_type, int, nc_type, int *);
extern int
EXTERNL int
NC4_def_grp(int, const char *, int *);
extern int
EXTERNL int
NC4_inq_user_type(int, nc_type, char *, size_t *, nc_type *,
size_t *, int *);
extern int
EXTERNL int
NC4_def_compound(int, size_t, const char *, nc_type *);
extern int
EXTERNL int
NC4_insert_compound(int, nc_type, const char *, size_t, nc_type);
extern int
EXTERNL int
NC4_insert_array_compound(int, nc_type, const char *, size_t,
nc_type, int, const int *);
extern int
EXTERNL int
NC4_inq_typeid(int, const char *, nc_type *);
extern int
EXTERNL int
NC4_inq_compound_field(int, nc_type, int, char *, size_t *,
nc_type *, int *, int *);
extern int
EXTERNL int
NC4_inq_compound_fieldindex(int, nc_type, const char *, int *);
extern int
EXTERNL int
NC4_def_vlen(int, const char *, nc_type base_typeid, nc_type *);
extern int
EXTERNL int
NC4_put_vlen_element(int, int, void *, size_t, const void *);
extern int
EXTERNL int
NC4_get_vlen_element(int, int, const void *, size_t *, void *);
extern int
EXTERNL int
NC4_def_enum(int, nc_type, const char *, nc_type *);
extern int
EXTERNL int
NC4_insert_enum(int, nc_type, const char *, const void *);
extern int
EXTERNL int
NC4_inq_enum_member(int, nc_type, int, char *, void *);
extern int
EXTERNL int
NC4_inq_enum_ident(int, nc_type, long long, char *);
extern int
EXTERNL int
NC4_def_opaque(int, size_t, const char *, nc_type *);
extern int
EXTERNL int
NC4_def_var_deflate(int, int, int, int, int);
extern int
EXTERNL int
NC4_def_var_fletcher32(int, int, int);
extern int
EXTERNL int
NC4_def_var_chunking(int, int, int, const size_t *);
extern int
EXTERNL int
NC4_def_var_fill(int, int, int, const void *);
extern int
EXTERNL int
NC4_def_var_endian(int, int, int);
extern int
EXTERNL int
NC4_set_var_chunk_cache(int, int, size_t, size_t, float);
extern int
EXTERNL int
NC4_get_var_chunk_cache(int, int, size_t *, size_t *, float *);
extern int
EXTERNL int
NC4_inq_unlimdims(int, int *, int *);
extern int
EXTERNL int
NC4_show_metadata(int);
extern int

View File

@ -113,7 +113,7 @@ NC4_inq_typeid(int ncid, const char *name, nc_type *typeidp)
return NC_EINVAL;
/* Normalize name. */
if (!(norm_name = malloc(strlen(name) + 1)))
if (!(norm_name = (char*)malloc(strlen(name) + 1)))
return NC_ENOMEM;
if ((retval = nc4_normalize_name(name, norm_name)))
return retval;
@ -259,7 +259,7 @@ add_user_type(int ncid, size_t size, const char *name, nc_type base_typeid,
/* Get the name and size of a type. For strings, 1 is returned. For
* VLEN the base type len is returned. */
int
NC4_inq_type(int ncid, nc_type typeid, char *name, size_t *size)
NC4_inq_type(int ncid, nc_type typeid1, char *name, size_t *size)
{
NC_GRP_INFO_T *grp;
NC_TYPE_INFO_T *type;
@ -273,12 +273,12 @@ NC4_inq_type(int ncid, nc_type typeid, char *name, size_t *size)
LOG((2, "nc_inq_type: ncid 0x%x typeid %d", ncid, typeid));
/* If this is an atomic type, the answer is easy. */
if (typeid < NUM_ATOMIC_TYPES)
if (typeid1 < NUM_ATOMIC_TYPES)
{
if (name)
strcpy(name, atomic_name[typeid]);
strcpy(name, atomic_name[typeid1]);
if (size)
*size = atomic_size[typeid];
*size = atomic_size[typeid1];
return NC_NOERR;
}
@ -287,7 +287,7 @@ NC4_inq_type(int ncid, nc_type typeid, char *name, size_t *size)
return retval;
/* Find this type. */
if (!(type = nc4_rec_find_nc_type(grp->nc4_info->root_grp, typeid)))
if (!(type = nc4_rec_find_nc_type(grp->nc4_info->root_grp, typeid1)))
return NC_EBADTYPE;
if (name)
@ -313,16 +313,16 @@ NC4_def_compound(int ncid, size_t size, const char *name, nc_type *typeidp)
/* Insert a named field into a compound type. */
int
NC4_insert_compound(int ncid, nc_type typeid, const char *name, size_t offset,
NC4_insert_compound(int ncid, nc_type typeid1, const char *name, size_t offset,
nc_type field_typeid)
{
return nc_insert_array_compound(ncid, typeid, name, offset,
return nc_insert_array_compound(ncid, typeid1, name, offset,
field_typeid, 0, NULL);
}
/* Insert a named array into a compound type. */
EXTERNL int
NC4_insert_array_compound(int ncid, int typeid, const char *name,
NC4_insert_array_compound(int ncid, int typeid1, const char *name,
size_t offset, nc_type field_typeid,
int ndims, const int *dim_sizesp)
{
@ -344,7 +344,7 @@ NC4_insert_array_compound(int ncid, int typeid, const char *name,
return retval;
/* Find type metadata. */
if ((retval = nc4_find_type(grp->nc4_info, typeid, &type)))
if ((retval = nc4_find_type(grp->nc4_info, typeid1, &type)))
return retval;
/* Did the user give us a good compound type typeid? */
@ -369,7 +369,7 @@ NC4_insert_array_compound(int ncid, int typeid, const char *name,
/* Find info about any user defined type. */
int
NC4_inq_user_type(int ncid, nc_type typeid, char *name, size_t *size,
NC4_inq_user_type(int ncid, nc_type typeid1, char *name, size_t *size,
nc_type *base_nc_typep, size_t *nfieldsp, int *classp)
{
NC_GRP_INFO_T *grp;
@ -377,14 +377,14 @@ NC4_inq_user_type(int ncid, nc_type typeid, char *name, size_t *size,
NC_FIELD_INFO_T *field;
int retval;
LOG((2, "nc_inq_user_type: ncid 0x%x typeid %d", ncid, typeid));
LOG((2, "nc_inq_user_type: ncid 0x%x typeid %d", ncid, typeid1));
/* Find group metadata. */
if ((retval = nc4_find_nc4_grp(ncid, &grp)))
return retval;
/* Find this type. */
if (!(type = nc4_rec_find_nc_type(grp->nc4_info->root_grp, typeid)))
if (!(type = nc4_rec_find_nc_type(grp->nc4_info->root_grp, typeid1)))
return NC_EBADTYPE;
/* Count the number of fields. */
@ -424,7 +424,7 @@ NC4_inq_user_type(int ncid, nc_type typeid, char *name, size_t *size,
/* Given the ncid, typeid and fieldid, get info about the field. */
int
NC4_inq_compound_field(int ncid, nc_type typeid, int fieldid, char *name,
NC4_inq_compound_field(int ncid, nc_type typeid1, int fieldid, char *name,
size_t *offsetp, nc_type *field_typeidp, int *ndimsp,
int *dim_sizesp)
{
@ -438,7 +438,7 @@ NC4_inq_compound_field(int ncid, nc_type typeid, int fieldid, char *name,
return retval;
/* Find this type. */
if (!(type = nc4_rec_find_nc_type(grp->nc4_info->root_grp, typeid)))
if (!(type = nc4_rec_find_nc_type(grp->nc4_info->root_grp, typeid1)))
return NC_EBADTYPE;
/* Find the field. */
@ -481,7 +481,7 @@ find_nc4_file(int ncid, NC **nc)
/* Given the typeid and the name, get the fieldid. */
int
NC4_inq_compound_fieldindex(int ncid, nc_type typeid, const char *name, int *fieldidp)
NC4_inq_compound_fieldindex(int ncid, nc_type typeid1, const char *name, int *fieldidp)
{
NC *nc;
NC_TYPE_INFO_T *type;
@ -497,7 +497,7 @@ NC4_inq_compound_fieldindex(int ncid, nc_type typeid, const char *name, int *fie
return retval;
/* Find the type. */
if ((retval = nc4_find_type(NC4_DATA(nc), typeid, &type)))
if ((retval = nc4_find_type(NC4_DATA(nc), typeid1, &type)))
return retval;
/* Did the user give us a good compound type typeid? */
@ -628,7 +628,7 @@ NC4_inq_enum_ident(int ncid, nc_type xtype, long long value, char *identifier)
/* Get information about an enum member: an identifier and
* value. Identifier size will be <= NC_MAX_NAME. */
int
NC4_inq_enum_member(int ncid, nc_type typeid, int idx, char *identifier,
NC4_inq_enum_member(int ncid, nc_type typeid1, int idx, char *identifier,
void *value)
{
NC_GRP_INFO_T *grp;
@ -637,14 +637,14 @@ NC4_inq_enum_member(int ncid, nc_type typeid, int idx, char *identifier,
int i;
int retval;
LOG((2, "nc_inq_enum_member: ncid 0x%x typeid %d", ncid, typeid));
LOG((2, "nc_inq_enum_member: ncid 0x%x typeid %d", ncid, typeid1));
/* Find group metadata. */
if ((retval = nc4_find_nc4_grp(ncid, &grp)))
return retval;
/* Find this type. */
if (!(type = nc4_rec_find_nc_type(grp->nc4_info->root_grp, typeid)))
if (!(type = nc4_rec_find_nc_type(grp->nc4_info->root_grp, typeid1)))
return NC_EBADTYPE;
/* Complain if they are confused about the type. */
@ -672,7 +672,7 @@ NC4_inq_enum_member(int ncid, nc_type typeid, int idx, char *identifier,
/* Insert a identifierd value into an enum type. The value must fit within
* the size of the enum type, the identifier size must be <= NC_MAX_NAME. */
int
NC4_insert_enum(int ncid, nc_type typeid, const char *identifier,
NC4_insert_enum(int ncid, nc_type typeid1, const char *identifier,
const void *value)
{
NC_GRP_INFO_T *grp;
@ -692,7 +692,7 @@ NC4_insert_enum(int ncid, nc_type typeid, const char *identifier,
return retval;
/* Find type metadata. */
if ((retval = nc4_find_type(grp->nc4_info, typeid, &type)))
if ((retval = nc4_find_type(grp->nc4_info, typeid1, &type)))
return retval;
/* Did the user give us a good enum typeid? */
@ -716,10 +716,10 @@ NC4_insert_enum(int ncid, nc_type typeid, const char *identifier,
/* Insert one element into an already allocated vlen array element. */
int
NC4_put_vlen_element(int ncid, int typeid, void *vlen_element,
NC4_put_vlen_element(int ncid, int typeid1, void *vlen_element,
size_t len, const void *data)
{
nc_vlen_t *tmp = vlen_element;
nc_vlen_t *tmp = (nc_vlen_t*)vlen_element;
tmp->len = len;
tmp->p = (void *)data;
return NC_NOERR;
@ -727,10 +727,10 @@ NC4_put_vlen_element(int ncid, int typeid, void *vlen_element,
/* Insert one element into an already allocated vlen array element. */
int
NC4_get_vlen_element(int ncid, int typeid, const void *vlen_element,
NC4_get_vlen_element(int ncid, int typeid1, const void *vlen_element,
size_t *len, void *data)
{
const nc_vlen_t *tmp = vlen_element;
const nc_vlen_t *tmp = (nc_vlen_t*)vlen_element;
int type_size = 4;
*len = tmp->len;

View File

@ -1003,6 +1003,7 @@ makeconstdata(nc_type nctype)
consttype = nctype;
con.nctype = nctype;
con.lineno = lineno;
con.filled = 0;
switch (nctype) {
case NC_CHAR: con.value.charv = char_val; break;
case NC_BYTE: con.value.int8v = byte_val; break;

View File

@ -67,7 +67,7 @@ gen_load_c(
double *doublevalp;
char stmnt[C_MAX_STMNT];
size_t stmnt_len;
char s2[C_MAX_STMNT];
char s2[C_MAX_STMNT] = {'\0'};
if (!vars[varnum].has_data)
return;