mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-11-21 03:13:42 +08:00
Merge pull request #393 from wkliao/open_check_vlens
check the number of legal large variables at open time
This commit is contained in:
commit
e1ff8f9873
@ -424,6 +424,9 @@ nc_put_rec(int ncid, size_t recnum, void *const *datap);
|
||||
|
||||
/* End defined in putget.c */
|
||||
|
||||
extern int
|
||||
NC_check_vlens(NC3_INFO *ncp);
|
||||
|
||||
/* Define accessors for the dispatchdata */
|
||||
#define NC3_DATA(nc) ((NC3_INFO*)(nc)->dispatchdata)
|
||||
#define NC3_DATA_SET(nc,data) ((nc)->dispatchdata = (void*)(data))
|
||||
|
@ -683,7 +683,7 @@ move_vars_r(NC3_INFO *gnu, NC3_INFO *old)
|
||||
* Given a valid ncp, return NC_EVARSIZE if any variable has a bad len
|
||||
* (product of non-rec dim sizes too large), else return NC_NOERR.
|
||||
*/
|
||||
static int
|
||||
int
|
||||
NC_check_vlens(NC3_INFO *ncp)
|
||||
{
|
||||
NC_var **vpp;
|
||||
|
@ -1521,6 +1521,10 @@ nc_get_NC(NC3_INFO* ncp)
|
||||
if(status != NC_NOERR)
|
||||
goto unwind_get;
|
||||
|
||||
status = NC_check_vlens(ncp);
|
||||
if(status != NC_NOERR)
|
||||
goto unwind_get;
|
||||
|
||||
unwind_get:
|
||||
(void) rel_v1hs(&gs);
|
||||
return status;
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
#define FILE_NAME "tst_elatefill.nc"
|
||||
|
||||
#define ERR {if(err!=NC_NOERR)printf("Error at line %d: %s\n",__LINE__,nc_strerror(err));}
|
||||
#define ERR_CHK {if(err!=NC_NOERR)printf("Error at line %d: %s\n",__LINE__,nc_strerror(err));}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
@ -28,18 +28,18 @@ main(int argc, char **argv)
|
||||
int ncid, dimid, varid, err;
|
||||
int no_fill, fillv, buf[10];
|
||||
|
||||
err = nc_create(FILE_NAME, NC_NETCDF4, &ncid); ERR;
|
||||
err = nc_def_dim(ncid, "dim", 10, &dimid); ERR;
|
||||
err = nc_def_var(ncid, "var", NC_INT, 1, &dimid, &varid); ERR;
|
||||
err = nc_enddef(ncid); ERR;
|
||||
err = nc_create(FILE_NAME, NC_NETCDF4, &ncid); ERR_CHK;
|
||||
err = nc_def_dim(ncid, "dim", 10, &dimid); ERR_CHK;
|
||||
err = nc_def_var(ncid, "var", NC_INT, 1, &dimid, &varid); ERR_CHK;
|
||||
err = nc_enddef(ncid); ERR_CHK;
|
||||
|
||||
err = nc_redef(ncid); ERR;
|
||||
err = nc_redef(ncid); ERR_CHK;
|
||||
|
||||
/* try put attribute _FillValue and expect NC_ELATEFILL */
|
||||
fillv = 9;
|
||||
err = nc_put_att_int(ncid, varid, _FillValue, NC_INT, 1, &fillv);
|
||||
if (err != NC_ELATEFILL)
|
||||
printf("line %d expecting NC_ELATEFILL but got %d\n",__LINE__,err);
|
||||
err = nc_close(ncid); ERR;
|
||||
err = nc_close(ncid); ERR_CHK;
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user