From 5f2eb8afbfc8fbc0a2f82958f3cbd4e9b38af25b Mon Sep 17 00:00:00 2001 From: Dennis Heimbigner Date: Wed, 12 Dec 2012 20:05:06 +0000 Subject: [PATCH] Fix a number of potential problems by changing calls to nc_XXX to NC3/4_XXX --- include/netcdf.h | 1 + libsrc/nc3dispatch.c | 8 ++++---- libsrc/nc3internal.c | 2 +- libsrc4/nc4dim.c | 5 +++-- libsrc4/nc4file.c | 5 ++--- libsrc4/nc4grp.c | 12 ++++++------ libsrc4/nc4hdf.c | 13 +++++++------ libsrc4/nc4type.c | 3 ++- libsrc4/nc4var.c | 6 +++--- 9 files changed, 29 insertions(+), 26 deletions(-) diff --git a/include/netcdf.h b/include/netcdf.h index 1c9e40e1a..2e7530bd1 100644 --- a/include/netcdf.h +++ b/include/netcdf.h @@ -828,6 +828,7 @@ nc_get_var_chunk_cache(int ncid, int varid, size_t *sizep, size_t *nelemsp, EXTERNL int nc_redef(int ncid); +/* Is this ever used? */ EXTERNL int nc__enddef(int ncid, size_t h_minfree, size_t v_align, size_t v_minfree, size_t r_align); diff --git a/libsrc/nc3dispatch.c b/libsrc/nc3dispatch.c index 8b2f1b940..10c4087f9 100644 --- a/libsrc/nc3dispatch.c +++ b/libsrc/nc3dispatch.c @@ -202,7 +202,7 @@ NC3_inq_unlimdims(int ncid, int *ndimsp, int *unlimdimidsp) int retval; int unlimid; - if ((retval = nc_inq_unlimdim(ncid, &unlimid))) + if ((retval = NC3_inq_unlimdim(ncid, &unlimid))) return retval; if (unlimid != -1) { if(ndimsp) *ndimsp = 1; @@ -267,9 +267,9 @@ static int NC3_inq_varids(int ncid, int *nvarsp, int *varids) { int retval,v,nvars; - /* If this is a netcdf-3 file, there is only one group, the root + /* This is a netcdf-3 file, there is only one group, the root group, and its vars have ids 0 thru nvars - 1. */ - if ((retval = nc_inq(ncid, NULL, &nvars, NULL, NULL))) + if ((retval = NC3_inq(ncid, NULL, &nvars, NULL, NULL))) return retval; if(nvarsp) *nvarsp = nvars; if (varids) @@ -284,7 +284,7 @@ NC3_inq_dimids(int ncid, int *ndimsp, int *dimids, int include_parents) int retval,d,ndims; /* If this is a netcdf-3 file, then the dimids are going to be 0 thru ndims-1, so just provide them. */ - if ((retval = nc_inq(ncid, &ndims, NULL, NULL, NULL))) + if ((retval = NC3_inq(ncid, &ndims, NULL, NULL, NULL))) return retval; if(ndimsp) *ndimsp = ndims; if (dimids) diff --git a/libsrc/nc3internal.c b/libsrc/nc3internal.c index 0c85c645d..063d25039 100644 --- a/libsrc/nc3internal.c +++ b/libsrc/nc3internal.c @@ -1097,7 +1097,7 @@ NC3_close(int ncid) status = NC_endef(nc3, 0, 1, 0, 1); /* TODO: defaults */ if(status != NC_NOERR ) { - (void) nc_abort(ncid); + (void) NC3_abort(ncid); return status; } } diff --git a/libsrc4/nc4dim.c b/libsrc4/nc4dim.c index 60ab4a5d4..932d9883b 100644 --- a/libsrc4/nc4dim.c +++ b/libsrc4/nc4dim.c @@ -12,6 +12,7 @@ $Id: nc4dim.c,v 1.41 2010/05/25 17:54:23 dmh Exp $ */ #include "nc4internal.h" +#include "nc4dispatch.h" #ifdef USE_PNETCDF #include @@ -113,7 +114,7 @@ NC4_def_dim(int ncid, const char *name, size_t len, int *idp) /* If it's not in define mode, enter define mode. */ if (!(h5->flags & NC_INDEF)) - if ((retval = nc_redef(ncid))) + if ((retval = NC4_redef(ncid))) return retval; /* Make sure this is a valid netcdf name. */ @@ -328,7 +329,7 @@ NC4_rename_dim(int ncid, int dimid, const char *name) /* { */ /* if (h5->cmode & NC_CLASSIC_MODEL) */ /* return NC_ENOTINDEFINE; */ -/* if ((retval = nc_redef(ncid))) */ +/* if ((retval = NC4_redef(ncid))) */ /* return retval; */ /* } */ diff --git a/libsrc4/nc4file.c b/libsrc4/nc4file.c index 922603817..d0c4e2d0f 100644 --- a/libsrc4/nc4file.c +++ b/libsrc4/nc4file.c @@ -1245,8 +1245,7 @@ read_type(NC_GRP_INFO_T *grp, char *type_name) if ((retval = nc4_enum_member_add(&type->enum_member, type->size, member_name, value))) return retval; - - H5MM_xfree(member_name); + H5MM_xfree(member_name); /* Where is this defined? */ } /* Free the tempory memory for one value, and the member name @@ -2900,7 +2899,7 @@ NC4_sync(int ncid) { if (nc4_info->cmode & NC_CLASSIC_MODEL) return NC_EINDEFINE; - if ((retval = nc_enddef(ncid))) + if ((retval = NC4_enddef(ncid))) return retval; } diff --git a/libsrc4/nc4grp.c b/libsrc4/nc4grp.c index 45dffe1e8..b038e18e8 100644 --- a/libsrc4/nc4grp.c +++ b/libsrc4/nc4grp.c @@ -178,7 +178,7 @@ NC4_inq_grpname_full(int ncid, size_t *lenp, char *full_name) int i, ret = NC_NOERR; /* How many generations? */ - for (g = 0; !nc_inq_grp_parent(id, &parent_id); g++, id = parent_id) + for (g = 0; !NC4_inq_grp_parent(id, &parent_id); g++, id = parent_id) ; /* Allocate storage. */ @@ -197,12 +197,12 @@ NC4_inq_grpname_full(int ncid, size_t *lenp, char *full_name) /* Get the ncids for all generations. */ gid[0] = ncid; for (i = 1; i < g && !ret; i++) - ret = nc_inq_grp_parent(gid[i - 1], &gid[i]); + ret = NC4_inq_grp_parent(gid[i - 1], &gid[i]); /* Assemble the full name. */ for (i = g - 1; !ret && i >= 0 && !ret; i--) { - if ((ret = nc_inq_grpname(gid[i], grp_name))) + if ((ret = NC4_inq_grpname(gid[i], grp_name))) break; strcat(name, grp_name); if (i) @@ -297,7 +297,7 @@ NC4_inq_grp_full_ncid(int ncid, const char *full_name, int *grp_ncid) /* Keep parsing the string. */ for (; cp; id1 = id2) { - if ((ret = nc_inq_grp_ncid(id1, cp, &id2))) + if ((ret = NC4_inq_ncid(id1, cp, &id2))) { free(full_name_cpy); return ret; @@ -335,7 +335,7 @@ NC4_inq_varids(int ncid, int *nvars, int *varids) { /* If this is a netcdf-3 file, there is only one group, the root * group, and its vars have ids 0 thru nvars - 1. */ - if ((retval = nc_inq(ncid, NULL, &num_vars, NULL, NULL))) + if ((retval = NC4_inq(ncid, NULL, &num_vars, NULL, NULL))) return retval; if (varids) for (v = 0; v < num_vars; v++) @@ -396,7 +396,7 @@ NC4_inq_dimids(int ncid, int *ndims, int *dimids, int include_parents) { /* If this is a netcdf-3 file, then the dimids are going to be 0 * thru ndims-1, so just provide them. */ - if ((retval = nc_inq(ncid, &num, NULL, NULL, NULL))) + if ((retval = NC4_inq(ncid, &num, NULL, NULL, NULL))) return retval; if (dimids) for (d = 0; d < num; d++) diff --git a/libsrc4/nc4hdf.c b/libsrc4/nc4hdf.c index 7bb68dca4..941f4a0d6 100644 --- a/libsrc4/nc4hdf.c +++ b/libsrc4/nc4hdf.c @@ -15,6 +15,7 @@ #include "config.h" #include "nc4internal.h" +#include "nc4dispatch.h" #include #include @@ -924,7 +925,7 @@ nc4_get_vara(NC *nc, int ncid, int varid, const size_t *startp, /* We can't go beyond the latgest current extent of the unlimited dim. */ - if ((retval = nc_inq_dimlen(ncid, dim->dimid, &ulen))) + if ((retval = NC4_inq_dim(ncid, dim->dimid, NULL, &ulen))) BAIL(retval); /* Check for out of bound requests. */ @@ -2561,7 +2562,7 @@ pg_var(NC_PG_T pg, NC *nc, int ncid, int varid, nc_type xtype, for (i = 0; i < var->ndims; i++) { start[i] = 0; - if ((retval = nc_inq_dimlen(ncid, var->dimids[i], &(count[i])))) + if ((retval = NC4_inq_dim(ncid, var->dimids[i], NULL, &(count[i])))) return retval; } @@ -2662,7 +2663,7 @@ nc4_pg_varm(NC_PG_T pg, NC *nc, int ncid, int varid, const size_t *start, { if (h5->cmode & NC_CLASSIC_MODEL) return NC_EINDEFINE; - if ((retval = nc_enddef(ncid))) + if ((retval = NC4__enddef(ncid,0,0,0,0))) BAIL(retval); } @@ -2748,7 +2749,7 @@ nc4_pg_varm(NC_PG_T pg, NC *nc, int ncid, int varid, const size_t *start, else { size_t len; - if ((retval = nc_inq_dimlen(ncid, var->dimids[idim], &len))) + if ((retval = NC4_inq_dim(ncid, var->dimids[idim], NULL, &len))) goto done; myedges[idim] = len - mystart[idim]; } @@ -2773,13 +2774,13 @@ nc4_pg_varm(NC_PG_T pg, NC *nc, int ncid, int varid, const size_t *start, for (idim = maxidim; idim >= 0; --idim) { size_t dimlen; - if ((retval = nc_inq_dimlen(ncid, var->dimids[idim], &dimlen))) + if ((retval = NC4_inq_dim(ncid, var->dimids[idim], NULL, &dimlen))) goto done; /* Don't check unlimited dimension on PUTs. */ if (pg == PUT) { int stop = 0, d, num_unlim_dim, unlim_dimids[NC_MAX_DIMS]; - if ((retval = nc_inq_unlimdims(ncid, &num_unlim_dim, unlim_dimids))) + if ((retval = NC4_inq_unlimdims(ncid, &num_unlim_dim, unlim_dimids))) goto done; for (d = 0; d < num_unlim_dim; d++) if (var->dimids[idim] == unlim_dimids[d]) diff --git a/libsrc4/nc4type.c b/libsrc4/nc4type.c index 20a019057..415c7c2f6 100644 --- a/libsrc4/nc4type.c +++ b/libsrc4/nc4type.c @@ -13,6 +13,7 @@ $Id: nc4type.c,v 1.73 2010/05/25 17:54:24 dmh Exp $ */ #include "nc4internal.h" +#include "nc4dispatch.h" #define NUM_ATOMIC_TYPES 13 char atomic_name[NUM_ATOMIC_TYPES][NC_MAX_NAME + 1] = {"none", "byte", "char", @@ -206,7 +207,7 @@ add_user_type(int ncid, size_t size, const char *name, nc_type base_typeid, /* Turn on define mode if it is not on. */ if (!(h5->cmode & NC_INDEF)) - if ((retval = nc_redef(ncid))) + if ((retval = NC4_redef(ncid))) return retval; /* No size is provided for vlens or enums, get it from the base type. */ diff --git a/libsrc4/nc4var.c b/libsrc4/nc4var.c index 95021046e..7ccbb1093 100644 --- a/libsrc4/nc4var.c +++ b/libsrc4/nc4var.c @@ -137,7 +137,7 @@ nc_set_var_chunk_cache_ints(int ncid, int varid, int size, int nelems, if (preemption >= 0) real_preemption = preemption / 100.; - return nc_set_var_chunk_cache(ncid, varid, real_size, real_nelems, + return NC4_set_var_chunk_cache(ncid, varid, real_size, real_nelems, real_preemption); } @@ -190,7 +190,7 @@ nc_get_var_chunk_cache_ints(int ncid, int varid, int *sizep, float real_preemption; int ret; - if ((ret = nc_get_var_chunk_cache(ncid, varid, &real_size, + if ((ret = NC4_get_var_chunk_cache(ncid, varid, &real_size, &real_nelems, &real_preemption))) return ret; @@ -915,7 +915,7 @@ nc_def_var_extra(int ncid, int varid, int *shuffle, int *deflate, memcpy(var->fill_value, fill_value, type_size); /* If there's a _FillValue attribute, delete it. */ - retval = nc_del_att(ncid, varid, _FillValue); + retval = NC4_del_att(ncid, varid, _FillValue); if (retval && retval != NC_ENOTATT) return retval;