summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/H5Dchunk.c1
-rw-r--r--src/H5FDfamily.c6
-rw-r--r--src/H5FDsec2.c8
-rw-r--r--src/H5Fsuper_cache.c11
-rw-r--r--src/H5T.c101
-rw-r--r--src/H5Zdeflate.c5
-rw-r--r--src/H5Ztrans.c45
7 files changed, 97 insertions, 80 deletions
diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c
index 8788d86..a358320 100644
--- a/src/H5Dchunk.c
+++ b/src/H5Dchunk.c
@@ -2431,6 +2431,7 @@ H5D_chunk_flush_entry(const H5D_t *dset, hid_t dxpl_id, const H5D_dxpl_cache_t *
done:
/* Free the temp buffer only if it's different than the entry chunk */
if(buf != ent->chunk)
+ /* coverity["double_free"] */
H5MM_xfree(buf);
/*
diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c
index 9817270..87e5e84 100644
--- a/src/H5FDfamily.c
+++ b/src/H5FDfamily.c
@@ -818,9 +818,11 @@ H5FD_family_open(const char *name, unsigned flags, hid_t fapl_id,
/* Enlarge member array */
if(file->nmembs >= file->amembs) {
unsigned n = MAX(64, 2 * file->amembs);
- H5FD_t **x = (H5FD_t **)H5MM_realloc(file->memb, n * sizeof(H5FD_t *));
+ H5FD_t **x;
- if(!x)
+ HDassert(n > 0);
+ /* coverity["freed_arg"] */
+ if(NULL == (x = (H5FD_t **)H5MM_realloc(file->memb, n * sizeof(H5FD_t *))))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to reallocate members")
file->amembs = n;
file->memb = x;
diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c
index 181a153..a030934 100644
--- a/src/H5FDsec2.c
+++ b/src/H5FDsec2.c
@@ -425,9 +425,11 @@ H5FD_sec2_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr)
ret_value = (H5FD_t*)file;
done:
- if(ret_value==NULL) {
- if(fd>=0)
+ if(NULL == ret_value) {
+ if(fd >= 0)
HDclose(fd);
+ if(file)
+ file = H5FL_FREE(H5FD_sec2_t, file);
} /* end if */
FUNC_LEAVE_NOAPI(ret_value)
@@ -464,7 +466,7 @@ H5FD_sec2_close(H5FD_t *_file)
HSYS_GOTO_ERROR(H5E_IO, H5E_CANTCLOSEFILE, FAIL, "unable to close file")
/* Release the file info */
- (void)H5FL_FREE(H5FD_sec2_t, file);
+ file = H5FL_FREE(H5FD_sec2_t, file);
done:
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5Fsuper_cache.c b/src/H5Fsuper_cache.c
index 501e64b..d2aaef8 100644
--- a/src/H5Fsuper_cache.c
+++ b/src/H5Fsuper_cache.c
@@ -111,7 +111,8 @@ H5FL_EXTERN(H5F_super_t);
*-------------------------------------------------------------------------
*/
static H5F_super_t *
-H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *udata1, void *udata2/*out*/)
+H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, const void UNUSED *udata1,
+ void *udata2/*out*/)
{
H5F_super_t *sblock = NULL; /* File's superblock */
haddr_t base_addr = HADDR_UNDEF; /* Base address of file */
@@ -609,6 +610,11 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *udata1
ret_value = sblock;
done:
+ /* Release the [possibly partially initialized] superblock on errors */
+ if(!ret_value && sblock)
+ if(H5F_sblock_dest(f, sblock) < 0)
+ HDONE_ERROR(H5E_FILE, H5E_CANTFREE, NULL, "unable to destroy superblock data")
+
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5F_sblock_load() */
@@ -628,7 +634,8 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5F_sblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5F_super_t *sblock)
+H5F_sblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t UNUSED addr,
+ H5F_super_t *sblock)
{
herr_t ret_value = SUCCEED;
diff --git a/src/H5T.c b/src/H5T.c
index 4041cd5..64e39d6 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -3816,84 +3816,85 @@ H5T_get_size(const H5T_t *dt)
* Programmer: Robb Matzke
* Wednesday, December 10, 1997
*
- * Modifications:
- * Robb Matzke, 22 Dec 1998
- * Able to compare enumeration data types.
- *
- * Robb Matzke, 20 May 1999
- * Compares bitfields and opaque types.
- *
- * Quincey Koziol, 19 Mar 2005
- * Allow an enumerated datatypes to compare equal, if the "superset"
- * flag is set and dt2 has a superset of the enumerated values in dt1
*-------------------------------------------------------------------------
*/
int
H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset)
{
unsigned *idx1 = NULL, *idx2 = NULL;
- int ret_value = 0;
+ size_t base_size;
+ hbool_t swapped;
int i, j;
unsigned u;
int tmp;
- hbool_t swapped;
- size_t base_size;
+ int ret_value = 0;
- FUNC_ENTER_NOAPI(H5T_cmp, 0);
+ FUNC_ENTER_NOAPI(H5T_cmp, 0)
+ /* Sanity check */
+ HDassert(dt1);
+ HDassert(dt2);
+
/* the easy case */
- if (dt1 == dt2) HGOTO_DONE(0);
- assert(dt1);
- assert(dt2);
+ if(dt1 == dt2)
+ HGOTO_DONE(0);
/* compare */
- if (dt1->shared->type < dt2->shared->type) HGOTO_DONE(-1);
- if (dt1->shared->type > dt2->shared->type) HGOTO_DONE(1);
-
- if (dt1->shared->size < dt2->shared->size) HGOTO_DONE(-1);
- if (dt1->shared->size > dt2->shared->size) HGOTO_DONE(1);
-
- if (dt1->shared->parent && !dt2->shared->parent) HGOTO_DONE(-1);
- if (!dt1->shared->parent && dt2->shared->parent) HGOTO_DONE(1);
- if (dt1->shared->parent) {
+ if(dt1->shared->type < dt2->shared->type)
+ HGOTO_DONE(-1);
+ if(dt1->shared->type > dt2->shared->type)
+ HGOTO_DONE(1);
+
+ if(dt1->shared->size < dt2->shared->size)
+ HGOTO_DONE(-1);
+ if(dt1->shared->size > dt2->shared->size)
+ HGOTO_DONE(1);
+
+ if(dt1->shared->parent && !dt2->shared->parent)
+ HGOTO_DONE(-1);
+ if(!dt1->shared->parent && dt2->shared->parent)
+ HGOTO_DONE(1);
+ if(dt1->shared->parent) {
tmp = H5T_cmp(dt1->shared->parent, dt2->shared->parent, superset);
- if (tmp<0) HGOTO_DONE(-1);
- if (tmp>0) HGOTO_DONE(1);
- }
+ if(tmp < 0)
+ HGOTO_DONE(-1);
+ if(tmp > 0)
+ HGOTO_DONE(1);
+ } /* end if */
switch(dt1->shared->type) {
case H5T_COMPOUND:
/*
* Compound data types...
*/
- if (dt1->shared->u.compnd.nmembs < dt2->shared->u.compnd.nmembs)
+ if(dt1->shared->u.compnd.nmembs < dt2->shared->u.compnd.nmembs)
HGOTO_DONE(-1);
- if (dt1->shared->u.compnd.nmembs > dt2->shared->u.compnd.nmembs)
+ if(dt1->shared->u.compnd.nmembs > dt2->shared->u.compnd.nmembs)
HGOTO_DONE(1);
/* Build an index for each type so the names are sorted */
- if (NULL==(idx1 = H5MM_malloc(dt1->shared->u.compnd.nmembs * sizeof(unsigned))) ||
- NULL==(idx2 = H5MM_malloc(dt2->shared->u.compnd.nmembs * sizeof(unsigned))))
+ if(NULL == (idx1 = H5MM_malloc(dt1->shared->u.compnd.nmembs * sizeof(unsigned))) ||
+ NULL == (idx2 = H5MM_malloc(dt2->shared->u.compnd.nmembs * sizeof(unsigned))))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed");
- for (u=0; u<dt1->shared->u.compnd.nmembs; u++)
+ for(u = 0; u < dt1->shared->u.compnd.nmembs; u++)
idx1[u] = idx2[u] = u;
if(dt1->shared->u.enumer.nmembs > 1) {
- for (i=dt1->shared->u.compnd.nmembs-1, swapped=TRUE; swapped && i>=0; --i)
- for (j=0, swapped=FALSE; j<i; j++)
- if (HDstrcmp(dt1->shared->u.compnd.memb[idx1[j]].name,
- dt1->shared->u.compnd.memb[idx1[j+1]].name) > 0) {
+ for(i = dt1->shared->u.compnd.nmembs - 1, swapped = TRUE; swapped && i >= 0; --i)
+ for(j = 0, swapped=FALSE; j < i; j++)
+ if(HDstrcmp(dt1->shared->u.compnd.memb[idx1[j]].name,
+ dt1->shared->u.compnd.memb[idx1[j + 1]].name) > 0) {
tmp = idx1[j];
- idx1[j] = idx1[j+1];
- idx1[j+1] = tmp;
+ idx1[j] = idx1[j + 1];
+ idx1[j + 1] = tmp;
swapped = TRUE;
}
- for (i=dt2->shared->u.compnd.nmembs-1, swapped=TRUE; swapped && i>=0; --i)
- for (j=0, swapped=FALSE; j<i; j++)
- if (HDstrcmp(dt2->shared->u.compnd.memb[idx2[j]].name,
- dt2->shared->u.compnd.memb[idx2[j+1]].name) > 0) {
+ for(i = dt2->shared->u.compnd.nmembs - 1, swapped = TRUE; swapped && i >= 0; --i)
+ for(j = 0, swapped = FALSE; j<i; j++)
+ if(HDstrcmp(dt2->shared->u.compnd.memb[idx2[j]].name,
+ dt2->shared->u.compnd.memb[idx2[j + 1]].name) > 0) {
tmp = idx2[j];
- idx2[j] = idx2[j+1];
- idx2[j+1] = tmp;
+ idx2[j] = idx2[j + 1];
+ idx2[j + 1] = tmp;
swapped = TRUE;
}
} /* end if */
@@ -4212,13 +4213,13 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset)
} /* end switch */
done:
- if(idx1!=NULL)
+ if(NULL != idx1)
H5MM_xfree(idx1);
- if(idx2!=NULL)
+ if(NULL != idx2)
H5MM_xfree(idx2);
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5T_cmp() */
/*-------------------------------------------------------------------------
diff --git a/src/H5Zdeflate.c b/src/H5Zdeflate.c
index c0bcd70..c490720 100644
--- a/src/H5Zdeflate.c
+++ b/src/H5Zdeflate.c
@@ -78,6 +78,11 @@ H5Z_filter_deflate (unsigned flags, size_t cd_nelmts,
FUNC_ENTER_NOAPI(H5Z_filter_deflate, 0)
+ /* Sanity check */
+ HDassert(*buf_size > 0);
+ HDassert(buf);
+ HDassert(*buf);
+
/* Check arguments */
if (cd_nelmts!=1 || cd_values[0]>9)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid deflate aggression level")
diff --git a/src/H5Ztrans.c b/src/H5Ztrans.c
index 2b35786..1a6988f 100644
--- a/src/H5Ztrans.c
+++ b/src/H5Ztrans.c
@@ -335,29 +335,29 @@ H5Z_unget_token(H5Z_token *current)
/*-------------------------------------------------------------------------
* Function: H5Z_get_token
+ *
* Purpose: Determine what the next valid H5Z_token is in the expression
* string. The current position within the H5Z_token string is
* kept internal to the H5Z_token and handled by this and the
* unget_H5Z_token function.
+ *
* Return: Succeess: The passed in H5Z_token with a valid tok_type
* field.
* Failure: The passed in H5Z_token but with the tok_type
* field set to ERROR.
+ *
* Programmer: Bill Wendling
* 26. August 2003
- * Modifications:
- * Leon Arber: Added FUNC_ENTER / FUNC_LEAVE pairs
+ *
*-------------------------------------------------------------------------
*/
static H5Z_token *
H5Z_get_token(H5Z_token *current)
{
-
- void* ret_value=current;
+ void *ret_value = current;
FUNC_ENTER_NOAPI(H5Z_get_token, NULL)
-
/* check args */
assert(current);
@@ -463,11 +463,11 @@ H5Z_get_token(H5Z_token *current)
if (current->tok_begin[0] == '\0')
current->tok_type = H5Z_XFORM_END;
- HGOTO_DONE(current);
+ /* Set return value */
+ ret_value = (void *)current;
done:
FUNC_LEAVE_NOAPI(ret_value)
-
}
@@ -498,17 +498,17 @@ H5Z_xform_destroy_parse_tree(H5Z_node *tree)
FUNC_LEAVE_NOAPI_VOID
}
-
/*-------------------------------------------------------------------------
* Function: H5Z_parse
+ *
* Purpose: Entry function for parsing the expression string.
+ *
* Return: Success: Valid H5Z_node ptr to an expression tree.
* NULLure: NULL
+ *
* Programmer: Bill Wendling
* 26. August 2003
- * Modifications:
- * Leon Arber: Added FUNC_ENTER / FUNC_LEAVE pairs
*
*-------------------------------------------------------------------------
*/
@@ -518,11 +518,10 @@ H5Z_xform_parse(const char *expression, H5Z_datval_ptrs* dat_val_pointers)
H5Z_token tok;
void* ret_value;
- FUNC_ENTER_NOAPI_NOFUNC(H5Z_xform_parse)
-
- if (!expression)
- HGOTO_DONE(NULL)
+ FUNC_ENTER_NOAPI(H5Z_xform_parse, NULL)
+ if(!expression)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "No expression provided?")
/* Set up the initial H5Z_token for parsing */
tok.tok_expr = tok.tok_begin = tok.tok_end = expression;
@@ -573,7 +572,7 @@ H5Z_parse_expression(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers)
if (!new_node) {
H5Z_xform_destroy_parse_tree(expr);
- HGOTO_DONE(expr)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Unable to allocate new node")
}
new_node->lchild = expr;
@@ -592,7 +591,7 @@ H5Z_parse_expression(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers)
if (!new_node) {
H5Z_xform_destroy_parse_tree(expr);
- HGOTO_DONE(expr)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Unable to allocate new node")
}
new_node->lchild = expr;
@@ -643,7 +642,7 @@ static H5Z_node *
H5Z_parse_term(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers)
{
H5Z_node *term = NULL;
- void* ret_value;
+ H5Z_node *ret_value;
FUNC_ENTER_NOAPI(H5Z_parse_term, NULL);
term = H5Z_parse_factor(current, dat_val_pointers);
@@ -659,7 +658,7 @@ H5Z_parse_term(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers)
if (!new_node) {
H5Z_xform_destroy_parse_tree(term);
- HGOTO_DONE(term)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Unable to allocate new node")
}
new_node->lchild = term;
@@ -678,7 +677,7 @@ H5Z_parse_term(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers)
if (!new_node) {
H5Z_xform_destroy_parse_tree(term);
- HGOTO_DONE(term)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Unable to allocate new node")
}
new_node->lchild = term;
@@ -744,7 +743,7 @@ H5Z_parse_factor(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers)
factor = H5Z_new_node(H5Z_XFORM_INTEGER);
if (!factor)
- HGOTO_DONE(factor)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Unable to allocate new node")
sscanf(current->tok_begin, "%ld", &factor->value.int_val);
break;
@@ -752,7 +751,7 @@ H5Z_parse_factor(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers)
factor = H5Z_new_node(H5Z_XFORM_FLOAT);
if (!factor)
- HGOTO_DONE(factor)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Unable to allocate new node")
sscanf(current->tok_begin, "%lf", &factor->value.float_val);
break;
@@ -760,7 +759,7 @@ H5Z_parse_factor(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers)
factor = H5Z_new_node(H5Z_XFORM_SYMBOL);
if (!factor)
- HGOTO_DONE(factor)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Unable to allocate new node")
factor->value.dat_val = &(dat_val_pointers->ptr_dat_val[dat_val_pointers->num_ptrs]);
dat_val_pointers->num_ptrs++;
@@ -770,7 +769,7 @@ H5Z_parse_factor(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers)
factor = H5Z_parse_expression(current, dat_val_pointers);
if (!factor)
- HGOTO_DONE(factor)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Unable to allocate new node")
current = H5Z_get_token(current);