summaryrefslogtreecommitdiffstats
path: root/src/H5O.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2010-07-29 19:17:29 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2010-07-29 19:17:29 (GMT)
commit6e3ff79f0c26c85a8cc444a535870a956fd02b6e (patch)
tree37b0eda7665939cf8955bd7c0a0b03da79515ac9 /src/H5O.c
parent87172f5ba1778c0b5fb7abb9dc840ff5c8694e86 (diff)
downloadhdf5-6e3ff79f0c26c85a8cc444a535870a956fd02b6e.zip
hdf5-6e3ff79f0c26c85a8cc444a535870a956fd02b6e.tar.gz
hdf5-6e3ff79f0c26c85a8cc444a535870a956fd02b6e.tar.bz2
[svn-r19154] Description:
Bring r19153 from trunk to 1.8 branch: 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 3234577..c385bc6 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -1051,17 +1051,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;
@@ -1227,7 +1239,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;
/* Cache object header */
@@ -1478,7 +1490,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)
@@ -1510,7 +1522,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)
@@ -1667,6 +1679,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;
@@ -1708,8 +1721,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;
@@ -1983,7 +1995,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 */
@@ -2419,23 +2431,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 */
@@ -2497,7 +2521,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)
@@ -2517,8 +2541,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)
@@ -2679,7 +2702,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;
@@ -2689,11 +2712,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 */