Merge pull request #2875 from seanm/clang-tidy-fixes

Misc clang-tidy fixes, and added a .clang-tidy config file
This commit is contained in:
Ward Fisher 2024-04-05 14:45:22 -06:00 committed by GitHub
commit 9639ba445d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
57 changed files with 214 additions and 177 deletions

88
.clang-tidy Normal file
View File

@ -0,0 +1,88 @@
---
Checks: "-*,\
bugprone-*,\
-bugprone-easily-swappable-parameters,\
-bugprone-assignment-in-if-condition,\
-bugprone-signed-char-misuse,\
-bugprone-branch-clone,\
-bugprone-narrowing-conversions,\
-bugprone-macro-parentheses,\
-bugprone-switch-missing-default-case,\
-bugprone-suspicious-include,\
-bugprone-reserved-identifier,\
-bugprone-misplaced-widening-cast,\
-bugprone-implicit-widening-of-multiplication-result,\
-bugprone-suspicious-realloc-usage,\
-bugprone-sizeof-expression,\
cert*,\
-cert-err33-c,\
-cert-err34-c,\
-cert-str34-c,\
-cert-dcl03-c,\
-cert-msc30-c,\
-cert-msc50-cpp,\
-cert-dcl37-c,\
-cert-dcl51-cpp,\
clang-analyzer-*,\
-clang-analyzer-core.CallAndMessage,\
-clang-analyzer-core.DivideZero,\
-clang-analyzer-core.NonNullParamChecker,\
-clang-analyzer-core.NullDereference,\
-clang-analyzer-core.UndefinedBinaryOperatorResult,\
-clang-analyzer-core.VLASize,\
-clang-analyzer-core.uninitialized.ArraySubscript,\
-clang-analyzer-core.uninitialized.Assign,\
-clang-analyzer-core.uninitialized.Branch,\
-clang-analyzer-cplusplus.Move,\
-clang-analyzer-cplusplus.NewDelete,\
-clang-analyzer-cplusplus.NewDeleteLeaks,\
-clang-analyzer-cplusplus.PlacementNew,\
-clang-analyzer-deadcode.DeadStores,\
-clang-analyzer-optin.cplusplus.UninitializedObject,\
-clang-analyzer-optin.cplusplus.VirtualCall,\
-clang-analyzer-optin.mpi.MPI-Checker,\
-clang-analyzer-optin.performance.Padding,\
-clang-analyzer-optin.portability.UnixAPI,\
-clang-analyzer-security.FloatLoopCounter,\
-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,\
-clang-analyzer-security.insecureAPI.rand,\
-clang-analyzer-security.insecureAPI.strcpy,\
-clang-analyzer-unix.Malloc,\
-clang-analyzer-unix.MallocSizeof,\
-clang-analyzer-unix.MismatchedDeallocator,\
-clang-analyzer-unix.cstring.NullArg,\
-clang-analyzer-valist.Unterminated,\
misc-*,\
-misc-header-include-cycle,\
-misc-include-cleaner,\
-misc-no-recursion,\
-misc-unused-parameters,\
-misc-static-assert,\
-misc-redundant-expression,\
modernize-*,\
-modernize-macro-to-enum,\
mpi-*,\
openmp-*,\
performance-*,\
-performance-no-int-to-ptr,\
portability-*,\
readability-*,\
-readability-identifier-length,\
-readability-isolate-declaration,\
-readability-braces-around-statements,\
-readability-magic-numbers,\
-readability-else-after-return,\
-readability-function-cognitive-complexity,\
-readability-function-size,\
-readability-non-const-parameter,\
-readability-inconsistent-declaration-parameter-name,\
-readability-avoid-unconditional-preprocessor-if,\
-readability-named-parameter,\
-readability-duplicate-include,\
-readability-misleading-indentation,\
-readability-avoid-const-params-in-decls,\
-readability-redundant-declaration,\
-readability-redundant-preprocessor,\
"
#WarningsAsErrors: "*"
...

View File

@ -45,7 +45,7 @@ main()
/* Create a bunch of phoney data so we have something to write in
the example file. */
for (fp=(float *)temp, i=0; i<LAT_LEN*LON_LEN; i++)
*fp++ = 10.f + (float)i/10.f;
*fp++ = 10.F + (float)i/10.F;
/* Now create the file in both formats with the same code. */
for (i=0; i<2; i++)

View File

@ -87,9 +87,9 @@ main()
* would have some real data to write, for example, model
* output. */
for (lat = 0; lat < NLAT; lat++)
lats[lat] = START_LAT + 5.f*(float)lat;
lats[lat] = START_LAT + 5.F*(float)lat;
for (lon = 0; lon < NLON; lon++)
lons[lon] = START_LON + 5.f*(float)lon;
lons[lon] = START_LON + 5.F*(float)lon;
for (lvl = 0; lvl < NLVL; lvl++)
for (lat = 0; lat < NLAT; lat++)

View File

@ -140,22 +140,22 @@ main()
them and check them. */
if ((retval = nc_get_att_text(ncid, lat_varid, UNITS, lat_units_in)))
ERR(retval);
if (strncmp(lat_units_in, LAT_UNITS, strlen(LAT_UNITS)))
if (strncmp(lat_units_in, LAT_UNITS, strlen(LAT_UNITS)) != 0)
return 2;
if ((retval = nc_get_att_text(ncid, lon_varid, UNITS, lon_units_in)))
ERR(retval);
if (strncmp(lon_units_in, LON_UNITS, strlen(LON_UNITS)))
if (strncmp(lon_units_in, LON_UNITS, strlen(LON_UNITS)) != 0)
return 2;
if ((retval = nc_get_att_text(ncid, pres_varid, UNITS, pres_units_in)))
ERR(retval);
if (strncmp(pres_units_in, PRES_UNITS, strlen(PRES_UNITS)))
if (strncmp(pres_units_in, PRES_UNITS, strlen(PRES_UNITS)) != 0)
return 2;
if ((retval = nc_get_att_text(ncid, temp_varid, UNITS, temp_units_in)))
ERR(retval);
if (strncmp(temp_units_in, TEMP_UNITS, strlen(TEMP_UNITS))) return 2;
if (strncmp(temp_units_in, TEMP_UNITS, strlen(TEMP_UNITS)) != 0) return 2;
/* Close the file. */
if ((retval = nc_close(ncid)))

View File

@ -78,9 +78,9 @@ main()
* would have some real data to write, for example, model
* output. */
for (lat = 0; lat < NLAT; lat++)
lats[lat] = START_LAT + 5.f*(float)lat;
lats[lat] = START_LAT + 5.F*(float)lat;
for (lon = 0; lon < NLON; lon++)
lons[lon] = START_LON + 5.f*(float)lon;
lons[lon] = START_LON + 5.F*(float)lon;
for (lat = 0; lat < NLAT; lat++)
for (lon = 0; lon < NLON; lon++)

View File

@ -12,7 +12,6 @@
static void completesegments(NClist* fullpath, NClist* segments);
static NCerror qualifyprojectionnames(DCEprojection* proj);
static NCerror qualifyprojectionsizes(DCEprojection* proj);
static NCerror qualifyprojectionnames(DCEprojection* proj);
static NCerror matchpartialname(NClist* nodes, NClist* segments, CDFnode** nodep);
static int matchsuffix(NClist* matchpath, NClist* segments);
static int iscontainer(CDFnode* node);

