Skip to content

Commit

Permalink
Revert "build HDF5 with C89"
Browse files Browse the repository at this point in the history
This reverts commit 680e599.
  • Loading branch information
JDanielSmith committed Dec 22, 2022
1 parent 680e599 commit 5a42864
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 54 deletions.
3 changes: 1 addition & 2 deletions modules/drivers/hdf5/source/H5.c
Original file line number Diff line number Diff line change
Expand Up @@ -1026,8 +1026,7 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum)
/* H5_VERS_RELEASE should be compatible, we will only add checks for exceptions */
/* Library develop release versions are incompatible by design */
if (H5_VERS_RELEASE != relnum) {
unsigned i = 0;
for (i = 0; i < VERS_RELEASE_EXCEPTIONS_SIZE; i++) {
for (unsigned i = 0; i < VERS_RELEASE_EXCEPTIONS_SIZE; i++) {
/* Check for incompatible headers or incompatible library */
if (VERS_RELEASE_EXCEPTIONS[i] == relnum || VERS_RELEASE_EXCEPTIONS[i] == H5_VERS_RELEASE) {
switch (disable_version_check) {
Expand Down
8 changes: 3 additions & 5 deletions modules/drivers/hdf5/source/H5Cimage.c
Original file line number Diff line number Diff line change
Expand Up @@ -2860,11 +2860,10 @@ H5C__prep_for_file_close__scan_entries(const H5F_t *f, H5C_t *cache_ptr)
HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL,
"memory allocation failed for fd parent addrs buffer")

{ int i = 0;
for (i = 0; i < (int)(entry_ptr->fd_parent_count); i++) {
for (int i = 0; i < (int)(entry_ptr->fd_parent_count); i++) {
entry_ptr->fd_parent_addrs[i] = entry_ptr->flush_dep_parent[i]->addr;
HDassert(H5F_addr_defined(entry_ptr->fd_parent_addrs[i]));
} /* end for */ }
} /* end for */
} /* end if */
else if (entry_ptr->fd_parent_count > 0) {
HDassert(entry_ptr->fd_parent_addrs);
Expand Down Expand Up @@ -2946,9 +2945,8 @@ H5C__prep_for_file_close__scan_entries(const H5F_t *f, H5C_t *cache_ptr)
HDassert(num_entries_in_image <= num_entries_tentatively_in_image);

#ifndef NDEBUG
int i = H5C_MAX_RING_IN_IMAGE + 1;
unsigned j = 0;
for (i = H5C_MAX_RING_IN_IMAGE + 1; i <= H5C_RING_SB; i++)
for (int i = H5C_MAX_RING_IN_IMAGE + 1; i <= H5C_RING_SB; i++)
j += cache_ptr->index_ring_len[i];

/* This will change */
Expand Down
15 changes: 5 additions & 10 deletions modules/drivers/hdf5/source/H5FDonion.c
Original file line number Diff line number Diff line change
Expand Up @@ -1370,8 +1370,7 @@ H5FD__onion_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, h
n_pages = (len + page_size - 1) >> page_size_log2;

/* Read, page-by-page */
size_t i = 0;
for (i = 0; i < n_pages; i++) {
for (size_t i = 0; i < n_pages; i++) {
const H5FD_onion_index_entry_t *entry_out = NULL;
haddr_t page_gap_head = 0; /* start of page to start of buffer */
haddr_t page_gap_tail = 0; /* end of buffer to end of page */
Expand Down Expand Up @@ -1422,8 +1421,7 @@ H5FD__onion_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, h
/* Fill with 0s any gaps after end of original bytes
* and before end of page.
*/
size_t j = read_size;
for (j = read_size; j < page_readsize; j++)
for (size_t j = read_size; j < page_readsize; j++)
buf_out[j] = 0;
}

Expand Down Expand Up @@ -1497,13 +1495,11 @@ H5FD__onion_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id,
page_0 = offset >> page_size_log2;
n_pages = (len + page_size - 1) >> page_size_log2;


size_t i = 0;
if (NULL == (page_buf = H5MM_calloc(page_size * sizeof(unsigned char))))
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "cannot allocate temporary buffer")

/* Write, page-by-page */
for (i = 0; i < n_pages; i++) {
for (size_t i = 0; i < n_pages; i++) {
const unsigned char *write_buf = buf;
H5FD_onion_index_entry_t new_entry;
const H5FD_onion_index_entry_t *entry_out = NULL;
Expand Down Expand Up @@ -1570,14 +1566,13 @@ H5FD__onion_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id,
/* Fill with 0s any gaps after end of original bytes
* or start of page and before start of new data.
*/
size_t j;
for (j = read_size; j < page_gap_head; j++)
for (size_t j = read_size; j < page_gap_head; j++)
page_buf[j] = 0;

/* Fill with 0s any gaps after end of original bytes
* or end of new data and before end of page.
*/
for (j = MAX(read_size, page_size - page_gap_tail); j < page_size; j++)
for (size_t j = MAX(read_size, page_size - page_gap_tail); j < page_size; j++)
page_buf[j] = 0;
} /* end if page exists in neither index */

Expand Down
6 changes: 2 additions & 4 deletions modules/drivers/hdf5/source/H5FDonion_history.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,7 @@ H5FD__onion_history_decode(unsigned char *buf, H5FD_onion_history_t *history)
if (NULL == history->record_locs)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "list is NULL -- cannot populate")

uint64_t i = 0;
for (i = 0; i < n_revisions; i++) {
for (uint64_t i = 0; i < n_revisions; i++) {
H5FD_onion_record_loc_t *rloc = &history->record_locs[i];

/* Decode into appropriately sized types, then do a checked
Expand Down Expand Up @@ -281,8 +280,7 @@ H5FD__onion_history_encode(H5FD_onion_history_t *history, unsigned char *buf, ui
UINT64ENCODE(ptr, history->n_revisions);
if (history->n_revisions > 0) {
HDassert(history->record_locs != NULL);
uint64_t i = 0;
for (i = 0; i < history->n_revisions; i++) {
for (uint64_t i = 0; i < history->n_revisions; i++) {
H5FD_onion_record_loc_t *rloc = &history->record_locs[i];

/* Do a checked assignment from the struct value into appropriately
Expand Down
20 changes: 7 additions & 13 deletions modules/drivers/hdf5/source/H5FDonion_index.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,8 @@ H5FD__onion_archival_index_is_valid(const H5FD_onion_archival_index_t *aix)
HGOTO_DONE(FALSE)

/* Ensure list is sorted on logical_page field */
uint64_t i = 1;
if (aix->n_entries > 1)
for (i = 1; i < aix->n_entries - 1; i++)
for (uint64_t i = 1; i < aix->n_entries - 1; i++)
if (aix->list[i + 1].logical_page <= aix->list[i].logical_page)
HGOTO_DONE(FALSE)

Expand Down Expand Up @@ -297,8 +296,7 @@ H5FD__onion_revision_index_destroy(H5FD_onion_revision_index_t *rix)
HDassert(rix);
HDassert(H5FD_ONION_REVISION_INDEX_VERSION_CURR == rix->version);

size_t i = 0;
for (i = 0; 0 < rix->_hash_table_n_keys_populated && i < rix->_hash_table_size; i++) {
for (size_t i = 0; 0 < rix->_hash_table_n_keys_populated && i < rix->_hash_table_size; i++) {
H5FD_onion_revision_index_hash_chain_node_t *next = NULL;
H5FD_onion_revision_index_hash_chain_node_t *node = rix->_hash_table[i];

Expand Down Expand Up @@ -397,11 +395,10 @@ H5FD__onion_revision_index_resize(H5FD_onion_revision_index_t *rix)
HDassert(H5FD_ONION_REVISION_INDEX_VERSION_CURR == rix->version);
HDassert(rix->_hash_table);

uint64_t i = 0;
if (NULL == (new_table = H5MM_calloc(new_size * sizeof(H5FD_onion_revision_index_hash_chain_node_t *))))
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "cannot allocate new hash table")

for (i = 0; i < rix->_hash_table_size; i++) {
for (uint64_t i = 0; i < rix->_hash_table_size; i++) {
while (rix->_hash_table[i] != NULL) {
H5FD_onion_revision_index_hash_chain_node_t *node = NULL;
uint64_t key = 0;
Expand Down Expand Up @@ -667,11 +664,10 @@ H5FD__onion_revision_record_decode(unsigned char *buf, H5FD_onion_revision_recor
else {
H5FD_onion_index_entry_t *entry = NULL;

size_t i = 0;
if (record->archival_index.list == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "no archival index entry list")

for (i = 0; i < n_entries; i++) {
for (size_t i = 0; i < n_entries; i++) {
entry = &record->archival_index.list[i];

HDmemcpy(&ui64, ptr, 8);
Expand Down Expand Up @@ -784,8 +780,7 @@ H5FD__onion_revision_record_encode(H5FD_onion_revision_record_t *record, unsigne
uint64_t page_size_log2 = record->archival_index.page_size_log2;

HDassert(record->archival_index.list != NULL);
uint64_t i = 0;
for (i = 0; i < record->archival_index.n_entries; i++) {
for (uint64_t i = 0; i < record->archival_index.n_entries; i++) {
uint32_t sum = 0;
H5FD_onion_index_entry_t *entry = NULL;
uint64_t logi_addr = 0;
Expand Down Expand Up @@ -873,11 +868,10 @@ H5FD__onion_merge_revision_index_into_archival_index(const H5FD_onion_revision_i
/* Add all revision index entries to new archival list */
new_aix.page_size_log2 = aix->page_size_log2;

uint64_t i = 0;
if (NULL == (new_aix.list = H5MM_calloc(rix->n_entries * sizeof(H5FD_onion_index_entry_t))))
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to allocate new archival index list")

for (i = 0; i < rix->_hash_table_size; i++) {
for (uint64_t i = 0; i < rix->_hash_table_size; i++) {
const H5FD_onion_revision_index_hash_chain_node_t *node = NULL;

for (node = rix->_hash_table[i]; node != NULL; node = node->next) {
Expand All @@ -901,7 +895,7 @@ H5FD__onion_merge_revision_index_into_archival_index(const H5FD_onion_revision_i
if (NULL == (kept_list = H5MM_calloc(aix->n_entries * sizeof(H5FD_onion_index_entry_t))))
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to allocate larger archival index list")

for (i = 0; i < aix->n_entries; i++) {
for (uint64_t i = 0; i < aix->n_entries; i++) {
const H5FD_onion_index_entry_t *entry = NULL;

/* Add only if page not already added from revision index */
Expand Down
6 changes: 2 additions & 4 deletions modules/drivers/hdf5/source/H5Fio.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,7 @@ H5F_shared_vector_read(H5F_shared_t *f_sh, uint32_t count, H5FD_mem_t types[], h
* for now, assume the caller has done this already.
*/
#ifndef NDEBUG
uint32_t i = 0;
for (i = 0; i < count; i++)
for (uint32_t i = 0; i < count; i++)
HDassert(types[i] != H5FD_MEM_GHEAP);
#endif

Expand Down Expand Up @@ -395,8 +394,7 @@ H5F_shared_vector_write(H5F_shared_t *f_sh, uint32_t count, H5FD_mem_t types[],
* for now, assume the caller has done this already.
*/
#ifndef NDEBUG
uint32_t i = 0;
for (i = 0; i < count; i++)
for (uint32_t i = 0; i < count; i++)
HDassert(types[i] != H5FD_MEM_GHEAP);
#endif

Expand Down
6 changes: 2 additions & 4 deletions modules/drivers/hdf5/source/H5Opline.c
Original file line number Diff line number Diff line change
Expand Up @@ -653,8 +653,7 @@ H5O__pline_debug(H5F_t H5_ATTR_UNUSED *f, const void *mesg, FILE *stream, int in
pline->nalloc);

/* Loop over all the filters */
size_t i = 0;
for (i = 0; i < pline->nused; i++) {
for (size_t i = 0; i < pline->nused; i++) {
/* 19 characters for text + 20 characters for largest 64-bit size_t +
* terminal NUL = 40 characters.
*/
Expand All @@ -677,8 +676,7 @@ H5O__pline_debug(H5F_t H5_ATTR_UNUSED *f, const void *mesg, FILE *stream, int in
"Num CD values:", pline->filter[i].cd_nelmts);

/* Filter parameters */
size_t j = 0;
for (j = 0; j < pline->filter[i].cd_nelmts; j++) {
for (size_t j = 0; j < pline->filter[i].cd_nelmts; j++) {
char field_name[32];

HDsnprintf(field_name, sizeof(field_name), "CD value %lu", (unsigned long)j);
Expand Down
24 changes: 12 additions & 12 deletions modules/drivers/hdf5/source/H5lib_settings.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// This file is generated as part of the build process.
// It isn't necessary different for each compiler, but that's
// probably a slightly better discriminant than OS/platform.

// These have a ".c_" extention so the normal build process won't find them.
#if defined(_MSC_VER)
#include "H5lib_settings_MSVC.c_"
#elif defined(__GNUC__)
#include "H5lib_settings_GCC.c_"
#else
#error "Unknown compiler."
#endif
// This file is generated as part of the build process.
// It isn't necessary different for each compiler, but that's
// probably a slightly better discriminant than OS/platform.

// These have a ".c_" extention so the normal build process won't find them.
#if defined(_MSC_VER)
#include "H5lib_settings_MSVC.c_"
#elif defined(__GNUC__)
#include "H5lib_settings_GCC.c_"
#else
#error "Unknown compiler."
#endif

0 comments on commit 5a42864

Please sign in to comment.