diff --git a/h5_test/tst_h_files.c b/h5_test/tst_h_files.c index 13b3f90f4..92dff86e2 100644 --- a/h5_test/tst_h_files.c +++ b/h5_test/tst_h_files.c @@ -88,7 +88,7 @@ main() if ((typeid = H5Topen(grpid, obj_name)) < 0) ERR; if ((class = H5Tget_class(typeid)) < 0) ERR; if (class != H5T_OPAQUE) ERR; - if (!(type_size = H5Tget_size(typeid))) ERR; + if (!(H5Tget_size(typeid))) ERR; } /* Close everything. */ @@ -152,7 +152,7 @@ main() /* Once open for read only access, the file can't be opened again * for write access. */ if ((fileid = H5Fopen(FILE_NAME, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) ERR; - if ((fileid2 = H5Fopen(FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT)) >= 0) ERR; + if (H5Fopen(FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT) >= 0) ERR; if (H5Fclose(fileid) < 0) ERR; /* But you can open the file for read/write access, and then open diff --git a/h5_test/tst_h_strings.c b/h5_test/tst_h_strings.c index 9238d8665..9d530cb13 100644 --- a/h5_test/tst_h_strings.c +++ b/h5_test/tst_h_strings.c @@ -66,7 +66,9 @@ main() if ((class = H5Tget_class(typeid)) < 0) ERR; if (class != H5T_STRING) ERR; if (!(type_size = H5Tget_size(typeid))) ERR; + if (type_size != sizeof(char *)) ERR; if ((is_str = H5Tis_variable_str(typeid)) < 0) ERR; + if (!is_str) ERR; /* Make sure this is a scalar. */ if (H5Sget_simple_extent_type(spaceid) != H5S_SCALAR) ERR; diff --git a/libdispatch/nctime.c b/libdispatch/nctime.c index caa4cab6f..2cb55deed 100644 --- a/libdispatch/nctime.c +++ b/libdispatch/nctime.c @@ -1063,7 +1063,7 @@ cdRel2Comp(cdCalenType timetype, char* relunits, double reltime, cdCompTime* com } /* Calculate new epochal time. */ /* Convert back to human, then comptime. */ - else{ + else if(baseunits == cdHour){ Cde2h(base_etm+delta, old_timetype, 1970, &humantime); } diff --git a/libsrc4/nc4dim.c b/libsrc4/nc4dim.c index f7e6193ad..3651eb71b 100644 --- a/libsrc4/nc4dim.c +++ b/libsrc4/nc4dim.c @@ -192,7 +192,6 @@ NC4_inq_dimid(int ncid, const char *name, int *idp) { if (idp) *idp = dim->dimid; - finished++; return NC_NOERR; } diff --git a/libsrc4/nc4file.c b/libsrc4/nc4file.c index 11ff7d698..2b4c7764b 100644 --- a/libsrc4/nc4file.c +++ b/libsrc4/nc4file.c @@ -802,6 +802,8 @@ get_type_info2(NC_HDF5_FILE_INFO_T *h5, hid_t datasetid, endianness = NC_ENDIAN_LITTLE; else if (order == H5T_ORDER_BE) endianness = NC_ENDIAN_BIG; + else /* don't support H5T_ORDER_VAX, H5T_ORDER_MIXED, H5T_ORDER_NONE */ + return NC_EBADTYPE; /* Copy this into the type_info struct. */ (*type_info)->endianness = endianness; } @@ -1960,9 +1962,9 @@ nc4_rec_read_vars(NC_GRP_INFO_T *grp) res = H5Literate(grp->hdf_grpid, H5_INDEX_NAME, H5_ITER_INC, &idx, nc4_rec_read_vars_cb, (void *)grp); - if (res<0) - return NC_EHDFERR; } + if (res<0) + return NC_EHDFERR; /* Scan the group for global (i.e. group-level) attributes. */ if ((retval = read_grp_atts(grp))) @@ -2807,9 +2809,7 @@ int NC4__enddef(int ncid, size_t h_minfree, size_t v_align, size_t v_minfree, size_t r_align) { - NC_FILE_INFO_T *nc; - - if (!(nc = nc4_find_nc_file(ncid))) + if (!nc4_find_nc_file(ncid)) return NC_EBADID; return NC4_enddef(ncid); @@ -3151,7 +3151,6 @@ NC4_inq(int ncid, int *ndimsp, int *nvarsp, int *nattsp, int *unlimdimidp) if (dim->unlimited) { *unlimdimidp = dim->dimid; - found++; break; } } diff --git a/libsrc4/nc4hdf.c b/libsrc4/nc4hdf.c index d6bb789f6..7ec98eb10 100644 --- a/libsrc4/nc4hdf.c +++ b/libsrc4/nc4hdf.c @@ -418,7 +418,7 @@ nc4_get_hdf_typeid(NC_HDF5_FILE_INFO_T *h5, nc_type xtype, break; default: /* Maybe this is a user defined type? */ - if (!(retval = nc4_find_type(h5, xtype, &type))) + if (!nc4_find_type(h5, xtype, &type)) { if (!type) return NC_EBADTYPE; diff --git a/libsrc4/nc4internal.c b/libsrc4/nc4internal.c index 628d55350..db13e4200 100644 --- a/libsrc4/nc4internal.c +++ b/libsrc4/nc4internal.c @@ -122,7 +122,7 @@ find_var_shape_grp(NC_GRP_INFO_T *grp, int varid, int *ndims, dim in the space. */ if ((dataset_ndims = H5Sget_simple_extent_ndims(spaceid)) < 0) BAIL(NC_EHDFERR); - if (dataset_ndims != *ndims) + if (ndims && dataset_ndims != *ndims) BAIL(NC_EHDFERR); if (!(h5dimlen = malloc(dataset_ndims * sizeof(hsize_t)))) BAIL(NC_ENOMEM); diff --git a/libsrc4/nc4var.c b/libsrc4/nc4var.c index 139566f78..443e96b2d 100644 --- a/libsrc4/nc4var.c +++ b/libsrc4/nc4var.c @@ -396,7 +396,7 @@ nc_def_var_nc4(int ncid, const char *name, nc_type xtype, /* If this is a user defined type, find it. */ if (xtype > NC_STRING) - if ((retval = nc4_find_type(grp->file->nc4_info, xtype, &type_info))) + if (nc4_find_type(grp->file->nc4_info, xtype, &type_info)) return NC_EBADTYPE; /* cast needed for braindead systems with signed size_t */ diff --git a/nc_test/test_put.m4 b/nc_test/test_put.m4 index ff6b6aed9..526dc3812 100644 --- a/nc_test/test_put.m4 +++ b/nc_test/test_put.m4 @@ -433,7 +433,8 @@ test_nc_put_var_$1(void) assert(var_rank[i] <= MAX_RANK); assert(var_nels[i] <= MAX_NELS); err = nc_put_var_$1(BAD_ID, i, value); - + IF (err != NC_EBADID) + error("bad ncid: status = %d", err); nels = 1; for (j = 0; j < var_rank[i]; j++) { nels *= var_shape[i][j]; diff --git a/nc_test/test_read.c b/nc_test/test_read.c index dc8302531..894a50e77 100644 --- a/nc_test/test_read.c +++ b/nc_test/test_read.c @@ -264,10 +264,14 @@ test_nc_inq(void) int ngatts0; int recdim0; err = nc_enddef(ncid2); /* enter data mode */ + IF (err) + error("nc_enddef: %s", nc_strerror(err)); err = nc_inq(ncid2, &ndims0, &nvars0, &ngatts0, &recdim0); IF (err) error("nc_inq: %s", nc_strerror(err)); err = nc_redef(ncid2); /* enter define mode */ + IF (err) + error("nc_redef: %s", nc_strerror(err)); /* Check that inquire still works in define mode */ err = nc_inq(ncid2, &ndims, &nvars, &ngatts, &recdim); IF (err) diff --git a/nc_test/test_write.c b/nc_test/test_write.c index 5a757b33f..e334aa03a 100644 --- a/nc_test/test_write.c +++ b/nc_test/test_write.c @@ -522,6 +522,8 @@ test_nc_def_dim(void) IF (dimid != 0) error("Unexpected recdim"); err = nc_inq_dimlen(ncid, dimid, &length); + IF (err) + error("nc_inq_dimlen: %s", nc_strerror(err)); IF (length != 0) error("Unexpected length"); err = nc_def_dim(ncid, "abc", NC_UNLIMITED, &dimid); @@ -600,6 +602,8 @@ test_nc_rename_dim(void) IF (err) error("nc_rename_dim: %s", nc_strerror(err)); err = nc_inq_dimname(ncid, 2, name); + IF (err) + error("nc_inq_dimname: %s", nc_strerror(err)); IF (strcmp(name, "abc") != 0) error("Unexpected name: %s", name); err = nc_rename_dim(ncid, 0, "abc"); @@ -2072,6 +2076,6 @@ test_nc_set_default_format(void) } /* Remove the left-over file. */ - if ((err = remove(scratch))) + if (remove(scratch)) error("remove of %s failed", scratch); } diff --git a/nc_test/tst_diskless2.c b/nc_test/tst_diskless2.c index 8ea03ac18..14125e772 100644 --- a/nc_test/tst_diskless2.c +++ b/nc_test/tst_diskless2.c @@ -100,10 +100,13 @@ main() {/* create tst_diskless2.nc */ check_err(stat,__LINE__,__FILE__); econst = 0; stat = nc_insert_enum(root_grp, enum_t_typ, "Clear", &econst); + check_err(stat,__LINE__,__FILE__); econst = 1; stat = nc_insert_enum(root_grp, enum_t_typ, "Cumulonimbus", &econst); + check_err(stat,__LINE__,__FILE__); econst = 2; stat = nc_insert_enum(root_grp, enum_t_typ, "Stratus", &econst); + check_err(stat,__LINE__,__FILE__); } stat = nc_def_opaque(root_grp, 11, "opaque_t", &opaque_t_typ); diff --git a/nc_test/tst_diskless3.c b/nc_test/tst_diskless3.c index 0cb688725..0cdf156a3 100644 --- a/nc_test/tst_diskless3.c +++ b/nc_test/tst_diskless3.c @@ -124,7 +124,7 @@ test_one_with_att(const char *testfile) if (ndims != 1 && nvars != 1 && natts != 0 && unlimdimid != 0) ERR; if (nc_get_var_text(ncid, varid, &data_in)) ERR; if (data_in != data) ERR; - if (nc_get_att_text(ncid, NC_GLOBAL, ATT_NAME, &data_in)); + if (nc_get_att_text(ncid, NC_GLOBAL, ATT_NAME, &data_in)) ERR; if (data_in != data) ERR; if (nc_close(ncid)) ERR; return 0; diff --git a/nc_test/tst_nofill.c b/nc_test/tst_nofill.c index 4b3c5a59a..8485fade3 100644 --- a/nc_test/tst_nofill.c +++ b/nc_test/tst_nofill.c @@ -457,7 +457,7 @@ main(int argc, char **argv) if (data1[nn] != data2[nn]) { badvars++; fprintf(stderr, - "\tFrom nofill file, %s[%d] = %d\tFrom fill file, %s[%d] = %d\n", + "\tFrom nofill file, %s[%lu] = %d\tFrom fill file, %s[%lu] = %d\n", varname1, nn, data1[nn], varname2, nn, data2[nn]); break; }; diff --git a/nc_test/tst_small.c b/nc_test/tst_small.c index 7ac9918e7..47e175686 100644 --- a/nc_test/tst_small.c +++ b/nc_test/tst_small.c @@ -53,7 +53,7 @@ test_small_atts(const char *testfile) if (ndims != 0 && nvars != 0 && natts != 1 && unlimdimid != -1) ERR; if (nc_inq_attlen(ncid, NC_GLOBAL, ATT_NAME, &len_in)) ERR; if (len_in != t + 1) ERR; - if (nc_get_att_text(ncid, NC_GLOBAL, ATT_NAME, att_in)); + if (nc_get_att_text(ncid, NC_GLOBAL, ATT_NAME, att_in)) ERR; if (strncmp(att_in, att, t)) ERR; if (nc_close(ncid)) ERR; } @@ -292,7 +292,7 @@ test_one_growing_with_att(const char *testfile) index[0] = r; if (nc_get_var1_text(ncid, 0, index, &data_in)) ERR; if (data_in != data[r]) ERR; - if (nc_get_att_text(ncid, varid, att_name, &data_in)); + if (nc_get_att_text(ncid, varid, att_name, &data_in)) ERR; if (data_in != data[r]) ERR; if (nc_close(ncid)) ERR; } /* Next record. */ @@ -388,7 +388,7 @@ test_one_with_att(const char *testfile) if (ndims != 1 && nvars != 1 && natts != 0 && unlimdimid != 0) ERR; if (nc_get_var_text(ncid, varid, &data_in)) ERR; if (data_in != data) ERR; - if (nc_get_att_text(ncid, NC_GLOBAL, ATT_NAME, &data_in)); + if (nc_get_att_text(ncid, NC_GLOBAL, ATT_NAME, &data_in)) ERR; if (data_in != data) ERR; if (nc_close(ncid)) ERR; return 0; diff --git a/nc_test4/tst_endian_fill.c b/nc_test4/tst_endian_fill.c index b98b11c54..d5bd57d72 100644 --- a/nc_test4/tst_endian_fill.c +++ b/nc_test4/tst_endian_fill.c @@ -38,7 +38,7 @@ main(int argc, char **argv) * NC_FILL_INT */ if (nc_def_var(ncid, VAR3_NAME, NC_INT, VAR_RANK, 0, &var3id)) ERR; if (nc_def_var_endian(ncid, var3id, NC_ENDIAN_BIG)) ERR; - if (nc_put_var(ncid, var3id, &fill)); + if (nc_put_var(ncid, var3id, &fill)) ERR; if (nc_close(ncid)) ERR; /* Check it out. */ diff --git a/nc_test4/tst_files.c b/nc_test4/tst_files.c index 31fd2c9ec..56f59994e 100644 --- a/nc_test4/tst_files.c +++ b/nc_test4/tst_files.c @@ -418,8 +418,8 @@ test_redef(int format) /* This will fail, except for netcdf-4/hdf5, which permits any * name. */ if (format != NC_FORMAT_NETCDF4) - if ((ret = nc_def_dim(ncid, REDEF_NAME_ILLEGAL, REDEF_DIM2_LEN, - &dimids[1])) != NC_EBADNAME) ERR; + if (nc_def_dim(ncid, REDEF_NAME_ILLEGAL, REDEF_DIM2_LEN, + &dimids[1]) != NC_EBADNAME) ERR; if (nc_def_dim(ncid, REDEF_DIM1_NAME, REDEF_DIM1_LEN, &dimids[0])) ERR; if (nc_def_dim(ncid, REDEF_DIM2_NAME, REDEF_DIM2_LEN, &dimids[1])) ERR; diff --git a/nc_test4/tst_strings.c b/nc_test4/tst_strings.c index a77bb0e74..66a8aeaef 100644 --- a/nc_test4/tst_strings.c +++ b/nc_test4/tst_strings.c @@ -424,7 +424,7 @@ main(int argc, char **argv) if (nc_get_var(ncid, varid, data_in)) ERR; for (i = 0; i < DHR_LEN; i++) if (strcmp(data_in[i], data[i])) ERR; - if (nc_free_string(DHR_LEN, data_in)); + if (nc_free_string(DHR_LEN, data_in)) ERR; /* Check the empty var and att. */ if (nc_inq_varid(ncid, VAR_NAME2, &varid)) ERR; diff --git a/ncdump/cdl4/n3time.cdl b/ncdump/cdl4/n3time.cdl index f1da33ca4..b34657ba0 100644 --- a/ncdump/cdl4/n3time.cdl +++ b/ncdump/cdl4/n3time.cdl @@ -190,7 +190,6 @@ variables: :WMOStationNumber = -1 ; :Location = "Louisville, Colorado" ; :AlignmentDeg = 0.f ; - :FrequencyHz = 4.49e+08f ; :LapxmVersion = "2.5.0.0" ; :ConfigFile = "NetCDF4 10.cfg" ; :DataTypes = "Moments," ; diff --git a/ncdump/chunkspec.c b/ncdump/chunkspec.c index e1a77146f..0c85c08af 100644 --- a/ncdump/chunkspec.c +++ b/ncdump/chunkspec.c @@ -42,13 +42,13 @@ chunkspec_parse(int ncid, const char *spec) { size_t ndims = 0; int idim; int ret; + int comma_seen = 0; chunkspecs.ndims = 0; if (!spec || *spec == '\0') return NC_NOERR; /* Count unescaped commas, handle consecutive unescaped commas as error */ for(cp = spec; *cp; cp++) { - int comma_seen = 0; if(*cp == ',' && *pp != '\\') { if(comma_seen) { /* consecutive commas detected */ return(NC_EINVAL); @@ -65,7 +65,6 @@ chunkspec_parse(int ncid, const char *spec) { chunkspecs.dimids = (int *) emalloc(ndims * sizeof(int)); chunkspecs.chunksizes = (size_t *) emalloc(ndims * sizeof(size_t)); /* Look up dimension ids and assign chunksizes */ - cp = spec; pp = spec; np = spec; idim = 0; diff --git a/ncdump/expected4/n3time.dmp b/ncdump/expected4/n3time.dmp index f1da33ca4..b34657ba0 100644 --- a/ncdump/expected4/n3time.dmp +++ b/ncdump/expected4/n3time.dmp @@ -190,7 +190,6 @@ variables: :WMOStationNumber = -1 ; :Location = "Louisville, Colorado" ; :AlignmentDeg = 0.f ; - :FrequencyHz = 4.49e+08f ; :LapxmVersion = "2.5.0.0" ; :ConfigFile = "NetCDF4 10.cfg" ; :DataTypes = "Moments," ; diff --git a/ncdump/ncdump.c b/ncdump/ncdump.c index 30c106b48..f4d264dcd 100644 --- a/ncdump/ncdump.c +++ b/ncdump/ncdump.c @@ -729,6 +729,8 @@ pr_att( case NC_UINT64: value = *((uint64_t *)data + i); break; + default: + error("enum must have an integer base type: %d", base_nc_type); } NC_CHECK( nc_inq_enum_ident(ncid, att.type, value, enum_name)); diff --git a/ncdump/vardata.c b/ncdump/vardata.c index db88144db..ab133b1a1 100644 --- a/ncdump/vardata.c +++ b/ncdump/vardata.c @@ -81,6 +81,7 @@ lput(const char *cp) { * general lput-type function. */ +#define CDL_COMMENT_PREFIX "// " void lput2( const char *cp, /* string to print */ @@ -91,8 +92,7 @@ lput2( { static int linep; /* current line position (number of */ /* chars); saved between calls */ - static char *prefix = "// "; /* prefix for CDL comment */ - int len_prefix = strlen (prefix); + int len_prefix = strlen (CDL_COMMENT_PREFIX); boolean make_newline; size_t len1 = strlen(cp); /* length of input string */ @@ -122,14 +122,14 @@ lput2( if (len_prefix > 0) { if (first_item || make_newline) { - printf (prefix); + printf (CDL_COMMENT_PREFIX); linep = linep + len_prefix; } } /* (3) Output caller's string value. */ - printf (cp); + printf ("%s", cp); } diff --git a/ncgen/nciter.c b/ncgen/nciter.c index ae6209897..3ca953421 100644 --- a/ncgen/nciter.c +++ b/ncgen/nciter.c @@ -52,6 +52,7 @@ nc_get_iter(Symbol* vsym, stat = nciter_ndims(vsym, &ndims); CHECK(stat, nciter_ndims); stat = nciter_dimlens(vsym,dimsizes); + CHECK(stat, nciter_dimlens); /* compute total # elements */ nvalues=1; for(dim = 0; dim < ndims; dim++) { diff --git a/nctest/cdftests.c b/nctest/cdftests.c index 797c1cb3a..7cf5e0d84 100644 --- a/nctest/cdftests.c +++ b/nctest/cdftests.c @@ -64,7 +64,7 @@ test_nccreate(path) nerrs++; } /* this call should fail, since we're using NC_NOCLOBBER mode */ - if ((ncid = nccreate(path, NC_NOCLOBBER)) != -1) { + if (nccreate(path, NC_NOCLOBBER) != -1) { error("%s: nccreate failed to honor NC_NOCLOBBER mode", pname); nerrs++; } @@ -114,7 +114,7 @@ test_ncopen(path) (void) fprintf(stderr, "*** Testing %s ...\t\t", &pname[5]); /* Open a nonexistent file */ - if((ncid0 = ncopen(xpath, NC_NOWRITE)) != -1) { + if(ncopen(xpath, NC_NOWRITE) != -1) { error("%s: ncopen should fail opening nonexistent file", pname); return ++nerrs; @@ -148,7 +148,7 @@ test_ncopen(path) return ++nerrs; } - if((ncid0 = ncopen(TEMP_FILE_NAME, NC_NOWRITE)) != -1) { + if(ncopen(TEMP_FILE_NAME, NC_NOWRITE) != -1) { error("%s: ncopen should fail opening non-netCDF file", pname); return ++nerrs; diff --git a/nctest/tst_rename.c b/nctest/tst_rename.c index 66171e643..be1246a79 100644 --- a/nctest/tst_rename.c +++ b/nctest/tst_rename.c @@ -175,7 +175,6 @@ create_file() size_t aa_startset[1] = {0} ; size_t aa_countset[1] = {4} ; stat = nc_put_vara(ncid, aa_id, aa_startset, aa_countset, aa_data); - stat = nc_put_vara(ncid, aa_id, aa_startset, aa_countset, aa_data); check_err(stat,__LINE__,__FILE__); } @@ -184,7 +183,6 @@ create_file() size_t bb_startset[2] = {0, 0} ; size_t bb_countset[2] = {3, 3} ; stat = nc_put_vara(ncid, bb_id, bb_startset, bb_countset, bb_data); - stat = nc_put_vara(ncid, bb_id, bb_startset, bb_countset, bb_data); check_err(stat,__LINE__,__FILE__); } @@ -193,7 +191,6 @@ create_file() size_t dd_startset[1] = {0} ; size_t dd_countset[1] = {3} ; stat = nc_put_vara(ncid, dd_id, dd_startset, dd_countset, dd_data); - stat = nc_put_vara(ncid, dd_id, dd_startset, dd_countset, dd_data); check_err(stat,__LINE__,__FILE__); } diff --git a/nctest/vardef.c b/nctest/vardef.c index 6a92c4579..bf1087408 100644 --- a/nctest/vardef.c +++ b/nctest/vardef.c @@ -226,7 +226,6 @@ test_ncvardef(path) ncclose(cdfid); return ++nerrs; } /* try bad ids in dims vector, should fail */ - id = va[0].dims[0]; va[0].dims[va[0].ndims-1] = -1; if (ncvardef(cdfid, "baddims", va[0].type, va[0].ndims, va[0].dims) != -1) {