Make scalar X filter return an error instead of ignoring it

This commit is contained in:
Dennis Heimbigner 2020-03-02 15:10:54 -07:00
parent e82d33a9bb
commit 73537603e2
4 changed files with 10 additions and 9 deletions

View File

@ -223,7 +223,7 @@ NC4_filter_actions(int ncid, int varid, int op, NC_Filterobject* args)
/* If the HDF5 dataset has already been created, then it is too
* late to set all the extra stuff. */
if (!(h5->flags & NC_INDEF)) return THROW(NC_EINDEFINE);
if (!var->ndims) return NC_NOERR; /* For scalars, ignore */
if (!var->ndims) return NC_EINVAL; /* For scalars, complain */
if (var->created)
return THROW(NC_ELATEDEF);
/* Can't turn on parallel and szip before HDF5 1.10.2. */
@ -315,7 +315,7 @@ NC4_filter_actions(int ncid, int varid, int op, NC_Filterobject* args)
#endif /* USE_PARALLEL */
} break;
case NCFILTER_INQ: {
if (!var->ndims) return THROW(NC_ENOFILTER); /* For scalars, fail */
if (!var->ndims) return THROW(NC_EINVAL); /* For scalars, fail */
if(obj->sort != NC_FILTER_SORT_SPEC) return THROW(NC_EFILTER);
idp = &obj->u.spec.filterid;
nparamsp = &obj->u.spec.nparams;

View File

@ -679,9 +679,9 @@ nc_def_var_extra(int ncid, int varid, int *shuffle, int *unused1,
/* Cannot set filters of any sort on scalars */
if(var->ndims == 0) {
if(shuffle && *shuffle)
return NC_NOERR; /* ignore */
return NC_EINVAL;
if(fletcher32 && *fletcher32)
return NC_NOERR; /* ignore */
return NC_EINVAL;
}
/* Shuffle filter? */

View File

@ -1478,8 +1478,8 @@ main(int argc, char **argv)
if (shuffle_in || deflate_in) ERR;
if (nc_inq_var_deflate(ncid, varid, NULL, NULL, NULL)) ERR;
/* Deflate is ignored for scalar. */
if (nc_def_var_deflate(ncid, varid_scalar, 0, 1, 4)) ERR;
/* Deflate fails for scalar. */
if (nc_def_var_deflate(ncid, varid_scalar, 0, 1, 4) != NC_EINVAL) ERR;
if (nc_inq_var_deflate(ncid, varid, &shuffle_in, &deflate_in, &deflate_level_in)) ERR;
if (shuffle_in || deflate_in) ERR;

View File

@ -1069,18 +1069,19 @@ copy_var_specials(int igrp, int varid, int ogrp, int o_varid, int inkind, int ou
int innc4 = (inkind == NC_FORMAT_NETCDF4 || inkind == NC_FORMAT_NETCDF4_CLASSIC);
int outnc4 = (outkind == NC_FORMAT_NETCDF4 || outkind == NC_FORMAT_NETCDF4_CLASSIC);
int deflated = 0; /* true iff deflation is applied */
int ndims;
if(!outnc4)
return stat; /* Ignore non-netcdf4 files */
{ /* handle chunking parameters */
int ndims;
NC_CHECK(nc_inq_varndims(igrp, varid, &ndims));
if (ndims > 0) { /* no chunking for scalar variables */
NC_CHECK(copy_chunking(igrp, varid, ogrp, o_varid, ndims, inkind, outkind));
}
}
if(ndims > 0)
{ /* handle compression parameters, copying from input, overriding
* with command-line options */
int shuffle_in=0, deflate_in=0, deflate_level_in=0;
@ -1112,7 +1113,7 @@ copy_var_specials(int igrp, int varid, int ogrp, int o_varid, int inkind, int ou
}
}
if(innc4 && outnc4)
if(innc4 && outnc4 && ndims > 0)
{ /* handle checksum parameters */
int fletcher32 = 0;
NC_CHECK(nc_inq_var_fletcher32(igrp, varid, &fletcher32));
@ -1130,7 +1131,7 @@ copy_var_specials(int igrp, int varid, int ogrp, int o_varid, int inkind, int ou
}
}
if(!deflated) {
if(!deflated && ndims > 0) {
/* handle other general filters */
NC_CHECK(copy_var_filter(igrp, varid, ogrp, o_varid, inkind, outkind));
}