summaryrefslogtreecommitdiffstats
path: root/src/H5Spoint.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2015-09-26 23:52:42 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2015-09-26 23:52:42 (GMT)
commit8186a5cee10c41e97ba24b6fe1de9f6ce0c3902d (patch)
treeff9e92097542b930801522e1ce6c0ed5de72cecc /src/H5Spoint.c
parentaec3e1242d0d0f5c0fcbe796f2c2801c828e7efb (diff)
downloadhdf5-8186a5cee10c41e97ba24b6fe1de9f6ce0c3902d.zip
hdf5-8186a5cee10c41e97ba24b6fe1de9f6ce0c3902d.tar.gz
hdf5-8186a5cee10c41e97ba24b6fe1de9f6ce0c3902d.tar.bz2
[svn-r27884] Description:
Update dataspace selection encode/decode routines to avoid type aliasing errors. Tested on: Linux/64 2.6.x (platypus) w/production (h5committest forthcoming)
Diffstat (limited to 'src/H5Spoint.c')
-rw-r--r--src/H5Spoint.c51
1 files changed, 31 insertions, 20 deletions
diff --git a/src/H5Spoint.c b/src/H5Spoint.c
index d225ab2..daee160 100644
--- a/src/H5Spoint.c
+++ b/src/H5Spoint.c
@@ -822,28 +822,32 @@ H5S_point_serial_size (const H5S_t *space)
static herr_t
H5S_point_serialize (const H5S_t *space, uint8_t **p)
{
- H5S_pnt_node_t *curr; /* Point information nodes */
- uint8_t *lenp; /* pointer to length location for later storage */
- uint32_t len=0; /* number of bytes used */
- unsigned u; /* local counting variable */
+ H5S_pnt_node_t *curr; /* Point information nodes */
+ uint8_t *pp = (*p); /* Local pointer for decoding */
+ uint8_t *lenp; /* pointer to length location for later storage */
+ uint32_t len=0; /* number of bytes used */
+ unsigned u; /* local counting variable */
FUNC_ENTER_NOAPI_NOINIT_NOERR
+ /* Check args */
HDassert(space);
+ HDassert(p);
+ HDassert(pp);
/* Store the preamble information */
- UINT32ENCODE(*p, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */
- UINT32ENCODE(*p, (uint32_t)1); /* Store the version number */
- UINT32ENCODE(*p, (uint32_t)0); /* Store the un-used padding */
- lenp=*p; /* keep the pointer to the length location for later */
- *p+=4; /* skip over space for length */
+ UINT32ENCODE(pp, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */
+ UINT32ENCODE(pp, (uint32_t)1); /* Store the version number */
+ UINT32ENCODE(pp, (uint32_t)0); /* Store the un-used padding */
+ lenp = pp; /* Keep the pointer to the length location for later */
+ pp += 4; /* Skip over space for length */
/* Encode number of dimensions */
- UINT32ENCODE(*p, (uint32_t)space->extent.rank);
+ UINT32ENCODE(pp, (uint32_t)space->extent.rank);
len+=4;
/* Encode number of elements */
- UINT32ENCODE(*p, (uint32_t)space->select.num_elem);
+ UINT32ENCODE(pp, (uint32_t)space->select.num_elem);
len+=4;
/* Encode each point in selection */
@@ -854,7 +858,7 @@ H5S_point_serialize (const H5S_t *space, uint8_t **p)
/* Encode each point */
for(u=0; u<space->extent.rank; u++)
- UINT32ENCODE(*p, (uint32_t)curr->pnt[u]);
+ UINT32ENCODE(pp, (uint32_t)curr->pnt[u]);
curr=curr->next;
} /* end while */
@@ -862,6 +866,9 @@ H5S_point_serialize (const H5S_t *space, uint8_t **p)
/* Encode length */
UINT32ENCODE(lenp, (uint32_t)len); /* Store the length of the extra information */
+ /* Update encoding pointer */
+ *p = pp;
+
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5S_point_serialize() */
@@ -891,24 +898,25 @@ H5S_point_serialize (const H5S_t *space, uint8_t **p)
static herr_t
H5S_point_deserialize (H5S_t *space, const uint8_t **p)
{
- H5S_seloper_t op=H5S_SELECT_SET; /* Selection operation */
- unsigned rank; /* Rank of points */
- size_t num_elem=0; /* Number of elements in selection */
- hsize_t *coord=NULL, *tcoord; /* Pointer to array of elements */
+ H5S_seloper_t op = H5S_SELECT_SET; /* Selection operation */
+ hsize_t *coord = NULL, *tcoord; /* Pointer to array of elements */
+ const uint8_t *pp = (*p); /* Local pointer for decoding */
+ size_t num_elem = 0; /* Number of elements in selection */
+ unsigned rank; /* Rank of points */
unsigned i, j; /* local counting variables */
- herr_t ret_value = SUCCEED; /* return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
/* Check args */
HDassert(space);
HDassert(p);
- HDassert(*p);
+ HDassert(pp);
/* Deserialize points to select */
/* (The header and rank have already beed decoded) */
rank = space->extent.rank; /* Retrieve rank from space */
- UINT32DECODE(*p, num_elem); /* decode the number of points */
+ UINT32DECODE(pp, num_elem); /* decode the number of points */
/* Allocate space for the coordinates */
if(NULL == (coord = (hsize_t *)H5MM_malloc(num_elem * rank * sizeof(hsize_t))))
@@ -917,12 +925,15 @@ H5S_point_deserialize (H5S_t *space, const uint8_t **p)
/* Retrieve the coordinates from the buffer */
for(tcoord = coord, i = 0; i < num_elem; i++)
for(j = 0; j < (unsigned)rank; j++, tcoord++)
- UINT32DECODE(*p, *tcoord);
+ UINT32DECODE(pp, *tcoord);
/* Select points */
if(H5S_select_elements(space, op, num_elem, (const hsize_t *)coord) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection")
+ /* Update decoding pointer */
+ *p = pp;
+
done:
/* Free the coordinate array if necessary */
if(coord != NULL)