View File

@ -628,7 +628,6 @@ normal: *s++ = *t++;
}
}
*s = '\0';
return;
}

View File

@ -15,8 +15,6 @@
#include <io.h>
#endif
extern int mkstemp(char *template);
#define LBRACKET '['
#define RBRACKET ']'

View File

@ -311,7 +311,7 @@ done:
#define LBRACK '['
#define RBRACK ']'
static int gettype(const int q0, const int q1, int* unsignedp);
static int gettype(int q0, int q1, int* unsignedp);
/* Look at q0 and q1) to determine type */
static int

View File

@ -77,7 +77,7 @@ NC_compare_nc_types(int ncid1, int typeid1, int ncid2, int typeid2, int *equalp)
return ret;
/* Check the obvious. */
if(size1 != size2 || class1 != class2 || strcmp(name1,name2))
if(size1 != size2 || class1 != class2 || strcmp(name1,name2) != 0)
return NC_NOERR;
/* Check user-defined types in detail. */
@ -109,7 +109,7 @@ NC_compare_nc_types(int ncid1, int typeid1, int ncid2, int typeid2, int *equalp)
value1)) ||
(ret = nc_inq_enum_member(ncid2, typeid2, i, name2,
value2)) ||
strcmp(name1, name2) || memcmp(value1, value2, size1))
strcmp(name1, name2) != 0 || memcmp(value1, value2, size1) != 0)
{
free(value1);
free(value2);

View File

@ -45,8 +45,6 @@
#endif
extern int NC_initialized; /**< True when dispatch table is initialized. */
/* User-defined formats. */
NC_Dispatch *UDF0_dispatch_table = NULL;
char UDF0_magic_number[NC_MAX_MAGIC_NUMBER_LEN + 1] = "";

View File

@ -516,7 +516,6 @@ trim(char* s)
/* Ok, overwrite any leading whitespace */
for(q=s;*p;) {*q++ = *p++;}
*q = '\0';
return;
}
static size_t

View File

@ -1386,7 +1386,9 @@ openmagic(struct MagicFile* file)
file->filelen = (long long)size;
#endif
}
rewind(file->fp);
int retval2 = fseek(file->fp, 0L, SEEK_SET);
if(retval2 != 0)
{status = errno; goto done;}
}
done:
return check(status);

View File

@ -235,7 +235,7 @@ nc_copy_data_all(int ncid, nc_type xtype, const void* memory, size_t count, void
/* allocate the top-level */
if(count > 0) {
if((copy = calloc(xsize,count))==NULL)
if((copy = calloc(count,xsize))==NULL)
{stat = NC_ENOMEM; goto done;}
}
stat = nc_copy_data(ncid,xtype,memory,count,copy);

View File

@ -567,7 +567,7 @@ NC_copy_data_all(NC* nc, nc_type xtype, const void* memory, size_t count, void**
if(xtype <= NC_STRING && count > 0) {
xsize = NC_atomictypelen(xtype);
if((copy = calloc(xsize,count))==NULL) {stat = NC_ENOMEM; goto done;}
if((copy = calloc(count,xsize))==NULL) {stat = NC_ENOMEM; goto done;}
if(xtype < NC_STRING) /* fixed-size atomic type */
memcpy(copy,memory,xsize*count);
else { /* string type */
@ -589,7 +589,7 @@ NC_copy_data_all(NC* nc, nc_type xtype, const void* memory, size_t count, void**
xsize = utype->size;
/* allocate the top-level */
if(count > 0) {
if((copy = calloc(xsize,count))==NULL) {stat = NC_ENOMEM; goto done;}
if((copy = calloc(count,xsize))==NULL) {stat = NC_ENOMEM; goto done;}
}
if((stat = NC_copy_data(nc,xtype,memory,count,copy)))
(void)NC_reclaim_data_all(nc,xtype,copy,count);

View File

@ -117,7 +117,7 @@ static int NCJcloneDict(const NCjson* dict, NCjson** clonep);
static int NCJunparseR(const NCjson* json, NCJbuf* buf, unsigned flags);
static int bytesappendquoted(NCJbuf* buf, const char* s);
static int bytesappend(NCJbuf* buf, const char* s);
static int bytesappendc(NCJbuf* bufp, const char c);
static int bytesappendc(NCJbuf* bufp, char c);
/* Hide everything for plugins */
#ifdef NETCDF_JSON_H

View File

@ -55,7 +55,6 @@ cdTrim(char* s, int n)
return;
for(c=s; *c && c<s+n-1 && !isspace((int)*c); c++);
*c='\0';
return;
}
static void
@ -73,7 +72,6 @@ cdError(char *fmt, ...)
}
if(cuErrOpts & CU_FATAL)
exit(1);
return;
}
#define ISLEAP(year,timeType) ((timeType & Cd366) || (((timeType) & CdHasLeap) && (!((year) % 4) && (((timeType) & CdJulianType) || (((year) % 100) || !((year) % 400))))))
@ -134,7 +132,6 @@ CdMonthDay(int *doy, CdTime *date)
if(idoy <= 0)
return;
}
return;
}
/* Compute day-of-year from year, month and day
@ -175,7 +172,6 @@ CdDayOfYear(CdTime *date, int *doy)
} else { /* date->timeType & Cd360 */
*doy = 30*(month-1) + date->day + leap_add ;
}
return;
}
/* Convert epochal time (hours since 00 jan 1, 1970)
@ -235,8 +231,6 @@ Cde2h(double etime, CdTimeType timeType, long baseYear, CdTime *htime)
if(!(timeType & CdChronCal)) htime->year = 0; /* Set year to 0 for Clim */
htime->timeType = timeType;
CdMonthDay(&doy,htime);
return;
}
/* Add 'nDel' times 'delTime' to epochal time 'begEtm',
@ -250,9 +244,6 @@ CdAddDelTime(double begEtm, long nDel, CdDeltaTime delTime, CdTimeType timeType,
long delMonths, delYears;
CdTime bhtime, ehtime;
extern void Cde2h(double etime, CdTimeType timeType, long baseYear, CdTime *htime);
extern void Cdh2e(CdTime *htime, double *etime);
switch(delTime.units){
case CdYear:
delMonths = 12;
@ -305,7 +296,6 @@ CdAddDelTime(double begEtm, long nDel, CdDeltaTime delTime, CdTimeType timeType,
break;
default: break;
}
return;
}
/* Parse relative units, returning the unit and base component time. */
@ -473,8 +463,6 @@ CdDivDelTime(double begEtm, double endEtm, CdDeltaTime delTime, CdTimeType timeT
CdTime bhtime, ehtime;
int hoursInYear;
extern void Cde2h(double etime, CdTimeType timeType, long baseYear, CdTime *htime);
switch(delTime.units){
case CdYear:
delMonths = 12;
@ -541,7 +529,6 @@ CdDivDelTime(double begEtm, double endEtm, CdDeltaTime delTime, CdTimeType timeT
break;
default: break;
}
return;
}
/* Value is in hours. Translate to units. */
@ -655,7 +642,6 @@ Cdh2e(CdTime *htime, double *etime)
}
}
*etime = (double) (day_cnt + doy - 1) * 24. + htime->hour;
return;
}
/* Validate the component time, return 0 if valid, 1 if not */
@ -764,7 +750,6 @@ cdChar2Comp(cdCalenType timetype, char* chartime, cdCompTime* comptime)
}
}
(void)cdValidateTime(timetype,*comptime);
return;
}
/* Convert ct to relunits (unit, basetime) */
@ -778,7 +763,6 @@ cdComp2RelMixed(cdCompTime ct, cdUnitTime unit, cdCompTime basetime, double *rel
hourdiff = cdDiffMixed(ct, basetime);
*reltime = cdFromHours(hourdiff, unit);
return;
}
static void
@ -884,8 +868,6 @@ cdComp2Rel(cdCalenType timetype, cdCompTime comptime, char* relunits, double* re
cdError("invalid unit in conversion");
break;
}
return;
}
/* Add (value,unit) to comptime. */
@ -899,7 +881,6 @@ cdCompAdd(cdCompTime comptime, double value, cdCalenType calendar, cdCompTime *r
cdComp2Rel(calendar, comptime, "hours", &reltime);
reltime += value;
cdRel2Comp(calendar, "hours", reltime, result);
return;
}
/* Add value in hours to ct, in the mixed Julian/Gregorian
@ -927,7 +908,6 @@ cdCompAddMixed(cdCompTime ct, double value, cdCompTime *result){
cdCompAdd(ZA, value-xg, cdJulian, result);
}
}
return;
}
/* Return value expressed in hours. */
@ -969,7 +949,6 @@ cdRel2CompMixed(double reltime, cdUnitTime unit, cdCompTime basetime, cdCompTime
reltime = cdToHours(reltime, unit);
cdCompAddMixed(basetime, reltime, comptime);
return;
}
@ -1079,8 +1058,6 @@ cdRel2Comp(cdCalenType timetype, char* relunits, double reltime, cdCompTime* com
comptime->month = humantime.month;
comptime->day = humantime.day;
comptime->hour = humantime.hour;
return;
}
/* rkr: output as ISO 8601 strings */
@ -1166,7 +1143,6 @@ cdComp2Iso(cdCalenType timetype, int separator, cdCompTime comptime, char* time,
break;
}
}
return;
}
/* rkr: added for output closer to ISO 8601 */
@ -1177,8 +1153,6 @@ cdRel2Iso(cdCalenType timetype, char* relunits, int separator, double reltime, c
cdRel2Comp(timetype, relunits, reltime, &comptime);
cdComp2Iso(timetype, separator, comptime, chartime, chartime_size);
return;
}
int

