Skip to content

Commit

Permalink
Fixed uninitialized warnings (#360)
Browse files Browse the repository at this point in the history
* Fixed all -Wsometimes-uninitialized warnings by initializing variables

* Fixed all -Wconditional-uninitialized warnings by initializing variables

* Commit alignment changes from running bin/format_source with clang
version 10.0.1.

Co-authored-by: Larry Knox <[email protected]>
  • Loading branch information
seanm and lrknox authored Feb 19, 2021
1 parent a6f1b6c commit 0a2a385
Show file tree
Hide file tree
Showing 30 changed files with 156 additions and 155 deletions.
108 changes: 54 additions & 54 deletions src/H5B2int.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,15 @@ H5B2__split1(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr,
unsigned *parent_cache_info_flags_ptr, H5B2_internal_t *internal, unsigned *internal_flags_ptr,
unsigned idx)
{
const H5AC_class_t *child_class; /* Pointer to child node's class info */
haddr_t left_addr, right_addr; /* Addresses of left & right child nodes */
void * left_child = NULL, *right_child = NULL; /* Pointers to child nodes */
uint16_t * left_nrec, *right_nrec; /* Pointers to child # of records */
uint8_t * left_native, *right_native; /* Pointers to childs' native records */
H5B2_node_ptr_t * left_node_ptrs = NULL,
*right_node_ptrs = NULL; /* Pointers to childs' node pointer info */
uint16_t mid_record; /* Index of "middle" record in current node */
uint16_t old_node_nrec; /* Number of records in internal node split */
const H5AC_class_t *child_class; /* Pointer to child node's class info */
haddr_t left_addr = HADDR_UNDEF, right_addr = HADDR_UNDEF; /* Addresses of left & right child nodes */
void * left_child = NULL, *right_child = NULL; /* Pointers to child nodes */
uint16_t *left_nrec, *right_nrec; /* Pointers to child # of records */
uint8_t * left_native, *right_native; /* Pointers to childs' native records */
H5B2_node_ptr_t *left_node_ptrs = NULL,
*right_node_ptrs = NULL; /* Pointers to childs' node pointer info */
uint16_t mid_record; /* Index of "middle" record in current node */
uint16_t old_node_nrec; /* Number of records in internal node split */
unsigned left_child_flags = H5AC__NO_FLAGS_SET,
right_child_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting child nodes */
herr_t ret_value = SUCCEED; /* Return value */
Expand Down Expand Up @@ -423,13 +423,13 @@ H5B2__split_root(H5B2_hdr_t *hdr)
herr_t
H5B2__redistribute2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, unsigned idx)
{
const H5AC_class_t *child_class; /* Pointer to child node's class info */
haddr_t left_addr, right_addr; /* Addresses of left & right child nodes */
void * left_child = NULL, *right_child = NULL; /* Pointers to child nodes */
uint16_t * left_nrec, *right_nrec; /* Pointers to child # of records */
uint8_t * left_native, *right_native; /* Pointers to childs' native records */
H5B2_node_ptr_t * left_node_ptrs = NULL,
*right_node_ptrs = NULL; /* Pointers to childs' node pointer info */
const H5AC_class_t *child_class; /* Pointer to child node's class info */
haddr_t left_addr = HADDR_UNDEF, right_addr = HADDR_UNDEF; /* Addresses of left & right child nodes */
void * left_child = NULL, *right_child = NULL; /* Pointers to child nodes */
uint16_t *left_nrec, *right_nrec; /* Pointers to child # of records */
uint8_t * left_native, *right_native; /* Pointers to childs' native records */
H5B2_node_ptr_t *left_node_ptrs = NULL,
*right_node_ptrs = NULL; /* Pointers to childs' node pointer info */
hssize_t left_moved_nrec = 0, right_moved_nrec = 0; /* Number of records moved, for internal redistrib */
unsigned left_child_flags = H5AC__NO_FLAGS_SET,
right_child_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting child nodes */
Expand Down Expand Up @@ -696,20 +696,20 @@ H5B2__redistribute3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal,
unsigned idx)
{
H5B2_node_ptr_t *left_node_ptrs = NULL,
*right_node_ptrs = NULL; /* Pointers to childs' node pointer info */
H5B2_node_ptr_t * middle_node_ptrs = NULL; /* Pointers to childs' node pointer info */
const H5AC_class_t *child_class; /* Pointer to child node's class info */
haddr_t left_addr, right_addr; /* Addresses of left & right child nodes */
haddr_t middle_addr; /* Address of middle child node */
void * left_child = NULL, *right_child = NULL; /* Pointers to child nodes */
void * middle_child = NULL; /* Pointers to middle child node */
uint16_t * left_nrec, *right_nrec; /* Pointers to child # of records */
uint16_t * middle_nrec; /* Pointers to middle child # of records */
uint8_t * left_native, *right_native; /* Pointers to childs' native records */
uint8_t * middle_native; /* Pointers to middle child's native records */
hssize_t left_moved_nrec = 0, right_moved_nrec = 0; /* Number of records moved, for internal split */
hssize_t middle_moved_nrec = 0; /* Number of records moved, for internal split */
unsigned left_child_flags = H5AC__NO_FLAGS_SET,
*right_node_ptrs = NULL; /* Pointers to childs' node pointer info */
H5B2_node_ptr_t * middle_node_ptrs = NULL; /* Pointers to childs' node pointer info */
const H5AC_class_t *child_class; /* Pointer to child node's class info */
haddr_t left_addr = HADDR_UNDEF, right_addr = HADDR_UNDEF; /* Addresses of left & right child nodes */
haddr_t middle_addr = HADDR_UNDEF; /* Address of middle child node */
void * left_child = NULL, *right_child = NULL; /* Pointers to child nodes */
void * middle_child = NULL; /* Pointers to middle child node */
uint16_t *left_nrec, *right_nrec; /* Pointers to child # of records */
uint16_t *middle_nrec; /* Pointers to middle child # of records */
uint8_t * left_native, *right_native; /* Pointers to childs' native records */
uint8_t * middle_native; /* Pointers to middle child's native records */
hssize_t left_moved_nrec = 0, right_moved_nrec = 0; /* Number of records moved, for internal split */
hssize_t middle_moved_nrec = 0; /* Number of records moved, for internal split */
unsigned left_child_flags = H5AC__NO_FLAGS_SET,
right_child_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting child nodes */
unsigned middle_child_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting child nodes */
herr_t ret_value = SUCCEED; /* Return value */
Expand Down Expand Up @@ -1122,16 +1122,16 @@ H5B2__merge2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr,
unsigned *parent_cache_info_flags_ptr, H5B2_internal_t *internal, unsigned *internal_flags_ptr,
unsigned idx)
{
const H5AC_class_t *child_class; /* Pointer to child node's class info */
haddr_t left_addr, right_addr; /* Addresses of left & right child nodes */
void * left_child = NULL, *right_child = NULL; /* Pointers to left & right child nodes */
uint16_t * left_nrec, *right_nrec; /* Pointers to left & right child # of records */
uint8_t * left_native, *right_native; /* Pointers to left & right children's native records */
H5B2_node_ptr_t * left_node_ptrs = NULL,
*right_node_ptrs = NULL; /* Pointers to childs' node pointer info */
unsigned left_child_flags = H5AC__NO_FLAGS_SET,
right_child_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting child nodes */
herr_t ret_value = SUCCEED; /* Return value */
const H5AC_class_t *child_class; /* Pointer to child node's class info */
haddr_t left_addr = HADDR_UNDEF, right_addr = HADDR_UNDEF; /* Addresses of left & right child nodes */
void * left_child = NULL, *right_child = NULL; /* Pointers to left & right child nodes */
uint16_t *left_nrec, *right_nrec; /* Pointers to left & right child # of records */
uint8_t * left_native, *right_native; /* Pointers to left & right children's native records */
H5B2_node_ptr_t *left_node_ptrs = NULL,
*right_node_ptrs = NULL; /* Pointers to childs' node pointer info */
unsigned left_child_flags = H5AC__NO_FLAGS_SET,
right_child_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting child nodes */
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_PACKAGE

Expand Down Expand Up @@ -1297,19 +1297,19 @@ H5B2__merge3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr,
unsigned *parent_cache_info_flags_ptr, H5B2_internal_t *internal, unsigned *internal_flags_ptr,
unsigned idx)
{
const H5AC_class_t *child_class; /* Pointer to child node's class info */
haddr_t left_addr, right_addr; /* Addresses of left & right child nodes */
haddr_t middle_addr; /* Address of middle child node */
void * left_child = NULL, *right_child = NULL; /* Pointers to left & right child nodes */
void * middle_child = NULL; /* Pointer to middle child node */
uint16_t * left_nrec, *right_nrec; /* Pointers to left & right child # of records */
uint16_t * middle_nrec; /* Pointer to middle child # of records */
uint8_t * left_native, *right_native; /* Pointers to left & right children's native records */
uint8_t * middle_native; /* Pointer to middle child's native records */
H5B2_node_ptr_t * left_node_ptrs = NULL,
*right_node_ptrs = NULL; /* Pointers to childs' node pointer info */
H5B2_node_ptr_t *middle_node_ptrs = NULL; /* Pointer to child's node pointer info */
hsize_t middle_moved_nrec; /* Number of records moved, for internal split */
const H5AC_class_t *child_class; /* Pointer to child node's class info */
haddr_t left_addr = HADDR_UNDEF, right_addr = HADDR_UNDEF; /* Addresses of left & right child nodes */
haddr_t middle_addr = HADDR_UNDEF; /* Address of middle child node */
void * left_child = NULL, *right_child = NULL; /* Pointers to left & right child nodes */
void * middle_child = NULL; /* Pointer to middle child node */
uint16_t *left_nrec, *right_nrec; /* Pointers to left & right child # of records */
uint16_t *middle_nrec; /* Pointer to middle child # of records */
uint8_t * left_native, *right_native; /* Pointers to left & right children's native records */
uint8_t * middle_native; /* Pointer to middle child's native records */
H5B2_node_ptr_t *left_node_ptrs = NULL,
*right_node_ptrs = NULL; /* Pointers to childs' node pointer info */
H5B2_node_ptr_t *middle_node_ptrs = NULL; /* Pointer to child's node pointer info */
hsize_t middle_moved_nrec; /* Number of records moved, for internal split */
unsigned left_child_flags = H5AC__NO_FLAGS_SET,
right_child_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting child nodes */
unsigned middle_child_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting child nodes */
Expand Down Expand Up @@ -1933,7 +1933,7 @@ H5B2__update_flush_depend(H5B2_hdr_t *hdr, unsigned depth, const H5B2_node_ptr_t

/* If the node is in the cache, check for retargeting its parent */
if (node_status & H5AC_ES__IN_CACHE) {
void ** parent_ptr; /* Pointer to child node's parent */
void ** parent_ptr = NULL; /* Pointer to child node's parent */
hbool_t update_deps = FALSE; /* Whether to update flush dependencies */

/* Get child node pointer */
Expand Down
10 changes: 5 additions & 5 deletions src/H5B2leaf.c
Original file line number Diff line number Diff line change
Expand Up @@ -607,11 +607,11 @@ herr_t
H5B2__swap_leaf(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, unsigned *internal_flags_ptr,
unsigned idx, void *swap_loc)
{
const H5AC_class_t *child_class; /* Pointer to child node's class info */
haddr_t child_addr; /* Address of child node */
void * child = NULL; /* Pointer to child node */
uint8_t * child_native; /* Pointer to child's native records */
herr_t ret_value = SUCCEED; /* Return value */
const H5AC_class_t *child_class; /* Pointer to child node's class info */
haddr_t child_addr = HADDR_UNDEF; /* Address of child node */
void * child = NULL; /* Pointer to child node */
uint8_t * child_native; /* Pointer to child's native records */
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_PACKAGE

Expand Down
4 changes: 2 additions & 2 deletions src/H5C.c
Original file line number Diff line number Diff line change
Expand Up @@ -2229,8 +2229,8 @@ H5C_protect(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *udata, unsign
#ifdef H5_HAVE_PARALLEL
hbool_t coll_access = FALSE; /* whether access to the cache entry is done collectively */
#endif /* H5_HAVE_PARALLEL */
hbool_t write_permitted;
hbool_t was_loaded = FALSE; /* Whether the entry was loaded as a result of the protect */
hbool_t write_permitted = FALSE;
hbool_t was_loaded = FALSE; /* Whether the entry was loaded as a result of the protect */
size_t empty_space;
void * thing;
H5C_cache_entry_t *entry_ptr;
Expand Down
6 changes: 3 additions & 3 deletions src/H5Dchunk.c
Original file line number Diff line number Diff line change
Expand Up @@ -3151,9 +3151,9 @@ H5D__chunk_hash_val(const H5D_shared_t *shared, const hsize_t *scaled)
herr_t
H5D__chunk_lookup(const H5D_t *dset, const hsize_t *scaled, H5D_chunk_ud_t *udata)
{
H5D_rdcc_ent_t * ent = NULL; /* Cache entry */
H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk);
unsigned idx; /* Index of chunk in cache, if present */
H5D_rdcc_ent_t * ent = NULL; /* Cache entry */
H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk);
unsigned idx = 0; /* Index of chunk in cache, if present */
hbool_t found = FALSE; /* In cache? */
herr_t ret_value = SUCCEED; /* Return value */

Expand Down
4 changes: 2 additions & 2 deletions src/H5Dvirtual.c
Original file line number Diff line number Diff line change
Expand Up @@ -2299,7 +2299,7 @@ H5D__virtual_init(H5F_t *f, const H5D_t *dset, hid_t dapl_id)
hbool_t
H5D__virtual_is_space_alloc(const H5O_storage_t H5_ATTR_UNUSED *storage)
{
hbool_t ret_value; /* Return value */
hbool_t ret_value = FALSE; /* Return value */

FUNC_ENTER_PACKAGE_NOERR

Expand Down Expand Up @@ -2383,7 +2383,7 @@ H5D__virtual_pre_io(H5D_io_info_t *io_info, H5O_storage_virtual_t *storage, cons
hssize_t select_nelmts; /* Number of elements in selection */
hsize_t bounds_start[H5S_MAX_RANK]; /* Selection bounds start */
hsize_t bounds_end[H5S_MAX_RANK]; /* Selection bounds end */
int rank;
int rank = 0;
hbool_t bounds_init = FALSE; /* Whether bounds_start, bounds_end, and rank are valid */
size_t i, j, k; /* Local index variables */
herr_t ret_value = SUCCEED; /* Return value */
Expand Down
3 changes: 2 additions & 1 deletion src/H5EA.c
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,8 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_get(const H5EA_t *ea, hsize_t
/* Local variables */
H5EA_hdr_t *hdr = ea->hdr; /* Header for EA */
void *thing = NULL; /* Pointer to the array metadata containing the array index we are interested in */
H5EA__unprotect_func_t thing_unprot_func; /* Function pointer for unprotecting the array metadata */
H5EA__unprotect_func_t thing_unprot_func =
NULL; /* Function pointer for unprotecting the array metadata */

/*
* Check arguments.
Expand Down
34 changes: 17 additions & 17 deletions src/H5FDlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,8 @@ H5FD__log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr)
#ifdef H5_HAVE_WIN32_API
struct _BY_HANDLE_FILE_INFORMATION fileinfo;
#endif
H5_timer_t open_timer; /* Timer for open() call */
H5_timer_t stat_timer; /* Timer for stat() call */
H5_timer_t open_timer = {{0}, {0}, {0}, FALSE}; /* Timer for open() call */
H5_timer_t stat_timer = {{0}, {0}, {0}, FALSE}; /* Timer for stat() call */
h5_stat_t sb;
H5FD_t * ret_value = NULL; /* Return value */

Expand Down Expand Up @@ -677,9 +677,9 @@ H5FD__log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr)
static herr_t
H5FD__log_close(H5FD_t *_file)
{
H5FD_log_t *file = (H5FD_log_t *)_file;
H5_timer_t close_timer; /* Timer for close() call */
herr_t ret_value = SUCCEED; /* Return value */
H5FD_log_t *file = (H5FD_log_t *)_file;
H5_timer_t close_timer = {{0}, {0}, {0}, FALSE}; /* Timer for close() call */
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_STATIC

Expand Down Expand Up @@ -1174,11 +1174,11 @@ static herr_t
H5FD__log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, size_t size,
void *buf /*out*/)
{
H5FD_log_t * file = (H5FD_log_t *)_file;
size_t orig_size = size; /* Save the original size for later */
haddr_t orig_addr = addr;
H5_timer_t read_timer; /* Timer for read operation */
H5_timevals_t read_times; /* Elapsed time for read operation */
H5FD_log_t * file = (H5FD_log_t *)_file;
size_t orig_size = size; /* Save the original size for later */
haddr_t orig_addr = addr;
H5_timer_t read_timer = {{0}, {0}, {0}, FALSE}; /* Timer for read operation */
H5_timevals_t read_times; /* Elapsed time for read operation */
#ifndef H5_HAVE_PREADWRITE
H5_timer_t seek_timer; /* Timer for seek operation */
H5_timevals_t seek_times; /* Elapsed time for seek operation */
Expand Down Expand Up @@ -1388,11 +1388,11 @@ static herr_t
H5FD__log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, size_t size,
const void *buf)
{
H5FD_log_t * file = (H5FD_log_t *)_file;
size_t orig_size = size; /* Save the original size for later */
haddr_t orig_addr = addr;
H5_timer_t write_timer; /* Timer for write operation */
H5_timevals_t write_times; /* Elapsed time for write operation */
H5FD_log_t * file = (H5FD_log_t *)_file;
size_t orig_size = size; /* Save the original size for later */
haddr_t orig_addr = addr;
H5_timer_t write_timer = {{0}, {0}, {0}, FALSE}; /* Timer for write operation */
H5_timevals_t write_times; /* Elapsed time for write operation */
#ifndef H5_HAVE_PREADWRITE
H5_timer_t seek_timer; /* Timer for seek operation */
H5_timevals_t seek_times; /* Elapsed time for seek operation */
Expand Down Expand Up @@ -1612,8 +1612,8 @@ H5FD__log_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_

/* Extend the file to make sure it's large enough */
if (!H5F_addr_eq(file->eoa, file->eof)) {
H5_timer_t trunc_timer; /* Timer for truncate operation */
H5_timevals_t trunc_times; /* Elapsed time for truncate operation */
H5_timer_t trunc_timer = {{0}, {0}, {0}, FALSE}; /* Timer for truncate operation */
H5_timevals_t trunc_times; /* Elapsed time for truncate operation */

/* Start timer for truncate operation */
if (file->fa.flags & H5FD_LOG_TIME_TRUNCATE) {
Expand Down
Loading

0 comments on commit 0a2a385

Please sign in to comment.