summaryrefslogtreecommitdiffstats
path: root/src/H5O.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2010-07-29 19:07:26 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2010-07-29 19:07:26 (GMT)
commit7fe87a24722f991ffc030782cd42d24df00dbace (patch)
tree7d466f911a952916b99e2c86e83202d0e07cffaa /src/H5O.c
parent178b80b679b874d99287b28898e242533721ea67 (diff)
downloadhdf5-7fe87a24722f991ffc030782cd42d24df00dbace.zip
hdf5-7fe87a24722f991ffc030782cd42d24df00dbace.tar.gz
hdf5-7fe87a24722f991ffc030782cd42d24df00dbace.tar.bz2
[svn-r19153] Description:
Bring changes on Coverity branch back to trunk: r19040: Fixed coverity #440 - NULL check after dereference. We moved the NULL check up into the IF block and changed it to assertion. r19041: Maintenance: Addressed Coverity issues 441 and 449 by initializing proper variables r19042: In function H5O_chunk_protect (H5Ochunk.c): - Initialize H5O_chunk_proxy_t pointers chk_proxy and ret_value. - Free chk_proxy on error. r19043: Addressed coverity issues 442 - 448 by initializing pointers to NULL. Tested on: Mac OS X/32 10.6.4 (amazon) w/debug & production (Too minor to require h5committest)
Diffstat (limited to 'src/H5O.c')
-rw-r--r--src/H5O.c69
1 files changed, 46 insertions, 23 deletions
diff --git a/src/H5O.c b/src/H5O.c
index 473dc23..3b4d70a 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -1052,17 +1052,29 @@ H5Oclose(hid_t object_id)
H5TRACE1("e", "i", object_id);
/* Get the type of the object and close it in the correct way */
- switch(H5I_get_type(object_id))
- {
- case(H5I_GROUP):
- case(H5I_DATATYPE):
- case(H5I_DATASET):
+ switch(H5I_get_type(object_id)) {
+ case H5I_GROUP:
+ case H5I_DATATYPE:
+ case H5I_DATASET:
if(H5I_object(object_id) == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid object")
if(H5I_dec_ref(object_id, TRUE) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to close object")
break;
+ case H5I_UNINIT:
+ case H5I_BADID:
+ case H5I_FILE:
+ case H5I_DATASPACE:
+ case H5I_ATTR:
+ case H5I_REFERENCE:
+ case H5I_VFL:
+ case H5I_GENPROP_CLS:
+ case H5I_GENPROP_LST:
+ case H5I_ERROR_CLASS:
+ case H5I_ERROR_MSG:
+ case H5I_ERROR_STACK:
+ case H5I_NTYPES:
default:
HGOTO_ERROR(H5E_ARGS, H5E_CANTRELEASE, FAIL, "not a valid file object ID (dataset, group, or datatype)")
break;
@@ -1228,7 +1240,7 @@ H5O_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, hid_t ocpl_id,
oh->mesg[0].dirty = TRUE;
oh->mesg[0].native = NULL;
oh->mesg[0].raw = oh->chunk[0].image + (H5O_SIZEOF_HDR(oh) - H5O_SIZEOF_CHKSUM_OH(oh)) + H5O_SIZEOF_MSGHDR_OH(oh);
- oh->mesg[0].raw_size = size_hint - H5O_SIZEOF_MSGHDR_OH(oh);
+ oh->mesg[0].raw_size = size_hint - (size_t)H5O_SIZEOF_MSGHDR_OH(oh);
oh->mesg[0].chunkno = 0;
/* Set metadata tag in dxpl_id */
@@ -1485,7 +1497,7 @@ H5O_link_oh(H5F_t *f, int adjust, hid_t dxpl_id, H5O_t *oh, hbool_t *deleted)
HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "link count would be negative")
/* Adjust the link count for the object header */
- oh->nlink += adjust;
+ oh->nlink = (unsigned)((int)oh->nlink + adjust);
/* Mark object header as dirty in cache */
if(H5AC_mark_entry_dirty(oh) < 0)
@@ -1517,7 +1529,7 @@ H5O_link_oh(H5F_t *f, int adjust, hid_t dxpl_id, H5O_t *oh, hbool_t *deleted)
} /* end if */
/* Adjust the link count for the object header */
- oh->nlink += adjust;
+ oh->nlink = (unsigned)((int)oh->nlink + adjust);
/* Mark object header as dirty in cache */
if(H5AC_mark_entry_dirty(oh) < 0)
@@ -1674,6 +1686,7 @@ H5O_protect(const H5O_loc_t *loc, hid_t dxpl_id, H5AC_protect_t prot)
* when the object header is actually loaded from the file.
*/
HDassert(udata.made_attempt == TRUE);
+ HDassert(cont_msg_info.msgs);
/* Construct the user data for protecting chunks */
chk_udata.decoding = TRUE;
@@ -1715,8 +1728,7 @@ H5O_protect(const H5O_loc_t *loc, hid_t dxpl_id, H5AC_protect_t prot)
} /* end while */
/* Release any continuation messages built up */
- if(cont_msg_info.msgs)
- cont_msg_info.msgs = (H5O_cont_t *)H5FL_SEQ_FREE(H5O_cont_t, cont_msg_info.msgs);
+ cont_msg_info.msgs = (H5O_cont_t *)H5FL_SEQ_FREE(H5O_cont_t, cont_msg_info.msgs);
/* Pass back out some of the chunk's user data */
udata.common.merged_null_msgs = chk_udata.common.merged_null_msgs;
@@ -1990,7 +2002,7 @@ H5O_touch_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh, hbool_t force)
break;
/* Create a new message, if necessary */
- if(idx == oh->nmesgs) {
+ if(idx == (int)oh->nmesgs) {
unsigned mesg_flags = 0; /* Flags for message in object header */
/* If we would have to create a new message, but we aren't 'forcing' it, get out now */
@@ -2426,23 +2438,35 @@ H5O_get_loc(hid_t object_id)
FUNC_ENTER_NOAPI_NOINIT(H5O_get_loc)
- switch(H5I_get_type(object_id))
- {
- case(H5I_GROUP):
+ switch(H5I_get_type(object_id)) {
+ case H5I_GROUP:
if(NULL == (ret_value = H5O_OBJ_GROUP->get_oloc(object_id)))
HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to get object location from group ID")
break;
- case(H5I_DATASET):
+ case H5I_DATASET:
if(NULL == (ret_value = H5O_OBJ_DATASET->get_oloc(object_id)))
HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to get object location from dataset ID")
break;
- case(H5I_DATATYPE):
+ case H5I_DATATYPE:
if(NULL == (ret_value = H5O_OBJ_DATATYPE->get_oloc(object_id)))
HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to get object location from datatype ID")
break;
+ case H5I_UNINIT:
+ case H5I_BADID:
+ case H5I_FILE:
+ case H5I_DATASPACE:
+ case H5I_ATTR:
+ case H5I_REFERENCE:
+ case H5I_VFL:
+ case H5I_GENPROP_CLS:
+ case H5I_GENPROP_LST:
+ case H5I_ERROR_CLASS:
+ case H5I_ERROR_MSG:
+ case H5I_ERROR_STACK:
+ case H5I_NTYPES:
default:
HGOTO_ERROR(H5E_OHDR, H5E_BADTYPE, NULL, "invalid object type")
} /* end switch */
@@ -2504,7 +2528,7 @@ H5O_loc_reset(H5O_loc_t *loc)
*-------------------------------------------------------------------------
*/
herr_t
-H5O_loc_copy(H5O_loc_t *dst, const H5O_loc_t *src, H5_copy_depth_t depth)
+H5O_loc_copy(H5O_loc_t *dst, H5O_loc_t *src, H5_copy_depth_t depth)
{
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_loc_copy)
@@ -2524,8 +2548,7 @@ H5O_loc_copy(H5O_loc_t *dst, const H5O_loc_t *src, H5_copy_depth_t depth)
if(src->holding_file)
dst->file->nopen_objs++;
} else if(depth == H5_COPY_SHALLOW) {
- /* Discarding 'const' qualifier OK - QAK */
- H5O_loc_reset((H5O_loc_t *)src);
+ H5O_loc_reset(src);
} /* end if */
FUNC_LEAVE_NOAPI(SUCCEED)
@@ -2686,7 +2709,7 @@ H5O_get_hdr_info_real(const H5O_t *oh, H5O_hdr_info_t *hdr)
hdr->flags = oh->flags;
/* Iterate over all the messages, accumulating message size & type information */
- hdr->space.meta = H5O_SIZEOF_HDR(oh) + (H5O_SIZEOF_CHKHDR_OH(oh) * (oh->nchunks - 1));
+ hdr->space.meta = (hsize_t)H5O_SIZEOF_HDR(oh) + (hsize_t)(H5O_SIZEOF_CHKHDR_OH(oh) * (oh->nchunks - 1));
hdr->space.mesg = 0;
hdr->space.free = 0;
hdr->mesg.present = 0;
@@ -2696,11 +2719,11 @@ H5O_get_hdr_info_real(const H5O_t *oh, H5O_hdr_info_t *hdr)
/* Accumulate space usage information, based on the type of message */
if(H5O_NULL_ID == curr_msg->type->id)
- hdr->space.free += H5O_SIZEOF_MSGHDR_OH(oh) + curr_msg->raw_size;
+ hdr->space.free += (hsize_t)((size_t)H5O_SIZEOF_MSGHDR_OH(oh) + curr_msg->raw_size);
else if(H5O_CONT_ID == curr_msg->type->id)
- hdr->space.meta += H5O_SIZEOF_MSGHDR_OH(oh) + curr_msg->raw_size;
+ hdr->space.meta += (hsize_t)((size_t)H5O_SIZEOF_MSGHDR_OH(oh) + curr_msg->raw_size);
else {
- hdr->space.meta += H5O_SIZEOF_MSGHDR_OH(oh);
+ hdr->space.meta += (hsize_t)H5O_SIZEOF_MSGHDR_OH(oh);
hdr->space.mesg += curr_msg->raw_size;
} /* end else */