View File

@ -11,13 +11,8 @@
#include "ncdispatch.h"
extern int NC3_initialize(void);
extern int NC3_finalize(void);
#ifdef USE_NETCDF4
#include "nc4internal.h"
extern int NC4_initialize(void);
extern int NC4_finalize(void);
#endif
#ifdef USE_HDF5
@ -36,6 +31,7 @@ extern int NCD4_initialize(void);
extern int NCD4_finalize(void);
#endif
#ifdef USE_PNETCDF
extern int NCP_initialize(void);
extern int NCP_finalize(void);

View File

@ -10,7 +10,7 @@
static int pcounter = 0;
/* Forward */
static int compute_intersection(const NCZSlice* slice, const size64_t chunklen, unsigned char isunlimited, NCZChunkRange* range);
static int compute_intersection(const NCZSlice* slice, size64_t chunklen, unsigned char isunlimited, NCZChunkRange* range);
static void skipchunk(const NCZSlice* slice, NCZProjection* projection);
static int verifyslice(const NCZSlice* slice);

View File

@ -537,7 +537,7 @@ NCZ_freeenvv(int n, char** envv)
char** p;
if(envv == NULL) return;
if(n < 0)
{for(n=0, p = envv; *p; n++); /* count number of strings */}
{for(n=0, p = envv; *p; n++) {}; /* count number of strings */}
for(i=0;i<n;i++) {
if(envv[i]) {
free(envv[i]);

View File

@ -1726,7 +1726,7 @@ define_vars(NC_FILE_INFO_T* file, NC_GRP_INFO_T* grp, NClist* varnames)
/* Capture row vs column major; currently, column major not used*/
{
if((stat = NCJdictget(jvar,"order",&jvalue))) goto done;
if(strcmp(NCJstring(jvalue),"C")==1)
if(strcmp(NCJstring(jvalue),"C") > 0)
((NCZ_VAR_INFO_T*)var->format_var_info)->order = 1;
else ((NCZ_VAR_INFO_T*)var->format_var_info)->order = 0;
}

View File

@ -25,13 +25,6 @@ extern NC_Dispatch UDF0_DISPATCH;
extern NC_Dispatch UDF1_DISPATCH;
#endif /* USE_UDF1 */
#ifdef USE_NETCDF4
/* Pointers to dispatch tables for user-defined formats. */
extern NC_Dispatch *UDF0_dispatch_table;
extern NC_Dispatch *UDF1_dispatch_table;
#endif /* USE_NETCDF4 */
/**
* @internal Initialize netCDF-4. If user-defined format(s) have been

View File

@ -585,7 +585,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type,
bit_xpl_nbr_zro = BIT_XPL_NBR_SGN_FLT - prc_bnr_xpl_rqr;
/* Create mask */
msk_f32_u32_zro = 0u; /* Zero all bits */
msk_f32_u32_zro = 0U; /* Zero all bits */
msk_f32_u32_zro = ~msk_f32_u32_zro; /* Turn all bits to ones */
/* BitShave mask for AND: Left shift zeros into bits to be
@ -605,7 +605,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type,
bit_xpl_nbr_zro = BIT_XPL_NBR_SGN_DBL - prc_bnr_xpl_rqr;
/* Create mask. */
msk_f64_u64_zro = 0ul; /* Zero all bits. */
msk_f64_u64_zro = 0UL; /* Zero all bits. */
msk_f64_u64_zro = ~msk_f64_u64_zro; /* Turn all bits to ones. */
/* BitShave mask for AND: Left shift zeros into bits to be
@ -1461,7 +1461,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type,
prc_bnr_xpl_rqr--; /* 20211003 Reduce formula result by 1 bit: Passes all tests, improves CR by ~10% */
bit_xpl_nbr_zro = BIT_XPL_NBR_SGN_FLT - prc_bnr_xpl_rqr;
msk_f32_u32_zro = 0u; /* Zero all bits */
msk_f32_u32_zro = 0U; /* Zero all bits */
msk_f32_u32_zro = ~msk_f32_u32_zro; /* Turn all bits to ones */
/* Bit Shave mask for AND: Left shift zeros into bits to be rounded, leave ones in untouched bits */
msk_f32_u32_zro <<= bit_xpl_nbr_zro;
@ -1495,7 +1495,7 @@ nc4_convert_type(const void *src, void *dest, const nc_type src_type,
prc_bnr_xpl_rqr--; /* 20211003 Reduce formula result by 1 bit: Passes all tests, improves CR by ~10% */
bit_xpl_nbr_zro = BIT_XPL_NBR_SGN_DBL - prc_bnr_xpl_rqr;
msk_f64_u64_zro = 0ull; /* Zero all bits */
msk_f64_u64_zro = 0ULL; /* Zero all bits */
msk_f64_u64_zro = ~msk_f64_u64_zro; /* Turn all bits to ones */
/* Bit Shave mask for AND: Left shift zeros into bits to be rounded, leave ones in untouched bits */
msk_f64_u64_zro <<= bit_xpl_nbr_zro;

View File

@ -110,8 +110,9 @@ createtestdims(int cdfid, size_t num_dims, const size_t *sizes, const char * con
int dimid;
while(num_dims-- != 0)
{
assert( nc_def_dim(cdfid, *dim_names++, *sizes, &dimid)
assert( nc_def_dim(cdfid, *dim_names, *sizes, &dimid)
== NC_NOERR);
dim_names++;
sizes++;
}
@ -131,7 +132,8 @@ testdims(int cdfid, size_t num_dims, size_t *sizes, const char * const dim_names
(void) fprintf(stderr, "%d: %lu != %lu\n",
ii, (unsigned long)size, (unsigned long)*sizes);
assert( size == *sizes);
assert( strcmp(cp, *dim_names++) == 0);
assert( strcmp(cp, *dim_names) == 0);
dim_names++;
}
}
@ -313,7 +315,6 @@ check_fill_seq(int id)
bad_ret :
(void) printf("couldn't get a var in check_fill_seq() %d\n",
ii);
return;
}
static size_t indices[][3] = {

View File

@ -126,7 +126,7 @@ printf("*** testing diskless file with scalar vars...");
int ndims_in, nvars_in, natts_in, unlimdimid_in;
char name_in[NC_MAX_NAME + 1];
nc_type type_in;
float float_data = 3.14f, float_data_in;
float float_data = 3.14F, float_data_in;
int int_data = 42, int_data_in;
short short_data = 2, short_data_in;
@ -152,13 +152,13 @@ printf("*** testing diskless file with scalar vars...");
/* Check variables. */
if (nc_inq_var(ncid, varid0, name_in, &type_in, &ndims_in, NULL, &natts_in)) ERR;
if (strcmp(name_in, RESISTOR) || type_in != NC_INT || ndims_in != 0 ||
if (strcmp(name_in, RESISTOR) != 0 || type_in != NC_INT || ndims_in != 0 ||
natts_in != 0) ERR;
if (nc_inq_var(ncid, varid1, name_in, &type_in, &ndims_in, NULL, &natts_in)) ERR;
if (strcmp(name_in, CAPACITOR) || type_in != NC_FLOAT || ndims_in != 0 ||
if (strcmp(name_in, CAPACITOR) != 0 || type_in != NC_FLOAT || ndims_in != 0 ||
natts_in != 0) ERR;
if (nc_inq_var(ncid, varid2, name_in, &type_in, &ndims_in, NULL, &natts_in)) ERR;
if (strcmp(name_in, NUM555) || type_in != NC_SHORT || natts_in != 0) ERR;
if (strcmp(name_in, NUM555) != 0 || type_in != NC_SHORT || natts_in != 0) ERR;
/* Read my absolutely crucial data. */
if (nc_get_vara_int(ncid, varid0, NULL, NULL, &int_data_in)) ERR;
@ -176,7 +176,7 @@ printf("*** testing diskless file with scalar vars...");
if(!usenetcdf4 && persist) {
int ncid, varid0, varid1, varid2;
float float_data = 3.14f, float_data_in;
float float_data = 3.14F, float_data_in;
int int_data = 42, int_data_in;
short short_data = 2, short_data_in;
@ -220,7 +220,10 @@ printf("*** testing diskless file with scalar vars...");
short short_data[DIM1_LEN];
size_t start[1] = {0};
size_t count[1] = {DIM1_LEN};
float float_data = 42.22f, float_data_in;
int i;
float float_data = 42.22F, float_data_in;
/* This is some really important data that I want to save. */
for (short i = 0; i < DIM1_LEN; i++)
@ -261,23 +264,23 @@ printf("*** testing diskless file with scalar vars...");
* of scientists to understand my data. */
if (nc_get_att_text(ncid, NC_GLOBAL, ATT0_NAME, att0_in)) ERR;
att0_in[sizeof(ATT0_TEXT)] = '\0';
if (strcmp(att0_in, ATT0_TEXT)) ERR;
if (strcmp(att0_in, ATT0_TEXT) != 0) ERR;
/* Check dimensions. */
if (nc_inq_dim(ncid, dimid[0], name_in, &len_in)) ERR;
if (strcmp(name_in, DIM0_NAME) || len_in != 0) ERR;
if (strcmp(name_in, DIM0_NAME) != 0 || len_in != 0) ERR;
if (nc_inq_dim(ncid, dimid[1], name_in, &len_in)) ERR;
if (strcmp(name_in, DIM1_NAME) || len_in != DIM1_LEN) ERR;
if (strcmp(name_in, DIM1_NAME) != 0 || len_in != DIM1_LEN) ERR;
/* Check variables. */
if (nc_inq_var(ncid, varid0, name_in, &type_in, &ndims_in, dimid_in, &natts_in)) ERR;
if (strcmp(name_in, VAR0_NAME) || type_in != NC_INT || ndims_in != NDIMS ||
if (strcmp(name_in, VAR0_NAME) != 0 || type_in != NC_INT || ndims_in != NDIMS ||
dimid_in[0] != 0 || dimid_in[1] != 1 || natts_in != 0) ERR;
if (nc_inq_var(ncid, varid1, name_in, &type_in, &ndims_in, dimid_in, &natts_in)) ERR;
if (strcmp(name_in, VAR1_NAME) || type_in != NC_FLOAT || ndims_in != 0 ||
if (strcmp(name_in, VAR1_NAME) != 0 || type_in != NC_FLOAT || ndims_in != 0 ||
natts_in != 0) ERR;
if (nc_inq_var(ncid, varid2, name_in, &type_in, &ndims_in, dimid_in, &natts_in)) ERR;
if (strcmp(name_in, VAR2_NAME) || type_in != NC_SHORT || ndims_in != 1 ||
if (strcmp(name_in, VAR2_NAME) != 0 || type_in != NC_SHORT || ndims_in != 1 ||
dimid_in[0] != 1 || natts_in != 0) ERR;
/* Read my absolutely crucial data. */
@ -300,7 +303,7 @@ printf("*** testing diskless file with scalar vars...");
int ndims_in, nvars_in, natts_in, unlimdimid_in;
char name_in[NC_MAX_NAME + 1];
nc_type type_in;
float float_data = 3.14f, float_data_in;
float float_data = 3.14F, float_data_in;
int int_data = 42, int_data_in;
short short_data = 2, short_data_in;
@ -326,14 +329,14 @@ printf("*** testing diskless file with scalar vars...");
/* Check variables. */
if (nc_inq_var(ncid, varid0, name_in, &type_in, &ndims_in, NULL, &natts_in)) ERR;
if (strcmp(name_in, DUNE) || type_in != NC_INT || ndims_in != 0 ||
if (strcmp(name_in, DUNE) != 0 || type_in != NC_INT || ndims_in != 0 ||
natts_in != 0) ERR;
if (nc_inq_var(ncid, varid1, name_in, &type_in, &ndims_in, NULL, &natts_in)) ERR;
if (strcmp(name_in, STAR_TREK) || type_in != NC_FLOAT || ndims_in != 0 ||
if (strcmp(name_in, STAR_TREK) != 0 || type_in != NC_FLOAT || ndims_in != 0 ||
natts_in != 0) ERR;
if (nc_inq_var(ncid, varid2, name_in, &type_in, &ndims_in, NULL, &natts_in)) ERR;
if (strcmp(name_in, STAR_WARS) || type_in != NC_SHORT || natts_in != 0) ERR;
if (strcmp(name_in, STAR_WARS) != 0 || type_in != NC_SHORT || natts_in != 0) ERR;
/* Read my absolutely crucial data. */
if (nc_get_vara_int(ncid, varid0, NULL, NULL, &int_data_in)) ERR;

View File

@ -334,7 +334,7 @@ main(int argc, char **argv)
var_dimid[1] != dimid[1] || natts != 0) ERR;
if (!(data_in = malloc(DATA_LEN * type_size[t]))) ERR;
if (nc_get_vars(ncid, varid[t], start, count, NULL, data_in)) ERR;
if (memcmp(data_in, data_ptr[t], DATA_LEN * type_size[t])) ERR;
if (memcmp(data_in, data_ptr[t], DATA_LEN * type_size[t]) != 0) ERR;
free(data_in);
}

View File

@ -383,27 +383,27 @@ verify_file(int ncid, int modified, int extra)
CHECK(nc_get_att_text(ncid, NC_GLOBAL, ATT0_NAME, att0_in));
att0_in[sizeof(ATT0_TEXT)] = '\0';
if (strcmp(att0_in, ATT0_TEXT)) CHECK(NC_EINVAL);
if (strcmp(att0_in, ATT0_TEXT) != 0) CHECK(NC_EINVAL);
/* CHECK dimensions. */
CHECK(nc_inq_dim(ncid, dimid[0], name_in, &len_in));
if (strcmp(name_in, DIM0_NAME)) CHECK(NC_EINVAL);
if (strcmp(name_in, DIM0_NAME) != 0) CHECK(NC_EINVAL);
CHECK(nc_inq_dim(ncid, dimid[1], name_in, &len_in));
if (strcmp(name_in, DIM1_NAME) || len_in != DIM1_LEN) CHECK(NC_EINVAL);
if (strcmp(name_in, DIM1_NAME) != 0 || len_in != DIM1_LEN) CHECK(NC_EINVAL);
if(extra) {
CHECK(nc_inq_dim(ncid, dimid[2], name_in, &len_in));
if (strcmp(name_in, DIMX_NAME) || len_in != DIMX_LEN) CHECK(NC_EINVAL);
if (strcmp(name_in, DIMX_NAME) != 0 || len_in != DIMX_LEN) CHECK(NC_EINVAL);
}
/* CHECK variables. */
CHECK(nc_inq_var(ncid, varid[0], name_in, &type_in, &ndims_in, dimid_in, &natts_in));
if (strcmp(name_in, VAR0_NAME) || type_in != NC_INT || ndims_in != NDIMS0 ||
if (strcmp(name_in, VAR0_NAME) != 0 || type_in != NC_INT || ndims_in != NDIMS0 ||
dimid_in[0] != 0 || dimid_in[1] != 1 || natts_in != 0) CHECK(NC_EINVAL);
CHECK(nc_inq_var(ncid, varid[1], name_in, &type_in, &ndims_in, dimid_in, &natts_in));
if (strcmp(name_in, VAR1_NAME) || type_in != NC_SHORT || ndims_in != 1 || dimid_in[0] != 1 || natts_in != 0)
if (strcmp(name_in, VAR1_NAME) != 0 || type_in != NC_SHORT || ndims_in != 1 || dimid_in[0] != 1 || natts_in != 0)
CHECK(NC_EINVAL);
CHECK(nc_inq_var(ncid, varid[2], name_in, &type_in, &ndims_in, dimid_in, &natts_in));
if (strcmp(name_in, VAR2_NAME) || type_in != NC_FLOAT || ndims_in != 0 || natts_in != 0)
if (strcmp(name_in, VAR2_NAME) != 0 || type_in != NC_FLOAT || ndims_in != 0 || natts_in != 0)
CHECK(NC_EINVAL);
CHECK(nc_get_var_int(ncid, varid[0], nightdata_in));
@ -422,7 +422,7 @@ verify_file(int ncid, int modified, int extra)
if(modified) {
size_t unlimlen;
CHECK(nc_inq_var(ncid, varid[3], name_in, &type_in, &ndims_in, dimid_in, &natts_in));
if (strcmp(name_in, VAR3_NAME) || type_in != NC_INT || ndims_in != 1 ||
if (strcmp(name_in, VAR3_NAME) != 0 || type_in != NC_INT || ndims_in != 1 ||
dimid_in[0] != 0 || natts_in != 0) CHECK(NC_EINVAL);
CHECK(nc_inq_dimlen(ncid, dimid_in[0], &unlimlen));
CHECK(nc_get_var_int(ncid, varid[3], milesdata_in));
@ -434,7 +434,7 @@ verify_file(int ncid, int modified, int extra)
if(extra) {
size_t xlen;
CHECK(nc_inq_var(ncid, varid[4], name_in, &type_in, &ndims_in, dimid_in, &natts_in));
if (strcmp(name_in, VARX_NAME) || type_in != NC_INT || ndims_in != 1 ||
if (strcmp(name_in, VARX_NAME) != 0 || type_in != NC_INT || ndims_in != 1 ||
dimid_in[0] != dimid[2] || natts_in != 0) CHECK(NC_EINVAL);
CHECK(nc_inq_dimlen(ncid, dimid_in[0], &xlen));
CHECK(nc_get_var_int(ncid, varid[4], expenses_in));

View File

@ -122,7 +122,7 @@ test_small_atts(const char *testfile)
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)) ERR;
if (strncmp(att_in, att, t)) ERR;
if (strncmp(att_in, att, t) != 0) ERR;
if (nc_close(ncid)) ERR;
}
}
@ -184,7 +184,7 @@ test_small_unlim(const char *testfile)
if (ndims != 2 && nvars != 1 && natts != 0 && unlimdimid != 0) ERR;
if (nc_get_var_text(ncid, varid, (char *)data_in)) ERR;
for (i = 0; i < NUM_VALS; i++)
if (strncmp(data[i], data_in[i], STR_LEN)) ERR;
if (strncmp(data[i], data_in[i], STR_LEN) != 0) ERR;
if (nc_close(ncid)) ERR;
return 0;
}
@ -229,7 +229,7 @@ test_small_fixed(const char *testfile)
if (ndims != 2 && nvars != 1 && natts != 0 && unlimdimid != -1) ERR;
if (nc_get_var_text(ncid, varid, (char *)data_in)) ERR;
for (i = 0; i < NUM_VALS; i++)
if (strncmp(data[i], data_in[i], STR_LEN)) ERR;
if (strncmp(data[i], data_in[i], STR_LEN) != 0) ERR;
if (nc_close(ncid)) ERR;
return 0;
}

View File

@ -1368,7 +1368,7 @@ main(int argc, char **argv)
for (i = 0; i < DIM_LEN_SIMPLE; i++)
{
if (fabs(float_data_in[i] - float_data[i]) > EPSILON)
if (fabsf(float_data_in[i] - float_data[i]) > EPSILON)
ERR;
if (fabs(double_data_in[i] - double_data[i]) > EPSILON)
ERR;

View File

@ -317,7 +317,7 @@ static float int162float32_data[DIMSIZE]={0.000,256.000,512.000,768.000,1024.000
static int int32_data[DIMSIZE]={0,2048,4096,6144,8192,10240,12288,14336,16384,18432,20480,22528,24576,26624,28672,30720,32768,34816,36864,38912,40960,43008,45056,47104,49152};
static float int32tofloat32_data[DIMSIZE]={0.000,2048.000,4096.000,6144.000,8192.000,10240.000,12288.000,14336.000,16384.000,18432.000,20480.000,22528.000,24576.000,26624.000,28672.000,30720.000,32768.000,34816.000,36864.000,38912.000,40960.000,43008.000,45056.000,47104.000,49152.000};
static long int32toilong_data[DIMSIZE]={0,2048,4096,6144,8192,10240,12288,14336,16384,18432,20480,22528,24576,26624,28672,30720,32768,34816,36864,38912,40960,43008,45056,47104,49152};
static float float32_data[DIMSIZE]={0.000f,0.010f,0.020f,0.030f,0.040f,0.050f,0.060f,0.070f,0.080f,0.090f,0.100f,0.110f,0.120f,0.130f,0.140f,0.149f,0.159f,0.169f,0.179f,0.189f,0.199f,0.208f,0.218f,0.228f,0.238f};
static float float32_data[DIMSIZE]={0.000F,0.010F,0.020F,0.030F,0.040F,0.050F,0.060F,0.070F,0.080F,0.090F,0.100F,0.110F,0.120F,0.130F,0.140F,0.149F,0.159F,0.169F,0.179F,0.189F,0.199F,0.208F,0.218F,0.228F,0.238F};
static double float64_data[DIMSIZE]={1.000,1.000,1.000,1.000,0.999,0.999,0.998,0.998,0.997,0.996,0.995,0.994,0.993,0.992,0.990,0.989,0.987,0.986,0.984,0.982,0.980,0.978,0.976,0.974,0.971};
#ifndef USE_NETCDF4

View File

@ -316,7 +316,7 @@ static float int162float32_data[DIMSIZE]={0.000,256.000,512.000,768.000,1024.000
static int int32_data[DIMSIZE]={0,2048,4096,6144,8192,10240,12288,14336,16384,18432,20480,22528,24576,26624,28672,30720,32768,34816,36864,38912,40960,43008,45056,47104,49152};
static float int32tofloat32_data[DIMSIZE]={0.000,2048.000,4096.000,6144.000,8192.000,10240.000,12288.000,14336.000,16384.000,18432.000,20480.000,22528.000,24576.000,26624.000,28672.000,30720.000,32768.000,34816.000,36864.000,38912.000,40960.000,43008.000,45056.000,47104.000,49152.000};
static long int32toilong_data[DIMSIZE]={0,2048,4096,6144,8192,10240,12288,14336,16384,18432,20480,22528,24576,26624,28672,30720,32768,34816,36864,38912,40960,43008,45056,47104,49152};
static float float32_data[DIMSIZE]={0.000f,0.010f,0.020f,0.030f,0.040f,0.050f,0.060f,0.070f,0.080f,0.090f,0.100f,0.110f,0.120f,0.130f,0.140f,0.149f,0.159f,0.169f,0.179f,0.189f,0.199f,0.208f,0.218f,0.228f,0.238f};
static float float32_data[DIMSIZE]={0.000F,0.010F,0.020F,0.030F,0.040F,0.050F,0.060F,0.070F,0.080F,0.090F,0.100F,0.110F,0.120F,0.130F,0.140F,0.149F,0.159F,0.169F,0.179F,0.189F,0.199F,0.208F,0.218F,0.228F,0.238F};
static double float64_data[DIMSIZE]={1.000,1.000,1.000,1.000,0.999,0.999,0.998,0.998,0.997,0.996,0.995,0.994,0.993,0.992,0.990,0.989,0.987,0.986,0.984,0.982,0.980,0.978,0.976,0.974,0.971};
#ifndef USE_NETCDF4

View File

@ -33,33 +33,33 @@ TODO: Note that this test uses thredds server
#define VAR "SST"
static float expected_stride1[12] = {
29.430857f,
29.403780f,
29.325428f,
29.578333f,
29.660833f,
29.378437f,
29.151943f,
29.109715f,
29.114864f,
29.550285f,
29.542500f,
29.500286f
29.430857F,
29.403780F,
29.325428F,
29.578333F,
29.660833F,
29.378437F,
29.151943F,
29.109715F,
29.114864F,
29.550285F,
29.542500F,
29.500286F
};
static float expected_stride2[6] = {
29.430857f,
29.325428f,
29.660833f,
29.151943f,
29.114864f,
29.542500f
29.430857F,
29.325428F,
29.660833F,
29.151943F,
29.114864F,
29.542500F
};
static float expected_stride3[3] = {
29.430857f,
29.378437f,
29.542500f
29.430857F,
29.378437F,
29.542500F
};
void

View File

@ -129,8 +129,7 @@ dimchunkspec_parse(int igrp, const char *spec)
size_t chunksize;
for(; pp > np && *pp != '/'; pp--) { /* look backwards for "/" */
continue;
}
}
if(*pp != '/') { /* no '/' found, no chunksize specified for dimension */
ret = NC_EINVAL;
goto done;

View File

@ -537,7 +537,7 @@ ncfloat_val_equals(const nctype_t *this,
const void *v1p, const void *v2p) {
float v1 = *(float* )v1p;
float v2 = *(float* )v2p;
if((v1 > 0.0f) != (v2 > 0.0f)) /* avoid overflow */
if((v1 > 0.0F) != (v2 > 0.0F)) /* avoid overflow */
return false;
if(isfinite(v1) && isfinite(v2))
return (absval(v1 - v2) <= absval(float_eps * v2)) ;
@ -1440,7 +1440,6 @@ set_tostring_func(ncvar_t *varp) {
varp->tinfo->class);
}
#endif /* USE_NETCDF4 */
return;
}

View File

@ -39,7 +39,7 @@
/* default bytes of memory we are willing to allocate for variable
* values during copy */
#define COPY_BUFFER_SIZE (5000000)
#define COPY_CHUNKCACHE_PREEMPTION (1.0f) /* for copying, can eject fully read chunks */
#define COPY_CHUNKCACHE_PREEMPTION (1.0F) /* for copying, can eject fully read chunks */
#define SAME_AS_INPUT (-1) /* default, if kind not specified */
#define CHUNK_THRESHOLD (8192) /* non-record variables with fewer bytes don't get chunked */
@ -484,7 +484,7 @@ inq_var_chunking_params(int igrp, int ivarid, int ogrp, int ovarid,
if(icontig == NC_CHUNKED && ocontig != NC_CHUNKED) { /* chunking only in input */
*chunkcache_nelemsp = 1; /* read one input chunk at a time */
*chunkcache_sizep = iprod;
*chunkcache_preemptionp = 1.0f;
*chunkcache_preemptionp = 1.0F;
return stat;
}

View File

@ -257,7 +257,6 @@ tztrim(char *ss)
while (*ep)
*cp++ = *ep++;
*cp = '\0';
return;
}
@ -605,7 +604,7 @@ pr_att_valgs(
if(isnan(ff)) {
printf("NaNf%s", delim);
} else if(isinf(ff)) {
if(ff < 0.0f) {
if(ff < 0.0F) {
printf("-");
}
printf("Infinityf%s", delim);
@ -2246,7 +2245,6 @@ adapt_url_for_cache(char **pathp)
if(pathp) {*pathp = path; path = NULL;}
ncurifree(url);
nullfree(path);
return;
}
#endif

View File

@ -237,7 +237,6 @@ get_timeinfo(int ncid1, int varid1, ncvar_t *vp) {
vp->has_timeval = true;
free(units);
}
return;
}
/* print_att_times

View File

@ -1563,7 +1563,7 @@ val_get_NC_attrarray(int fd,
* checking the tag when ndefined is zero.
*/
if (trace) {
if (strcmp(loc, "Global")) printf("\t\t");
if (strcmp(loc, "Global") != 0) printf("\t\t");
printf("\ttag = ABSENT (no attribute defined)\n");
}
return NC_NOERR;
@ -1582,9 +1582,9 @@ val_get_NC_attrarray(int fd,
DEBUG_RETURN_ERROR(NC_ENOTNC)
}
if (trace) {
if (strcmp(loc, "Global")) printf("\t\t");
if (strcmp(loc, "Global") != 0) printf("\t\t");
printf("\ttag = NC_ATTRIBUTE\n");
if (strcmp(loc, "Global")) printf("\t\t");
if (strcmp(loc, "Global") != 0) printf("\t\t");
printf("\tnumber of attributes = %d\n", ncap->ndefined);
}
@ -1601,7 +1601,7 @@ val_get_NC_attrarray(int fd,
}
if (status == NC_NOERR) status = err;
if (trace) {
if (strcmp(loc, "Global")) printf("\t\t");
if (strcmp(loc, "Global") != 0) printf("\t\t");
printf("\tattribute name \"%s\", type = %s, length = %lld\n",
ncap->value[i]->name, str_NC_type(ncap->value[i]->xtype),
ncap->value[i]->nelems);

View File

@ -107,7 +107,7 @@ main(int argc, char **argv)
};
#define NNAME ((char *) norm_utf8)
#define NNAMELEN (sizeof norm_utf8)
if (strncmp(NNAME, name_in, NNAMELEN))
if (strncmp(NNAME, name_in, NNAMELEN) != 0)
ERR;
}
if (nc_inq_att(ncid, varid, UNITS, &att_type, &att_len))
@ -118,7 +118,7 @@ main(int argc, char **argv)
if (nc_get_att_text(ncid, varid, UNITS, strings_in))
ERR;
strings_in[att_len] = '\0';
if (strncmp(UNAME, strings_in, UNAMELEN))
if (strncmp(UNAME, strings_in, UNAMELEN) != 0)
ERR;
if (nc_close(ncid))
ERR;

View File

@ -7,8 +7,6 @@ See COPYRIGHT for license information.
#define TRACE
extern char* ncclassname(nc_class);
#ifdef TRACE
#define T(fcn,mem) {if(trace) {fprintf(stderr,"X: %s: %p\n", fcn,mem);}}
#else

View File

@ -353,7 +353,6 @@ generate_primdata(Symbol* basetype, NCConstant* prim, Bytebuffer* codebuf,
generator->constant(generator,basetype,target,codebuf);
reclaimconstant(target);
target = NULL;
return;
}
/* Avoid long argument lists */

View File

@ -18,7 +18,6 @@ static List* f77procs = NULL; /* bodies of generated procedures */
/* Forward */
static void genf77_definevardata(Symbol* vsym);
static void genf77_defineattr(Symbol* asym);
static void genf77_definevardata(Symbol*);
static void f77attrify(Symbol* asym, Bytebuffer* buf);
static const char* f77varncid(Symbol* vsym);
@ -26,7 +25,6 @@ static const char* f77dimncid(Symbol* vsym);
static const char* nfstype(nc_type nctype);
static const char* nftype(nc_type type);
static const char* nfstype(nc_type nctype);
static const char* ncftype(nc_type type);
static const char* nfdtype(nc_type type);

View File

@ -18,8 +18,6 @@
extern List* vlenconstants; /* List<Constant*>;*/
/* Forward */
static void genj_definevardata(Symbol* vsym);
static const char* jtypeallcaps(nc_type type);
static const char* jtypecap(nc_type type);
static const char* jtype(nc_type type);

View File

@ -454,7 +454,7 @@ main(
(void)fread(bom,1,1,fp);
break;
default: /* legal printable char, presumably; rewind */
rewind(fp);
(void)fseek(fp, 0L, SEEK_SET);
break;
}
}

View File

@ -3403,11 +3403,11 @@ truefalse(NCConstant* con, int tag)
{
if(con->nctype == NC_STRING) {
char* sdata = con->value.stringv.stringv;
if(strncmp(sdata,"false",NC_MAX_NAME) == 0
|| strncmp(sdata,"0",NC_MAX_NAME) == 0)
if(strcmp(sdata,"false") == 0
|| strcmp(sdata,"0") == 0)
return 0;
else if(strncmp(sdata,"true",NC_MAX_NAME) == 0
|| strncmp(sdata,"1",NC_MAX_NAME) == 0)
else if(strcmp(sdata,"true") == 0
|| strcmp(sdata,"1") == 0)
return 1;
else goto fail;
} else if(con->value.int32v < 0 || con->value.int32v > 1)

View File

@ -23,7 +23,6 @@ static void processtypesizes(void);
static void processvars(void);
static void processattributes(void);
static void processunlimiteddims(void);
static void processeconstrefs(void);
static void processeconstrefsR(Symbol*,Datalist*);
static void processroot(void);
static void processvardata(void);
@ -1220,7 +1219,7 @@ createfilename(void)
if(p != NULL) {
char* q = filename;
p++; /* skip the '/' */
while((*q++ = *p++));
while((*q++ = *p++)) {};
}
} else {/* construct name from dataset name */
strlcat(filename,datasetname,sizeof(filename));

View File

@ -97,7 +97,6 @@ tztrim(
while (*ep)
*cp++ = *ep++;
*cp = '\0';
return;
}
static void

View File

@ -92,5 +92,4 @@ expand_escapes(
}
}
*s = '\0';
return;
}

View File

@ -2026,5 +2026,4 @@ deescapify (char *name)
/* assert(strlen(newname) <= strlen(name)); */
strncpy(name, newname, len);
free(newname);
return;
}

View File

@ -52,7 +52,6 @@ tztrim(
while (*ep)
*cp++ = *ep++;
*cp = '\0';
return;
}

View File

@ -54,7 +54,6 @@ error(fmt, va_alist)
void
off_errs()
{
extern int ncopts; /* error options */
ncopts &= ~NC_FATAL; /* make errors nonfatal */
ncopts &= ~NC_VERBOSE; /* turn off error messages */
}
@ -67,7 +66,6 @@ off_errs()
void
on_errs()
{
extern int ncopts; /* error options */
ncopts |= NC_FATAL; /* make errors fatal */
ncopts |= NC_VERBOSE; /* library prints error messages */
}

View File

@ -247,7 +247,7 @@ main(int argc, char **argv)
if (nc_def_dim(ncid, QQ, QQ_SIZE, &qq_dimid)) ERR;
if (nc_rename_dim(ncid, pp_dimid, NEW_NAME)) ERR;
if (nc_inq_dimname(ncid, pp_dimid, name_in)) ERR;
if (strcmp(NEW_NAME, name_in)) ERR;
if (strcmp(NEW_NAME, name_in) != 0) ERR;
if (nc_rename_dim(ncid, pp_dimid, QQ) != NC_ENAMEINUSE) ERR;
if (nc_rename_dim(ncid, -1, ANOTHER_NAME) != NC_EBADDIM) ERR;
if (nc_rename_dim(ncid, 12, ANOTHER_NAME) != NC_EBADDIM) ERR;

View File

@ -73,7 +73,7 @@ main(int argc, char **argv)
if (nc_inq(ncid, &ndims, &nvars, &ngatts, &unlimdimid)) ERR;
if (nvars != 3 || ndims != 3 || ngatts != 0 || unlimdimid != -1) ERR;
if (nc_inq_var(ncid, 0, var_name_in, &xtype_in, &ndims_in, &dimids_in, &natts_in)) ERR;
if (strcmp(var_name_in, V_SMALL) || xtype_in != NC_INT64 || ndims_in != 1 ||
if (strcmp(var_name_in, V_SMALL) != 0 || xtype_in != NC_INT64 || ndims_in != 1 ||
natts_in != 0) ERR;
/* Make sure chunking sizes are what we expect. */
@ -200,7 +200,7 @@ main(int argc, char **argv)
if (nc_inq(ncid, &ndims, &nvars, &ngatts, &unlimdimid)) ERR;
if (nvars != 3 || ndims != 3 || ngatts != 0 || unlimdimid != -1) ERR;
if (nc_inq_var(ncid, 0, var_name_in, &xtype_in, &ndims_in, &dimids_in, &natts_in)) ERR;
if (strcmp(var_name_in, V_SMALL) || xtype_in != NC_INT64 || ndims_in != 1 ||
if (strcmp(var_name_in, V_SMALL) != 0 || xtype_in != NC_INT64 || ndims_in != 1 ||
natts_in != 0) ERR;
/* Make sure chunking settings are what we expect. */

View File

@ -110,14 +110,14 @@ main(int argc, char **argv)
if (nc_inq(ncid, &ndims, &nvars, &ngatts, &unlimdimid)) ERR;
if (nvars != NUM_VARS || ndims != NDIMS3 || ngatts != 0 || unlimdimid != -1) ERR;
if (nc_inq_var(ncid, 0, name_in, &type_in, &ndims, dims_in, &natts)) ERR;
if (strcmp(name_in, VAR_NAME_JOE) || type_in != NC_FLOAT || ndims != NDIMS3 ||
if (strcmp(name_in, VAR_NAME_JOE) != 0 || type_in != NC_FLOAT || ndims != NDIMS3 ||
dims_in[0] != dims[0] || dims_in[1] != dims[1] || dims_in[2] != dims[2] || natts != 0) ERR;
if (nc_inq_dim(ncid, 0, name_in, &len_in[0])) ERR;
if (strcmp(name_in, X_NAME) || len_in[0] != XDIM_LEN) ERR;
if (strcmp(name_in, X_NAME) != 0 || len_in[0] != XDIM_LEN) ERR;
if (nc_inq_dim(ncid, 1, name_in, &len_in[1])) ERR;
if (strcmp(name_in, Y_NAME) || len_in[1] != YDIM_LEN) ERR;
if (strcmp(name_in, Y_NAME) != 0 || len_in[1] != YDIM_LEN) ERR;
if (nc_inq_dim(ncid, 2, name_in, &len_in[2])) ERR;
if (strcmp(name_in, Z_NAME) || len_in[2] != ZDIM_LEN) ERR;
if (strcmp(name_in, Z_NAME) != 0 || len_in[2] != ZDIM_LEN) ERR;
if (nc_inq_var_chunking(ncid, 0, &storage, chunksizes)) ERR;
if (storage != NC_CHUNKED) ERR;
if (nc_close(ncid)) ERR;
@ -127,14 +127,14 @@ main(int argc, char **argv)
if (nc_inq(ncid, &ndims, &nvars, &ngatts, &unlimdimid)) ERR;
if (nvars != NUM_VARS || ndims != NDIMS3 || ngatts != 0 || unlimdimid != -1) ERR;
if (nc_inq_var(ncid, 0, name_in, &type_in, &ndims, dims_in, &natts)) ERR;
if (strcmp(name_in, VAR_NAME_JOE) || type_in != NC_FLOAT || ndims != NDIMS3 ||
if (strcmp(name_in, VAR_NAME_JOE) != 0 || type_in != NC_FLOAT || ndims != NDIMS3 ||
dims_in[0] != dims[0] || dims_in[1] != dims[1] || dims_in[2] != dims[2] || natts != 0) ERR;
if (nc_inq_dim(ncid, 0, name_in, &len_in[0])) ERR;
if (strcmp(name_in, X_NAME) || len_in[0] != XDIM_LEN) ERR;
if (strcmp(name_in, X_NAME) != 0 || len_in[0] != XDIM_LEN) ERR;
if (nc_inq_dim(ncid, 1, name_in, &len_in[1])) ERR;
if (strcmp(name_in, Y_NAME) || len_in[1] != YDIM_LEN) ERR;
if (strcmp(name_in, Y_NAME) != 0 || len_in[1] != YDIM_LEN) ERR;
if (nc_inq_dim(ncid, 2, name_in, &len_in[2])) ERR;
if (strcmp(name_in, Z_NAME) || len_in[2] != ZDIM_LEN) ERR;
if (strcmp(name_in, Z_NAME) != 0 || len_in[2] != ZDIM_LEN) ERR;
if (nc_inq_var_chunking(ncid, 0, &storage, chunksizes)) ERR;
if (storage != NC_CHUNKED) ERR;
if (calculate_waste(NDIMS3, len_in, chunksizes, &waste)) ERR;

View File

@ -419,12 +419,19 @@ static OCerror
ocextractddsinfile(OCstate* state, OCtree* tree, OCflags flags)
{
OCerror stat = OC_NOERR;
size_t ddslen, bod;
size_t ddslen, bod, bodfound;
int retVal;
/* Read until we find the separator (or EOF)*/
ncbytesclear(state->packet);
rewind(tree->data.file);
int bodfound = 0;
retVal = fseek(tree->data.file, 0L, SEEK_SET);
if (retVal != 0) {
stat = OC_EDATADDS;
return OCTHROW(stat);
}
bodfound = 0;
do {
char chunk[1024];
size_t count;

View File

@ -12,7 +12,6 @@ static OCerror mergedods1(OCnode* dds, OCnode* das);
static OCerror mergeother1(OCnode* root, OCnode* das);
static char* pathtostring(NClist* path, char* separator);
static void computefullname(OCnode* node);
static OCerror mergeother1(OCnode* root, OCnode* das);
static OCerror mergeother(OCnode* ddsroot, NClist* dasnodes);
/* Process ocnodes to fix various semantic issues*/

View File

@ -54,7 +54,7 @@ H5PLget_plugin_info(void)
}
#define H5Z_DEFLATE_SIZE_ADJUST(s) (HDceil(((double)(s)) * (double)1.001f) + 12)
#define H5Z_DEFLATE_SIZE_ADJUST(s) (HDceil(((double)(s)) * (double)1.001F) + 12)
/*-------------------------------------------------------------------------