summaryrefslogtreecommitdiffstats
path: root/src/H5HLdbg.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2014-02-20 21:29:26 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2014-02-20 21:29:26 (GMT)
commit1e36b5a348415501aa8eb992fd57c09d834900cd (patch)
tree9a423be6cbe38eed62268779703258972fb94191 /src/H5HLdbg.c
parentb30e37ea78a85c9a2e3abda7fddaabb636935b1c (diff)
downloadhdf5-1e36b5a348415501aa8eb992fd57c09d834900cd.zip
hdf5-1e36b5a348415501aa8eb992fd57c09d834900cd.tar.gz
hdf5-1e36b5a348415501aa8eb992fd57c09d834900cd.tar.bz2
[svn-r24726] Description:
Revert some earlier usage of strncpy, which was incorrect. Bring Coverity changes from branch back to trunk: r20821: Use HDstrncpy. --gh (Fixed already, with strdup) r20822: (Not merged, incorrect use of HDstrncpy()) r20823: (Not merged, incorrect use of HDstrncpy()) r20824: Maintenance: Bug fix: addressed CID 666. Value stored at *expression_len should be used in the call to HD5packFstring to avoid overflow (and unnecessary arithmetic calculation and casting) r20825: Issue 642: Added check for error and handler with print to stderr and exit. r20826: Undo revision 20818, as that issue has already been fixed in the 1.8 branch and trunk (but not coverity branch) r20827: (Not merged, incorrect use of HDstrncpy()) r20828: Use HDstrncpy. --gh (Corrected use of strncpy()) r20829: Check return of H5Lget_val(print_udata->fid, path, targbuf, linfo->u.val_size + 1, H5P_DEFAULT) and if error set trgbuf[0] to 0. Check if H5Lunpack_elink_val(targbuf, linfo->u.val_size, NULL, &filename, &objname) was successful and allow print. Otherwise filename and objname are not created. (init those to NULL) r20830: resolved coverity issues 939, 940, 941, 944, and 947. all were complaints about use of sprintf, and in all cases, the buffers used were large enough for all eventualities. Resolved issue by replacing calls to sprintf with calls to snprintf. r20831: Maintenance: Addressed CID 852 Replaced sprintf with snprintf r20832: Purpose: Fix valgrind issues with hl/examples/ex_image2 Description: Modified hl/examples/ex_image2 to free global "gbuf" before exit. Tested on: Mac OSX/64 10.9.1 (amaon) w/C++, FORTRAN & Threadsafety (too minor to require h5committest)
Diffstat (limited to 'src/H5HLdbg.c')
-rw-r--r--src/H5HLdbg.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/H5HLdbg.c b/src/H5HLdbg.c
index 29d5c82..4ac22b8 100644
--- a/src/H5HLdbg.c
+++ b/src/H5HLdbg.c
@@ -54,8 +54,8 @@ herr_t
H5HL_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, int fwidth)
{
H5HL_t *h = NULL;
- int i, overlap, free_block;
- H5HL_free_t *freelist = NULL;
+ int free_block;
+ H5HL_free_t *freelist;
uint8_t *marker = NULL;
size_t amount_free = 0;
herr_t ret_value = SUCCEED; /* Return value */
@@ -72,8 +72,8 @@ H5HL_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, int
if(NULL == (h = (H5HL_t *)H5HL_protect(f, dxpl_id, addr, H5AC_READ)))
HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap")
- fprintf(stream, "%*sLocal Heap...\n", indent, "");
- fprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth,
+ HDfprintf(stream, "%*sLocal Heap...\n", indent, "");
+ HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth,
"Header size (in bytes):",
(unsigned long)h->prfx_size);
HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth,
@@ -90,34 +90,36 @@ H5HL_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, int
if(NULL == (marker = (uint8_t *)H5MM_calloc(h->dblk_size)))
HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed")
- fprintf(stream, "%*sFree Blocks (offset, size):\n", indent, "");
-
+ HDfprintf(stream, "%*sFree Blocks (offset, size):\n", indent, "");
for(free_block = 0, freelist = h->freelist; freelist; freelist = freelist->next, free_block++) {
char temp_str[32];
- sprintf(temp_str,"Block #%d:",free_block);
+ HDsnprintf(temp_str, sizeof(temp_str), "Block #%d:", free_block);
HDfprintf(stream, "%*s%-*s %8Zu, %8Zu\n", indent+3, "", MAX(0,fwidth-9),
temp_str,
freelist->offset, freelist->size);
if((freelist->offset + freelist->size) > h->dblk_size)
- fprintf(stream, "***THAT FREE BLOCK IS OUT OF BOUNDS!\n");
+ HDfprintf(stream, "***THAT FREE BLOCK IS OUT OF BOUNDS!\n");
else {
- for(i = overlap = 0; i < (int)(freelist->size); i++) {
+ int overlap = 0;
+ size_t i;
+
+ for(i = 0; i < freelist->size; i++) {
if(marker[freelist->offset + i])
overlap++;
marker[freelist->offset + i] = 1;
} /* end for */
if(overlap)
- fprintf(stream, "***THAT FREE BLOCK OVERLAPPED A PREVIOUS ONE!\n");
+ HDfprintf(stream, "***THAT FREE BLOCK OVERLAPPED A PREVIOUS ONE!\n");
else
amount_free += freelist->size;
} /* end for */
} /* end for */
if(h->dblk_size)
- fprintf(stream, "%*s%-*s %.2f%%\n", indent, "", fwidth,
+ HDfprintf(stream, "%*s%-*s %.2f%%\n", indent, "", fwidth,
"Percent of heap used:",
- (100.0 * (double)(h->dblk_size - amount_free) / (double)h->dblk_size));
+ ((double)100.0f * (double)(h->dblk_size - amount_free) / (double)h->dblk_size));
/*
* Print the data in a VMS-style octal dump.