Commit 575a9ea6 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Check stdname argument.

parent 786c3aa1
......@@ -63,8 +63,7 @@ static int gridCompareP ( void * gridptr1, void * gridptr2 );
static void gridDestroyP ( void * gridptr );
static void gridPrintP ( void * gridptr, FILE * fp );
static int gridGetPackSize ( void * gridptr, void *context);
static void gridPack ( void * gridptr, void * buff, int size,
int *position, void *context);
static void gridPack ( void * gridptr, void * buff, int size, int *position, void *context);
static int gridTxCode ( void );
static const resOps gridOps = {
......@@ -78,11 +77,12 @@ static const resOps gridOps = {
static int GRID_Debug = 0; /* If set to 1, debugging */
grid_t *grid_to_pointer(int gridID)
{
return (grid_t *)reshGetVal(gridID, &gridOps);
}
#define grid_to_pointer(gridID) (grid_t *)reshGetVal(gridID, &gridOps)
#define gridMark4Update(gridID) reshSetStatus(gridID, &gridOps, RESH_DESYNC_IN_USE)
......@@ -228,6 +228,7 @@ grid_t *grid_copy_base(grid_t *gridptrOrig)
return gridptrDup;
}
unsigned cdiGridCount(void)
{
return reshCountType(&gridOps);
......@@ -537,8 +538,8 @@ void gridDestroy(int gridID)
gridptr->vtable->destroy(gridptr);
}
void gridDestroyP ( void * gridptr )
static
void gridDestroyP(void * gridptr)
{
((grid_t *)gridptr)->vtable->destroy((grid_t *)gridptr);
}
......@@ -548,7 +549,7 @@ const char *gridNamePtr(int gridtype)
{
int size = (int) (sizeof(Grids)/sizeof(Grids[0]));
const char *name = gridtype >= 0 && gridtype < size ? Grids[gridtype] : Grids[GRID_GENERIC];
const char *name = (gridtype >= 0 && gridtype < size) ? Grids[gridtype] : Grids[GRID_GENERIC];
return name;
}
......@@ -848,11 +849,12 @@ void gridInqXunits(int gridID, char *xunits)
void gridInqXstdname(int gridID, char *xstdname)
{
grid_t *gridptr = grid_to_pointer(gridID);
if ( gridptr->x.stdname )
strcpy(xstdname, gridptr->x.stdname);
else
xstdname[0] = 0;
if ( xstdname )
{
xstdname[0] = 0;
grid_t *gridptr = grid_to_pointer(gridID);
if ( gridptr->x.stdname ) strcpy(xstdname, gridptr->x.stdname);
}
}
/*
......@@ -930,11 +932,12 @@ void gridInqYunits(int gridID, char *yunits)
void gridInqYstdname(int gridID, char *ystdname)
{
grid_t *gridptr = grid_to_pointer(gridID);
if ( gridptr->y.stdname )
strcpy(ystdname, gridptr->y.stdname);
else
ystdname[0] = 0;
if ( ystdname )
{
ystdname[0] = 0;
grid_t *gridptr = grid_to_pointer(gridID);
if ( gridptr->y.stdname ) strcpy(ystdname, gridptr->y.stdname);
}
}
......@@ -3799,7 +3802,6 @@ The function @func{gridInqPosition} returns the position of grid in the referenc
int gridInqPosition(int gridID)
{
grid_t *gridptr = grid_to_pointer(gridID);
return gridptr->position;
}
......
......@@ -1997,7 +1997,7 @@ int vlistInqVarIntKey(int vlistID, int varID, const char* name)
void vlistDefVarIOrank(int vlistID, int varID, int iorank)
{
vlist_t *vlistptr = vlist_to_pointer(vlistID );
vlist_t *vlistptr = vlist_to_pointer(vlistID);
vlistCheckVarID ( __func__, vlistID, varID );
......
......@@ -107,8 +107,14 @@ void zaxisGetTypeDescription(int zaxisType, int *outPositive, const char **outNa
}
}
zaxis_t *zaxis_to_pointer(int id)
{
return (zaxis_t *)reshGetVal(id, &zaxisOps);
}
static
void zaxisDefaultValue(zaxis_t *zaxisptr)
void zaxis_init(zaxis_t *zaxisptr)
{
zaxisptr->self = CDI_UNDEFID;
zaxisptr->name[0] = 0;
......@@ -143,8 +149,7 @@ static
zaxis_t *zaxisNewEntry(int id)
{
zaxis_t *zaxisptr = (zaxis_t *) Malloc(sizeof(zaxis_t));
zaxisDefaultValue ( zaxisptr );
zaxis_init(zaxisptr);
if ( id == CDI_UNDEFID )
zaxisptr->self = reshPut(zaxisptr, &zaxisOps);
......@@ -157,12 +162,6 @@ zaxis_t *zaxisNewEntry(int id)
return zaxisptr;
}
zaxis_t *zaxis_to_pointer(int id)
{
return (zaxis_t *)reshGetVal(id, &zaxisOps);
}
static
void zaxisInit(void)
{
......@@ -182,14 +181,14 @@ void zaxis_copy(zaxis_t *zaxisptr2, zaxis_t *zaxisptr1)
zaxisptr2->self = zaxisID2;
}
unsigned cdiZaxisCount(void)
{
return reshCountType(&zaxisOps);
}
static int
zaxisCreate_(int zaxistype, int size, int id)
static
int zaxisCreate_(int zaxistype, int size, int id)
{
zaxis_t *zaxisptr = zaxisNewEntry(id);
......@@ -257,7 +256,8 @@ int zaxisCreate(int zaxistype, int size)
{
if ( CDI_Debug ) Message("zaxistype: %d size: %d ", zaxistype, size);
zaxisInit ();
zaxisInit();
return zaxisCreate_(zaxistype, size, CDI_UNDEFID);
}
......@@ -568,8 +568,12 @@ void zaxisInqUnits(int zaxisID, char *units)
void zaxisInqStdname(int zaxisID, char *stdname)
{
zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
strcpy(stdname, zaxisptr->stdname);
if ( stdname )
{
stdname[0] = 0;
zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
if ( zaxisptr->stdname ) strcpy(stdname, zaxisptr->stdname);
}
}
......@@ -577,7 +581,7 @@ void zaxisDefPrec(int zaxisID, int prec)
{
zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
if (zaxisptr->prec != prec)
if ( zaxisptr->prec != prec )
{
zaxisptr->prec = prec;
reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
......@@ -649,7 +653,7 @@ void zaxisDefLtype2(int zaxisID, int ltype2)
{
zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
if (zaxisptr->ltype2 != ltype2)
if ( zaxisptr->ltype2 != ltype2 )
{
zaxisptr->ltype2 = ltype2;
reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
......@@ -1250,16 +1254,12 @@ int zaxisDuplicate(int zaxisID)
return zaxisIDnew;
}
static
void zaxisPrintKernel(zaxis_t *zaxisptr, int index, FILE *fp)
{
unsigned char uuid[CDI_UUID_SIZE];
xassert(zaxisptr);
int zaxisID = zaxisptr->self;
int type = zaxisptr->type;
int nlevels = zaxisptr->size;
int prec = zaxisptr->prec;
......@@ -1368,6 +1368,7 @@ void zaxisPrintKernel(zaxis_t *zaxisptr, int index, FILE *fp)
if ( type == ZAXIS_REFERENCE )
{
unsigned char uuid[CDI_UUID_SIZE];
zaxisInqUUID(zaxisID, uuid);
if ( *uuid )
{
......@@ -1380,11 +1381,10 @@ void zaxisPrintKernel(zaxis_t *zaxisptr, int index, FILE *fp)
}
void zaxisPrint ( int zaxisID, int index )
void zaxisPrint(int zaxisID, int index)
{
zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
zaxisPrintKernel ( zaxisptr, index, stdout );
zaxisPrintKernel(zaxisptr, index, stdout);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment