From 54c202e4ec4bc9c7e45543cea5b51868a091b3e9 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 5 May 2021 12:52:43 -0700 Subject: Normalization with develop (mainly VFDs) --- MANIFEST | 1 + src/CMakeLists.txt | 1 + src/H5Defl.c | 5 +- src/H5FA.c | 3 +- src/H5FAcache.c | 22 +- src/H5FAhdr.c | 4 +- src/H5FAint.c | 2 +- src/H5FAstat.c | 6 +- src/H5FD.c | 4 +- src/H5FDdirect.c | 273 ++++++------- src/H5FDfamily.c | 519 ++++++++++++------------ src/H5FDlog.c | 474 +++++++++++----------- src/H5FDmirror.c | 886 +++++++++++++++++++++------------------- src/H5FDmirror.h | 291 +------------- src/H5FDmirror_priv.h | 317 +++++++++++++++ src/H5FDmulti.c | 778 ++++++++++++++++++----------------- src/H5FDros3.c | 597 ++++++++++----------------- src/H5FDs3comms.c | 1067 ++++++++++++++++++------------------------------- src/H5FDsec2.c | 221 +++++----- src/H5FDspace.c | 14 +- src/H5FDsplitter.c | 766 +++++++++++++++-------------------- src/H5FDstdio.c | 110 ++--- src/H5FL.c | 2 +- src/H5FS.c | 11 +- src/H5FScache.c | 12 +- src/H5FSdbg.c | 2 +- src/H5FSint.c | 2 +- src/H5FSsection.c | 156 +------- src/H5HFspace.c | 19 +- src/H5HFstat.c | 2 +- src/H5HFtest.c | 8 +- src/H5HFtiny.c | 12 +- src/H5HG.c | 2 +- src/H5HGcache.c | 4 +- src/H5HGdbg.c | 3 +- src/H5HGquery.c | 2 +- src/H5HL.c | 8 +- src/H5HLcache.c | 10 +- src/H5HLdbg.c | 2 +- src/H5HLdblk.c | 2 +- src/H5HLint.c | 2 +- src/H5HLprfx.c | 2 +- src/H5HP.c | 72 ++-- src/H5M.c | 4 +- src/H5MM.c | 17 +- src/H5MMpublic.h | 5 + src/H5MP.c | 30 +- src/H5MPtest.c | 20 +- src/H5VM.c | 39 +- src/H5WB.c | 6 +- 50 files changed, 3062 insertions(+), 3755 deletions(-) create mode 100644 src/H5FDmirror_priv.h diff --git a/MANIFEST b/MANIFEST index da0f66c..52be873 100644 --- a/MANIFEST +++ b/MANIFEST @@ -793,6 +793,7 @@ ./src/H5FDlog.h ./src/H5FDmirror.c ./src/H5FDmirror.h +./src/H5FDmirror_priv.h ./src/H5FDmodule.h ./src/H5FDmpi.c ./src/H5FDmpi.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a364452..2c9b760 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -891,6 +891,7 @@ set (H5_PRIVATE_HEADERS ${HDF5_SRC_DIR}/H5FApkg.h ${HDF5_SRC_DIR}/H5FAprivate.h + ${HDF5_SRC_DIR}/H5FDmirror_priv.h ${HDF5_SRC_DIR}/H5FDpkg.h ${HDF5_SRC_DIR}/H5FDprivate.h ${HDF5_SRC_DIR}/H5FDvfd_swmr_private.h diff --git a/src/H5Defl.c b/src/H5Defl.c index 2ad09ba..85c9dba 100644 --- a/src/H5Defl.c +++ b/src/H5Defl.c @@ -12,7 +12,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Thursday, September 30, 2004 */ @@ -310,9 +310,6 @@ done: * Programmer: Robb Matzke * Wednesday, March 4, 1998 * - * Modifications: - * Robb Matzke, 1999-07-28 - * The ADDR argument is passed by value. *------------------------------------------------------------------------- */ static herr_t diff --git a/src/H5FA.c b/src/H5FA.c index e4da82c..05b0bd8 100644 --- a/src/H5FA.c +++ b/src/H5FA.c @@ -15,7 +15,7 @@ * * Created: H5FA.c * April 2009 - * Vailin Choi + * Vailin Choi * * Purpose: Implements a Fixed Array for storing elements * of datasets with fixed dimensions. @@ -101,7 +101,6 @@ H5FL_BLK_DEFINE(fa_native_elmt); * NULL on failure * * Programmer: Quincey Koziol - * koziol@lbl.gov * Oct 17 2016 * *------------------------------------------------------------------------- diff --git a/src/H5FAcache.c b/src/H5FAcache.c index cdfbd46..171f4e8 100644 --- a/src/H5FAcache.c +++ b/src/H5FAcache.c @@ -15,7 +15,7 @@ * * Created: H5FAcache.c * Jul 2 2009 - * Quincey Koziol + * Quincey Koziol * * Purpose: Implement fixed array metadata cache methods. * @@ -166,7 +166,6 @@ const H5AC_class_t H5AC_FARRAY_DBLK_PAGE[1] = {{ * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * July 31, 2013 * *------------------------------------------------------------------------- @@ -228,7 +227,6 @@ END_FUNC(STATIC) /* end H5FA__cache_hdr_verify_chksum() */ * Failure: NULL * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * August 12, 2013 * *------------------------------------------------------------------------- @@ -257,7 +255,7 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, hdr->addr = udata->addr; /* Magic number */ - if (HDmemcmp(image, H5FA_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + if (HDmemcmp(image, H5FA_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) H5E_THROW(H5E_BADVALUE, "wrong fixed array header signature") image += H5_SIZEOF_MAGIC; @@ -339,7 +337,6 @@ END_FUNC(STATIC) /* end H5FA__cache_hdr_deserialize() */ * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * August 12, 2013 * *------------------------------------------------------------------------- @@ -367,7 +364,6 @@ END_FUNC(STATIC) /* end H5FA__cache_hdr_image_len() */ * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * August 12, 2013 * *------------------------------------------------------------------------- @@ -506,7 +502,6 @@ END_FUNC(STATIC) /* end H5FA__cache_hdr_notify() */ * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * August 12, 2013 * *------------------------------------------------------------------------- @@ -532,7 +527,6 @@ END_FUNC(STATIC) /* end H5FA__cache_hdr_free_icr() */ * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * August 12, 2013 * *------------------------------------------------------------------------- @@ -616,7 +610,6 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_verify_chksum() */ * Failure: NULL * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * August 14, 2013 * *------------------------------------------------------------------------- @@ -647,7 +640,7 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, dblock->addr = udata->dblk_addr; /* Magic number */ - if (HDmemcmp(image, H5FA_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + if (HDmemcmp(image, H5FA_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) H5E_THROW(H5E_BADVALUE, "wrong fixed array data block signature") image += H5_SIZEOF_MAGIC; @@ -715,7 +708,6 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_deserialize() */ * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * August 14, 2013 * *------------------------------------------------------------------------- @@ -746,7 +738,6 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_image_len() */ * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * August 14, 2013 * *------------------------------------------------------------------------- @@ -893,7 +884,6 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_notify() */ * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * August 14, 2013 * *------------------------------------------------------------------------- @@ -965,7 +955,6 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_fsf_size() */ * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * August 14, 2013 * *------------------------------------------------------------------------- @@ -1028,7 +1017,6 @@ END_FUNC(STATIC) /* end H5FA__cache_dblk_page_verify_chksum() */ * Failure: NULL * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * August 14, 2013 * *------------------------------------------------------------------------- @@ -1100,7 +1088,6 @@ END_FUNC(STATIC) /* end H5FA__cache_dblk_page_deserialize() */ * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * August 14, 2013 * *------------------------------------------------------------------------- @@ -1128,7 +1115,6 @@ END_FUNC(STATIC) /* end H5FA__cache_dblk_page_image_len() */ * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * August 14, 2013 * *------------------------------------------------------------------------- @@ -1179,7 +1165,6 @@ END_FUNC(STATIC) /* end H5FA__cache_dblk_page_serialize() */ * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@lbl.gov * Oct 17 2016 * *------------------------------------------------------------------------- @@ -1241,7 +1226,6 @@ END_FUNC(STATIC) /* end H5FA__cache_dblk_page_notify() */ * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * August 14, 2013 * *------------------------------------------------------------------------- diff --git a/src/H5FAhdr.c b/src/H5FAhdr.c index 3ff5e59..867160f 100644 --- a/src/H5FAhdr.c +++ b/src/H5FAhdr.c @@ -382,7 +382,6 @@ END_FUNC(PKG) /* end H5FA__hdr_modified() */ * Return: Non-NULL pointer to header on success/NULL on failure * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Aug 12 2013 * *------------------------------------------------------------------------- @@ -438,7 +437,6 @@ END_FUNC(PKG) /* end H5FA__hdr_protect() */ * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Aug 12 2013 * *------------------------------------------------------------------------- @@ -457,7 +455,7 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_unprotect(H5FA_hdr_t *hdr, CATCH -END_FUNC(PKG) /* end H5EA__hdr_unprotect() */ +END_FUNC(PKG) /* end H5FA__hdr_unprotect() */ /*------------------------------------------------------------------------- * Function: H5FA__hdr_delete diff --git a/src/H5FAint.c b/src/H5FAint.c index 8f40e32..864c7ee 100644 --- a/src/H5FAint.c +++ b/src/H5FAint.c @@ -15,7 +15,7 @@ * * Created: H5FAint.c * Fall 2012 - * Dana Robinson + * Dana Robinson * * Purpose: Internal routines for fixed arrays. * diff --git a/src/H5FAstat.c b/src/H5FAstat.c index a5b9cac..1fdf47f 100644 --- a/src/H5FAstat.c +++ b/src/H5FAstat.c @@ -33,9 +33,9 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FApkg.h" /* Fixed Arrays */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FApkg.h" /* Fixed Arrays */ #include "H5MMprivate.h" /* Memory management */ /****************/ diff --git a/src/H5FD.c b/src/H5FD.c index a802cc6..ef443ac 100644 --- a/src/H5FD.c +++ b/src/H5FD.c @@ -769,8 +769,8 @@ finish: H5FD_t * H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { - H5FD_class_t * driver; /* VFD for file */ - H5FD_t * file; + H5FD_class_t * driver; /* VFD for file */ + H5FD_t * file = NULL; /* VFD file struct */ H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */ H5P_genplist_t * plist; /* Property list pointer */ unsigned long driver_flags = 0; /* File-inspecific driver feature flags */ diff --git a/src/H5FDdirect.c b/src/H5FDdirect.c index 1233799..54704cf 100644 --- a/src/H5FDdirect.c +++ b/src/H5FDdirect.c @@ -22,15 +22,15 @@ #include "H5FDdrvr_module.h" /* This source code file is part of the H5FD driver module */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FDdirect.h" /* Direct file driver */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDdirect.h" /* Direct file driver */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ #ifdef H5_HAVE_DIRECT @@ -119,59 +119,59 @@ typedef struct H5FD_direct_t { (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || HADDR_UNDEF == (A) + (Z) || (HDoff_t)((A) + (Z)) < (HDoff_t)(A)) /* Prototypes */ -static herr_t H5FD_direct_term(void); -static void * H5FD_direct_fapl_get(H5FD_t *file); -static void * H5FD_direct_fapl_copy(const void *_old_fa); -static H5FD_t *H5FD_direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); -static herr_t H5FD_direct_close(H5FD_t *_file); -static int H5FD_direct_cmp(const H5FD_t *_f1, const H5FD_t *_f2); -static herr_t H5FD_direct_query(const H5FD_t *_f1, unsigned long *flags); -static haddr_t H5FD_direct_get_eoa(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD_direct_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); -static haddr_t H5FD_direct_get_eof(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD_direct_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle); -static herr_t H5FD_direct_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, - void *buf); -static herr_t H5FD_direct_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, - const void *buf); -static herr_t H5FD_direct_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); -static herr_t H5FD_direct_lock(H5FD_t *_file, hbool_t rw); -static herr_t H5FD_direct_unlock(H5FD_t *_file); +static herr_t H5FD__direct_term(void); +static void * H5FD__direct_fapl_get(H5FD_t *file); +static void * H5FD__direct_fapl_copy(const void *_old_fa); +static H5FD_t *H5FD__direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); +static herr_t H5FD__direct_close(H5FD_t *_file); +static int H5FD__direct_cmp(const H5FD_t *_f1, const H5FD_t *_f2); +static herr_t H5FD__direct_query(const H5FD_t *_f1, unsigned long *flags); +static haddr_t H5FD__direct_get_eoa(const H5FD_t *_file, H5FD_mem_t type); +static herr_t H5FD__direct_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); +static haddr_t H5FD__direct_get_eof(const H5FD_t *_file, H5FD_mem_t type); +static herr_t H5FD__direct_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle); +static herr_t H5FD__direct_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + void *buf); +static herr_t H5FD__direct_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + const void *buf); +static herr_t H5FD__direct_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); +static herr_t H5FD__direct_lock(H5FD_t *_file, hbool_t rw); +static herr_t H5FD__direct_unlock(H5FD_t *_file); static const H5FD_class_t H5FD_direct_g = { - "direct", /*name */ - MAXADDR, /*maxaddr */ - H5F_CLOSE_WEAK, /* fc_degree */ - H5FD_direct_term, /*terminate */ - NULL, /*sb_size */ - NULL, /*sb_encode */ - NULL, /*sb_decode */ - sizeof(H5FD_direct_fapl_t), /*fapl_size */ - H5FD_direct_fapl_get, /*fapl_get */ - H5FD_direct_fapl_copy, /*fapl_copy */ - NULL, /*fapl_free */ - 0, /*dxpl_size */ - NULL, /*dxpl_copy */ - NULL, /*dxpl_free */ - H5FD_direct_open, /*open */ - H5FD_direct_close, /*close */ - H5FD_direct_cmp, /*cmp */ - H5FD_direct_query, /*query */ - NULL, /*get_type_map */ - NULL, /*alloc */ - NULL, /*free */ - H5FD_direct_get_eoa, /*get_eoa */ - H5FD_direct_set_eoa, /*set_eoa */ - H5FD_direct_get_eof, /*get_eof */ - H5FD_direct_get_handle, /*get_handle */ - H5FD_direct_read, /*read */ - H5FD_direct_write, /*write */ - NULL, /*flush */ - H5FD_direct_truncate, /*truncate */ - H5FD_direct_lock, /*lock */ - H5FD_direct_unlock, /*unlock */ + "direct", /* name */ + MAXADDR, /* maxaddr */ + H5F_CLOSE_WEAK, /* fc_degree */ + H5FD__direct_term, /* terminate */ + NULL, /* sb_size */ + NULL, /* sb_encode */ + NULL, /* sb_decode */ + sizeof(H5FD_direct_fapl_t), /* fapl_size */ + H5FD__direct_fapl_get, /* fapl_get */ + H5FD__direct_fapl_copy, /* fapl_copy */ + NULL, /* fapl_free */ + 0, /* dxpl_size */ + NULL, /* dxpl_copy */ + NULL, /* dxpl_free */ + H5FD__direct_open, /* open */ + H5FD__direct_close, /* close */ + H5FD__direct_cmp, /* cmp */ + H5FD__direct_query, /* query */ + NULL, /* get_type_map */ + NULL, /* alloc */ + NULL, /* free */ + H5FD__direct_get_eoa, /* get_eoa */ + H5FD__direct_set_eoa, /* set_eoa */ + H5FD__direct_get_eof, /* get_eof */ + H5FD__direct_get_handle, /* get_handle */ + H5FD__direct_read, /* read */ + H5FD__direct_write, /* write */ + NULL, /* flush */ + H5FD__direct_truncate, /* truncate */ + H5FD__direct_lock, /* lock */ + H5FD__direct_unlock, /* unlock */ NULL, /* dedup */ - H5FD_FLMAP_DICHOTOMY /*fl_map */ + H5FD_FLMAP_DICHOTOMY /* fl_map */ }; /* Declare a free list to manage the H5FD_direct_t struct */ @@ -245,7 +245,7 @@ done: } /* end H5FD_direct_init() */ /*--------------------------------------------------------------------------- - * Function: H5FD_direct_term + * Function: H5FD__direct_term * * Purpose: Shut down the VFD * @@ -257,15 +257,15 @@ done: *--------------------------------------------------------------------------- */ static herr_t -H5FD_direct_term(void) +H5FD__direct_term(void) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Reset VFL ID */ H5FD_DIRECT_g = 0; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5FD_direct_term() */ +} /* end H5FD__direct_term() */ /*------------------------------------------------------------------------- * Function: H5Pset_fapl_direct @@ -365,7 +365,7 @@ done: } /* end H5Pget_fapl_direct() */ /*------------------------------------------------------------------------- - * Function: H5FD_direct_fapl_get + * Function: H5FD__direct_fapl_get * * Purpose: Returns a file access property list which indicates how the * specified file is being accessed. The return list could be @@ -379,27 +379,24 @@ done: * Programmer: Raymond Lu * Wednesday, 18 October 2006 * - * Modifications: - * *------------------------------------------------------------------------- */ static void * -H5FD_direct_fapl_get(H5FD_t *_file) +H5FD__direct_fapl_get(H5FD_t *_file) { - H5FD_direct_t *file = (H5FD_direct_t *)_file; - void * ret_value; /* Return value */ + H5FD_direct_t *file = (H5FD_direct_t *)_file; + void * ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC_NOERR /* Set return value */ - ret_value = H5FD_direct_fapl_copy(&(file->fa)); + ret_value = H5FD__direct_fapl_copy(&(file->fa)); -done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_direct_fapl_get() */ +} /* end H5FD__direct_fapl_get() */ /*------------------------------------------------------------------------- - * Function: H5FD_direct_fapl_copy + * Function: H5FD__direct_fapl_copy * * Purpose: Copies the direct-specific file access properties. * @@ -410,17 +407,15 @@ done: * Programmer: Raymond Lu * Wednesday, 18 October 2006 * - * Modifications: - * *------------------------------------------------------------------------- */ static void * -H5FD_direct_fapl_copy(const void *_old_fa) +H5FD__direct_fapl_copy(const void *_old_fa) { const H5FD_direct_fapl_t *old_fa = (const H5FD_direct_fapl_t *)_old_fa; H5FD_direct_fapl_t * new_fa = H5MM_calloc(sizeof(H5FD_direct_fapl_t)); - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDassert(new_fa); @@ -428,10 +423,10 @@ H5FD_direct_fapl_copy(const void *_old_fa) H5MM_memcpy(new_fa, old_fa, sizeof(H5FD_direct_fapl_t)); FUNC_LEAVE_NOAPI(new_fa) -} /* end H5FD_direct_fapl_copy() */ +} /* end H5FD__direct_fapl_copy() */ /*------------------------------------------------------------------------- - * Function: H5FD_direct_open + * Function: H5FD__direct_open * * Purpose: Create and/or opens a Unix file for direct I/O as an HDF5 file. * @@ -444,17 +439,15 @@ H5FD_direct_fapl_copy(const void *_old_fa) * Programmer: Raymond Lu * Wednesday, 20 September 2006 * - * Modifications: - * *------------------------------------------------------------------------- */ static H5FD_t * -H5FD_direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) +H5FD__direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { - int o_flags; - int fd = (-1); - H5FD_direct_t * file = NULL; - H5FD_direct_fapl_t *fa; + int o_flags; + int fd = (-1); + H5FD_direct_t * file = NULL; + const H5FD_direct_fapl_t *fa; #ifdef H5_HAVE_WIN32_API HFILE filehandle; struct _BY_HANDLE_FILE_INFORMATION fileinfo; @@ -464,7 +457,7 @@ H5FD_direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxadd void * buf1, *buf2; H5FD_t * ret_value = NULL; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Sanity check on file offsets */ HDassert(sizeof(HDoff_t) >= sizeof(size_t)); @@ -596,7 +589,7 @@ done: } /*------------------------------------------------------------------------- - * Function: H5FD_direct_close + * Function: H5FD__direct_close * * Purpose: Closes the file. * @@ -607,17 +600,15 @@ done: * Programmer: Raymond Lu * Wednesday, 20 September 2006 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t -H5FD_direct_close(H5FD_t *_file) +H5FD__direct_close(H5FD_t *_file) { H5FD_direct_t *file = (H5FD_direct_t *)_file; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC if (HDclose(file->fd) < 0) HSYS_GOTO_ERROR(H5E_IO, H5E_CANTCLOSEFILE, FAIL, "unable to close file") @@ -629,7 +620,7 @@ done: } /*------------------------------------------------------------------------- - * Function: H5FD_direct_cmp + * Function: H5FD__direct_cmp * * Purpose: Compares two files belonging to this driver using an * arbitrary (but consistent) ordering. @@ -642,18 +633,16 @@ done: * Programmer: Raymond Lu * Thursday, 21 September 2006 * - * Modifications: - * *------------------------------------------------------------------------- */ static int -H5FD_direct_cmp(const H5FD_t *_f1, const H5FD_t *_f2) +H5FD__direct_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { const H5FD_direct_t *f1 = (const H5FD_direct_t *)_f1; const H5FD_direct_t *f2 = (const H5FD_direct_t *)_f2; int ret_value = 0; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR #ifdef H5_HAVE_WIN32_API if (f1->fileindexhi < f2->fileindexhi) @@ -695,7 +684,7 @@ done: } /*------------------------------------------------------------------------- - * Function: H5FD_direct_query + * Function: H5FD__direct_query * * Purpose: Set the flags that this VFL driver is capable of supporting. * (listed in H5FDpublic.h) @@ -707,14 +696,12 @@ done: * Programmer: Raymond Lu * Thursday, 21 September 2006 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t -H5FD_direct_query(const H5FD_t H5_ATTR_UNUSED *_f, unsigned long *flags /* out */) +H5FD__direct_query(const H5FD_t H5_ATTR_UNUSED *_f, unsigned long *flags /* out */) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Set the VFL feature flags that this driver supports */ if (flags) { @@ -731,7 +718,7 @@ H5FD_direct_query(const H5FD_t H5_ATTR_UNUSED *_f, unsigned long *flags /* out * } /*------------------------------------------------------------------------- - * Function: H5FD_direct_get_eoa + * Function: H5FD__direct_get_eoa * * Purpose: Gets the end-of-address marker for the file. The EOA marker * is the first address past the last byte allocated in the @@ -744,25 +731,20 @@ H5FD_direct_query(const H5FD_t H5_ATTR_UNUSED *_f, unsigned long *flags /* out * * Programmer: Raymond Lu * Wednesday, 20 September 2006 * - * Modifications: - * Raymond Lu - * 21 Dec. 2006 - * Added the parameter TYPE. It's only used for MULTI driver. - * *------------------------------------------------------------------------- */ static haddr_t -H5FD_direct_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) +H5FD__direct_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { const H5FD_direct_t *file = (const H5FD_direct_t *)_file; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR FUNC_LEAVE_NOAPI(file->eoa) } /*------------------------------------------------------------------------- - * Function: H5FD_direct_set_eoa + * Function: H5FD__direct_set_eoa * * Purpose: Set the end-of-address marker for the file. This function is * called shortly after an existing HDF5 file is opened in order @@ -775,19 +757,14 @@ H5FD_direct_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) * Programmer: Raymond Lu * Wednesday, 20 September 2006 * - * Modifications: - * Raymond Lu - * 21 Dec. 2006 - * Added the parameter TYPE. It's only used for MULTI driver. - * *------------------------------------------------------------------------- */ static herr_t -H5FD_direct_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) +H5FD__direct_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) { H5FD_direct_t *file = (H5FD_direct_t *)_file; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR file->eoa = addr; @@ -795,7 +772,7 @@ H5FD_direct_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) } /*------------------------------------------------------------------------- - * Function: H5FD_direct_get_eof + * Function: H5FD__direct_get_eof * * Purpose: Returns the end-of-file marker, which is the greater of * either the Unix end-of-file or the HDF5 end-of-address @@ -810,16 +787,14 @@ H5FD_direct_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) * Programmer: Raymond Lu * Wednesday, 20 September 2006 * - * Modifications: - * *------------------------------------------------------------------------- */ static haddr_t -H5FD_direct_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) +H5FD__direct_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { const H5FD_direct_t *file = (const H5FD_direct_t *)_file; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC_NOERR FUNC_LEAVE_NOAPI(file->eof) } @@ -834,17 +809,15 @@ H5FD_direct_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) * Programmer: Raymond Lu * 21 September 2006 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t -H5FD_direct_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void **file_handle) +H5FD__direct_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void **file_handle) { H5FD_direct_t *file = (H5FD_direct_t *)_file; herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC if (!file_handle) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file handle not valid") @@ -855,7 +828,7 @@ done: } /*------------------------------------------------------------------------- - * Function: H5FD_direct_read + * Function: H5FD__direct_read * * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR * into buffer BUF according to data transfer properties in @@ -869,13 +842,11 @@ done: * Programmer: Raymond Lu * Thursday, 21 September 2006 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t -H5FD_direct_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, - size_t size, void *buf /*out*/) +H5FD__direct_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, + size_t size, void *buf /*out*/) { H5FD_direct_t *file = (H5FD_direct_t *)_file; ssize_t nbytes; @@ -890,7 +861,7 @@ H5FD_direct_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UN size_t copy_size = size; /* Size remaining to read when using copy buffer */ size_t copy_offset; /* Offset into copy buffer of the requested data */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC HDassert(file && file->pub.cls); HDassert(buf); @@ -1038,7 +1009,7 @@ done: } /*------------------------------------------------------------------------- - * Function: H5FD_direct_write + * Function: H5FD__direct_write * * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR * from buffer BUF according to data transfer properties in @@ -1051,13 +1022,11 @@ done: * Programmer: Raymond Lu * Thursday, 21 September 2006 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t -H5FD_direct_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, - size_t size, const void *buf) +H5FD__direct_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, + size_t size, const void *buf) { H5FD_direct_t *file = (H5FD_direct_t *)_file; ssize_t nbytes; @@ -1075,7 +1044,7 @@ H5FD_direct_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_U size_t copy_size = size; /* Size remaining to write when using copy buffer */ size_t copy_offset; /* Offset into copy buffer of the data to write */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC HDassert(file && file->pub.cls); HDassert(buf); @@ -1269,7 +1238,7 @@ done: } /*------------------------------------------------------------------------- - * Function: H5FD_direct_truncate + * Function: H5FD__direct_truncate * * Purpose: Makes sure that the true file size is the same (or larger) * than the end-of-address. @@ -1284,12 +1253,12 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_direct_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_UNUSED closing) +H5FD__direct_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_UNUSED closing) { H5FD_direct_t *file = (H5FD_direct_t *)_file; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC HDassert(file); @@ -1330,10 +1299,10 @@ H5FD_direct_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATT done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_direct_truncate() */ +} /* end H5FD__direct_truncate() */ /*------------------------------------------------------------------------- - * Function: H5FD_direct_lock + * Function: H5FD__direct_lock * * Purpose: To place an advisory lock on a file. * The lock type to apply depends on the parameter "rw": @@ -1347,13 +1316,13 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_direct_lock(H5FD_t *_file, hbool_t rw) +H5FD__direct_lock(H5FD_t *_file, hbool_t rw) { H5FD_direct_t *file = (H5FD_direct_t *)_file; /* VFD file struct */ int lock_flags; /* file locking flags */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC HDassert(file); @@ -1374,10 +1343,10 @@ H5FD_direct_lock(H5FD_t *_file, hbool_t rw) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_direct_lock() */ +} /* end H5FD__direct_lock() */ /*------------------------------------------------------------------------- - * Function: H5FD_direct_unlock + * Function: H5FD__direct_unlock * * Purpose: To remove the existing lock on the file * @@ -1388,12 +1357,12 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_direct_unlock(H5FD_t *_file) +H5FD__direct_unlock(H5FD_t *_file) { H5FD_direct_t *file = (H5FD_direct_t *)_file; /* VFD file struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC HDassert(file); @@ -1410,6 +1379,6 @@ H5FD_direct_unlock(H5FD_t *_file) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_direct_unlock() */ +} /* end H5FD__direct_unlock() */ #endif /* H5_HAVE_DIRECT */ diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c index 9ffecf9..8817c47 100644 --- a/src/H5FDfamily.c +++ b/src/H5FDfamily.c @@ -34,15 +34,15 @@ #include "H5FDdrvr_module.h" /* This source code file is part of the H5FD driver module */ -#include "H5private.h" /* Generic Functions */ +#include "H5private.h" /* Generic Functions */ #include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FDfamily.h" /* Family file driver */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDfamily.h" /* Family file driver */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ /* The size of the member name buffers */ #define H5FD_FAM_MEMB_NAME_BUF_SIZE 4096 @@ -52,16 +52,16 @@ static hid_t H5FD_FAMILY_g = 0; /* The description of a file belonging to this driver. */ typedef struct H5FD_family_t { - H5FD_t pub; /*public stuff, must be first */ - hid_t memb_fapl_id; /*file access property list for members */ - hsize_t memb_size; /*actual size of each member file */ - hsize_t pmem_size; /*member size passed in from property */ - unsigned nmembs; /*number of family members */ - unsigned amembs; /*number of member slots allocated */ - H5FD_t **memb; /*dynamic array of member pointers */ - haddr_t eoa; /*end of allocated addresses */ - char * name; /*name generator printf format */ - unsigned flags; /*flags for opening additional members */ + H5FD_t pub; /*public stuff, must be first */ + hid_t memb_fapl_id; /*file access property list for members */ + hsize_t memb_size; /*actual size of each member file */ + hsize_t pmem_size; /*member size passed in from property */ + unsigned nmembs; /*number of family members */ + unsigned amembs; /*number of member slots allocated */ + H5FD_t **memb; /*dynamic array of member pointers */ + haddr_t eoa; /*end of allocated addresses */ + char * name; /*name generator printf format */ + unsigned flags; /*flags for opening additional members */ /* Information from properties set by 'h5repart' tool */ hsize_t mem_newsize; /*new member size passed in as private @@ -73,70 +73,70 @@ typedef struct H5FD_family_t { /* Driver-specific file access properties */ typedef struct H5FD_family_fapl_t { - hsize_t memb_size; /*size of each member */ + hsize_t memb_size; /*size of each member */ hid_t memb_fapl_id; /*file access property list of each memb*/ } H5FD_family_fapl_t; /* Callback prototypes */ -static herr_t H5FD_family_term(void); -static void * H5FD_family_fapl_get(H5FD_t *_file); -static void * H5FD_family_fapl_copy(const void *_old_fa); -static herr_t H5FD_family_fapl_free(void *_fa); -static hsize_t H5FD_family_sb_size(H5FD_t *_file); -static herr_t H5FD_family_sb_encode(H5FD_t *_file, char *name /*out*/, unsigned char *buf /*out*/); -static herr_t H5FD_family_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf); -static H5FD_t *H5FD_family_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); -static herr_t H5FD_family_close(H5FD_t *_file); -static int H5FD_family_cmp(const H5FD_t *_f1, const H5FD_t *_f2); -static herr_t H5FD_family_query(const H5FD_t *_f1, unsigned long *flags); -static haddr_t H5FD_family_get_eoa(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD_family_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t eoa); -static haddr_t H5FD_family_get_eof(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD_family_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle); -static herr_t H5FD_family_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, - void *_buf /*out*/); -static herr_t H5FD_family_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, - const void *_buf); -static herr_t H5FD_family_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); -static herr_t H5FD_family_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); -static herr_t H5FD_family_lock(H5FD_t *_file, hbool_t rw); -static herr_t H5FD_family_unlock(H5FD_t *_file); +static herr_t H5FD__family_term(void); +static void * H5FD__family_fapl_get(H5FD_t *_file); +static void * H5FD__family_fapl_copy(const void *_old_fa); +static herr_t H5FD__family_fapl_free(void *_fa); +static hsize_t H5FD__family_sb_size(H5FD_t *_file); +static herr_t H5FD__family_sb_encode(H5FD_t *_file, char *name /*out*/, unsigned char *buf /*out*/); +static herr_t H5FD__family_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf); +static H5FD_t *H5FD__family_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); +static herr_t H5FD__family_close(H5FD_t *_file); +static int H5FD__family_cmp(const H5FD_t *_f1, const H5FD_t *_f2); +static herr_t H5FD__family_query(const H5FD_t *_f1, unsigned long *flags); +static haddr_t H5FD__family_get_eoa(const H5FD_t *_file, H5FD_mem_t type); +static herr_t H5FD__family_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t eoa); +static haddr_t H5FD__family_get_eof(const H5FD_t *_file, H5FD_mem_t type); +static herr_t H5FD__family_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle); +static herr_t H5FD__family_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, + void *_buf /*out*/); +static herr_t H5FD__family_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, + const void *_buf); +static herr_t H5FD__family_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); +static herr_t H5FD__family_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); +static herr_t H5FD__family_lock(H5FD_t *_file, hbool_t rw); +static herr_t H5FD__family_unlock(H5FD_t *_file); /* The class struct */ static const H5FD_class_t H5FD_family_g = { - "family", /*name */ - HADDR_MAX, /*maxaddr */ - H5F_CLOSE_WEAK, /*fc_degree */ - H5FD_family_term, /*terminate */ - H5FD_family_sb_size, /*sb_size */ - H5FD_family_sb_encode, /*sb_encode */ - H5FD_family_sb_decode, /*sb_decode */ - sizeof(H5FD_family_fapl_t), /*fapl_size */ - H5FD_family_fapl_get, /*fapl_get */ - H5FD_family_fapl_copy, /*fapl_copy */ - H5FD_family_fapl_free, /*fapl_free */ - 0, /*dxpl_size */ - NULL, /*dxpl_copy */ - NULL, /*dxpl_free */ - H5FD_family_open, /*open */ - H5FD_family_close, /*close */ - H5FD_family_cmp, /*cmp */ - H5FD_family_query, /*query */ - NULL, /*get_type_map */ - NULL, /*alloc */ - NULL, /*free */ - H5FD_family_get_eoa, /*get_eoa */ - H5FD_family_set_eoa, /*set_eoa */ - H5FD_family_get_eof, /*get_eof */ - H5FD_family_get_handle, /*get_handle */ - H5FD_family_read, /*read */ - H5FD_family_write, /*write */ - H5FD_family_flush, /*flush */ - H5FD_family_truncate, /*truncate */ - H5FD_family_lock, /*lock */ - H5FD_family_unlock, /*unlock */ + "family", /* name */ + HADDR_MAX, /* maxaddr */ + H5F_CLOSE_WEAK, /* fc_degree */ + H5FD__family_term, /* terminate */ + H5FD__family_sb_size, /* sb_size */ + H5FD__family_sb_encode, /* sb_encode */ + H5FD__family_sb_decode, /* sb_decode */ + sizeof(H5FD_family_fapl_t), /* fapl_size */ + H5FD__family_fapl_get, /* fapl_get */ + H5FD__family_fapl_copy, /* fapl_copy */ + H5FD__family_fapl_free, /* fapl_free */ + 0, /* dxpl_size */ + NULL, /* dxpl_copy */ + NULL, /* dxpl_free */ + H5FD__family_open, /* open */ + H5FD__family_close, /* close */ + H5FD__family_cmp, /* cmp */ + H5FD__family_query, /* query */ + NULL, /* get_type_map */ + NULL, /* alloc */ + NULL, /* free */ + H5FD__family_get_eoa, /* get_eoa */ + H5FD__family_set_eoa, /* set_eoa */ + H5FD__family_get_eof, /* get_eof */ + H5FD__family_get_handle, /* get_handle */ + H5FD__family_read, /* read */ + H5FD__family_write, /* write */ + H5FD__family_flush, /* flush */ + H5FD__family_truncate, /* truncate */ + H5FD__family_lock, /* lock */ + H5FD__family_unlock, /* unlock */ NULL, /*dedup */ - H5FD_FLMAP_DICHOTOMY /*fl_map */ + H5FD_FLMAP_DICHOTOMY /* fl_map */ }; /*-------------------------------------------------------------------------- @@ -197,9 +197,9 @@ done: } /* H5FD_family_init() */ /*--------------------------------------------------------------------------- - * Function: H5FD_family_term + * Function: H5FD__family_term * - * Purpose: Shut down the VFD + * Purpose: Shut down the VFD * * Returns: Non-negative on success or negative on failure * @@ -209,30 +209,30 @@ done: *--------------------------------------------------------------------------- */ static herr_t -H5FD_family_term(void) +H5FD__family_term(void) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Reset VFL ID */ H5FD_FAMILY_g = 0; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5FD_family_term() */ +} /* end H5FD__family_term() */ /*------------------------------------------------------------------------- - * Function: H5Pset_fapl_family + * Function: H5Pset_fapl_family * - * Purpose: Sets the file access property list FAPL_ID to use the family - * driver. The MEMB_SIZE is the size in bytes of each file - * member (used only when creating a new file) and the - * MEMB_FAPL_ID is a file access property list to be used for - * each family member. + * Purpose: Sets the file access property list FAPL_ID to use the family + * driver. The MEMB_SIZE is the size in bytes of each file + * member (used only when creating a new file) and the + * MEMB_FAPL_ID is a file access property list to be used for + * each family member. * - * Return: Success: Non-negative + * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- @@ -268,16 +268,16 @@ done: } /*------------------------------------------------------------------------- - * Function: H5Pget_fapl_family + * Function: H5Pget_fapl_family * - * Purpose: Returns information about the family file access property - * list though the function arguments. + * Purpose: Returns information about the family file access property + * list though the function arguments. * - * Return: Success: Non-negative + * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- @@ -311,29 +311,29 @@ done: } /*------------------------------------------------------------------------- - * Function: H5FD_family_fapl_get + * Function: H5FD__family_fapl_get * - * Purpose: Gets a file access property list which could be used to - * create an identical file. + * Purpose: Gets a file access property list which could be used to + * create an identical file. * - * Return: Success: Ptr to new file access property list. + * Return: Success: Ptr to new file access property list. * - * Failure: NULL + * Failure: NULL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Friday, August 13, 1999 * *------------------------------------------------------------------------- */ static void * -H5FD_family_fapl_get(H5FD_t *_file) +H5FD__family_fapl_get(H5FD_t *_file) { H5FD_family_t * file = (H5FD_family_t *)_file; H5FD_family_fapl_t *fa = NULL; H5P_genplist_t * plist; /* Property list pointer */ void * ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC if (NULL == (fa = (H5FD_family_fapl_t *)H5MM_calloc(sizeof(H5FD_family_fapl_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") @@ -347,36 +347,36 @@ H5FD_family_fapl_get(H5FD_t *_file) ret_value = fa; done: - if (ret_value == NULL) { + if (ret_value == NULL) if (fa != NULL) H5MM_xfree(fa); - } /* end if */ + FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- - * Function: H5FD_family_fapl_copy + * Function: H5FD__family_fapl_copy * - * Purpose: Copies the family-specific file access properties. + * Purpose: Copies the family-specific file access properties. * - * Return: Success: Ptr to a new property list + * Return: Success: Ptr to a new property list * - * Failure: NULL + * Failure: NULL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- */ static void * -H5FD_family_fapl_copy(const void *_old_fa) +H5FD__family_fapl_copy(const void *_old_fa) { const H5FD_family_fapl_t *old_fa = (const H5FD_family_fapl_t *)_old_fa; H5FD_family_fapl_t * new_fa = NULL; H5P_genplist_t * plist; /* Property list pointer */ void * ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC if (NULL == (new_fa = (H5FD_family_fapl_t *)H5MM_malloc(sizeof(H5FD_family_fapl_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") @@ -399,34 +399,34 @@ H5FD_family_fapl_copy(const void *_old_fa) ret_value = new_fa; done: - if (ret_value == NULL) { + if (ret_value == NULL) if (new_fa != NULL) H5MM_xfree(new_fa); - } /* end if */ + FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- - * Function: H5FD_family_fapl_free + * Function: H5FD__family_fapl_free * - * Purpose: Frees the family-specific file access properties. + * Purpose: Frees the family-specific file access properties. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- */ static herr_t -H5FD_family_fapl_free(void *_fa) +H5FD__family_fapl_free(void *_fa) { H5FD_family_fapl_t *fa = (H5FD_family_fapl_t *)_fa; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC if (H5I_dec_ref(fa->memb_fapl_id) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't close driver ID") @@ -437,24 +437,24 @@ done: } /*------------------------------------------------------------------------- - * Function: H5FD_family_sb_size + * Function: H5FD__family_sb_size * - * Purpose: Returns the size of the private information to be stored in - * the superblock. + * Purpose: Returns the size of the private information to be stored in + * the superblock. * - * Return: Success: The super block driver data size. + * Return: Success: The super block driver data size. * - * Failure: never fails + * Failure: never fails * - * Programmer: Raymond Lu + * Programmer: Raymond Lu * Tuesday, May 10, 2005 * *------------------------------------------------------------------------- */ static hsize_t -H5FD_family_sb_size(H5FD_t H5_ATTR_UNUSED *_file) +H5FD__family_sb_size(H5FD_t H5_ATTR_UNUSED *_file) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* 8 bytes field for the size of member file size field should be * enough for now. */ @@ -462,29 +462,29 @@ H5FD_family_sb_size(H5FD_t H5_ATTR_UNUSED *_file) } /*------------------------------------------------------------------------- - * Function: H5FD_family_sb_encode + * Function: H5FD__family_sb_encode * - * Purpose: Encode driver information for the superblock. The NAME - * argument is a nine-byte buffer which will be initialized with - * an eight-character name/version number and null termination. + * Purpose: Encode driver information for the superblock. The NAME + * argument is a nine-byte buffer which will be initialized with + * an eight-character name/version number and null termination. * - * The encoding is the member file size and name template. + * The encoding is the member file size and name template. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Raymond Lu + * Programmer: Raymond Lu * Tuesday, May 10, 2005 * *------------------------------------------------------------------------- */ static herr_t -H5FD_family_sb_encode(H5FD_t *_file, char *name /*out*/, unsigned char *buf /*out*/) +H5FD__family_sb_encode(H5FD_t *_file, char *name /*out*/, unsigned char *buf /*out*/) { H5FD_family_t *file = (H5FD_family_t *)_file; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Name and version number */ HDstrncpy(name, "NCSAfami", (size_t)9); @@ -494,41 +494,41 @@ H5FD_family_sb_encode(H5FD_t *_file, char *name /*out*/, unsigned char *buf /*ou * This is to guarantee backward compatibility. If a file is created with * v1.6 library and the driver info isn't saved in the superblock. We open * it with v1.8, the FILE->MEMB_SIZE will be the actual size of the first - * member file (see H5FD_family_open). So it isn't safe to use FILE->MEMB_SIZE. + * member file (see H5FD__family_open). So it isn't safe to use FILE->MEMB_SIZE. * If the file is created with v1.8, the correctness of FILE->PMEM_SIZE is - * checked in H5FD_family_sb_decode. SLU - 2009/3/21 + * checked in H5FD__family_sb_decode. SLU - 2009/3/21 */ UINT64ENCODE(buf, (uint64_t)file->pmem_size); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5FD_family_sb_encode() */ +} /* end H5FD__family_sb_encode() */ /*------------------------------------------------------------------------- - * Function: H5FD_family_sb_decode + * Function: H5FD__family_sb_decode * - * Purpose: This function has 2 separate purpose. One is to decodes the + * Purpose: This function has 2 separate purpose. One is to decodes the * superblock information for this driver. The NAME argument is * the eight-character (plus null termination) name stored in i * the file. The FILE argument is updated according to the * information in the superblock. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Raymond Lu + * Programmer: Raymond Lu * Tuesday, May 10, 2005 * *------------------------------------------------------------------------- */ static herr_t -H5FD_family_sb_decode(H5FD_t *_file, const char H5_ATTR_UNUSED *name, const unsigned char *buf) +H5FD__family_sb_decode(H5FD_t *_file, const char H5_ATTR_UNUSED *name, const unsigned char *buf) { H5FD_family_t *file = (H5FD_family_t *)_file; uint64_t msize; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Read member file size. Skip name template for now although it's saved. */ UINT64DECODE(buf, msize); @@ -557,20 +557,20 @@ H5FD_family_sb_decode(H5FD_t *_file, const char H5_ATTR_UNUSED *name, const unsi done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_family_sb_decode() */ +} /* end H5FD__family_sb_decode() */ /*------------------------------------------------------------------------- - * Function: H5FD_family_open + * Function: H5FD__family_open * - * Purpose: Creates and/or opens a family of files as an HDF5 file. + * Purpose: Creates and/or opens a family of files as an HDF5 file. * - * Return: Success: A pointer to a new file dat structure. The - * public fields will be initialized by the - * caller, which is always H5FD_open(). + * Return: Success: A pointer to a new file dat structure. The + * public fields will be initialized by the + * caller, which is always H5FD_open(). * - * Failure: NULL + * Failure: NULL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- @@ -583,7 +583,7 @@ done: */ H5_GCC_DIAG_OFF("format-nonliteral") static H5FD_t * -H5FD_family_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) +H5FD__family_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { H5FD_family_t *file = NULL; char * memb_name = NULL, *temp = NULL; @@ -591,7 +591,7 @@ H5FD_family_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxadd unsigned t_flags = flags & ~H5F_ACC_CREAT; H5FD_t * ret_value = NULL; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check arguments */ if (!name || !*name) @@ -733,34 +733,34 @@ done: } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_family_open() */ +} /* end H5FD__family_open() */ H5_GCC_DIAG_ON("format-nonliteral") /*------------------------------------------------------------------------- - * Function: H5FD_family_close + * Function: H5FD__family_close * - * Purpose: Closes a family of files. + * Purpose: Closes a family of files. * - * Return: Success: Non-negative + * Return: Success: Non-negative * - * Failure: Negative with as many members closed as - * possible. The only subsequent operation - * permitted on the file is a close operation. + * Failure: Negative with as many members closed as + * possible. The only subsequent operation + * permitted on the file is a close operation. * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- */ static herr_t -H5FD_family_close(H5FD_t *_file) +H5FD__family_close(H5FD_t *_file) { H5FD_family_t *file = (H5FD_family_t *)_file; unsigned nerrors = 0; /* Number of errors while closing member files */ unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Close as many members as possible. Use private function here to avoid clearing * the error stack. We need the error message to indicate wrong member file size. */ @@ -785,32 +785,32 @@ H5FD_family_close(H5FD_t *_file) H5MM_xfree(file); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_family_close() */ +} /* end H5FD__family_close() */ /*------------------------------------------------------------------------- - * Function: H5FD_family_cmp + * Function: H5FD__family_cmp * - * Purpose: Compares two file families to see if they are the same. It - * does this by comparing the first member of the two families. + * Purpose: Compares two file families to see if they are the same. It + * does this by comparing the first member of the two families. * - * Return: Success: like strcmp() + * Return: Success: like strcmp() * - * Failure: never fails (arguments were checked by the - * caller). + * Failure: never fails (arguments were checked by the + * caller). * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- */ static int -H5FD_family_cmp(const H5FD_t *_f1, const H5FD_t *_f2) +H5FD__family_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { const H5FD_family_t *f1 = (const H5FD_family_t *)_f1; const H5FD_family_t *f2 = (const H5FD_family_t *)_f2; int ret_value = 0; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDassert(f1->nmembs >= 1 && f1->memb[0]); HDassert(f2->nmembs >= 1 && f2->memb[0]); @@ -818,28 +818,28 @@ H5FD_family_cmp(const H5FD_t *_f1, const H5FD_t *_f2) ret_value = H5FDcmp(f1->memb[0], f2->memb[0]); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_family_cmp() */ +} /* end H5FD__family_cmp() */ /*------------------------------------------------------------------------- - * Function: H5FD_family_query + * Function: H5FD__family_query * - * Purpose: Set the flags that this VFL driver is capable of supporting. + * Purpose: Set the flags that this VFL driver is capable of supporting. * (listed in H5FDpublic.h) * - * Return: Success: non-negative - * Failure: negative + * Return: Success: non-negative + * Failure: negative * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Friday, August 25, 2000 * *------------------------------------------------------------------------- */ static herr_t -H5FD_family_query(const H5FD_t *_file, unsigned long *flags /* out */) +H5FD__family_query(const H5FD_t *_file, unsigned long *flags /* out */) { const H5FD_family_t *file = (const H5FD_family_t *)_file; /* Family VFD info */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Set the VFL feature flags that this driver supports */ if (flags) { @@ -856,44 +856,44 @@ H5FD_family_query(const H5FD_t *_file, unsigned long *flags /* out */) } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5FD_family_query() */ +} /* end H5FD__family_query() */ /*------------------------------------------------------------------------- - * Function: H5FD_family_get_eoa + * Function: H5FD__family_get_eoa * - * Purpose: Returns the end-of-address marker for the file. The EOA - * marker is the first address past the last byte allocated in - * the format address space. + * Purpose: Returns the end-of-address marker for the file. The EOA + * marker is the first address past the last byte allocated in + * the format address space. * - * Return: Success: The end-of-address-marker + * Return: Success: The end-of-address-marker * - * Failure: HADDR_UNDEF + * Failure: HADDR_UNDEF * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- */ static haddr_t -H5FD_family_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) +H5FD__family_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { const H5FD_family_t *file = (const H5FD_family_t *)_file; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR FUNC_LEAVE_NOAPI(file->eoa) } /*------------------------------------------------------------------------- - * Function: H5FD_family_set_eoa + * Function: H5FD__family_set_eoa * - * Purpose: Set the end-of-address marker for the file. + * Purpose: Set the end-of-address marker for the file. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- @@ -906,7 +906,7 @@ H5FD_family_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) */ H5_GCC_DIAG_OFF("format-nonliteral") static herr_t -H5FD_family_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t abs_eoa) +H5FD__family_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t abs_eoa) { H5FD_family_t *file = (H5FD_family_t *)_file; haddr_t addr = abs_eoa; @@ -914,7 +914,7 @@ H5FD_family_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t abs_eoa) unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Allocate space for the member name buffer */ if (NULL == (memb_name = (char *)H5MM_malloc(H5FD_FAM_MEMB_NAME_BUF_SIZE))) @@ -976,31 +976,31 @@ done: H5_GCC_DIAG_ON("format-nonliteral") /*------------------------------------------------------------------------- - * Function: H5FD_family_get_eof + * Function: H5FD__family_get_eof * - * Purpose: Returns the end-of-file marker, which is the greater of - * either the total family size or the current EOA marker. + * Purpose: Returns the end-of-file marker, which is the greater of + * either the total family size or the current EOA marker. * - * Return: Success: End of file address, the first address past - * the end of the family of files or the current - * EOA, whichever is larger. + * Return: Success: End of file address, the first address past + * the end of the family of files or the current + * EOA, whichever is larger. * - * Failure: HADDR_UNDEF + * Failure: HADDR_UNDEF * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- */ static haddr_t -H5FD_family_get_eof(const H5FD_t *_file, H5FD_mem_t type) +H5FD__family_get_eof(const H5FD_t *_file, H5FD_mem_t type) { const H5FD_family_t *file = (const H5FD_family_t *)_file; haddr_t eof = 0; int i; /* Local index variable */ haddr_t ret_value = HADDR_UNDEF; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* * Find the last member that has a non-zero EOF and break out of the loop @@ -1031,7 +1031,7 @@ H5FD_family_get_eof(const H5FD_t *_file, H5FD_mem_t type) } /*------------------------------------------------------------------------- - * Function: H5FD_family_get_handle + * Function: H5FD__family_get_handle * * Purpose: Returns the file handle of FAMILY file driver. * @@ -1043,7 +1043,7 @@ H5FD_family_get_eof(const H5FD_t *_file, H5FD_mem_t type) *------------------------------------------------------------------------- */ static herr_t -H5FD_family_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle) +H5FD__family_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle) { H5FD_family_t * file = (H5FD_family_t *)_file; H5P_genplist_t *plist; @@ -1051,7 +1051,7 @@ H5FD_family_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle) int memb; herr_t ret_value = FAIL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Get the plist structure and family offset */ if (NULL == (plist = H5P_object_verify(fapl, H5P_FILE_ACCESS))) @@ -1070,24 +1070,25 @@ done: } /*------------------------------------------------------------------------- - * Function: H5FD_family_read + * Function: H5FD__family_read * - * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR - * into buffer BUF according to data transfer properties in - * DXPL_ID. + * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR + * into buffer BUF according to data transfer properties in + * DXPL_ID. * - * Return: Success: Zero. Result is stored in caller-supplied - * buffer BUF. + * Return: Success: Zero. Result is stored in caller-supplied + * buffer BUF. * - * Failure: -1, contents of buffer BUF are undefined. + * Failure: -1, contents of buffer BUF are undefined. * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- */ static herr_t -H5FD_family_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, void *_buf /*out*/) +H5FD__family_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, + void *_buf /*out*/) { H5FD_family_t * file = (H5FD_family_t *)_file; unsigned char * buf = (unsigned char *)_buf; @@ -1098,7 +1099,7 @@ H5FD_family_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, si H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* * Get the member data transfer property list. If the transfer property @@ -1136,23 +1137,23 @@ done: } /*------------------------------------------------------------------------- - * Function: H5FD_family_write + * Function: H5FD__family_write * - * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR - * from buffer BUF according to data transfer properties in - * DXPL_ID. + * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR + * from buffer BUF according to data transfer properties in + * DXPL_ID. * - * Return: Success: Zero + * Return: Success: Zero * - * Failure: -1 + * Failure: -1 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- */ static herr_t -H5FD_family_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, const void *_buf) +H5FD__family_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, const void *_buf) { H5FD_family_t * file = (H5FD_family_t *)_file; const unsigned char *buf = (const unsigned char *)_buf; @@ -1163,7 +1164,7 @@ H5FD_family_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, s H5P_genplist_t * plist; /* Property list pointer */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* * Get the member data transfer property list. If the transfer property @@ -1201,26 +1202,26 @@ done: } /*------------------------------------------------------------------------- - * Function: H5FD_family_flush + * Function: H5FD__family_flush * - * Purpose: Flushes all family members. + * Purpose: Flushes all family members. * - * Return: Success: 0 - * Failure: -1, as many files flushed as possible. + * Return: Success: 0 + * Failure: -1, as many files flushed as possible. * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- */ static herr_t -H5FD_family_flush(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t closing) +H5FD__family_flush(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t closing) { H5FD_family_t *file = (H5FD_family_t *)_file; unsigned u, nerrors = 0; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC for (u = 0; u < file->nmembs; u++) if (file->memb[u] && H5FD_flush(file->memb[u], closing) < 0) @@ -1231,30 +1232,30 @@ H5FD_family_flush(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t closing) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_family_flush() */ +} /* end H5FD__family_flush() */ /*------------------------------------------------------------------------- - * Function: H5FD_family_truncate + * Function: H5FD__family_truncate * - * Purpose: Truncates all family members. + * Purpose: Truncates all family members. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1, as many files truncated as possible. + * Failure: -1, as many files truncated as possible. * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Saturday, February 23, 2008 * *------------------------------------------------------------------------- */ static herr_t -H5FD_family_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t closing) +H5FD__family_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t closing) { H5FD_family_t *file = (H5FD_family_t *)_file; unsigned u, nerrors = 0; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC for (u = 0; u < file->nmembs; u++) if (file->memb[u] && H5FD_truncate(file->memb[u], closing) < 0) @@ -1265,10 +1266,10 @@ H5FD_family_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t closin done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_family_truncate() */ +} /* end H5FD__family_truncate() */ /*------------------------------------------------------------------------- - * Function: H5FD_family_lock + * Function: H5FD__family_lock * * Purpose: To place an advisory lock on a file. * The lock type to apply depends on the parameter "rw": @@ -1282,13 +1283,13 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_family_lock(H5FD_t *_file, hbool_t rw) +H5FD__family_lock(H5FD_t *_file, hbool_t rw) { H5FD_family_t *file = (H5FD_family_t *)_file; /* VFD file struct */ unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Place the lock on all the member files */ for (u = 0; u < file->nmembs; u++) @@ -1312,10 +1313,10 @@ H5FD_family_lock(H5FD_t *_file, hbool_t rw) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_family_lock() */ +} /* end H5FD__family_lock() */ /*------------------------------------------------------------------------- - * Function: H5FD_family_unlock + * Function: H5FD__family_unlock * * Purpose: To remove the existing lock on the file * @@ -1326,13 +1327,13 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_family_unlock(H5FD_t *_file) +H5FD__family_unlock(H5FD_t *_file) { H5FD_family_t *file = (H5FD_family_t *)_file; /* VFD file struct */ unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Remove the lock on the member files */ for (u = 0; u < file->nmembs; u++) @@ -1342,4 +1343,4 @@ H5FD_family_unlock(H5FD_t *_file) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_family_unlock() */ +} /* end H5FD__family_unlock() */ diff --git a/src/H5FDlog.c b/src/H5FDlog.c index 09e71f1..be8bfce 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -156,62 +156,62 @@ typedef struct H5FD_log_t { (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || HADDR_UNDEF == (A) + (Z) || (HDoff_t)((A) + (Z)) < (HDoff_t)(A)) /* Prototypes */ -static herr_t H5FD_log_term(void); -static void * H5FD_log_fapl_get(H5FD_t *file); -static void * H5FD_log_fapl_copy(const void *_old_fa); -static herr_t H5FD_log_fapl_free(void *_fa); -static H5FD_t *H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); -static herr_t H5FD_log_close(H5FD_t *_file); -static int H5FD_log_cmp(const H5FD_t *_f1, const H5FD_t *_f2); -static herr_t H5FD_log_query(const H5FD_t *_f1, unsigned long *flags); -static haddr_t H5FD_log_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size); +static herr_t H5FD__log_term(void); +static void * H5FD__log_fapl_get(H5FD_t *file); +static void * H5FD__log_fapl_copy(const void *_old_fa); +static herr_t H5FD__log_fapl_free(void *_fa); +static H5FD_t *H5FD__log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); +static herr_t H5FD__log_close(H5FD_t *_file); +static int H5FD__log_cmp(const H5FD_t *_f1, const H5FD_t *_f2); +static herr_t H5FD__log_query(const H5FD_t *_f1, unsigned long *flags); +static haddr_t H5FD__log_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size); static herr_t H5FD__log_free(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size); -static haddr_t H5FD_log_get_eoa(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD_log_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); -static haddr_t H5FD_log_get_eof(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD_log_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle); -static herr_t H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, - void *buf); -static herr_t H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, - const void *buf); -static herr_t H5FD_log_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); -static herr_t H5FD_log_lock(H5FD_t *_file, hbool_t rw); -static herr_t H5FD_log_unlock(H5FD_t *_file); +static haddr_t H5FD__log_get_eoa(const H5FD_t *_file, H5FD_mem_t type); +static herr_t H5FD__log_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); +static haddr_t H5FD__log_get_eof(const H5FD_t *_file, H5FD_mem_t type); +static herr_t H5FD__log_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle); +static herr_t H5FD__log_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + void *buf); +static herr_t H5FD__log_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + const void *buf); +static herr_t H5FD__log_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); +static herr_t H5FD__log_lock(H5FD_t *_file, hbool_t rw); +static herr_t H5FD__log_unlock(H5FD_t *_file); static const H5FD_class_t H5FD_log_g = { - "log", /*name */ - MAXADDR, /*maxaddr */ - H5F_CLOSE_WEAK, /* fc_degree */ - H5FD_log_term, /*terminate */ - NULL, /*sb_size */ - NULL, /*sb_encode */ - NULL, /*sb_decode */ - sizeof(H5FD_log_fapl_t), /*fapl_size */ - H5FD_log_fapl_get, /*fapl_get */ - H5FD_log_fapl_copy, /*fapl_copy */ - H5FD_log_fapl_free, /*fapl_free */ - 0, /*dxpl_size */ - NULL, /*dxpl_copy */ - NULL, /*dxpl_free */ - H5FD_log_open, /*open */ - H5FD_log_close, /*close */ - H5FD_log_cmp, /*cmp */ - H5FD_log_query, /*query */ - NULL, /*get_type_map */ - H5FD_log_alloc, /*alloc */ - H5FD__log_free, /*free */ - H5FD_log_get_eoa, /*get_eoa */ - H5FD_log_set_eoa, /*set_eoa */ - H5FD_log_get_eof, /*get_eof */ - H5FD_log_get_handle, /*get_handle */ - H5FD_log_read, /*read */ - H5FD_log_write, /*write */ - NULL, /*flush */ - H5FD_log_truncate, /*truncate */ - H5FD_log_lock, /*lock */ - H5FD_log_unlock, /*unlock */ - NULL, /*dedup */ - H5FD_FLMAP_DICHOTOMY /*fl_map */ + "log", /* name */ + MAXADDR, /* maxaddr */ + H5F_CLOSE_WEAK, /* fc_degree */ + H5FD__log_term, /* terminate */ + NULL, /* sb_size */ + NULL, /* sb_encode */ + NULL, /* sb_decode */ + sizeof(H5FD_log_fapl_t), /* fapl_size */ + H5FD__log_fapl_get, /* fapl_get */ + H5FD__log_fapl_copy, /* fapl_copy */ + H5FD__log_fapl_free, /* fapl_free */ + 0, /* dxpl_size */ + NULL, /* dxpl_copy */ + NULL, /* dxpl_free */ + H5FD__log_open, /* open */ + H5FD__log_close, /* close */ + H5FD__log_cmp, /* cmp */ + H5FD__log_query, /* query */ + NULL, /* get_type_map */ + H5FD__log_alloc, /* alloc */ + H5FD__log_free, /* free */ + H5FD__log_get_eoa, /* get_eoa */ + H5FD__log_set_eoa, /* set_eoa */ + H5FD__log_get_eof, /* get_eof */ + H5FD__log_get_handle, /* get_handle */ + H5FD__log_read, /* read */ + H5FD__log_write, /* write */ + NULL, /* flush */ + H5FD__log_truncate, /* truncate */ + H5FD__log_lock, /* lock */ + H5FD__log_unlock, /* unlock */ + NULL, /* dedup */ + H5FD_FLMAP_DICHOTOMY /* fl_map */ }; /* Declare a free list to manage the H5FD_log_t struct */ @@ -282,7 +282,7 @@ done: } /* end H5FD_log_init() */ /*--------------------------------------------------------------------------- - * Function: H5FD_log_term + * Function: H5FD__log_term * * Purpose: Shut down the VFD * @@ -294,15 +294,15 @@ done: *--------------------------------------------------------------------------- */ static herr_t -H5FD_log_term(void) +H5FD__log_term(void) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Reset VFL ID */ H5FD_LOG_g = 0; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5FD_log_term() */ +} /* end H5FD__log_term() */ /*------------------------------------------------------------------------- * Function: H5Pset_fapl_log @@ -327,12 +327,15 @@ H5Pset_fapl_log(hid_t fapl_id, const char *logfile, unsigned long long flags, si FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*sULz", fapl_id, logfile, flags, buf_size); + /* Do this first, so that we don't try to free a wild pointer if + * H5P_object_verify() fails. + */ + HDmemset(&fa, 0, sizeof(H5FD_log_fapl_t)); + /* Check arguments */ if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") - HDmemset(&fa, 0, sizeof(H5FD_log_fapl_t)); - /* Duplicate the log file string * A little wasteful, since this string will just be copied later, but * passing it in as a pointer sets off a chain of impossible-to-resolve @@ -353,7 +356,7 @@ done: } /* end H5Pset_fapl_log() */ /*------------------------------------------------------------------------- - * Function: H5FD_log_fapl_get + * Function: H5FD__log_fapl_get * * Purpose: Returns a file access property list which indicates how the * specified file is being accessed. The return list could be @@ -369,21 +372,21 @@ done: *------------------------------------------------------------------------- */ static void * -H5FD_log_fapl_get(H5FD_t *_file) +H5FD__log_fapl_get(H5FD_t *_file) { H5FD_log_t *file = (H5FD_log_t *)_file; void * ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Set return value */ - ret_value = H5FD_log_fapl_copy(&(file->fa)); + ret_value = H5FD__log_fapl_copy(&(file->fa)); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_log_fapl_get() */ +} /* end H5FD__log_fapl_get() */ /*------------------------------------------------------------------------- - * Function: H5FD_log_fapl_copy + * Function: H5FD__log_fapl_copy * * Purpose: Copies the log-specific file access properties. * @@ -396,13 +399,13 @@ H5FD_log_fapl_get(H5FD_t *_file) *------------------------------------------------------------------------- */ static void * -H5FD_log_fapl_copy(const void *_old_fa) +H5FD__log_fapl_copy(const void *_old_fa) { const H5FD_log_fapl_t *old_fa = (const H5FD_log_fapl_t *)_old_fa; H5FD_log_fapl_t * new_fa = NULL; /* New FAPL info */ void * ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC HDassert(old_fa); @@ -427,13 +430,13 @@ done: if (new_fa->logfile) new_fa->logfile = (char *)H5MM_xfree(new_fa->logfile); H5MM_free(new_fa); - } /* end if */ + } FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_log_fapl_copy() */ +} /* end H5FD__log_fapl_copy() */ /*------------------------------------------------------------------------- - * Function: H5FD_log_fapl_free + * Function: H5FD__log_fapl_free * * Purpose: Frees the log-specific file access properties. * @@ -445,11 +448,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_log_fapl_free(void *_fa) +H5FD__log_fapl_free(void *_fa) { H5FD_log_fapl_t *fa = (H5FD_log_fapl_t *)_fa; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Free the fapl information */ if (fa->logfile) @@ -457,10 +460,10 @@ H5FD_log_fapl_free(void *_fa) H5MM_xfree(fa); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5FD_log_fapl_free() */ +} /* end H5FD__log_fapl_free() */ /*------------------------------------------------------------------------- - * Function: H5FD_log_open + * Function: H5FD__log_open * * Purpose: Create and/or opens a file as an HDF5 file. * @@ -475,7 +478,7 @@ H5FD_log_fapl_free(void *_fa) *------------------------------------------------------------------------- */ static H5FD_t * -H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) +H5FD__log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { H5FD_log_t * file = NULL; H5P_genplist_t * plist; /* Property list */ @@ -485,12 +488,12 @@ 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 = {{0}, {0}, {0}, FALSE}; /* Timer for open() call */ - H5_timer_t stat_timer = {{0}, {0}, {0}, FALSE}; /* Timer for stat() call */ + H5_timer_t open_timer; /* Timer for open() call */ + H5_timer_t stat_timer; /* Timer for stat() call */ h5_stat_t sb; H5FD_t * ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Sanity check on file offsets */ HDcompile_assert(sizeof(HDoff_t) >= sizeof(size_t)); @@ -503,6 +506,10 @@ H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) if (ADDR_OVERFLOW(maxaddr)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "bogus maxaddr") + /* Initialize timers */ + H5_timer_init(&open_timer); + H5_timer_init(&stat_timer); + /* Build the open flags */ o_flags = (H5F_ACC_RDWR & flags) ? O_RDWR : O_RDONLY; if (H5F_ACC_TRUNC & flags) @@ -519,10 +526,8 @@ H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, NULL, "bad VFL driver info") /* Start timer for open() call */ - if (fa->flags & H5FD_LOG_TIME_OPEN) { - H5_timer_init(&open_timer); + if (fa->flags & H5FD_LOG_TIME_OPEN) H5_timer_start(&open_timer); - } /* end if */ /* Open the file */ if ((fd = HDopen(name, o_flags, H5_POSIX_CREATE_MODE_RW)) < 0) { @@ -532,17 +537,15 @@ H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file: name = '%s', errno = %d, error message = '%s', flags = %x, o_flags = %x", name, myerrno, HDstrerror(myerrno), flags, (unsigned)o_flags); - } /* end if */ + } /* Stop timer for open() call */ if (fa->flags & H5FD_LOG_TIME_OPEN) H5_timer_stop(&open_timer); /* Start timer for stat() call */ - if (fa->flags & H5FD_LOG_TIME_STAT) { - H5_timer_init(&stat_timer); + if (fa->flags & H5FD_LOG_TIME_STAT) H5_timer_start(&stat_timer); - } /* end if */ /* Get the file stats */ if (HDfstat(fd, &sb) < 0) @@ -595,15 +598,15 @@ H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) if (file->fa.flags & H5FD_LOG_FILE_READ) { file->nread = (unsigned char *)H5MM_calloc(file->iosize); HDassert(file->nread); - } /* end if */ + } if (file->fa.flags & H5FD_LOG_FILE_WRITE) { file->nwrite = (unsigned char *)H5MM_calloc(file->iosize); HDassert(file->nwrite); - } /* end if */ + } if (file->fa.flags & H5FD_LOG_FLAVOR) { file->flavor = (unsigned char *)H5MM_calloc(file->iosize); HDassert(file->flavor); - } /* end if */ + } /* Set the log file pointer */ if (fa->logfile) @@ -617,14 +620,14 @@ H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) H5_timer_get_times(open_timer, &open_times); HDfprintf(file->logfp, "Open took: (%f s)\n", open_times.elapsed); - } /* end if */ + } if (file->fa.flags & H5FD_LOG_TIME_STAT) { H5_timevals_t stat_times; /* Elapsed time for stat() call */ H5_timer_get_times(stat_timer, &stat_times); HDfprintf(file->logfp, "Stat took: (%f s)\n", stat_times.elapsed); - } /* end if */ - } /* end if */ + } + } /* Check the file locking flags in the fapl */ if (ignore_disabled_file_locks_s != FAIL) @@ -646,7 +649,7 @@ H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) if (H5P_exist_plist(plist, H5F_ACS_FAMILY_TO_SINGLE_NAME) > 0) if (H5P_get(plist, H5F_ACS_FAMILY_TO_SINGLE_NAME, &file->fam_to_single) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, NULL, "can't get property of changing family to single") - } /* end if */ + } /* Set return value */ ret_value = (H5FD_t *)file; @@ -657,13 +660,13 @@ done: HDclose(fd); if (file) file = H5FL_FREE(H5FD_log_t, file); - } /* end if */ + } FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_log_open() */ +} /* end H5FD__log_open() */ /*------------------------------------------------------------------------- - * Function: H5FD_log_close + * Function: H5FD__log_close * * Purpose: Closes an HDF5 file. * @@ -676,22 +679,23 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_log_close(H5FD_t *_file) +H5FD__log_close(H5FD_t *_file) { - 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 */ + H5FD_log_t *file = (H5FD_log_t *)_file; + H5_timer_t close_timer; /* Timer for close() call */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Sanity check */ HDassert(file); + /* Initialize timer */ + H5_timer_init(&close_timer); + /* Start timer for close() call */ - if (file->fa.flags & H5FD_LOG_TIME_CLOSE) { - H5_timer_init(&close_timer); + if (file->fa.flags & H5FD_LOG_TIME_CLOSE) H5_timer_start(&close_timer); - } /* end if */ /* Close the underlying file */ if (HDclose(file->fd) < 0) @@ -712,7 +716,7 @@ H5FD_log_close(H5FD_t *_file) H5_timer_get_times(close_timer, &close_times); HDfprintf(file->logfp, "Close took: (%f s)\n", close_times.elapsed); - } /* end if */ + } /* Dump the total number of seek/read/write operations */ if (file->fa.flags & H5FD_LOG_NUM_READ) @@ -746,12 +750,12 @@ H5FD_log_close(H5FD_t *_file) (addr - 1), (unsigned long)(addr - last_addr), (int)last_val); last_val = file->nwrite[addr]; last_addr = addr; - } /* end if */ + } addr++; - } /* end while */ + } HDfprintf(file->logfp, "\tAddr %10a-%10a (%10lu bytes) written to %3d times\n", last_addr, (addr - 1), (unsigned long)(addr - last_addr), (int)last_val); - } /* end if */ + } /* Dump the read I/O information */ if (file->fa.flags & H5FD_LOG_FILE_READ) { @@ -765,12 +769,12 @@ H5FD_log_close(H5FD_t *_file) (addr - 1), (unsigned long)(addr - last_addr), (int)last_val); last_val = file->nread[addr]; last_addr = addr; - } /* end if */ + } addr++; - } /* end while */ + } HDfprintf(file->logfp, "\tAddr %10a-%10a (%10lu bytes) read from %3d times\n", last_addr, (addr - 1), (unsigned long)(addr - last_addr), (int)last_val); - } /* end if */ + } /* Dump the I/O flavor information */ if (file->fa.flags & H5FD_LOG_FLAVOR) { @@ -784,12 +788,12 @@ H5FD_log_close(H5FD_t *_file) (addr - 1), (unsigned long)(addr - last_addr), flavors[last_val]); last_val = file->flavor[addr]; last_addr = addr; - } /* end if */ + } addr++; - } /* end while */ + } HDfprintf(file->logfp, "\tAddr %10a-%10a (%10lu bytes) flavor is %s\n", last_addr, (addr - 1), (unsigned long)(addr - last_addr), flavors[last_val]); - } /* end if */ + } /* Free the logging information */ if (file->fa.flags & H5FD_LOG_FILE_WRITE) @@ -810,10 +814,10 @@ H5FD_log_close(H5FD_t *_file) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_log_close() */ +} /* end H5FD__log_close() */ /*------------------------------------------------------------------------- - * Function: H5FD_log_cmp + * Function: H5FD__log_cmp * * Purpose: Compares two files belonging to this driver using an * arbitrary (but consistent) ordering. @@ -828,13 +832,13 @@ done: *------------------------------------------------------------------------- */ static int -H5FD_log_cmp(const H5FD_t *_f1, const H5FD_t *_f2) +H5FD__log_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { const H5FD_log_t *f1 = (const H5FD_log_t *)_f1; const H5FD_log_t *f2 = (const H5FD_log_t *)_f2; int ret_value = 0; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR #ifdef H5_HAVE_WIN32_API if (f1->dwVolumeSerialNumber < f2->dwVolumeSerialNumber) @@ -877,10 +881,10 @@ H5FD_log_cmp(const H5FD_t *_f1, const H5FD_t *_f2) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_log_cmp() */ +} /* end H5FD__log_cmp() */ /*------------------------------------------------------------------------- - * Function: H5FD_log_query + * Function: H5FD__log_query * * Purpose: Set the flags that this VFL driver is capable of supporting. * (listed in H5FDpublic.h) @@ -893,11 +897,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_log_query(const H5FD_t *_file, unsigned long *flags /* out */) +H5FD__log_query(const H5FD_t *_file, unsigned long *flags /* out */) { const H5FD_log_t *file = (const H5FD_log_t *)_file; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Set the VFL feature flags that this driver supports */ if (flags) { @@ -916,13 +920,13 @@ H5FD_log_query(const H5FD_t *_file, unsigned long *flags /* out */) if (file && file->fam_to_single) *flags |= H5FD_FEAT_IGNORE_DRVRINFO; /* Ignore the driver info when file is opened (which eliminates it) */ - } /* end if */ + } FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5FD_log_query() */ +} /* end H5FD__log_query() */ /*------------------------------------------------------------------------- - * Function: H5FD_log_alloc + * Function: H5FD__log_alloc * * Purpose: Allocate file memory. * @@ -935,13 +939,13 @@ H5FD_log_query(const H5FD_t *_file, unsigned long *flags /* out */) *------------------------------------------------------------------------- */ static haddr_t -H5FD_log_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, hsize_t size) +H5FD__log_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, hsize_t size) { H5FD_log_t *file = (H5FD_log_t *)_file; haddr_t addr; haddr_t ret_value = HADDR_UNDEF; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Compute the address for the block to allocate */ addr = file->eoa; @@ -955,18 +959,18 @@ H5FD_log_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, hsi HDassert(addr < file->iosize); H5_CHECK_OVERFLOW(size, hsize_t, size_t); HDmemset(&file->flavor[addr], (int)type, (size_t)size); - } /* end if */ + } if (file->fa.flags & H5FD_LOG_ALLOC) HDfprintf(file->logfp, "%10a-%10a (%10Hu bytes) (%s) Allocated\n", addr, (addr + size) - 1, size, flavors[type]); - } /* end if */ + } /* Set return value */ ret_value = addr; FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_log_alloc() */ +} /* end H5FD__log_alloc() */ /*------------------------------------------------------------------------- * Function: H5FD__log_free @@ -993,19 +997,19 @@ H5FD__log_free(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had HDassert(addr < file->iosize); H5_CHECK_OVERFLOW(size, hsize_t, size_t); HDmemset(&file->flavor[addr], H5FD_MEM_DEFAULT, (size_t)size); - } /* end if */ + } /* Log the file memory freed */ if (file->fa.flags & H5FD_LOG_FREE) HDfprintf(file->logfp, "%10a-%10a (%10Hu bytes) (%s) Freed\n", addr, (addr + size) - 1, size, flavors[type]); - } /* end if */ + } FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD__log_free() */ /*------------------------------------------------------------------------- - * Function: H5FD_log_get_eoa + * Function: H5FD__log_get_eoa * * Purpose: Gets the end-of-address marker for the file. The EOA marker * is the first address past the last byte allocated in the @@ -1020,17 +1024,17 @@ H5FD__log_free(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had *------------------------------------------------------------------------- */ static haddr_t -H5FD_log_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) +H5FD__log_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { const H5FD_log_t *file = (const H5FD_log_t *)_file; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR FUNC_LEAVE_NOAPI(file->eoa) -} /* end H5FD_log_get_eoa() */ +} /* end H5FD__log_get_eoa() */ /*------------------------------------------------------------------------- - * Function: H5FD_log_set_eoa + * Function: H5FD__log_set_eoa * * Purpose: Set the end-of-address marker for the file. This function is * called shortly after an existing HDF5 file is opened in order @@ -1044,11 +1048,11 @@ H5FD_log_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) *------------------------------------------------------------------------- */ static herr_t -H5FD_log_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr) +H5FD__log_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr) { H5FD_log_t *file = (H5FD_log_t *)_file; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR if (file->fa.flags != 0) { /* Check for increasing file size */ @@ -1060,13 +1064,13 @@ H5FD_log_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr) HDassert(addr < file->iosize); H5_CHECK_OVERFLOW(size, hsize_t, size_t); HDmemset(&file->flavor[file->eoa], (int)type, (size_t)size); - } /* end if */ + } /* Log the extension like an allocation */ if (file->fa.flags & H5FD_LOG_ALLOC) HDfprintf(file->logfp, "%10a-%10a (%10Hu bytes) (%s) Allocated\n", file->eoa, addr, size, flavors[type]); - } /* end if */ + } /* Check for decreasing file size */ if (H5F_addr_lt(addr, file->eoa) && H5F_addr_gt(addr, 0)) { @@ -1077,22 +1081,22 @@ H5FD_log_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr) HDassert((addr + size) < file->iosize); H5_CHECK_OVERFLOW(size, hsize_t, size_t); HDmemset(&file->flavor[addr], H5FD_MEM_DEFAULT, (size_t)size); - } /* end if */ + } /* Log the shrink like a free */ if (file->fa.flags & H5FD_LOG_FREE) HDfprintf(file->logfp, "%10a-%10a (%10Hu bytes) (%s) Freed\n", file->eoa, addr, size, flavors[type]); - } /* end if */ - } /* end if */ + } + } file->eoa = addr; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5FD_log_set_eoa() */ +} /* end H5FD__log_set_eoa() */ /*------------------------------------------------------------------------- - * Function: H5FD_log_get_eof + * Function: H5FD__log_get_eof * * Purpose: Returns the end-of-file marker, which is the greater of * either the filesystem end-of-file or the HDF5 end-of-address @@ -1109,17 +1113,17 @@ H5FD_log_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr) *------------------------------------------------------------------------- */ static haddr_t -H5FD_log_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) +H5FD__log_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { const H5FD_log_t *file = (const H5FD_log_t *)_file; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR FUNC_LEAVE_NOAPI(file->eof) -} /* end H5FD_log_get_eof() */ +} /* end H5FD__log_get_eof() */ /*------------------------------------------------------------------------- - * Function: H5FD_log_get_handle + * Function: H5FD__log_get_handle * * Purpose: Returns the file handle of LOG file driver. * @@ -1131,12 +1135,12 @@ H5FD_log_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) *------------------------------------------------------------------------- */ static herr_t -H5FD_log_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void **file_handle) +H5FD__log_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void **file_handle) { H5FD_log_t *file = (H5FD_log_t *)_file; herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC if (!file_handle) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file handle not valid") @@ -1145,10 +1149,10 @@ H5FD_log_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void **file_handle done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_log_get_handle() */ +} /* end H5FD__log_get_handle() */ /*------------------------------------------------------------------------- - * Function: H5FD_log_read + * Function: H5FD__log_read * * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR * into buffer BUF according to data transfer properties in @@ -1164,26 +1168,25 @@ done: *------------------------------------------------------------------------- */ 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_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 */ -#ifndef H5_HAVE_PREADWRITE - H5_timer_t seek_timer; /* Timer for seek operation */ - H5_timevals_t seek_times; /* Elapsed time for seek operation */ -#endif /* H5_HAVE_PREADWRITE */ - HDoff_t offset = (HDoff_t)addr; - herr_t ret_value = SUCCEED; /* Return value */ + HDoff_t offset = (HDoff_t)addr; + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC HDassert(file && file->pub.cls); HDassert(buf); + /* Initialize timer */ + H5_timer_init(&read_timer); + /* Check for overflow conditions */ if (!H5F_addr_defined(addr)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined, addr = %llu", (unsigned long long)addr) @@ -1200,17 +1203,22 @@ H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, hadd HDassert((addr + size) < file->iosize); while (tmp_size-- > 0) file->nread[tmp_addr++]++; - } /* end if */ - } /* end if */ + } + } #ifndef H5_HAVE_PREADWRITE /* Seek to the correct location (if we don't have pread) */ if (addr != file->pos || OP_READ != file->op) { + + H5_timer_t seek_timer; /* Timer for seek operation */ + H5_timevals_t seek_times; /* Elapsed time for seek operation */ + + /* Initialize timer */ + H5_timer_init(&seek_timer); + /* Start timer for seek() call */ - if (file->fa.flags & H5FD_LOG_TIME_SEEK) { - H5_timer_init(&seek_timer); + if (file->fa.flags & H5FD_LOG_TIME_SEEK) H5_timer_start(&seek_timer); - } /* end if */ if (HDlseek(file->fd, (HDoff_t)addr, SEEK_SET) < 0) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") @@ -1227,7 +1235,7 @@ H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, hadd if (file->fa.flags & H5FD_LOG_TIME_SEEK) { H5_timer_get_times(seek_timer, &seek_times); file->total_seek_time += seek_times.elapsed; - } /* end if */ + } /* Emit log string if we're tracking individual seek events. */ if (file->fa.flags & H5FD_LOG_LOC_SEEK) { @@ -1241,15 +1249,13 @@ H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, hadd HDfprintf(file->logfp, " (%fs @ %f)\n", seek_times.elapsed, seek_timer.initial.elapsed); else HDfprintf(file->logfp, "\n"); - } /* end if */ - } /* end if */ -#endif /* H5_HAVE_PREADWRITE */ + } + } +#endif /* H5_HAVE_PREADWRITE */ /* Start timer for read operation */ - if (file->fa.flags & H5FD_LOG_TIME_READ) { - H5_timer_init(&read_timer); + if (file->fa.flags & H5FD_LOG_TIME_READ) H5_timer_start(&read_timer); - } /* end if */ /* * Read data, being careful of interrupted system calls, partial results, @@ -1294,13 +1300,13 @@ H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, hadd HDctime(&mytime), file->filename, file->fd, myerrno, HDstrerror(myerrno), buf, (unsigned long long)size, (unsigned long long)bytes_in, (unsigned long long)bytes_read, (unsigned long long)offset); - } /* end if */ + } if (0 == bytes_read) { - /* end of file but not end of format address space */ + /* End of file but not end of format address space */ HDmemset(buf, 0, size); break; - } /* end if */ + } HDassert(bytes_read >= 0); HDassert((size_t)bytes_read <= size); @@ -1308,8 +1314,7 @@ H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, hadd size -= (size_t)bytes_read; addr += (haddr_t)bytes_read; buf = (char *)buf + bytes_read; - - } /* end while */ + } /* Stop timer for read operation */ if (file->fa.flags & H5FD_LOG_TIME_READ) @@ -1323,7 +1328,7 @@ H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, hadd if (file->fa.flags & H5FD_LOG_TIME_READ) { H5_timer_get_times(read_timer, &read_times); file->total_read_time += read_times.elapsed; - } /* end if */ + } /* Log information about the read */ if (file->fa.flags & H5FD_LOG_LOC_READ) { @@ -1337,7 +1342,7 @@ H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, hadd HDassert(type == H5FD_MEM_DEFAULT || type == (H5FD_mem_t)file->flavor[(orig_addr + orig_size) - 1] || (H5FD_mem_t)file->flavor[(orig_addr + orig_size) - 1] == H5FD_MEM_DEFAULT); - } /* end if */ + } /* Add the read time, if we're tracking that. * Note that the read time is NOT emitted for when just H5FD_LOG_TIME_READ @@ -1347,7 +1352,7 @@ H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, hadd HDfprintf(file->logfp, " (%fs @ %f)\n", read_times.elapsed, read_timer.initial.elapsed); else HDfprintf(file->logfp, "\n"); - } /* end if */ + } /* Update current position */ file->pos = addr; @@ -1358,13 +1363,13 @@ done: /* Reset last file I/O information */ file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; - } /* end if */ + } FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_log_read() */ +} /* end H5FD__log_read() */ /*------------------------------------------------------------------------- - * Function: H5FD_log_write + * Function: H5FD__log_write * * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR * from buffer BUF according to data transfer properties in @@ -1378,34 +1383,33 @@ done: *------------------------------------------------------------------------- */ 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_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 */ -#ifndef H5_HAVE_PREADWRITE - H5_timer_t seek_timer; /* Timer for seek operation */ - H5_timevals_t seek_times; /* Elapsed time for seek operation */ -#endif /* H5_HAVE_PREADWRITE */ - HDoff_t offset = (HDoff_t)addr; - herr_t ret_value = SUCCEED; /* Return value */ + HDoff_t offset = (HDoff_t)addr; + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC HDassert(file && file->pub.cls); HDassert(size > 0); HDassert(buf); + /* Initialize timer */ + H5_timer_init(&write_timer); + /* Verify that we are writing out the type of data we allocated in this location */ if (file->flavor) { HDassert(type == H5FD_MEM_DEFAULT || type == (H5FD_mem_t)file->flavor[addr] || (H5FD_mem_t)file->flavor[addr] == H5FD_MEM_DEFAULT); HDassert(type == H5FD_MEM_DEFAULT || type == (H5FD_mem_t)file->flavor[(addr + size) - 1] || (H5FD_mem_t)file->flavor[(addr + size) - 1] == H5FD_MEM_DEFAULT); - } /* end if */ + } /* Check for overflow conditions */ if (!H5F_addr_defined(addr)) @@ -1423,16 +1427,21 @@ H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had HDassert((addr + size) < file->iosize); while (tmp_size-- > 0) file->nwrite[tmp_addr++]++; - } /* end if */ + } #ifndef H5_HAVE_PREADWRITE /* Seek to the correct location (if we don't have pwrite) */ if (addr != file->pos || OP_WRITE != file->op) { + + H5_timer_t seek_timer; /* Timer for seek operation */ + H5_timevals_t seek_times; /* Elapsed time for seek operation */ + + /* Initialize timer */ + H5_timer_init(&seek_timer); + /* Start timer for seek() call */ - if (file->fa.flags & H5FD_LOG_TIME_SEEK) { - H5_timer_init(&seek_timer); + if (file->fa.flags & H5FD_LOG_TIME_SEEK) H5_timer_start(&seek_timer); - } /* end if */ if (HDlseek(file->fd, (HDoff_t)addr, SEEK_SET) < 0) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") @@ -1449,7 +1458,7 @@ H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had if (file->fa.flags & H5FD_LOG_TIME_SEEK) { H5_timer_get_times(seek_timer, &seek_times); file->total_seek_time += seek_times.elapsed; - } /* end if */ + } /* Emit log string if we're tracking individual seek events. */ if (file->fa.flags & H5FD_LOG_LOC_SEEK) { @@ -1463,15 +1472,13 @@ H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had HDfprintf(file->logfp, " (%fs @ %f)\n", seek_times.elapsed, seek_timer.initial.elapsed); else HDfprintf(file->logfp, "\n"); - } /* end if */ - } /* end if */ -#endif /* H5_HAVE_PREADWRITE */ + } + } +#endif /* H5_HAVE_PREADWRITE */ /* Start timer for write operation */ - if (file->fa.flags & H5FD_LOG_TIME_WRITE) { - H5_timer_init(&write_timer); + if (file->fa.flags & H5FD_LOG_TIME_WRITE) H5_timer_start(&write_timer); - } /* end if */ /* * Write the data, being careful of interrupted system calls and partial @@ -1538,12 +1545,12 @@ H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had if (file->fa.flags & H5FD_LOG_TIME_WRITE) { H5_timer_get_times(write_timer, &write_times); file->total_write_time += write_times.elapsed; - } /* end if */ + } /* Log information about the write */ if (file->fa.flags & H5FD_LOG_LOC_WRITE) { - HDfprintf(file->logfp, "%10a-%10a (%10Zu bytes) (%s) Written", orig_addr, (orig_addr + orig_size) - 1, - orig_size, flavors[type]); + HDfprintf(file->logfp, "%10" PRIuHADDR "-%10" PRIuHADDR " (%10zu bytes) (%s) Written", orig_addr, + (orig_addr + orig_size) - 1, orig_size, flavors[type]); /* Check if this is the first write into a "default" section, grabbed by the metadata agregation * algorithm */ @@ -1551,8 +1558,8 @@ H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had if ((H5FD_mem_t)file->flavor[orig_addr] == H5FD_MEM_DEFAULT) { HDmemset(&file->flavor[orig_addr], (int)type, orig_size); HDfprintf(file->logfp, " (fresh)"); - } /* end if */ - } /* end if */ + } + } /* Add the write time, if we're tracking that. * Note that the write time is NOT emitted for when just H5FD_LOG_TIME_WRITE @@ -1562,7 +1569,7 @@ H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had HDfprintf(file->logfp, " (%fs @ %f)\n", write_times.elapsed, write_timer.initial.elapsed); else HDfprintf(file->logfp, "\n"); - } /* end if */ + } /* Update current position and eof */ file->pos = addr; @@ -1575,13 +1582,13 @@ done: /* Reset last file I/O information */ file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; - } /* end if */ + } FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_log_write() */ +} /* end H5FD__log_write() */ /*------------------------------------------------------------------------- - * Function: H5FD_log_truncate + * Function: H5FD__log_truncate * * Purpose: Makes sure that the true file size is the same (or larger) * than the end-of-address. @@ -1594,12 +1601,12 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_log_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_UNUSED closing) +H5FD__log_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_UNUSED closing) { H5FD_log_t *file = (H5FD_log_t *)_file; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC HDassert(file); @@ -1608,11 +1615,12 @@ H5FD_log_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_U H5_timer_t trunc_timer; /* Timer for truncate operation */ H5_timevals_t trunc_times; /* Elapsed time for truncate operation */ + /* Initialize timer */ + H5_timer_init(&trunc_timer); + /* Start timer for truncate operation */ - if (file->fa.flags & H5FD_LOG_TIME_TRUNCATE) { - H5_timer_init(&trunc_timer); + if (file->fa.flags & H5FD_LOG_TIME_TRUNCATE) H5_timer_start(&trunc_timer); - } /* end if */ #ifdef H5_HAVE_WIN32_API { @@ -1636,7 +1644,7 @@ H5FD_log_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_U dwError = GetLastError(); if (dwError != NO_ERROR) HGOTO_ERROR(H5E_FILE, H5E_FILEOPEN, FAIL, "unable to set file pointer") - } /* end if */ + } if (0 == SetEndOfFile(file->hFile)) HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") @@ -1659,11 +1667,11 @@ H5FD_log_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_U if (file->fa.flags & H5FD_LOG_TIME_TRUNCATE) { H5_timer_get_times(trunc_timer, &trunc_times); file->total_truncate_time += trunc_times.elapsed; - } /* end if */ + } /* Emit log string if we're tracking individual truncate events. */ if (file->fa.flags & H5FD_LOG_TRUNCATE) { - HDfprintf(file->logfp, "Truncate: To %10a", file->eoa); + HDfprintf(file->logfp, "Truncate: To %10" PRIuHADDR, file->eoa); /* Add the truncate time, if we're tracking that. * Note that the truncate time is NOT emitted for when just H5FD_LOG_TIME_TRUNCATE @@ -1673,7 +1681,7 @@ H5FD_log_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_U HDfprintf(file->logfp, " (%fs @ %f)\n", trunc_times.elapsed, trunc_timer.initial.elapsed); else HDfprintf(file->logfp, "\n"); - } /* end if */ + } /* Update the eof value */ file->eof = file->eoa; @@ -1685,10 +1693,10 @@ H5FD_log_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_U done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_log_truncate() */ +} /* end H5FD__log_truncate() */ /*------------------------------------------------------------------------- - * Function: H5FD_log_lock + * Function: H5FD__log_lock * * Purpose: Place a lock on the file * @@ -1700,13 +1708,13 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_log_lock(H5FD_t *_file, hbool_t rw) +H5FD__log_lock(H5FD_t *_file, hbool_t rw) { H5FD_log_t *file = (H5FD_log_t *)_file; /* VFD file struct */ int lock_flags; /* file locking flags */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Sanity check */ HDassert(file); @@ -1728,10 +1736,10 @@ H5FD_log_lock(H5FD_t *_file, hbool_t rw) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_log_lock() */ +} /* end H5FD__log_lock() */ /*------------------------------------------------------------------------- - * Function: H5FD_log_unlock + * Function: H5FD__log_unlock * * Purpose: Remove the existing lock on the file * @@ -1742,12 +1750,12 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_log_unlock(H5FD_t *_file) +H5FD__log_unlock(H5FD_t *_file) { H5FD_log_t *file = (H5FD_log_t *)_file; /* VFD file struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC HDassert(file); @@ -1764,4 +1772,4 @@ H5FD_log_unlock(H5FD_t *_file) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_log_unlock() */ +} /* end H5FD__log_unlock() */ diff --git a/src/H5FDmirror.c b/src/H5FDmirror.c index 2b4b158..2f145a4 100644 --- a/src/H5FDmirror.c +++ b/src/H5FDmirror.c @@ -21,14 +21,15 @@ #ifdef H5_HAVE_MIRROR_VFD -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FDmirror.h" /* "Mirror" definitions */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDmirror.h" /* "Mirror" definitions */ +#include "H5FDmirror_priv.h" /* Private header for the mirror VFD */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ /* The driver identification number, initialized at runtime */ static hid_t H5FD_MIRROR_g = 0; @@ -131,72 +132,78 @@ typedef struct H5FD_mirror_t { #define LOG_OP_CALL(name) \ do { \ HDprintf("called %s()\n", (name)); \ - fflush(stdout); \ + HDfflush(stdout); \ } while (0) #else #define LOG_OP_CALL(name) /* no-op */ #endif /* MIRROR_DEBUG_OP_CALLS */ /* Prototypes */ -static herr_t H5FD_mirror_term(void); -static void * H5FD_mirror_fapl_get(H5FD_t *_file); -static void * H5FD_mirror_fapl_copy(const void *_old_fa); -static herr_t H5FD_mirror_fapl_free(void *_fa); -static haddr_t H5FD_mirror_get_eoa(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD_mirror_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); -static haddr_t H5FD_mirror_get_eof(const H5FD_t *_file, H5FD_mem_t type); -static H5FD_t *H5FD_mirror_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); -static herr_t H5FD_mirror_close(H5FD_t *_file); -static herr_t H5FD_mirror_query(const H5FD_t *_file, unsigned long *flags); -static herr_t H5FD_mirror_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, - const void *buf); -static herr_t H5FD_mirror_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, - void *buf); -static herr_t H5FD_mirror_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); -static herr_t H5FD_mirror_lock(H5FD_t *_file, hbool_t rw); -static herr_t H5FD_mirror_unlock(H5FD_t *_file); +static herr_t H5FD__mirror_term(void); +static void * H5FD__mirror_fapl_get(H5FD_t *_file); +static void * H5FD__mirror_fapl_copy(const void *_old_fa); +static herr_t H5FD__mirror_fapl_free(void *_fa); +static haddr_t H5FD__mirror_get_eoa(const H5FD_t *_file, H5FD_mem_t type); +static herr_t H5FD__mirror_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); +static haddr_t H5FD__mirror_get_eof(const H5FD_t *_file, H5FD_mem_t type); +static H5FD_t *H5FD__mirror_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); +static herr_t H5FD__mirror_close(H5FD_t *_file); +static herr_t H5FD__mirror_query(const H5FD_t *_file, unsigned long *flags); +static herr_t H5FD__mirror_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + const void *buf); +static herr_t H5FD__mirror_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + void *buf); +static herr_t H5FD__mirror_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); +static herr_t H5FD__mirror_lock(H5FD_t *_file, hbool_t rw); +static herr_t H5FD__mirror_unlock(H5FD_t *_file); static herr_t H5FD__mirror_verify_reply(H5FD_mirror_t *file); static const H5FD_class_t H5FD_mirror_g = { - "mirror", /* name */ - MAXADDR, /* maxaddr */ - H5F_CLOSE_WEAK, /* fc_degree */ - H5FD_mirror_term, /* terminate */ - NULL, /* sb_size */ - NULL, /* sb_encode */ - NULL, /* sb_decode */ - 0, /* fapl_size */ - H5FD_mirror_fapl_get, /* fapl_get */ - H5FD_mirror_fapl_copy, /* fapl_copy */ - H5FD_mirror_fapl_free, /* fapl_free */ - 0, /* dxpl_size */ - NULL, /* dxpl_copy */ - NULL, /* dxpl_free */ - H5FD_mirror_open, /* open */ - H5FD_mirror_close, /* close */ - NULL, /* cmp */ - H5FD_mirror_query, /* query */ - NULL, /* get_type_map */ - NULL, /* alloc */ - NULL, /* free */ - H5FD_mirror_get_eoa, /* get_eoa */ - H5FD_mirror_set_eoa, /* set_eoa */ - H5FD_mirror_get_eof, /* get_eof */ - NULL, /* get_handle */ - H5FD_mirror_read, /* read */ - H5FD_mirror_write, /* write */ - NULL, /* flush */ - H5FD_mirror_truncate, /* truncate */ - H5FD_mirror_lock, /* lock */ - H5FD_mirror_unlock, /* unlock */ + "mirror", /* name */ + MAXADDR, /* maxaddr */ + H5F_CLOSE_WEAK, /* fc_degree */ + H5FD__mirror_term, /* terminate */ + NULL, /* sb_size */ + NULL, /* sb_encode */ + NULL, /* sb_decode */ + 0, /* fapl_size */ + H5FD__mirror_fapl_get, /* fapl_get */ + H5FD__mirror_fapl_copy, /* fapl_copy */ + H5FD__mirror_fapl_free, /* fapl_free */ + 0, /* dxpl_size */ + NULL, /* dxpl_copy */ + NULL, /* dxpl_free */ + H5FD__mirror_open, /* open */ + H5FD__mirror_close, /* close */ + NULL, /* cmp */ + H5FD__mirror_query, /* query */ + NULL, /* get_type_map */ + NULL, /* alloc */ + NULL, /* free */ + H5FD__mirror_get_eoa, /* get_eoa */ + H5FD__mirror_set_eoa, /* set_eoa */ + H5FD__mirror_get_eof, /* get_eof */ + NULL, /* get_handle */ + H5FD__mirror_read, /* read */ + H5FD__mirror_write, /* write */ + NULL, /* flush */ + H5FD__mirror_truncate, /* truncate */ + H5FD__mirror_lock, /* lock */ + H5FD__mirror_unlock, /* unlock */ NULL, /* dedup */ - H5FD_FLMAP_DICHOTOMY /* fl_map */ + H5FD_FLMAP_DICHOTOMY /* fl_map */ }; +/* Declare a free list to manage the transmission buffers */ +H5FL_BLK_DEFINE_STATIC(xmit); + /* Declare a free list to manage the H5FD_mirror_t struct */ H5FL_DEFINE_STATIC(H5FD_mirror_t); +/* Declare a free list to manage the H5FD_mirror_xmit_open_t struct */ +H5FL_DEFINE_STATIC(H5FD_mirror_xmit_open_t); + /*------------------------------------------------------------------------- * Function: H5FD__init_package * @@ -212,11 +219,10 @@ H5FD__init_package(void) FUNC_ENTER_STATIC - LOG_OP_CALL("H5FD__init_package"); + LOG_OP_CALL(FUNC); - if (H5FD_mirror_init() < 0) { + if (H5FD_mirror_init() < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize mirror VFD"); - } done: FUNC_LEAVE_NOAPI(ret_value) @@ -237,13 +243,12 @@ H5FD_mirror_init(void) { hid_t ret_value = H5I_INVALID_HID; - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI(H5I_INVALID_HID) - LOG_OP_CALL("H5FD_mirror_init"); + LOG_OP_CALL(FUNC); - if (H5I_VFL != H5I_get_type(H5FD_MIRROR_g)) { + if (H5I_VFL != H5I_get_type(H5FD_MIRROR_g)) H5FD_MIRROR_g = H5FD_register(&H5FD_mirror_g, sizeof(H5FD_class_t), FALSE); - } ret_value = H5FD_MIRROR_g; @@ -252,7 +257,7 @@ done: } /* end H5FD_mirror_init() */ /* --------------------------------------------------------------------------- - * Function: H5FD_mirror_term + * Function: H5FD__mirror_term * * Purpose: Shut down the VFD * @@ -260,17 +265,17 @@ done: * --------------------------------------------------------------------------- */ static herr_t -H5FD_mirror_term(void) +H5FD__mirror_term(void) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Reset VFL ID */ H5FD_MIRROR_g = 0; - LOG_OP_CALL("H5FD_mirror_term"); + LOG_OP_CALL(FUNC); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5FD_mirror_term() */ +} /* end H5FD__mirror_term() */ /* --------------------------------------------------------------------------- * Function: H5FD__mirror_xmit_decode_uint16 @@ -289,10 +294,14 @@ size_t H5FD__mirror_xmit_decode_uint16(uint16_t *out, const unsigned char *_buf) { uint16_t n = 0; - LOG_OP_CALL("H5FD__mirror_xmit_decode_uint16"); + + LOG_OP_CALL(__func__); + HDassert(_buf && out); - HDmemcpy(&n, _buf, sizeof(n)); + + H5MM_memcpy(&n, _buf, sizeof(n)); *out = (uint16_t)HDntohs(n); + return 2; /* number of bytes eaten */ } /* end H5FD__mirror_xmit_decode_uint16() */ @@ -313,10 +322,14 @@ size_t H5FD__mirror_xmit_decode_uint32(uint32_t *out, const unsigned char *_buf) { uint32_t n = 0; - LOG_OP_CALL("H5FD__mirror_xmit_decode_uint32"); + + LOG_OP_CALL(__func__); + HDassert(_buf && out); - HDmemcpy(&n, _buf, sizeof(n)); + + H5MM_memcpy(&n, _buf, sizeof(n)); *out = (uint32_t)HDntohl(n); + return 4; /* number of bytes eaten */ } /* end H5FD__mirror_xmit_decode_uint32() */ @@ -342,12 +355,11 @@ is_host_little_endian(void) uint8_t u8[4]; } echeck; echeck.u32 = 0xA1B2C3D4; - if (echeck.u8[0] == 0xD4) { + + if (echeck.u8[0] == 0xD4) return TRUE; - } - else { + else return FALSE; - } } /* end is_host_little_endian() */ /* --------------------------------------------------------------------------- @@ -369,15 +381,17 @@ size_t H5FD__mirror_xmit_decode_uint64(uint64_t *out, const unsigned char *_buf) { uint64_t n = 0; - LOG_OP_CALL("H5FD__mirror_xmit_decode_uint64"); + + LOG_OP_CALL(__func__); + HDassert(_buf && out); - HDmemcpy(&n, _buf, sizeof(n)); - if (TRUE == is_host_little_endian()) { + + H5MM_memcpy(&n, _buf, sizeof(n)); + if (TRUE == is_host_little_endian()) *out = BSWAP_64(n); - } - else { + else *out = n; - } + return 8; } /* end H5FD__mirror_xmit_decode_uint64() */ @@ -395,9 +409,12 @@ H5FD__mirror_xmit_decode_uint64(uint64_t *out, const unsigned char *_buf) size_t H5FD__mirror_xmit_decode_uint8(uint8_t *out, const unsigned char *_buf) { - LOG_OP_CALL("H5FD__mirror_xmit_decode_uint8"); + LOG_OP_CALL(__func__); + HDassert(_buf && out); - HDmemcpy(out, _buf, sizeof(uint8_t)); + + H5MM_memcpy(out, _buf, sizeof(uint8_t)); + return 1; /* number of bytes eaten */ } /* end H5FD__mirror_xmit_decode_uint8() */ @@ -417,10 +434,14 @@ size_t H5FD__mirror_xmit_encode_uint16(unsigned char *_dest, uint16_t v) { uint16_t n = 0; - LOG_OP_CALL("H5FD__mirror_xmit_encode_uint16"); + + LOG_OP_CALL(__func__); + HDassert(_dest); + n = (uint16_t)HDhtons(v); - HDmemcpy(_dest, &n, sizeof(n)); + H5MM_memcpy(_dest, &n, sizeof(n)); + return 2; } /* end H5FD__mirror_xmit_encode_uint16() */ @@ -440,10 +461,14 @@ size_t H5FD__mirror_xmit_encode_uint32(unsigned char *_dest, uint32_t v) { uint32_t n = 0; - LOG_OP_CALL("H5FD__mirror_xmit_encode_uint32"); + + LOG_OP_CALL(__func__); + HDassert(_dest); + n = (uint32_t)HDhtonl(v); - HDmemcpy(_dest, &n, sizeof(n)); + H5MM_memcpy(_dest, &n, sizeof(n)); + return 4; } /* end H5FD__mirror_xmit_encode_uint32() */ @@ -463,12 +488,15 @@ size_t H5FD__mirror_xmit_encode_uint64(unsigned char *_dest, uint64_t v) { uint64_t n = v; - LOG_OP_CALL("H5FD__mirror_xmit_decode_uint64"); + + LOG_OP_CALL(__func__); + HDassert(_dest); - if (TRUE == is_host_little_endian()) { + + if (TRUE == is_host_little_endian()) n = BSWAP_64(v); - } - HDmemcpy(_dest, &n, sizeof(n)); + H5MM_memcpy(_dest, &n, sizeof(n)); + return 8; } /* H5FD__mirror_xmit_encode_uint64() */ @@ -488,9 +516,12 @@ H5FD__mirror_xmit_encode_uint64(unsigned char *_dest, uint64_t v) size_t H5FD__mirror_xmit_encode_uint8(unsigned char *dest, uint8_t v) { - LOG_OP_CALL("H5FD__mirror_xmit_encode_uint8"); + LOG_OP_CALL(__func__); + HDassert(dest); - HDmemcpy(dest, &v, sizeof(v)); + + H5MM_memcpy(dest, &v, sizeof(v)); + return 1; } /* end H5FD__mirror_xmit_encode_uint8() */ @@ -517,14 +548,18 @@ size_t H5FD_mirror_xmit_decode_header(H5FD_mirror_xmit_t *out, const unsigned char *buf) { size_t n_eaten = 0; - LOG_OP_CALL("H5FD_mirror_xmit_decode_header"); + + LOG_OP_CALL(__func__); + HDassert(out && buf); + n_eaten += H5FD__mirror_xmit_decode_uint32(&(out->magic), &buf[n_eaten]); n_eaten += H5FD__mirror_xmit_decode_uint8(&(out->version), &buf[n_eaten]); n_eaten += H5FD__mirror_xmit_decode_uint32(&(out->session_token), &buf[n_eaten]); n_eaten += H5FD__mirror_xmit_decode_uint32(&(out->xmit_count), &buf[n_eaten]); n_eaten += H5FD__mirror_xmit_decode_uint8(&(out->op), &buf[n_eaten]); HDassert(n_eaten == H5FD_MIRROR_XMIT_HEADER_SIZE); + return n_eaten; } /* end H5FD_mirror_xmit_decode_header() */ @@ -551,11 +586,15 @@ size_t H5FD_mirror_xmit_decode_lock(H5FD_mirror_xmit_lock_t *out, const unsigned char *buf) { size_t n_eaten = 0; - LOG_OP_CALL("H5FD_mirror_xmit_decode_lock"); + + LOG_OP_CALL(__func__); + HDassert(out && buf); + n_eaten += H5FD_mirror_xmit_decode_header(&(out->pub), buf); n_eaten += H5FD__mirror_xmit_decode_uint64(&(out->rw), &buf[n_eaten]); HDassert(n_eaten == H5FD_MIRROR_XMIT_LOCK_SIZE); + return n_eaten; } /* end H5FD_mirror_xmit_decode_lock() */ @@ -583,8 +622,11 @@ size_t H5FD_mirror_xmit_decode_open(H5FD_mirror_xmit_open_t *out, const unsigned char *buf) { size_t n_eaten = 0; - LOG_OP_CALL("H5FD_mirror_xmit_decode_open"); + + LOG_OP_CALL(__func__); + HDassert(out && buf); + n_eaten += H5FD_mirror_xmit_decode_header(&(out->pub), buf); n_eaten += H5FD__mirror_xmit_decode_uint32(&(out->flags), &buf[n_eaten]); n_eaten += H5FD__mirror_xmit_decode_uint64(&(out->maxaddr), &buf[n_eaten]); @@ -592,6 +634,7 @@ H5FD_mirror_xmit_decode_open(H5FD_mirror_xmit_open_t *out, const unsigned char * HDassert((H5FD_MIRROR_XMIT_OPEN_SIZE - H5FD_MIRROR_XMIT_FILEPATH_MAX) == n_eaten); HDstrncpy(out->filename, (const char *)&buf[n_eaten], H5FD_MIRROR_XMIT_FILEPATH_MAX - 1); out->filename[H5FD_MIRROR_XMIT_FILEPATH_MAX - 1] = 0; /* force final NULL */ + return H5FD_MIRROR_XMIT_OPEN_SIZE; } /* end H5FD_mirror_xmit_decode_open() */ @@ -619,13 +662,17 @@ size_t H5FD_mirror_xmit_decode_reply(H5FD_mirror_xmit_reply_t *out, const unsigned char *buf) { size_t n_eaten = 0; - LOG_OP_CALL("H5FD_mirror_xmit_decode_reply"); + + LOG_OP_CALL(__func__); + HDassert(out && buf); + n_eaten += H5FD_mirror_xmit_decode_header(&(out->pub), buf); n_eaten += H5FD__mirror_xmit_decode_uint32(&(out->status), &buf[n_eaten]); HDassert((H5FD_MIRROR_XMIT_REPLY_SIZE - H5FD_MIRROR_STATUS_MESSAGE_MAX) == n_eaten); HDstrncpy(out->message, (const char *)&buf[n_eaten], H5FD_MIRROR_STATUS_MESSAGE_MAX - 1); out->message[H5FD_MIRROR_STATUS_MESSAGE_MAX - 1] = 0; /* force NULL term */ + return H5FD_MIRROR_XMIT_REPLY_SIZE; } /* end H5FD_mirror_xmit_decode_reply() */ @@ -652,12 +699,16 @@ size_t H5FD_mirror_xmit_decode_set_eoa(H5FD_mirror_xmit_eoa_t *out, const unsigned char *buf) { size_t n_eaten = 0; - LOG_OP_CALL("H5FD_mirror_xmit_decode_set_eoa"); + + LOG_OP_CALL(__func__); + HDassert(out && buf); + n_eaten += H5FD_mirror_xmit_decode_header(&(out->pub), buf); n_eaten += H5FD__mirror_xmit_decode_uint8(&(out->type), &buf[n_eaten]); n_eaten += H5FD__mirror_xmit_decode_uint64(&(out->eoa_addr), &buf[n_eaten]); HDassert(n_eaten == H5FD_MIRROR_XMIT_EOA_SIZE); + return n_eaten; } /* end H5FD_mirror_xmit_decode_set_eoa() */ @@ -684,13 +735,17 @@ size_t H5FD_mirror_xmit_decode_write(H5FD_mirror_xmit_write_t *out, const unsigned char *buf) { size_t n_eaten = 0; - LOG_OP_CALL("H5FD_mirror_xmit_decode_write"); + + LOG_OP_CALL(__func__); + HDassert(out && buf); + n_eaten += H5FD_mirror_xmit_decode_header(&(out->pub), buf); n_eaten += H5FD__mirror_xmit_decode_uint8(&(out->type), &buf[n_eaten]); n_eaten += H5FD__mirror_xmit_decode_uint64(&(out->offset), &buf[n_eaten]); n_eaten += H5FD__mirror_xmit_decode_uint64(&(out->size), &buf[n_eaten]); HDassert(n_eaten == H5FD_MIRROR_XMIT_WRITE_SIZE); + return n_eaten; } /* end H5FD_mirror_xmit_decode_write() */ @@ -712,14 +767,18 @@ size_t H5FD_mirror_xmit_encode_header(unsigned char *dest, const H5FD_mirror_xmit_t *x) { size_t n_writ = 0; - LOG_OP_CALL("H5FD_mirror_xmit_encode_header"); + + LOG_OP_CALL(__func__); + HDassert(dest && x); + n_writ += H5FD__mirror_xmit_encode_uint32((dest + n_writ), x->magic); n_writ += H5FD__mirror_xmit_encode_uint8((dest + n_writ), x->version); n_writ += H5FD__mirror_xmit_encode_uint32((dest + n_writ), x->session_token); n_writ += H5FD__mirror_xmit_encode_uint32((dest + n_writ), x->xmit_count); n_writ += H5FD__mirror_xmit_encode_uint8((dest + n_writ), x->op); HDassert(n_writ == H5FD_MIRROR_XMIT_HEADER_SIZE); + return n_writ; } /* end H5FD_mirror_xmit_encode_header() */ @@ -740,11 +799,15 @@ size_t H5FD_mirror_xmit_encode_lock(unsigned char *dest, const H5FD_mirror_xmit_lock_t *x) { size_t n_writ = 0; - LOG_OP_CALL("H5FD_mirror_xmit_encode_lock"); + + LOG_OP_CALL(__func__); + HDassert(dest && x); + n_writ += H5FD_mirror_xmit_encode_header(dest, (const H5FD_mirror_xmit_t *)&(x->pub)); n_writ += H5FD__mirror_xmit_encode_uint64(&dest[n_writ], x->rw); HDassert(n_writ == H5FD_MIRROR_XMIT_LOCK_SIZE); + return n_writ; } /* end H5FD_mirror_xmit_encode_lock() */ @@ -766,19 +829,21 @@ size_t H5FD_mirror_xmit_encode_open(unsigned char *dest, const H5FD_mirror_xmit_open_t *x) { size_t n_writ = 0; - LOG_OP_CALL("H5FD_mirror_xmit_encode_open"); + + LOG_OP_CALL(__func__); + HDassert(dest && x); + /* clear entire structure, but especially its filepath string area */ - for (n_writ = 0; n_writ < H5FD_MIRROR_XMIT_OPEN_SIZE; n_writ++) { - *(dest + n_writ) = 0; - } - n_writ = 0; + HDmemset(dest, 0, H5FD_MIRROR_XMIT_OPEN_SIZE); + n_writ += H5FD_mirror_xmit_encode_header(dest, (const H5FD_mirror_xmit_t *)&(x->pub)); n_writ += H5FD__mirror_xmit_encode_uint32(&dest[n_writ], x->flags); n_writ += H5FD__mirror_xmit_encode_uint64(&dest[n_writ], x->maxaddr); n_writ += H5FD__mirror_xmit_encode_uint64(&dest[n_writ], x->size_t_blob); HDassert((H5FD_MIRROR_XMIT_OPEN_SIZE - H5FD_MIRROR_XMIT_FILEPATH_MAX) == n_writ); HDstrncpy((char *)&dest[n_writ], x->filename, H5FD_MIRROR_XMIT_FILEPATH_MAX); + return H5FD_MIRROR_XMIT_OPEN_SIZE; } /* end H5FD_mirror_xmit_encode_open() */ @@ -801,17 +866,19 @@ size_t H5FD_mirror_xmit_encode_reply(unsigned char *dest, const H5FD_mirror_xmit_reply_t *x) { size_t n_writ = 0; - LOG_OP_CALL("H5FD_mirror_xmit_encode_reply"); + + LOG_OP_CALL(__func__); + HDassert(dest && x); + /* clear entire structure, but especially its message string area */ - for (n_writ = 0; n_writ < H5FD_MIRROR_XMIT_REPLY_SIZE; n_writ++) { - *(dest + n_writ) = 0; - } - n_writ = 0; + HDmemset(dest, 0, H5FD_MIRROR_XMIT_REPLY_SIZE); + n_writ += H5FD_mirror_xmit_encode_header(dest, (const H5FD_mirror_xmit_t *)&(x->pub)); n_writ += H5FD__mirror_xmit_encode_uint32(&dest[n_writ], x->status); HDassert((H5FD_MIRROR_XMIT_REPLY_SIZE - H5FD_MIRROR_STATUS_MESSAGE_MAX) == n_writ); HDstrncpy((char *)&dest[n_writ], x->message, H5FD_MIRROR_STATUS_MESSAGE_MAX); + return H5FD_MIRROR_XMIT_REPLY_SIZE; } /* end H5FD_mirror_xmit_encode_reply() */ @@ -833,12 +900,16 @@ size_t H5FD_mirror_xmit_encode_set_eoa(unsigned char *dest, const H5FD_mirror_xmit_eoa_t *x) { size_t n_writ = 0; - LOG_OP_CALL("H5FD_mirror_xmit_encode_set_eoa"); + + LOG_OP_CALL(__func__); + HDassert(dest && x); + n_writ += H5FD_mirror_xmit_encode_header(dest, (const H5FD_mirror_xmit_t *)&(x->pub)); n_writ += H5FD__mirror_xmit_encode_uint8(&dest[n_writ], x->type); n_writ += H5FD__mirror_xmit_encode_uint64(&dest[n_writ], x->eoa_addr); HDassert(n_writ == H5FD_MIRROR_XMIT_EOA_SIZE); + return n_writ; } /* end H5FD_mirror_xmit_encode_set_eoa() */ @@ -860,13 +931,17 @@ size_t H5FD_mirror_xmit_encode_write(unsigned char *dest, const H5FD_mirror_xmit_write_t *x) { size_t n_writ = 0; - LOG_OP_CALL("H5FD_mirror_xmit_encode_write"); + + LOG_OP_CALL(__func__); + HDassert(dest && x); + n_writ += H5FD_mirror_xmit_encode_header(dest, (const H5FD_mirror_xmit_t *)&(x->pub)); n_writ += H5FD__mirror_xmit_encode_uint8(&dest[n_writ], x->type); n_writ += H5FD__mirror_xmit_encode_uint64(&dest[n_writ], x->offset); n_writ += H5FD__mirror_xmit_encode_uint64(&dest[n_writ], x->size); HDassert(n_writ == H5FD_MIRROR_XMIT_WRITE_SIZE); + return n_writ; } /* end H5FD_mirror_xmit_encode_write() */ @@ -880,14 +955,16 @@ H5FD_mirror_xmit_encode_write(unsigned char *dest, const H5FD_mirror_xmit_write_ * Return: TRUE if valid; else FALSE. * --------------------------------------------------------------------------- */ -hbool_t +H5_ATTR_PURE hbool_t H5FD_mirror_xmit_is_close(const H5FD_mirror_xmit_t *xmit) { - LOG_OP_CALL("H5FD_mirror_xmit_is_close"); + LOG_OP_CALL(__func__); + HDassert(xmit); - if ((TRUE == H5FD_mirror_xmit_is_xmit(xmit)) && (H5FD_MIRROR_OP_CLOSE == xmit->op)) { + + if ((TRUE == H5FD_mirror_xmit_is_xmit(xmit)) && (H5FD_MIRROR_OP_CLOSE == xmit->op)) return TRUE; - } + return FALSE; } /* end H5FD_mirror_xmit_is_close() */ @@ -901,14 +978,16 @@ H5FD_mirror_xmit_is_close(const H5FD_mirror_xmit_t *xmit) * Return: TRUE if valid; else FALSE. * --------------------------------------------------------------------------- */ -hbool_t +H5_ATTR_PURE hbool_t H5FD_mirror_xmit_is_lock(const H5FD_mirror_xmit_lock_t *xmit) { - LOG_OP_CALL("H5FD_mirror_xmit_is_lock"); + LOG_OP_CALL(__func__); + HDassert(xmit); - if ((TRUE == H5FD_mirror_xmit_is_xmit(&(xmit->pub))) && (H5FD_MIRROR_OP_LOCK == xmit->pub.op)) { + + if ((TRUE == H5FD_mirror_xmit_is_xmit(&(xmit->pub))) && (H5FD_MIRROR_OP_LOCK == xmit->pub.op)) return TRUE; - } + return FALSE; } /* end H5FD_mirror_xmit_is_lock() */ @@ -922,14 +1001,17 @@ H5FD_mirror_xmit_is_lock(const H5FD_mirror_xmit_lock_t *xmit) * Return: TRUE if valid; else FALSE. * --------------------------------------------------------------------------- */ -hbool_t +H5_ATTR_PURE hbool_t H5FD_mirror_xmit_is_open(const H5FD_mirror_xmit_open_t *xmit) { - LOG_OP_CALL("H5FD_mirror_xmit_is_open"); + LOG_OP_CALL(__func__); + HDassert(xmit); - if ((TRUE == H5FD_mirror_xmit_is_xmit(&(xmit->pub))) && (H5FD_MIRROR_OP_OPEN == xmit->pub.op)) { + + if ((TRUE == H5FD_mirror_xmit_is_xmit(&(xmit->pub))) && (H5FD_MIRROR_OP_OPEN == xmit->pub.op)) + return TRUE; - } + return FALSE; } /* end H5FD_mirror_xmit_is_open() */ @@ -943,14 +1025,16 @@ H5FD_mirror_xmit_is_open(const H5FD_mirror_xmit_open_t *xmit) * Return: TRUE if valid; else FALSE. * --------------------------------------------------------------------------- */ -hbool_t +H5_ATTR_PURE hbool_t H5FD_mirror_xmit_is_set_eoa(const H5FD_mirror_xmit_eoa_t *xmit) { - LOG_OP_CALL("H5FD_mirror_xmit_is_set_eoa"); + LOG_OP_CALL(__func__); + HDassert(xmit); - if ((TRUE == H5FD_mirror_xmit_is_xmit(&(xmit->pub))) && (H5FD_MIRROR_OP_SET_EOA == xmit->pub.op)) { + + if ((TRUE == H5FD_mirror_xmit_is_xmit(&(xmit->pub))) && (H5FD_MIRROR_OP_SET_EOA == xmit->pub.op)) return TRUE; - } + return FALSE; } /* end H5FD_mirror_xmit_is_eoa() */ @@ -964,14 +1048,16 @@ H5FD_mirror_xmit_is_set_eoa(const H5FD_mirror_xmit_eoa_t *xmit) * Return: TRUE if valid; else FALSE. * --------------------------------------------------------------------------- */ -hbool_t +H5_ATTR_PURE hbool_t H5FD_mirror_xmit_is_reply(const H5FD_mirror_xmit_reply_t *xmit) { - LOG_OP_CALL("H5FD_mirror_xmit_is_reply"); + LOG_OP_CALL(__func__); + HDassert(xmit); - if ((TRUE == H5FD_mirror_xmit_is_xmit(&(xmit->pub))) && (H5FD_MIRROR_OP_REPLY == xmit->pub.op)) { + + if ((TRUE == H5FD_mirror_xmit_is_xmit(&(xmit->pub))) && (H5FD_MIRROR_OP_REPLY == xmit->pub.op)) return TRUE; - } + return FALSE; } /* end H5FD_mirror_xmit_is_reply() */ @@ -985,14 +1071,16 @@ H5FD_mirror_xmit_is_reply(const H5FD_mirror_xmit_reply_t *xmit) * Return: TRUE if valid; else FALSE. * --------------------------------------------------------------------------- */ -hbool_t +H5_ATTR_PURE hbool_t H5FD_mirror_xmit_is_write(const H5FD_mirror_xmit_write_t *xmit) { - LOG_OP_CALL("H5FD_mirror_xmit_is_write"); + LOG_OP_CALL(__func__); + HDassert(xmit); - if ((TRUE == H5FD_mirror_xmit_is_xmit(&(xmit->pub))) && (H5FD_MIRROR_OP_WRITE == xmit->pub.op)) { + + if ((TRUE == H5FD_mirror_xmit_is_xmit(&(xmit->pub))) && (H5FD_MIRROR_OP_WRITE == xmit->pub.op)) return TRUE; - } + return FALSE; } /* end H5FD_mirror_xmit_is_write() */ @@ -1006,14 +1094,16 @@ H5FD_mirror_xmit_is_write(const H5FD_mirror_xmit_write_t *xmit) * Return: TRUE if valid; else FALSE. * --------------------------------------------------------------------------- */ -hbool_t +H5_ATTR_PURE hbool_t H5FD_mirror_xmit_is_xmit(const H5FD_mirror_xmit_t *xmit) { - LOG_OP_CALL("H5FD_mirror_xmit_is_xmit"); + LOG_OP_CALL(__func__); + HDassert(xmit); - if ((H5FD_MIRROR_XMIT_MAGIC != xmit->magic) || (H5FD_MIRROR_XMIT_CURR_VERSION != xmit->version)) { + + if ((H5FD_MIRROR_XMIT_MAGIC != xmit->magic) || (H5FD_MIRROR_XMIT_CURR_VERSION != xmit->version)) return FALSE; - } + return TRUE; } /* end H5FD_mirror_xmit_is_xmit() */ @@ -1028,57 +1118,54 @@ H5FD_mirror_xmit_is_xmit(const H5FD_mirror_xmit_t *xmit) * Return: SUCCEED if ok, else FAIL. * ---------------------------------------------------------------------------- */ -herr_t +static herr_t H5FD__mirror_verify_reply(H5FD_mirror_t *file) { - char xmit_buf[H5FD_MIRROR_XMIT_REPLY_SIZE]; + unsigned char * xmit_buf = NULL; struct H5FD_mirror_xmit_reply_t reply; ssize_t read_ret = 0; herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT; + FUNC_ENTER_STATIC - LOG_OP_CALL("H5FD__mirror_verify_reply"); + LOG_OP_CALL(FUNC); HDassert(file && file->sock_fd); + xmit_buf = H5FL_BLK_MALLOC(xmit, H5FD_MIRROR_XMIT_BUFFER_MAX); + if (NULL == xmit_buf) + HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, "unable to allocate xmit buffer"); + read_ret = HDread(file->sock_fd, xmit_buf, H5FD_MIRROR_XMIT_REPLY_SIZE); - if (read_ret < 0) { + if (read_ret < 0) HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "unable to read reply"); - } - if (read_ret != H5FD_MIRROR_XMIT_REPLY_SIZE) { + if (read_ret != H5FD_MIRROR_XMIT_REPLY_SIZE) HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "unexpected read size"); - } LOG_XMIT_BYTES("reply", xmit_buf, read_ret); - if (H5FD_mirror_xmit_decode_reply(&reply, (const unsigned char *)xmit_buf) != - H5FD_MIRROR_XMIT_REPLY_SIZE) { + if (H5FD_mirror_xmit_decode_reply(&reply, xmit_buf) != H5FD_MIRROR_XMIT_REPLY_SIZE) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "unable to decode reply xmit"); - } - if (H5FD_mirror_xmit_is_reply(&reply) != TRUE) { + if (H5FD_mirror_xmit_is_reply(&reply) != TRUE) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "xmit op code was not REPLY"); - } - if (reply.pub.session_token != file->xmit.session_token) { + if (reply.pub.session_token != file->xmit.session_token) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "wrong session"); - } - - if (reply.pub.xmit_count != (file->xmit_i)++) { + if (reply.pub.xmit_count != (file->xmit_i)++) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "xmit out of sync"); - } - - if (reply.status != H5FD_MIRROR_STATUS_OK) { + if (reply.status != H5FD_MIRROR_STATUS_OK) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "%s", (const char *)(reply.message)); - } done: + if (xmit_buf) + xmit_buf = H5FL_BLK_FREE(xmit, xmit_buf); + FUNC_LEAVE_NOAPI(ret_value); } /* end H5FD__mirror_verify_reply() */ /* ------------------------------------------------------------------------- - * Function: H5FD_mirror_fapl_get + * Function: H5FD__mirror_fapl_get * * Purpose: Get the file access propety list which could be used to create * an identical file. @@ -1088,36 +1175,34 @@ done: * ------------------------------------------------------------------------- */ static void * -H5FD_mirror_fapl_get(H5FD_t *_file) +H5FD__mirror_fapl_get(H5FD_t *_file) { H5FD_mirror_t * file = (H5FD_mirror_t *)_file; H5FD_mirror_fapl_t *fa = NULL; void * ret_value = NULL; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC - LOG_OP_CALL("H5FD_mirror_fapl_get"); + LOG_OP_CALL(FUNC); fa = (H5FD_mirror_fapl_t *)H5MM_calloc(sizeof(H5FD_mirror_fapl_t)); - if (NULL == fa) { - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "calloc failed"); - } + if (NULL == fa) + HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, NULL, "calloc failed"); - HDmemcpy(fa, &(file->fa), sizeof(H5FD_mirror_fapl_t)); + H5MM_memcpy(fa, &(file->fa), sizeof(H5FD_mirror_fapl_t)); ret_value = fa; done: - if (ret_value == NULL) { - if (fa != NULL) { + if (ret_value == NULL) + if (fa != NULL) H5MM_xfree(fa); - } - } + FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_mirror_fapl_get() */ +} /* end H5FD__mirror_fapl_get() */ /* ------------------------------------------------------------------------- - * Function: H5FD_mirror_fapl_copy + * Function: H5FD__mirror_fapl_copy * * Purpose: Copies the mirror vfd-specific file access properties. * @@ -1126,35 +1211,33 @@ done: * ------------------------------------------------------------------------- */ static void * -H5FD_mirror_fapl_copy(const void *_old_fa) +H5FD__mirror_fapl_copy(const void *_old_fa) { const H5FD_mirror_fapl_t *old_fa = (const H5FD_mirror_fapl_t *)_old_fa; H5FD_mirror_fapl_t * new_fa = NULL; void * ret_value = NULL; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC - LOG_OP_CALL("H5FD_mirror_fapl_copy"); + LOG_OP_CALL(FUNC); new_fa = (H5FD_mirror_fapl_t *)H5MM_malloc(sizeof(H5FD_mirror_fapl_t)); - if (new_fa == NULL) { - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); - } + if (new_fa == NULL) + HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, NULL, "memory allocation failed"); - HDmemcpy(new_fa, old_fa, sizeof(H5FD_mirror_fapl_t)); + H5MM_memcpy(new_fa, old_fa, sizeof(H5FD_mirror_fapl_t)); ret_value = new_fa; done: - if (ret_value == NULL) { - if (new_fa != NULL) { + if (ret_value == NULL) + if (new_fa != NULL) H5MM_xfree(new_fa); - } - } + FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_mirror_fapl_copy() */ +} /* end H5FD__mirror_fapl_copy() */ /*------------------------------------------------------------------------- - * Function: H5FD_mirror_fapl_free + * Function: H5FD__mirror_fapl_free * * Purpose: Frees the mirror VFD-specific file access properties. * @@ -1162,13 +1245,13 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_mirror_fapl_free(void *_fa) +H5FD__mirror_fapl_free(void *_fa) { H5FD_mirror_fapl_t *fa = (H5FD_mirror_fapl_t *)_fa; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR - LOG_OP_CALL("H5FD_mirror_fapl_free"); + LOG_OP_CALL(FUNC); /* sanity check */ HDassert(fa != NULL); @@ -1178,50 +1261,45 @@ H5FD_mirror_fapl_free(void *_fa) H5MM_xfree(fa); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5FD_mirror_fapl_free() */ +} /* end H5FD__mirror_fapl_free() */ /* ------------------------------------------------------------------------- * Function: H5Pget_fapl_mirror * * Purpose: Get the configuration information for this fapl. - * Data is memcopied into the fa_out pointer. + * Data is memcopied into the fa_dst pointer. * * Return: SUCCEED/FAIL * ------------------------------------------------------------------------- */ herr_t -H5Pget_fapl_mirror(hid_t fapl_id, H5FD_mirror_fapl_t *fa_out) +H5Pget_fapl_mirror(hid_t fapl_id, H5FD_mirror_fapl_t *fa_dst /*out*/) { - const H5FD_mirror_fapl_t *fa = NULL; + const H5FD_mirror_fapl_t *fa_src = NULL; H5P_genplist_t * plist = NULL; herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) - H5TRACE2("e", "i*#", fapl_id, fa_out); + H5TRACE2("e", "ix", fapl_id, fa_dst); - LOG_OP_CALL("H5Pget_fapl_mirror"); + LOG_OP_CALL(FUNC); - if (NULL == fa_out) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "fa_out is NULL"); - } + if (NULL == fa_dst) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "fa_dst is NULL"); plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS); - if (NULL == plist) { + if (NULL == plist) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list"); - } - - if (H5P_peek_driver(plist) != H5FD_MIRROR) { + if (H5P_peek_driver(plist) != H5FD_MIRROR) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver"); - } - fa = (const H5FD_mirror_fapl_t *)H5P_peek_driver_info(plist); - if (NULL == fa) { + fa_src = (const H5FD_mirror_fapl_t *)H5P_peek_driver_info(plist); + if (NULL == fa_src) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info"); - } - HDassert(fa->magic == H5FD_MIRROR_FAPL_MAGIC); /* sanity check */ + HDassert(fa_src->magic == H5FD_MIRROR_FAPL_MAGIC); /* sanity check */ - HDmemcpy(fa_out, fa, sizeof(H5FD_mirror_fapl_t)); + H5MM_memcpy(fa_dst, fa_src, sizeof(H5FD_mirror_fapl_t)); done: FUNC_LEAVE_API(ret_value); @@ -1245,21 +1323,17 @@ H5Pset_fapl_mirror(hid_t fapl_id, H5FD_mirror_fapl_t *fa) FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*#", fapl_id, fa); - LOG_OP_CALL("H5Pset_fapl_mirror"); + LOG_OP_CALL(FUNC); plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS); - if (NULL == plist) { + if (NULL == plist) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list"); - } - if (NULL == fa) { + if (NULL == fa) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null fapl_t pointer"); - } - if (H5FD_MIRROR_FAPL_MAGIC != fa->magic) { + if (H5FD_MIRROR_FAPL_MAGIC != fa->magic) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fapl_t magic"); - } - if (H5FD_MIRROR_CURR_FAPL_T_VERSION != fa->version) { + if (H5FD_MIRROR_CURR_FAPL_T_VERSION != fa->version) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unknown fapl_t version"); - } ret_value = H5P_set_driver(plist, H5FD_MIRROR, (const void *)fa); @@ -1268,7 +1342,7 @@ done: } /* end H5Pset_fapl_mirror() */ /*------------------------------------------------------------------------- - * Function: H5FD_mirror_open + * Function: H5FD__mirror_open * * Purpose: Create and/or opens a file as an HDF5 file. * @@ -1282,61 +1356,48 @@ done: *------------------------------------------------------------------------- */ static H5FD_t * -H5FD_mirror_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) +H5FD__mirror_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { -#define MIRR_OPEN_MAXBUF 16 /* local symbol to give meaning to magic number */ - /* #defined because it is needed at compile time */ - /* Large enough to hold a port number string */ - int live_socket = -1; - struct sockaddr_in target_addr; - socklen_t addr_size; - char xmit_buf[H5FD_MIRROR_XMIT_OPEN_SIZE]; - H5FD_mirror_fapl_t fa; - H5FD_mirror_t * file = NULL; - H5FD_mirror_xmit_open_t open_xmit; - H5FD_t * ret_value = NULL; - - FUNC_ENTER_NOAPI_NOINIT - - LOG_OP_CALL("H5FD_mirror_open"); + int live_socket = -1; + struct sockaddr_in target_addr; + socklen_t addr_size; + unsigned char * xmit_buf = NULL; + H5FD_mirror_fapl_t fa; + H5FD_mirror_t * file = NULL; + H5FD_mirror_xmit_open_t *open_xmit = NULL; + H5FD_t * ret_value = NULL; + + FUNC_ENTER_STATIC + + LOG_OP_CALL(FUNC); /* --------------- */ /* Check arguments */ /* --------------- */ - if (!name || !*name) { + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name"); - } - if (HDstrlen(name) >= H5FD_MIRROR_XMIT_FILEPATH_MAX) { + if (HDstrlen(name) >= H5FD_MIRROR_XMIT_FILEPATH_MAX) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "filename is too long"); - } - if (0 == maxaddr || HADDR_UNDEF == maxaddr) { + if (0 == maxaddr || HADDR_UNDEF == maxaddr) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr"); - } - if (ADDR_OVERFLOW(maxaddr)) { + if (ADDR_OVERFLOW(maxaddr)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "bogus maxaddr"); - } - if (H5Pget_fapl_mirror(fapl_id, &fa) == FAIL) { + if (H5Pget_fapl_mirror(fapl_id, &fa) == FAIL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "can't get config info"); - } - - if (H5FD_MIRROR_FAPL_MAGIC != fa.magic) { + if (H5FD_MIRROR_FAPL_MAGIC != fa.magic) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid fapl magic"); - } - - if (H5FD_MIRROR_CURR_FAPL_T_VERSION != fa.version) { + if (H5FD_MIRROR_CURR_FAPL_T_VERSION != fa.version) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid fapl version"); - } /* --------------------- */ /* Handshake with remote */ /* --------------------- */ live_socket = HDsocket(AF_INET, SOCK_STREAM, 0); - if (live_socket < 0) { + if (live_socket < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "can't create socket"); - } target_addr.sin_family = AF_INET; target_addr.sin_port = HDhtons((uint16_t)fa.handshake_port); @@ -1344,18 +1405,16 @@ H5FD_mirror_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxadd HDmemset(target_addr.sin_zero, '\0', sizeof target_addr.sin_zero); addr_size = sizeof(target_addr); - if (HDconnect(live_socket, (struct sockaddr *)&target_addr, addr_size) < 0) { + if (HDconnect(live_socket, (struct sockaddr *)&target_addr, addr_size) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "can't connect to remote server"); - } /* ------------- */ /* Open the file */ /* ------------- */ file = (H5FD_mirror_t *)H5FL_CALLOC(H5FD_mirror_t); - if (NULL == file) { - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate file struct"); - } + if (NULL == file) + HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, NULL, "unable to allocate file struct"); file->sock_fd = live_socket; file->xmit_i = 0; @@ -1366,46 +1425,52 @@ H5FD_mirror_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxadd file->xmit.session_token = (uint32_t)(0x01020304 ^ file->sock_fd); /* TODO: hashing? */ /* int --> uint32_t may truncate on some systems... shouldn't matter? */ - file->xmit.op = H5FD_MIRROR_OP_OPEN; - open_xmit.pub = file->xmit; - open_xmit.flags = (uint32_t)flags; - open_xmit.maxaddr = (uint64_t)maxaddr; - open_xmit.size_t_blob = (uint64_t)((size_t)(-1)); - HDsnprintf(open_xmit.filename, H5FD_MIRROR_XMIT_FILEPATH_MAX - 1, "%s", name); + open_xmit = (H5FD_mirror_xmit_open_t *)H5FL_CALLOC(H5FD_mirror_xmit_open_t); + if (NULL == open_xmit) + HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, NULL, "unable to allocate open_xmit struct"); + + file->xmit.op = H5FD_MIRROR_OP_OPEN; + open_xmit->pub = file->xmit; + open_xmit->flags = (uint32_t)flags; + open_xmit->maxaddr = (uint64_t)maxaddr; + open_xmit->size_t_blob = (uint64_t)((size_t)(-1)); + HDsnprintf(open_xmit->filename, H5FD_MIRROR_XMIT_FILEPATH_MAX - 1, "%s", name); + + xmit_buf = H5FL_BLK_MALLOC(xmit, H5FD_MIRROR_XMIT_BUFFER_MAX); + if (NULL == xmit_buf) + HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, NULL, "unable to allocate xmit buffer"); - if (H5FD_mirror_xmit_encode_open((unsigned char *)xmit_buf, - (const H5FD_mirror_xmit_open_t *)&open_xmit) != - H5FD_MIRROR_XMIT_OPEN_SIZE) { + if (H5FD_mirror_xmit_encode_open(xmit_buf, open_xmit) != H5FD_MIRROR_XMIT_OPEN_SIZE) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, NULL, "unable to encode open"); - } LOG_XMIT_BYTES("open", xmit_buf, H5FD_MIRROR_XMIT_OPEN_SIZE); - if (HDwrite(file->sock_fd, xmit_buf, H5FD_MIRROR_XMIT_OPEN_SIZE) < 0) { + if (HDwrite(file->sock_fd, xmit_buf, H5FD_MIRROR_XMIT_OPEN_SIZE) < 0) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, NULL, "unable to transmit open"); - } - if (H5FD__mirror_verify_reply(file) == FAIL) { + if (H5FD__mirror_verify_reply(file) == FAIL) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, NULL, "invalid reply"); - } ret_value = (H5FD_t *)file; done: if (NULL == ret_value) { - if (file) { + if (file) file = H5FL_FREE(H5FD_mirror_t, file); - } - if (live_socket >= 0 && HDclose(live_socket) < 0) { + if (live_socket >= 0 && HDclose(live_socket) < 0) HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, NULL, "can't close socket"); - } } + + if (open_xmit) + open_xmit = H5FL_FREE(H5FD_mirror_xmit_open_t, open_xmit); + if (xmit_buf) + xmit_buf = H5FL_BLK_FREE(xmit, xmit_buf); + FUNC_LEAVE_NOAPI(ret_value) -#undef MIRR_OPEN_MAXBUF -} /* end H5FD_mirror_open() */ +} /* end H5FD__mirror_open() */ /*------------------------------------------------------------------------- - * Function: H5FD_mirror_close + * Function: H5FD__mirror_close * * Purpose: Closes the HDF5 file. * @@ -1420,16 +1485,16 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_mirror_close(H5FD_t *_file) +H5FD__mirror_close(H5FD_t *_file) { - H5FD_mirror_t *file = (H5FD_mirror_t *)_file; - unsigned char xmit_buf[H5FD_MIRROR_XMIT_HEADER_SIZE]; + H5FD_mirror_t *file = (H5FD_mirror_t *)_file; + unsigned char *xmit_buf = NULL; int xmit_encoded = 0; /* monitor point of failure */ herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC - LOG_OP_CALL("H5FD_mirror_close"); + LOG_OP_CALL(FUNC); /* Sanity check */ HDassert(file); @@ -1438,25 +1503,24 @@ H5FD_mirror_close(H5FD_t *_file) file->xmit.xmit_count = (file->xmit_i)++; file->xmit.op = H5FD_MIRROR_OP_CLOSE; - if (H5FD_mirror_xmit_encode_header(xmit_buf, (const H5FD_mirror_xmit_t *)&(file->xmit)) != - H5FD_MIRROR_XMIT_HEADER_SIZE) { + xmit_buf = H5FL_BLK_MALLOC(xmit, H5FD_MIRROR_XMIT_BUFFER_MAX); + if (NULL == xmit_buf) + HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, "unable to allocate xmit buffer"); + + if (H5FD_mirror_xmit_encode_header(xmit_buf, &(file->xmit)) != H5FD_MIRROR_XMIT_HEADER_SIZE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to encode close"); - } xmit_encoded = 1; LOG_XMIT_BYTES("close", xmit_buf, H5FD_MIRROR_XMIT_HEADER_SIZE); - if (HDwrite(file->sock_fd, xmit_buf, H5FD_MIRROR_XMIT_HEADER_SIZE) < 0) { + if (HDwrite(file->sock_fd, xmit_buf, H5FD_MIRROR_XMIT_HEADER_SIZE) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to transmit close"); - } - if (H5FD__mirror_verify_reply(file) == FAIL) { + if (H5FD__mirror_verify_reply(file) == FAIL) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "invalid reply"); - } - if (HDclose(file->sock_fd) < 0) { + if (HDclose(file->sock_fd) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, "can't close socket"); - } done: if (ret_value == FAIL) { @@ -1467,31 +1531,30 @@ done: */ if (HDwrite(file->sock_fd, "GOODBYE", HDstrlen("GOODBYE")) < 0) { HDONE_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to transmit close"); - if (HDclose(file->sock_fd) < 0) { + if (HDclose(file->sock_fd) < 0) HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, "can't close socket"); - } file->sock_fd = -1; /* invalidate for later */ } /* end if problem writing goodbye; go down hard */ - else if (HDshutdown(file->sock_fd, SHUT_WR) < 0) { + else if (HDshutdown(file->sock_fd, SHUT_WR) < 0) HDONE_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "can't shutdown socket write: %s", HDstrerror(errno)); - } /* end else-if problem shutting down socket */ - } /* end if xmit encode failed */ + } /* end if xmit encode failed */ - if (file->sock_fd >= 0) { - if (HDclose(file->sock_fd) < 0) { + if (file->sock_fd >= 0) + if (HDclose(file->sock_fd) < 0) HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, "can't close socket"); - } - } /* end if socket not closed by going down hard */ - } /* end if error */ + } /* end if error */ file = H5FL_FREE(H5FD_mirror_t, file); /* always release resources */ + if (xmit_buf) + xmit_buf = H5FL_BLK_FREE(xmit, xmit_buf); + FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_mirror_close() */ +} /* end H5FD__mirror_close() */ /*------------------------------------------------------------------------- - * Function: H5FD_mirror_query + * Function: H5FD__mirror_query * * Purpose: Get the driver feature flags implemented by the driver. * @@ -1499,11 +1562,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_mirror_query(const H5FD_t H5_ATTR_UNUSED *_file, unsigned long *flags) +H5FD__mirror_query(const H5FD_t H5_ATTR_UNUSED *_file, unsigned long *flags) { - FUNC_ENTER_NOAPI_NOINIT_NOERR; + FUNC_ENTER_STATIC_NOERR; - LOG_OP_CALL("H5FD_mirror_query"); + LOG_OP_CALL(FUNC); /* Notice: the Mirror VFD Writer currently uses only the Sec2 driver as * the underying driver -- as such, the Mirror VFD implementation copies @@ -1513,17 +1576,16 @@ H5FD_mirror_query(const H5FD_t H5_ATTR_UNUSED *_file, unsigned long *flags) * is never included. * -- JOS 2020-01-13 */ - if (flags) { - *flags = 0 | H5FD_FEAT_AGGREGATE_METADATA | H5FD_FEAT_ACCUMULATE_METADATA | H5FD_FEAT_DATA_SIEVE | + if (flags) + *flags = H5FD_FEAT_AGGREGATE_METADATA | H5FD_FEAT_ACCUMULATE_METADATA | H5FD_FEAT_DATA_SIEVE | H5FD_FEAT_AGGREGATE_SMALLDATA | H5FD_FEAT_POSIX_COMPAT_HANDLE | H5FD_FEAT_SUPPORTS_SWMR_IO | H5FD_FEAT_DEFAULT_VFD_COMPATIBLE; - } FUNC_LEAVE_NOAPI(SUCCEED); -} /* end H5FD_mirror_query() */ +} /* end H5FD__mirror_query() */ /*------------------------------------------------------------------------- - * Function: H5FD_mirror_get_eoa + * Function: H5FD__mirror_get_eoa * * Purpose: Gets the end-of-address marker for the file. The EOA marker * is the first address past the last byte allocated in the @@ -1535,21 +1597,21 @@ H5FD_mirror_query(const H5FD_t H5_ATTR_UNUSED *_file, unsigned long *flags) *------------------------------------------------------------------------- */ static haddr_t -H5FD_mirror_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) +H5FD__mirror_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { const H5FD_mirror_t *file = (const H5FD_mirror_t *)_file; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR - LOG_OP_CALL("H5FD_mirror_get_eoa"); + LOG_OP_CALL(FUNC); HDassert(file); FUNC_LEAVE_NOAPI(file->eoa) -} /* end H5FD_mirror_get_eoa() */ +} /* end H5FD__mirror_get_eoa() */ /*------------------------------------------------------------------------- - * Function: H5FD_mirror_set_eoa + * Function: H5FD__mirror_set_eoa * * Purpose: Set the end-of-address marker for the file. This function is * called shortly after an existing HDF5 file is opened in order @@ -1559,16 +1621,16 @@ H5FD_mirror_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) *------------------------------------------------------------------------- */ static herr_t -H5FD_mirror_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr) +H5FD__mirror_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr) { H5FD_mirror_xmit_eoa_t xmit_eoa; - unsigned char xmit_buf[H5FD_MIRROR_XMIT_EOA_SIZE]; + unsigned char * xmit_buf = NULL; H5FD_mirror_t * file = (H5FD_mirror_t *)_file; herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC - LOG_OP_CALL("H5FD_mirror_set_eoa"); + LOG_OP_CALL(FUNC); HDassert(file); @@ -1581,27 +1643,30 @@ H5FD_mirror_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr) xmit_eoa.type = (uint8_t)type; xmit_eoa.eoa_addr = (uint64_t)addr; - if (H5FD_mirror_xmit_encode_set_eoa(xmit_buf, (const H5FD_mirror_xmit_eoa_t *)&xmit_eoa) != - H5FD_MIRROR_XMIT_EOA_SIZE) { + xmit_buf = H5FL_BLK_MALLOC(xmit, H5FD_MIRROR_XMIT_BUFFER_MAX); + if (NULL == xmit_buf) + HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, "unable to allocate xmit buffer"); + + if (H5FD_mirror_xmit_encode_set_eoa(xmit_buf, &xmit_eoa) != H5FD_MIRROR_XMIT_EOA_SIZE) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to encode set-eoa"); - } LOG_XMIT_BYTES("set-eoa", xmit_buf, H5FD_MIRROR_XMIT_EOA_SIZE); - if (HDwrite(file->sock_fd, xmit_buf, H5FD_MIRROR_XMIT_EOA_SIZE) < 0) { + if (HDwrite(file->sock_fd, xmit_buf, H5FD_MIRROR_XMIT_EOA_SIZE) < 0) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to transmit set-eoa"); - } - if (H5FD__mirror_verify_reply(file) == FAIL) { + if (H5FD__mirror_verify_reply(file) == FAIL) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "invalid reply"); - } done: + if (xmit_buf) + xmit_buf = H5FL_BLK_FREE(xmit, xmit_buf); + FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_mirror_set_eoa() */ +} /* end H5FD__mirror_set_eoa() */ /*------------------------------------------------------------------------- - * Function: H5FD_mirror_get_eof + * Function: H5FD__mirror_get_eof * * Purpose: Returns the end-of-file marker, which is the greater of * either the filesystem end-of-file or the HDF5 end-of-address @@ -1614,43 +1679,40 @@ done: *------------------------------------------------------------------------- */ static haddr_t -H5FD_mirror_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) +H5FD__mirror_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { const H5FD_mirror_t *file = (const H5FD_mirror_t *)_file; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR - LOG_OP_CALL("H5FD_mirror_get_eof"); + LOG_OP_CALL(FUNC); HDassert(file); FUNC_LEAVE_NOAPI(file->eof) -} /* end H5FD_mirror_get_eof() */ +} /* end H5FD__mirror_get_eof() */ /*------------------------------------------------------------------------- - * Function: H5FD_mirror_read + * Function: H5FD__mirror_read * - * Purpose: Required to register the driver. - * If called, MUST fail. + * Purpose: Required to register the driver, but if called, MUST fail. * * Return: FAIL *------------------------------------------------------------------------- */ static herr_t -H5FD_mirror_read(H5FD_t H5_ATTR_UNUSED *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED fapl_id, - haddr_t H5_ATTR_UNUSED addr, size_t H5_ATTR_UNUSED size, void H5_ATTR_UNUSED *buf) +H5FD__mirror_read(H5FD_t H5_ATTR_UNUSED *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED fapl_id, + haddr_t H5_ATTR_UNUSED addr, size_t H5_ATTR_UNUSED size, void H5_ATTR_UNUSED *buf) { - herr_t ret_value = FAIL; - - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR - LOG_OP_CALL("H5FD_mirror_read"); + LOG_OP_CALL(FUNC); - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_mirror_read() */ + FUNC_LEAVE_NOAPI(FAIL) +} /* end H5FD__mirror_read() */ /*------------------------------------------------------------------------- - * Function: H5FD_mirror_write + * Function: H5FD__mirror_write * * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR * from buffer BUF according to data transfer properties in @@ -1667,17 +1729,17 @@ H5FD_mirror_read(H5FD_t H5_ATTR_UNUSED *_file, H5FD_mem_t H5_ATTR_UNUSED type, h *------------------------------------------------------------------------- */ static herr_t -H5FD_mirror_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__mirror_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_mirror_xmit_write_t xmit_write; - unsigned char xmit_buf[H5FD_MIRROR_XMIT_WRITE_SIZE]; + unsigned char * xmit_buf = NULL; H5FD_mirror_t * file = (H5FD_mirror_t *)_file; herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC - LOG_OP_CALL("H5FD_mirror_write"); + LOG_OP_CALL(FUNC); HDassert(file); HDassert(buf); @@ -1690,39 +1752,40 @@ H5FD_mirror_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, xmit_write.offset = (uint64_t)addr; xmit_write.type = (uint8_t)type; + xmit_buf = H5FL_BLK_MALLOC(xmit, H5FD_MIRROR_XMIT_BUFFER_MAX); + if (NULL == xmit_buf) + HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, "unable to allocate xmit buffer"); + /* Notify Writer of incoming data to write. */ - if (H5FD_mirror_xmit_encode_write(xmit_buf, (const H5FD_mirror_xmit_write_t *)&xmit_write) != - H5FD_MIRROR_XMIT_WRITE_SIZE) { + if (H5FD_mirror_xmit_encode_write(xmit_buf, &xmit_write) != H5FD_MIRROR_XMIT_WRITE_SIZE) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to encode write"); - } LOG_XMIT_BYTES("write", xmit_buf, H5FD_MIRROR_XMIT_WRITE_SIZE); - if (HDwrite(file->sock_fd, xmit_buf, H5FD_MIRROR_XMIT_WRITE_SIZE) < 0) { + if (HDwrite(file->sock_fd, xmit_buf, H5FD_MIRROR_XMIT_WRITE_SIZE) < 0) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to transmit write"); - } /* Check that our write xmission was received */ - if (H5FD__mirror_verify_reply(file) == FAIL) { + if (H5FD__mirror_verify_reply(file) == FAIL) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "invalid reply"); - } /* Send the data to be written */ - if (HDwrite(file->sock_fd, buf, size) < 0) { + if (HDwrite(file->sock_fd, buf, size) < 0) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to transmit data"); - } /* Writer should reply that it got the data and is still okay/ready */ - if (H5FD__mirror_verify_reply(file) == FAIL) { + if (H5FD__mirror_verify_reply(file) == FAIL) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "invalid reply"); - } done: + if (xmit_buf) + xmit_buf = H5FL_BLK_FREE(xmit, xmit_buf); + FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_mirror_write() */ +} /* end H5FD__mirror_write() */ /*------------------------------------------------------------------------- - * Function: H5FD_mirror_truncate + * Function: H5FD__mirror_truncate * * Purpose: Makes sure that the true file size is the same (or larger) * than the end-of-address. @@ -1731,39 +1794,43 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_mirror_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_UNUSED closing) +H5FD__mirror_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_UNUSED closing) { - unsigned char xmit_buf[H5FD_MIRROR_XMIT_HEADER_SIZE]; + unsigned char *xmit_buf = NULL; H5FD_mirror_t *file = (H5FD_mirror_t *)_file; herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC - LOG_OP_CALL("H5FD_mirror_truncate"); + LOG_OP_CALL(FUNC); file->xmit.xmit_count = (file->xmit_i)++; file->xmit.op = H5FD_MIRROR_OP_TRUNCATE; - if (H5FD_mirror_xmit_encode_header(xmit_buf, &(file->xmit)) != H5FD_MIRROR_XMIT_HEADER_SIZE) { + xmit_buf = H5FL_BLK_MALLOC(xmit, H5FD_MIRROR_XMIT_BUFFER_MAX); + if (NULL == xmit_buf) + HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, "unable to allocate xmit buffer"); + + if (H5FD_mirror_xmit_encode_header(xmit_buf, &(file->xmit)) != H5FD_MIRROR_XMIT_HEADER_SIZE) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to encode truncate"); - } LOG_XMIT_BYTES("truncate", xmit_buf, H5FD_MIRROR_XMIT_HEADER_SIZE); - if (HDwrite(file->sock_fd, xmit_buf, H5FD_MIRROR_XMIT_HEADER_SIZE) < 0) { + if (HDwrite(file->sock_fd, xmit_buf, H5FD_MIRROR_XMIT_HEADER_SIZE) < 0) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to transmit truncate"); - } - if (H5FD__mirror_verify_reply(file) == FAIL) { + if (H5FD__mirror_verify_reply(file) == FAIL) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "invalid reply"); - } done: + if (xmit_buf) + xmit_buf = H5FL_BLK_FREE(xmit, xmit_buf); + FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_mirror_truncate() */ +} /* end H5FD__mirror_truncate() */ /*------------------------------------------------------------------------- - * Function: H5FD_mirror_lock + * Function: H5FD__mirror_lock * * Purpose: To place an advisory lock on a file. * The lock type to apply depends on the parameter "rw": @@ -1774,16 +1841,16 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_mirror_lock(H5FD_t *_file, hbool_t rw) +H5FD__mirror_lock(H5FD_t *_file, hbool_t rw) { H5FD_mirror_xmit_lock_t xmit_lock; - unsigned char xmit_buf[H5FD_MIRROR_XMIT_LOCK_SIZE]; + unsigned char * xmit_buf = NULL; H5FD_mirror_t * file = (H5FD_mirror_t *)_file; herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT; + FUNC_ENTER_STATIC - LOG_OP_CALL("H5FD_mirror_lock"); + LOG_OP_CALL(FUNC); file->xmit.xmit_count = (file->xmit_i)++; file->xmit.op = H5FD_MIRROR_OP_LOCK; @@ -1791,27 +1858,30 @@ H5FD_mirror_lock(H5FD_t *_file, hbool_t rw) xmit_lock.pub = file->xmit; xmit_lock.rw = (uint64_t)rw; - if (H5FD_mirror_xmit_encode_lock(xmit_buf, (const H5FD_mirror_xmit_lock_t *)&xmit_lock) != - H5FD_MIRROR_XMIT_LOCK_SIZE) { + xmit_buf = H5FL_BLK_MALLOC(xmit, H5FD_MIRROR_XMIT_BUFFER_MAX); + if (NULL == xmit_buf) + HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, "unable to allocate xmit buffer"); + + if (H5FD_mirror_xmit_encode_lock(xmit_buf, &xmit_lock) != H5FD_MIRROR_XMIT_LOCK_SIZE) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to encode lock"); - } LOG_XMIT_BYTES("lock", xmit_buf, H5FD_MIRROR_XMIT_LOCK_SIZE); - if (HDwrite(file->sock_fd, xmit_buf, H5FD_MIRROR_XMIT_LOCK_SIZE) < 0) { + if (HDwrite(file->sock_fd, xmit_buf, H5FD_MIRROR_XMIT_LOCK_SIZE) < 0) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to transmit lock"); - } - if (H5FD__mirror_verify_reply(file) == FAIL) { + if (H5FD__mirror_verify_reply(file) == FAIL) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "invalid reply"); - } done: + if (xmit_buf) + xmit_buf = H5FL_BLK_FREE(xmit, xmit_buf); + FUNC_LEAVE_NOAPI(ret_value); -} /* end H5FD_mirror_lock */ +} /* end H5FD__mirror_lock */ /*------------------------------------------------------------------------- - * Function: H5FD_mirror_unlock + * Function: H5FD__mirror_unlock * * Purpose: Remove the existing lock on the file. * @@ -1819,35 +1889,39 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_mirror_unlock(H5FD_t *_file) +H5FD__mirror_unlock(H5FD_t *_file) { - unsigned char xmit_buf[H5FD_MIRROR_XMIT_HEADER_SIZE]; + unsigned char *xmit_buf = NULL; H5FD_mirror_t *file = (H5FD_mirror_t *)_file; herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT; + FUNC_ENTER_STATIC - LOG_OP_CALL("H5FD_mirror_unlock"); + LOG_OP_CALL(FUNC); file->xmit.xmit_count = (file->xmit_i)++; file->xmit.op = H5FD_MIRROR_OP_UNLOCK; - if (H5FD_mirror_xmit_encode_header(xmit_buf, &(file->xmit)) != H5FD_MIRROR_XMIT_HEADER_SIZE) { + xmit_buf = H5FL_BLK_MALLOC(xmit, H5FD_MIRROR_XMIT_BUFFER_MAX); + if (NULL == xmit_buf) + HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, "unable to allocate xmit buffer"); + + if (H5FD_mirror_xmit_encode_header(xmit_buf, &(file->xmit)) != H5FD_MIRROR_XMIT_HEADER_SIZE) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to encode unlock"); - } LOG_XMIT_BYTES("unlock", xmit_buf, H5FD_MIRROR_XMIT_HEADER_SIZE); - if (HDwrite(file->sock_fd, xmit_buf, H5FD_MIRROR_XMIT_HEADER_SIZE) < 0) { + if (HDwrite(file->sock_fd, xmit_buf, H5FD_MIRROR_XMIT_HEADER_SIZE) < 0) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to transmit unlock"); - } - if (H5FD__mirror_verify_reply(file) == FAIL) { + if (H5FD__mirror_verify_reply(file) == FAIL) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "invalid reply"); - } done: + if (xmit_buf) + xmit_buf = H5FL_BLK_FREE(xmit, xmit_buf); + FUNC_LEAVE_NOAPI(ret_value); -} /* end H5FD_mirror_unlock */ +} /* end H5FD__mirror_unlock */ #endif /* H5_HAVE_MIRROR_VFD */ diff --git a/src/H5FDmirror.h b/src/H5FDmirror.h index 2ed6bbd..49e24c1 100644 --- a/src/H5FDmirror.h +++ b/src/H5FDmirror.h @@ -61,294 +61,21 @@ typedef struct H5FD_mirror_fapl_t { char remote_ip[H5FD_MIRROR_MAX_IP_LEN + 1]; } H5FD_mirror_fapl_t; -H5_DLL hid_t H5FD_mirror_init(void); -H5_DLL herr_t H5Pget_fapl_mirror(hid_t fapl_id, H5FD_mirror_fapl_t *fa_out); -H5_DLL herr_t H5Pset_fapl_mirror(hid_t fapl_id, H5FD_mirror_fapl_t *fa); - -/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = - * IPC - Mirror VFD and Remote Worker application. - * = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = - */ - -/* The maximum allowed size for a receiving buffer when accepting bytes to - * write. Writes larger than this size are performed by multiple accept-write - * steps by the Writer. */ -#define H5FD_MIRROR_DATA_BUFFER_MAX H5_GB /* 1 Gigabyte */ - -#define H5FD_MIRROR_XMIT_CURR_VERSION 1 -#define H5FD_MIRROR_XMIT_MAGIC 0x87F8005B - -#define H5FD_MIRROR_OP_OPEN 1 -#define H5FD_MIRROR_OP_CLOSE 2 -#define H5FD_MIRROR_OP_WRITE 3 -#define H5FD_MIRROR_OP_TRUNCATE 4 -#define H5FD_MIRROR_OP_REPLY 5 -#define H5FD_MIRROR_OP_SET_EOA 6 -#define H5FD_MIRROR_OP_LOCK 7 -#define H5FD_MIRROR_OP_UNLOCK 8 - -#define H5FD_MIRROR_STATUS_OK 0 -#define H5FD_MIRROR_STATUS_ERROR 1 -#define H5FD_MIRROR_STATUS_MESSAGE_MAX 256 /* Dedicated error message size */ - -/* Maximum length of a path/filename string, including the NULL-terminator. - * Must not be smaller than H5FD_SPLITTER_PATH_MAX. */ -#define H5FD_MIRROR_XMIT_FILEPATH_MAX 4097 - -/* Define the exact sizes of the various xmit blobs as sent over the wire. - * This is used to minimize the number of bytes transmitted as well as to - * sanity-check received bytes. - * Any modifications to the xmit structures and/or the encode/decode functions - * must be reflected here. - * */ -#define H5FD_MIRROR_XMIT_HEADER_SIZE 14 -#define H5FD_MIRROR_XMIT_EOA_SIZE (H5FD_MIRROR_XMIT_HEADER_SIZE + 9) -#define H5FD_MIRROR_XMIT_LOCK_SIZE (H5FD_MIRROR_XMIT_HEADER_SIZE + 8) -#define H5FD_MIRROR_XMIT_OPEN_SIZE (H5FD_MIRROR_XMIT_HEADER_SIZE + 20 + H5FD_MIRROR_XMIT_FILEPATH_MAX) -#define H5FD_MIRROR_XMIT_REPLY_SIZE (H5FD_MIRROR_XMIT_HEADER_SIZE + 4 + H5FD_MIRROR_STATUS_MESSAGE_MAX) -#define H5FD_MIRROR_XMIT_WRITE_SIZE (H5FD_MIRROR_XMIT_HEADER_SIZE + 17) +H5_DLL hid_t H5FD_mirror_init(void); -/* Maximum length of any xmit. */ -#define H5FD_MIRROR_XMIT_BUFFER_MAX \ - MAX2(MAX3(H5FD_MIRROR_XMIT_HEADER_SIZE, H5FD_MIRROR_XMIT_EOA_SIZE, H5FD_MIRROR_XMIT_LOCK_SIZE), \ - MAX3(H5FD_MIRROR_XMIT_OPEN_SIZE, H5FD_MIRROR_XMIT_REPLY_SIZE, H5FD_MIRROR_XMIT_WRITE_SIZE)) - -/* --------------------------------------------------------------------------- - * Structure: H5FD_mirror_xmit_t - * - * Common structure 'header' for all mirror VFD/worker IPC. - * Must be the first component of a derived operation xmit structure, - * such as file-open or write command. - * - * `magic` (uint32_t) - * A "unique" number identifying the structure and endianness of - * transmitting maching. - * Must be set to H5FD_MIRROR_XMIT_MAGIC native to the VFD "sender". +/** + * \ingroup FAPL * - * `version` (uint8_t) - * Number used to identify the structure membership. - * Allows sane modifications to this structure in the future. - * Must be set to H5FD_MIRROR_XMIT_CURR_VERSION. - * - * `session_token` (uint32_t) - * A "unique" number identifying the session between VFD sender and - * remote receiver/worker/writer. Exists to help sanity-check. - * - * `xmit_count` (uint32_t) - * Which transmission this is since the session began. - * Used to sanity-check transmission errors. - * First xmit (file-open) must be 0. - * - * `op` (uint8_t) - * Number identifying which operation to perform. - * Corresponds with the extended structure outside of this xmit header. - * Possible values are all defined H5FD_MIRROR_OP_* constants. - * - * --------------------------------------------------------------------------- + * \todo Add missing documentation */ -typedef struct H5FD_mirror_xmit_t { - uint32_t magic; - uint8_t version; - uint32_t session_token; - uint32_t xmit_count; - uint8_t op; -} H5FD_mirror_xmit_t; - -/* --------------------------------------------------------------------------- - * Structure: H5FD_mirror_xmit_eoa_t - * - * Structure containing eoa-set information from VFD sender. - * - * `pub` (H5FD_mirror_xmit_t) - * Common transmission header, containing session information. - * Must be first. - * - * `type` (uint8_t) - * System-independent alias for H5F[D]_mem_t. - * Specifies datatype to be written. - * - * `eoa_addr` (uint64_t) - * New address for eoa. - * (Natively 'haddr_t', always a 64-bit field) - * - * --------------------------------------------------------------------------- - */ -typedef struct H5FD_mirror_xmit_eoa_t { - H5FD_mirror_xmit_t pub; - uint8_t type; - uint64_t eoa_addr; -} H5FD_mirror_xmit_eoa_t; - -/* --------------------------------------------------------------------------- - * Structure: H5FD_mirror_xmit_lock_t - * - * Structure containing eoa-set information from VFD sender. - * - * `pub` (H5FD_mirror_xmit_t) - * Common transmission header, containing session information. - * Must be first. - * - * `rw` (uint64_t) - * The Read/Write mode flag passed into H5FDlock(). - * (Natively `hbool_t`, an 'int') TODO: native int may be 64-bit? - * - * --------------------------------------------------------------------------- - */ -typedef struct H5FD_mirror_xmit_lock_t { - H5FD_mirror_xmit_t pub; - uint64_t rw; -} H5FD_mirror_xmit_lock_t; - -/* --------------------------------------------------------------------------- - * Structure: H5FD_mirror_xmit_open_t - * - * Structure containing file-open information from the VFD sender. - * - * `pub` (H5FD_mirror_xmit_t) - * Common transmission header, containing session information. - * Must be first. - * - * `flags` (uint32_t) - * VFL-layer file-open flags passed directly to H5FDopen(). - * (Natively 'unsigned [int]') TODO: native int may be 64-bit? - * - * `maxaddr` (uint64_t) - * VFL-layer maximum allowed address space for the file to open passed - * directly to H5FDopen(). - * (Natively 'haddr_t', always a 64-bit field) - * - * `size_t_blob` (uint64_t) - * A number indicating how large a size_t is on the sending system. - * Must be set to (uint64_t)((size_t)(-1)) - * (maximum possible value of size_t, cast to uint64_t). - * The receiving system inspects this value -- if the local (remote) - * size_t is smaller than that of the Sender, issues a warning. - * Not an error, as: - * 1. It is assumed that underlying file systems/drivers have become - * smart enough to handle file sizes that otherwise might be - * constrained. - * 2. The Mirror Writer ingests bytes to write multiple 'slices' if the - * size is greater than H5FD_MIRROR_DATA_BUFFER_MAX, regardless of - * any size_t storage size disparity. - * - * `filename` (char[]) - * String giving the filename and path of file to open. - * - * --------------------------------------------------------------------------- - */ -typedef struct H5FD_mirror_xmit_open_t { - H5FD_mirror_xmit_t pub; - uint32_t flags; - uint64_t maxaddr; - uint64_t size_t_blob; - char filename[H5FD_MIRROR_XMIT_FILEPATH_MAX]; -} H5FD_mirror_xmit_open_t; - -/* --------------------------------------------------------------------------- - * Structure: H5FD_mirror_xmit_reply_t - * - * Structure used by the remote receiver/worker/writer to respond to - * a command from the VFD sender. - * - * `pub` (H5FD_mirror_xmit_t) - * Common transmission header, containing session information. - * Must be first. - * - * `status` (uint32_t) - * Number indicating whether the command was successful or if an - * occured. - * Allowed values are H5FD_MIRROR_STATUS_OK and - * H5FD_MIRROR_STATUS_ERROR. - * - * `message` (char[]) - * Error message. Populated if and only if there was a problem. - * It is possible that a message may reach the end of the alloted - * space without a NULL terminator -- the onus is on the programmer to - * handle this situation. - * - * --------------------------------------------------------------------------- - */ -typedef struct H5FD_mirror_xmit_reply_t { - H5FD_mirror_xmit_t pub; - uint32_t status; - char message[H5FD_MIRROR_STATUS_MESSAGE_MAX]; -} H5FD_mirror_xmit_reply_t; - -/* --------------------------------------------------------------------------- - * Structure: H5FD_mirror_xmit_write_t - * - * Structure containing data-write information from VFD sender. - * - * The data to be written is transmitted in subsequent, packets - * and may be broken up into more than one transmission buffer. - * The VFD sender and remote receiver/worker/writer must coordinate - * the receipt of data. - * - * `pub` (H5FD_mirror_xmit_t) - * Common transmission header, containing session information. - * Must be first. - * - * `type` (uint8_t) - * Specifies datatype to be written. - * (Natively 'H5FD_mem_t', an enumerated type in H5Fpublic.h) - * - * `offset` (uint64_t) - * Start location of write in file. - * (Natively 'haddr_t', always a 64-bit field) - * - * `size` (uint64_t) - * Size of the data to be written, in bytes. - * (Natively 'size_t', accommodate the largest possible as 64-bits) - * - * --------------------------------------------------------------------------- - */ -typedef struct H5FD_mirror_xmit_write_t { - H5FD_mirror_xmit_t pub; - uint8_t type; - uint64_t offset; - uint64_t size; -} H5FD_mirror_xmit_write_t; +H5_DLL herr_t H5Pget_fapl_mirror(hid_t fapl_id, H5FD_mirror_fapl_t *fa_out); -/* Encode/decode routines are required to "pack" the xmit data into a known - * byte format for transmission over the wire. - * - * All component numbers must be stored in "network" word order (Big-Endian). +/** + * \ingroup FAPL * - * All components must be packed in the order given in the structure definition. - * - * All components must be packed with zero padding between. + * \todo Add missing documentation */ - -H5_DLL size_t H5FD__mirror_xmit_decode_uint16(uint16_t *out, const unsigned char *buf); -H5_DLL size_t H5FD__mirror_xmit_decode_uint32(uint32_t *out, const unsigned char *buf); -H5_DLL size_t H5FD__mirror_xmit_decode_uint64(uint64_t *out, const unsigned char *buf); -H5_DLL size_t H5FD__mirror_xmit_decode_uint8(uint8_t *out, const unsigned char *buf); -H5_DLL size_t H5FD__mirror_xmit_encode_uint16(unsigned char *dest, uint16_t v); -H5_DLL size_t H5FD__mirror_xmit_encode_uint32(unsigned char *dest, uint32_t v); -H5_DLL size_t H5FD__mirror_xmit_encode_uint64(unsigned char *dest, uint64_t v); -H5_DLL size_t H5FD__mirror_xmit_encode_uint8(unsigned char *dest, uint8_t v); - -H5_DLL size_t H5FD_mirror_xmit_decode_header(H5FD_mirror_xmit_t *out, const unsigned char *buf); -H5_DLL size_t H5FD_mirror_xmit_decode_lock(H5FD_mirror_xmit_lock_t *out, const unsigned char *buf); -H5_DLL size_t H5FD_mirror_xmit_decode_open(H5FD_mirror_xmit_open_t *out, const unsigned char *buf); -H5_DLL size_t H5FD_mirror_xmit_decode_reply(H5FD_mirror_xmit_reply_t *out, const unsigned char *buf); -H5_DLL size_t H5FD_mirror_xmit_decode_set_eoa(H5FD_mirror_xmit_eoa_t *out, const unsigned char *buf); -H5_DLL size_t H5FD_mirror_xmit_decode_write(H5FD_mirror_xmit_write_t *out, const unsigned char *buf); - -H5_DLL size_t H5FD_mirror_xmit_encode_header(unsigned char *dest, const H5FD_mirror_xmit_t *x); -H5_DLL size_t H5FD_mirror_xmit_encode_lock(unsigned char *dest, const H5FD_mirror_xmit_lock_t *x); -H5_DLL size_t H5FD_mirror_xmit_encode_open(unsigned char *dest, const H5FD_mirror_xmit_open_t *x); -H5_DLL size_t H5FD_mirror_xmit_encode_reply(unsigned char *dest, const H5FD_mirror_xmit_reply_t *x); -H5_DLL size_t H5FD_mirror_xmit_encode_set_eoa(unsigned char *dest, const H5FD_mirror_xmit_eoa_t *x); -H5_DLL size_t H5FD_mirror_xmit_encode_write(unsigned char *dest, const H5FD_mirror_xmit_write_t *x); - -H5_DLL hbool_t H5FD_mirror_xmit_is_close(const H5FD_mirror_xmit_t *xmit); -H5_DLL hbool_t H5FD_mirror_xmit_is_lock(const H5FD_mirror_xmit_lock_t *xmit); -H5_DLL hbool_t H5FD_mirror_xmit_is_open(const H5FD_mirror_xmit_open_t *xmit); -H5_DLL hbool_t H5FD_mirror_xmit_is_reply(const H5FD_mirror_xmit_reply_t *xmit); -H5_DLL hbool_t H5FD_mirror_xmit_is_set_eoa(const H5FD_mirror_xmit_eoa_t *xmit); -H5_DLL hbool_t H5FD_mirror_xmit_is_write(const H5FD_mirror_xmit_write_t *xmit); -H5_DLL hbool_t H5FD_mirror_xmit_is_xmit(const H5FD_mirror_xmit_t *xmit); +H5_DLL herr_t H5Pset_fapl_mirror(hid_t fapl_id, H5FD_mirror_fapl_t *fa); #ifdef __cplusplus } diff --git a/src/H5FDmirror_priv.h b/src/H5FDmirror_priv.h new file mode 100644 index 0000000..21de97b --- /dev/null +++ b/src/H5FDmirror_priv.h @@ -0,0 +1,317 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://www.hdfgroup.org/licenses. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Public, shared definitions for Mirror VFD & remote Writer. + */ + +#ifndef H5FDmirror_priv_H +#define H5FDmirror_priv_H + +#ifdef H5_HAVE_MIRROR_VFD + +#ifdef __cplusplus +extern "C" { +#endif + +/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + * IPC - Mirror VFD and Remote Worker application. + * = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + */ + +/* The maximum allowed size for a receiving buffer when accepting bytes to + * write. Writes larger than this size are performed by multiple accept-write + * steps by the Writer. */ +#define H5FD_MIRROR_DATA_BUFFER_MAX H5_GB /* 1 Gigabyte */ + +#define H5FD_MIRROR_XMIT_CURR_VERSION 1 +#define H5FD_MIRROR_XMIT_MAGIC 0x87F8005B + +#define H5FD_MIRROR_OP_OPEN 1 +#define H5FD_MIRROR_OP_CLOSE 2 +#define H5FD_MIRROR_OP_WRITE 3 +#define H5FD_MIRROR_OP_TRUNCATE 4 +#define H5FD_MIRROR_OP_REPLY 5 +#define H5FD_MIRROR_OP_SET_EOA 6 +#define H5FD_MIRROR_OP_LOCK 7 +#define H5FD_MIRROR_OP_UNLOCK 8 + +#define H5FD_MIRROR_STATUS_OK 0 +#define H5FD_MIRROR_STATUS_ERROR 1 +#define H5FD_MIRROR_STATUS_MESSAGE_MAX 256 /* Dedicated error message size */ + +/* Maximum length of a path/filename string, including the NULL-terminator. + * Must not be smaller than H5FD_SPLITTER_PATH_MAX. */ +#define H5FD_MIRROR_XMIT_FILEPATH_MAX 4097 + +/* Define the exact sizes of the various xmit blobs as sent over the wire. + * This is used to minimize the number of bytes transmitted as well as to + * sanity-check received bytes. + * Any modifications to the xmit structures and/or the encode/decode functions + * must be reflected here. + * */ +#define H5FD_MIRROR_XMIT_HEADER_SIZE 14 +#define H5FD_MIRROR_XMIT_EOA_SIZE (H5FD_MIRROR_XMIT_HEADER_SIZE + 9) +#define H5FD_MIRROR_XMIT_LOCK_SIZE (H5FD_MIRROR_XMIT_HEADER_SIZE + 8) +#define H5FD_MIRROR_XMIT_OPEN_SIZE (H5FD_MIRROR_XMIT_HEADER_SIZE + 20 + H5FD_MIRROR_XMIT_FILEPATH_MAX) +#define H5FD_MIRROR_XMIT_REPLY_SIZE (H5FD_MIRROR_XMIT_HEADER_SIZE + 4 + H5FD_MIRROR_STATUS_MESSAGE_MAX) +#define H5FD_MIRROR_XMIT_WRITE_SIZE (H5FD_MIRROR_XMIT_HEADER_SIZE + 17) + +/* Maximum length of any xmit. */ +#define H5FD_MIRROR_XMIT_BUFFER_MAX \ + MAX2(MAX3(H5FD_MIRROR_XMIT_HEADER_SIZE, H5FD_MIRROR_XMIT_EOA_SIZE, H5FD_MIRROR_XMIT_LOCK_SIZE), \ + MAX3(H5FD_MIRROR_XMIT_OPEN_SIZE, H5FD_MIRROR_XMIT_REPLY_SIZE, H5FD_MIRROR_XMIT_WRITE_SIZE)) + +/* --------------------------------------------------------------------------- + * Structure: H5FD_mirror_xmit_t + * + * Common structure 'header' for all mirror VFD/worker IPC. + * Must be the first component of a derived operation xmit structure, + * such as file-open or write command. + * + * `magic` (uint32_t) + * A "unique" number identifying the structure and endianness of + * transmitting maching. + * Must be set to H5FD_MIRROR_XMIT_MAGIC native to the VFD "sender". + * + * `version` (uint8_t) + * Number used to identify the structure membership. + * Allows sane modifications to this structure in the future. + * Must be set to H5FD_MIRROR_XMIT_CURR_VERSION. + * + * `session_token` (uint32_t) + * A "unique" number identifying the session between VFD sender and + * remote receiver/worker/writer. Exists to help sanity-check. + * + * `xmit_count` (uint32_t) + * Which transmission this is since the session began. + * Used to sanity-check transmission errors. + * First xmit (file-open) must be 0. + * + * `op` (uint8_t) + * Number identifying which operation to perform. + * Corresponds with the extended structure outside of this xmit header. + * Possible values are all defined H5FD_MIRROR_OP_* constants. + * + * --------------------------------------------------------------------------- + */ +typedef struct H5FD_mirror_xmit_t { + uint32_t magic; + uint8_t version; + uint32_t session_token; + uint32_t xmit_count; + uint8_t op; +} H5FD_mirror_xmit_t; + +/* --------------------------------------------------------------------------- + * Structure: H5FD_mirror_xmit_eoa_t + * + * Structure containing eoa-set information from VFD sender. + * + * `pub` (H5FD_mirror_xmit_t) + * Common transmission header, containing session information. + * Must be first. + * + * `type` (uint8_t) + * System-independent alias for H5F[D]_mem_t. + * Specifies datatype to be written. + * + * `eoa_addr` (uint64_t) + * New address for eoa. + * (Natively 'haddr_t', always a 64-bit field) + * + * --------------------------------------------------------------------------- + */ +typedef struct H5FD_mirror_xmit_eoa_t { + H5FD_mirror_xmit_t pub; + uint8_t type; + uint64_t eoa_addr; +} H5FD_mirror_xmit_eoa_t; + +/* --------------------------------------------------------------------------- + * Structure: H5FD_mirror_xmit_lock_t + * + * Structure containing eoa-set information from VFD sender. + * + * `pub` (H5FD_mirror_xmit_t) + * Common transmission header, containing session information. + * Must be first. + * + * `rw` (uint64_t) + * The Read/Write mode flag passed into H5FDlock(). + * (Natively `hbool_t`, an 'int') TODO: native int may be 64-bit? + * + * --------------------------------------------------------------------------- + */ +typedef struct H5FD_mirror_xmit_lock_t { + H5FD_mirror_xmit_t pub; + uint64_t rw; +} H5FD_mirror_xmit_lock_t; + +/* --------------------------------------------------------------------------- + * Structure: H5FD_mirror_xmit_open_t + * + * Structure containing file-open information from the VFD sender. + * + * `pub` (H5FD_mirror_xmit_t) + * Common transmission header, containing session information. + * Must be first. + * + * `flags` (uint32_t) + * VFL-layer file-open flags passed directly to H5FDopen(). + * (Natively 'unsigned [int]') TODO: native int may be 64-bit? + * + * `maxaddr` (uint64_t) + * VFL-layer maximum allowed address space for the file to open passed + * directly to H5FDopen(). + * (Natively 'haddr_t', always a 64-bit field) + * + * `size_t_blob` (uint64_t) + * A number indicating how large a size_t is on the sending system. + * Must be set to (uint64_t)((size_t)(-1)) + * (maximum possible value of size_t, cast to uint64_t). + * The receiving system inspects this value -- if the local (remote) + * size_t is smaller than that of the Sender, issues a warning. + * Not an error, as: + * 1. It is assumed that underlying file systems/drivers have become + * smart enough to handle file sizes that otherwise might be + * constrained. + * 2. The Mirror Writer ingests bytes to write multiple 'slices' if the + * size is greater than H5FD_MIRROR_DATA_BUFFER_MAX, regardless of + * any size_t storage size disparity. + * + * `filename` (char[]) + * String giving the filename and path of file to open. + * + * --------------------------------------------------------------------------- + */ +typedef struct H5FD_mirror_xmit_open_t { + H5FD_mirror_xmit_t pub; + uint32_t flags; + uint64_t maxaddr; + uint64_t size_t_blob; + char filename[H5FD_MIRROR_XMIT_FILEPATH_MAX]; +} H5FD_mirror_xmit_open_t; + +/* --------------------------------------------------------------------------- + * Structure: H5FD_mirror_xmit_reply_t + * + * Structure used by the remote receiver/worker/writer to respond to + * a command from the VFD sender. + * + * `pub` (H5FD_mirror_xmit_t) + * Common transmission header, containing session information. + * Must be first. + * + * `status` (uint32_t) + * Number indicating whether the command was successful or if an + * occured. + * Allowed values are H5FD_MIRROR_STATUS_OK and + * H5FD_MIRROR_STATUS_ERROR. + * + * `message` (char[]) + * Error message. Populated if and only if there was a problem. + * It is possible that a message may reach the end of the alloted + * space without a NULL terminator -- the onus is on the programmer to + * handle this situation. + * + * --------------------------------------------------------------------------- + */ +typedef struct H5FD_mirror_xmit_reply_t { + H5FD_mirror_xmit_t pub; + uint32_t status; + char message[H5FD_MIRROR_STATUS_MESSAGE_MAX]; +} H5FD_mirror_xmit_reply_t; + +/* --------------------------------------------------------------------------- + * Structure: H5FD_mirror_xmit_write_t + * + * Structure containing data-write information from VFD sender. + * + * The data to be written is transmitted in subsequent, packets + * and may be broken up into more than one transmission buffer. + * The VFD sender and remote receiver/worker/writer must coordinate + * the receipt of data. + * + * `pub` (H5FD_mirror_xmit_t) + * Common transmission header, containing session information. + * Must be first. + * + * `type` (uint8_t) + * Specifies datatype to be written. + * (Natively 'H5FD_mem_t', an enumerated type in H5Fpublic.h) + * + * `offset` (uint64_t) + * Start location of write in file. + * (Natively 'haddr_t', always a 64-bit field) + * + * `size` (uint64_t) + * Size of the data to be written, in bytes. + * (Natively 'size_t', accommodate the largest possible as 64-bits) + * + * --------------------------------------------------------------------------- + */ +typedef struct H5FD_mirror_xmit_write_t { + H5FD_mirror_xmit_t pub; + uint8_t type; + uint64_t offset; + uint64_t size; +} H5FD_mirror_xmit_write_t; + +/* Encode/decode routines are required to "pack" the xmit data into a known + * byte format for transmission over the wire. + * + * All component numbers must be stored in "network" word order (Big-Endian). + * + * All components must be packed in the order given in the structure definition. + * + * All components must be packed with zero padding between. + */ + +H5_DLL size_t H5FD__mirror_xmit_decode_uint16(uint16_t *out, const unsigned char *buf); +H5_DLL size_t H5FD__mirror_xmit_decode_uint32(uint32_t *out, const unsigned char *buf); +H5_DLL size_t H5FD__mirror_xmit_decode_uint64(uint64_t *out, const unsigned char *buf); +H5_DLL size_t H5FD__mirror_xmit_decode_uint8(uint8_t *out, const unsigned char *buf); +H5_DLL size_t H5FD__mirror_xmit_encode_uint16(unsigned char *dest, uint16_t v); +H5_DLL size_t H5FD__mirror_xmit_encode_uint32(unsigned char *dest, uint32_t v); +H5_DLL size_t H5FD__mirror_xmit_encode_uint64(unsigned char *dest, uint64_t v); +H5_DLL size_t H5FD__mirror_xmit_encode_uint8(unsigned char *dest, uint8_t v); + +H5_DLL size_t H5FD_mirror_xmit_decode_header(H5FD_mirror_xmit_t *out, const unsigned char *buf); +H5_DLL size_t H5FD_mirror_xmit_decode_lock(H5FD_mirror_xmit_lock_t *out, const unsigned char *buf); +H5_DLL size_t H5FD_mirror_xmit_decode_open(H5FD_mirror_xmit_open_t *out, const unsigned char *buf); +H5_DLL size_t H5FD_mirror_xmit_decode_reply(H5FD_mirror_xmit_reply_t *out, const unsigned char *buf); +H5_DLL size_t H5FD_mirror_xmit_decode_set_eoa(H5FD_mirror_xmit_eoa_t *out, const unsigned char *buf); +H5_DLL size_t H5FD_mirror_xmit_decode_write(H5FD_mirror_xmit_write_t *out, const unsigned char *buf); + +H5_DLL size_t H5FD_mirror_xmit_encode_header(unsigned char *dest, const H5FD_mirror_xmit_t *x); +H5_DLL size_t H5FD_mirror_xmit_encode_lock(unsigned char *dest, const H5FD_mirror_xmit_lock_t *x); +H5_DLL size_t H5FD_mirror_xmit_encode_open(unsigned char *dest, const H5FD_mirror_xmit_open_t *x); +H5_DLL size_t H5FD_mirror_xmit_encode_reply(unsigned char *dest, const H5FD_mirror_xmit_reply_t *x); +H5_DLL size_t H5FD_mirror_xmit_encode_set_eoa(unsigned char *dest, const H5FD_mirror_xmit_eoa_t *x); +H5_DLL size_t H5FD_mirror_xmit_encode_write(unsigned char *dest, const H5FD_mirror_xmit_write_t *x); + +H5_DLL hbool_t H5FD_mirror_xmit_is_close(const H5FD_mirror_xmit_t *xmit); +H5_DLL hbool_t H5FD_mirror_xmit_is_lock(const H5FD_mirror_xmit_lock_t *xmit); +H5_DLL hbool_t H5FD_mirror_xmit_is_open(const H5FD_mirror_xmit_open_t *xmit); +H5_DLL hbool_t H5FD_mirror_xmit_is_reply(const H5FD_mirror_xmit_reply_t *xmit); +H5_DLL hbool_t H5FD_mirror_xmit_is_set_eoa(const H5FD_mirror_xmit_eoa_t *xmit); +H5_DLL hbool_t H5FD_mirror_xmit_is_write(const H5FD_mirror_xmit_write_t *xmit); +H5_DLL hbool_t H5FD_mirror_xmit_is_xmit(const H5FD_mirror_xmit_t *xmit); + +#ifdef __cplusplus +} +#endif + +#endif /* H5_HAVE_MIRROR_VFD */ + +#endif /* H5FDmirror_priv_H */ diff --git a/src/H5FDmulti.c b/src/H5FDmulti.c index e71f450..d6d56a6 100644 --- a/src/H5FDmulti.c +++ b/src/H5FDmulti.c @@ -15,12 +15,12 @@ * Programmer: Robb Matzke * Monday, November 10, 1997 * - * Purpose: Implements a file driver which dispatches I/O requests to - * other file drivers depending on the purpose of the address - * region being accessed. For instance, all meta-data could be - * place in one file while all raw data goes to some other file. - * This also serves as an example of coding a complex file driver, - * therefore, it should not use any non-public definitions. + * Purpose: Implements a file driver which dispatches I/O requests to + * other file drivers depending on the purpose of the address + * region being accessed. For instance, all meta-data could be + * place in one file while all raw data goes to some other file. + * This also serves as an example of coding a complex file driver, + * therefore, it should not use any non-public definitions. */ #include #include @@ -35,6 +35,15 @@ #define TRUE 1 #endif +/* Windows doesn't like some POSIX names and redefines them with an + * underscore + */ +#ifdef _WIN32 +#define my_strdup _strdup +#else +#define my_strdup strdup +#endif + /* Loop through all mapped files */ #define UNIQUE_MEMBERS_CORE(MAP, ITER, SEEN, LOOPVAR) \ { \ @@ -103,9 +112,8 @@ typedef struct H5FD_multi_dxpl_t { } H5FD_multi_dxpl_t; /* Private functions */ -static char *my_strdup(const char *s); -static int compute_next(H5FD_multi_t *file); -static int open_members(H5FD_multi_t *file); +static int compute_next(H5FD_multi_t *file); +static int open_members(H5FD_multi_t *file); /* Callback prototypes */ static herr_t H5FD_multi_term(void); @@ -173,36 +181,6 @@ static const H5FD_class_t H5FD_multi_g = { }; /*------------------------------------------------------------------------- - * Function: my_strdup - * - * Purpose: Private version of strdup() - * - * Return: Success: Ptr to new copy of string - * - * Failure: NULL - * - * Programmer: Robb Matzke - * Friday, August 13, 1999 - * - *------------------------------------------------------------------------- - */ -static char * -my_strdup(const char *s) -{ - char * x; - size_t str_len; - - if (!s) - return NULL; - str_len = strlen(s) + 1; - if (NULL == (x = (char *)malloc(str_len))) - return NULL; - memcpy(x, s, str_len); - - return x; -} - -/*------------------------------------------------------------------------- * Function: H5FD_multi_init * * Purpose: Initialize this driver by registering the driver with the @@ -229,9 +207,9 @@ H5FD_multi_init(void) } /* end H5FD_multi_init() */ /*--------------------------------------------------------------------------- - * Function: H5FD_multi_term + * Function: H5FD_multi_term * - * Purpose: Shut down the VFD + * Purpose: Shut down the VFD * * Returns: Non-negative on success or negative on failure * @@ -250,17 +228,17 @@ H5FD_multi_term(void) } /* end H5FD_multi_term() */ /*------------------------------------------------------------------------- - * Function: H5Pset_fapl_split + * Function: H5Pset_fapl_split * - * Purpose: Compatibility function. Makes the multi driver act like the - * old split driver which stored meta data in one file and raw - * data in another file. + * Purpose: Compatibility function. Makes the multi driver act like the + * old split driver which stored meta data in one file and raw + * data in another file. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 11, 1999 * *------------------------------------------------------------------------- @@ -340,77 +318,77 @@ H5Pset_fapl_split(hid_t fapl, const char *meta_ext, hid_t meta_plist_id, const c } /*------------------------------------------------------------------------- - * Function: H5Pset_fapl_multi + * Function: H5Pset_fapl_multi * - * Purpose: Sets the file access property list FAPL_ID to use the multi - * driver. The MEMB_MAP array maps memory usage types to other - * memory usage types and is the mechanism which allows the - * caller to specify how many files are created. The array - * contains H5FD_MEM_NTYPES entries which are either the value - * H5FD_MEM_DEFAULT or a memory usage type and the number of - * unique values determines the number of files which are - * opened. For each memory usage type which will be associated - * with a file the MEMB_FAPL array should have a property list - * and the MEMB_NAME array should be a name generator (a - * printf-style format with a %s which will be replaced with the - * name passed to H5FDopen(), usually from H5Fcreate() or - * H5Fopen()). + * Purpose: Sets the file access property list FAPL_ID to use the multi + * driver. The MEMB_MAP array maps memory usage types to other + * memory usage types and is the mechanism which allows the + * caller to specify how many files are created. The array + * contains H5FD_MEM_NTYPES entries which are either the value + * H5FD_MEM_DEFAULT or a memory usage type and the number of + * unique values determines the number of files which are + * opened. For each memory usage type which will be associated + * with a file the MEMB_FAPL array should have a property list + * and the MEMB_NAME array should be a name generator (a + * printf-style format with a %s which will be replaced with the + * name passed to H5FDopen(), usually from H5Fcreate() or + * H5Fopen()). * - * If RELAX is set then opening an existing file for read-only - * access will not fail if some file members are missing. This - * allows a file to be accessed in a limited sense if just the - * meta data is available. + * If RELAX is set then opening an existing file for read-only + * access will not fail if some file members are missing. This + * allows a file to be accessed in a limited sense if just the + * meta data is available. * - * Defaults: Default values for each of the optional arguments are: + * Defaults: Default values for each of the optional arguments are: * - * memb_map: The default member map has the value - * H5FD_MEM_DEFAULT for each element. + * memb_map: The default member map has the value + * H5FD_MEM_DEFAULT for each element. * - * memb_fapl: The value H5P_DEFAULT for each element. + * memb_fapl: The value H5P_DEFAULT for each element. * - * memb_name: The string `%s-X.h5' where `X' is one of the - * letters `s' (H5FD_MEM_SUPER), - * `b' (H5FD_MEM_BTREE), `r' (H5FD_MEM_DRAW), - * `g' (H5FD_MEM_GHEAP), 'l' (H5FD_MEM_LHEAP), - * `o' (H5FD_MEM_OHDR). + * memb_name: The string `%s-X.h5' where `X' is one of the + * letters `s' (H5FD_MEM_SUPER), + * `b' (H5FD_MEM_BTREE), `r' (H5FD_MEM_DRAW), + * `g' (H5FD_MEM_GHEAP), 'l' (H5FD_MEM_LHEAP), + * `o' (H5FD_MEM_OHDR). * - * memb_addr: The value HADDR_UNDEF for each element. + * memb_addr: The value HADDR_UNDEF for each element. * * - * Example: To set up a multi file access property list which partitions - * data into meta and raw files each being 1/2 of the address - * space one would say: + * Example: To set up a multi file access property list which partitions + * data into meta and raw files each being 1/2 of the address + * space one would say: * - * H5FD_mem_t mt, memb_map[H5FD_MEM_NTYPES]; - * hid_t memb_fapl[H5FD_MEM_NTYPES]; - * const char *memb[H5FD_MEM_NTYPES]; - * haddr_t memb_addr[H5FD_MEM_NTYPES]; + * H5FD_mem_t mt, memb_map[H5FD_MEM_NTYPES]; + * hid_t memb_fapl[H5FD_MEM_NTYPES]; + * const char *memb[H5FD_MEM_NTYPES]; + * haddr_t memb_addr[H5FD_MEM_NTYPES]; * - * // The mapping... - * for (mt=0; mt= H5FD_MEM_NTYPES) - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADRANGE, "file resource type out of range", - -1) if (H5FD_MEM_DEFAULT == mmt) mmt = mt; + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADRANGE, "file resource type out of range", -1); + if (H5FD_MEM_DEFAULT == mmt) + mmt = mt; /* * All members of MEMB_FAPL must be either defaults or actual file * access property lists. */ if (H5P_DEFAULT != memb_fapl[mmt] && TRUE != H5Pisa_class(memb_fapl[mmt], H5P_FILE_ACCESS)) - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "file resource type incorrect", -1) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "file resource type incorrect", -1); - /* All names must be defined */ - if (!memb_name[mmt] || !memb_name[mmt][0]) H5Epush_ret( - func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "file resource type not set", -1) + /* All names must be defined */ + if (!memb_name[mmt] || !memb_name[mmt][0]) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "file resource type not set", -1); } /* @@ -500,17 +479,17 @@ H5Pset_fapl_multi(hid_t fapl_id, const H5FD_mem_t *memb_map, const hid_t *memb_f } /*------------------------------------------------------------------------- - * Function: H5Pget_fapl_multi + * Function: H5Pget_fapl_multi * - * Purpose: Returns information about the multi file access property - * list though the function arguments which are the same as for - * H5Pset_fapl_multi() above. + * Purpose: Returns information about the multi file access property + * list though the function arguments which are the same as for + * H5Pset_fapl_multi() above. * - * Return: Success: Non-negative + * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- @@ -529,13 +508,14 @@ H5Pget_fapl_multi(hid_t fapl_id, H5FD_mem_t *memb_map /*out*/, hid_t *memb_fapl H5Eclear2(H5E_DEFAULT); if (H5I_GENPROP_LST != H5Iget_type(fapl_id) || TRUE != H5Pisa_class(fapl_id, H5P_FILE_ACCESS)) - H5Epush_ret(func, H5E_ERR_CLS, H5E_PLIST, H5E_BADTYPE, "not an access list", - -1) if (H5FD_MULTI != H5Pget_driver(fapl_id)) - H5Epush_ret(func, H5E_ERR_CLS, H5E_PLIST, H5E_BADVALUE, "incorrect VFL driver", - -1) if (NULL == (fa = (const H5FD_multi_fapl_t *)H5Pget_driver_info(fapl_id))) - H5Epush_ret(func, H5E_ERR_CLS, H5E_PLIST, H5E_BADVALUE, "bad VFL driver info", -1) - - if (memb_map) memcpy(memb_map, fa->memb_map, H5FD_MEM_NTYPES * sizeof(H5FD_mem_t)); + H5Epush_ret(func, H5E_ERR_CLS, H5E_PLIST, H5E_BADTYPE, "not an access list", -1); + if (H5FD_MULTI != H5Pget_driver(fapl_id)) + H5Epush_ret(func, H5E_ERR_CLS, H5E_PLIST, H5E_BADVALUE, "incorrect VFL driver", -1); + if (NULL == (fa = (const H5FD_multi_fapl_t *)H5Pget_driver_info(fapl_id))) + H5Epush_ret(func, H5E_ERR_CLS, H5E_PLIST, H5E_BADVALUE, "bad VFL driver info", -1); + + if (memb_map) + memcpy(memb_map, fa->memb_map, H5FD_MEM_NTYPES * sizeof(H5FD_mem_t)); if (memb_fapl) { for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt = (H5FD_mem_t)(mt + 1)) { if (fa->memb_fapl[mt] >= 0) @@ -561,16 +541,16 @@ H5Pget_fapl_multi(hid_t fapl_id, H5FD_mem_t *memb_map /*out*/, hid_t *memb_fapl } /*------------------------------------------------------------------------- - * Function: H5FD_multi_sb_size + * Function: H5FD_multi_sb_size * - * Purpose: Returns the size of the private information to be stored in - * the superblock. + * Purpose: Returns the size of the private information to be stored in + * the superblock. * - * Return: Success: The super block driver data size. + * Return: Success: The super block driver data size. * - * Failure: never fails + * Failure: never fails * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, August 16, 1999 * *------------------------------------------------------------------------- @@ -605,24 +585,24 @@ H5FD_multi_sb_size(H5FD_t *_file) } /*------------------------------------------------------------------------- - * Function: H5FD_multi_sb_encode + * Function: H5FD_multi_sb_encode * - * Purpose: Encode driver information for the superblock. The NAME - * argument is a nine-byte buffer which will be initialized with - * an eight-character name/version number and null termination. + * Purpose: Encode driver information for the superblock. The NAME + * argument is a nine-byte buffer which will be initialized with + * an eight-character name/version number and null termination. * - * The encoding is a six-byte member mapping followed two bytes - * which are unused. For each unique file in usage-type order - * encode all the starting addresses as unsigned 64-bit integers, - * then all the EOA values as unsigned 64-bit integers, then all - * the template names as null terminated strings which are - * multiples of 8 characters. + * The encoding is a six-byte member mapping followed two bytes + * which are unused. For each unique file in usage-type order + * encode all the starting addresses as unsigned 64-bit integers, + * then all the EOA values as unsigned 64-bit integers, then all + * the template names as null terminated strings which are + * multiples of 8 characters. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, August 16, 1999 * *------------------------------------------------------------------------- @@ -672,10 +652,10 @@ H5FD_multi_sb_encode(H5FD_t *_file, char *name /*out*/, unsigned char *buf /*out } END_MEMBERS; if (H5Tconvert(H5T_NATIVE_HADDR, H5T_STD_U64LE, nseen * 2, buf + 8, NULL, H5P_DEFAULT) < 0) - H5Epush_ret(func, H5E_ERR_CLS, H5E_DATATYPE, H5E_CANTCONVERT, "can't convert superblock info", -1) + H5Epush_ret(func, H5E_ERR_CLS, H5E_DATATYPE, H5E_CANTCONVERT, "can't convert superblock info", -1); - /* Encode all name templates */ - p = buf + 8 + nseen * 2 * 8; + /* Encode all name templates */ + p = buf + 8 + nseen * 2 * 8; UNIQUE_MEMBERS (file->fa.memb_map, mt) { size_t n = strlen(file->fa.memb_name[mt]) + 1; strncpy((char *)p, file->fa.memb_name[mt], n); @@ -689,21 +669,21 @@ H5FD_multi_sb_encode(H5FD_t *_file, char *name /*out*/, unsigned char *buf /*out } /* end H5FD_multi_sb_encode() */ /*------------------------------------------------------------------------- - * Function: H5FD_multi_sb_decode + * Function: H5FD_multi_sb_decode * - * Purpose: Decodes the superblock information for this driver. The NAME - * argument is the eight-character (plus null termination) name - * stored in the file. + * Purpose: Decodes the superblock information for this driver. The NAME + * argument is the eight-character (plus null termination) name + * stored in the file. * - * The FILE argument is updated according to the information in - * the superblock. This may mean that some member files are - * closed and others are opened. + * The FILE argument is updated according to the information in + * the superblock. This may mean that some member files are + * closed and others are opened. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, August 16, 1999 * *------------------------------------------------------------------------- @@ -728,16 +708,15 @@ H5FD_multi_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf) H5Eclear2(H5E_DEFAULT); /* Make sure the name/version number is correct */ - if (strcmp(name, "NCSAmult")) - H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_BADVALUE, "invalid multi superblock", -1) + if (strcmp(name, "NCSAmult") != 0) + H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_BADVALUE, "invalid multi superblock", -1); - /* Set default values */ - ALL_MEMBERS (mt) - { - memb_addr[mt] = HADDR_UNDEF; - memb_eoa[mt] = HADDR_UNDEF; - memb_name[mt] = NULL; - } + /* Set default values */ + ALL_MEMBERS (mt) { + memb_addr[mt] = HADDR_UNDEF; + memb_eoa[mt] = HADDR_UNDEF; + memb_name[mt] = NULL; + } END_MEMBERS; /* @@ -762,9 +741,9 @@ H5FD_multi_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf) memcpy(x, buf, (nseen * 2 * 8)); buf += nseen * 2 * 8; if (H5Tconvert(H5T_STD_U64LE, H5T_NATIVE_HADDR, nseen * 2, x, NULL, H5P_DEFAULT) < 0) - H5Epush_ret(func, H5E_ERR_CLS, H5E_DATATYPE, H5E_CANTCONVERT, "can't convert superblock info", -1) - ap = (haddr_t *)((void *)x); /* Extra (void *) cast to quiet "cast to create alignment" warning - - 2019/07/05, QAK */ + H5Epush_ret(func, H5E_ERR_CLS, H5E_DATATYPE, H5E_CANTCONVERT, "can't convert superblock info", -1); + ap = (haddr_t *)((void *)x); /* Extra (void *) cast to quiet "cast to create alignment" warning - + 2019/07/05, QAK */ UNIQUE_MEMBERS (map, mt) { memb_addr[_unmapped] = *ap++; memb_eoa[_unmapped] = *ap++; @@ -819,41 +798,40 @@ H5FD_multi_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf) } END_MEMBERS; if (compute_next(file) < 0) - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "compute_next() failed", -1) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "compute_next() failed", -1); - /* Open all necessary files */ - if (open_members(file) < 0) - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "open_members() failed", -1) + /* Open all necessary files */ + if (open_members(file) < 0) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "open_members() failed", -1); - /* Set the EOA marker for all open files */ - UNIQUE_MEMBERS (file->fa.memb_map, mt) - { - if (file->memb[mt]) - if (H5FDset_eoa(file->memb[mt], mt, memb_eoa[mt]) < 0) - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_CANTSET, "set_eoa() failed", -1) + /* Set the EOA marker for all open files */ + UNIQUE_MEMBERS (file->fa.memb_map, mt) { + if (file->memb[mt]) + if (H5FDset_eoa(file->memb[mt], mt, memb_eoa[mt]) < 0) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_CANTSET, "set_eoa() failed", -1); - /* Save the individual EOAs in one place for later comparison (in H5FD_multi_set_eoa) - */ - file->memb_eoa[mt] = memb_eoa[mt]; - } + /* Save the individual EOAs in one place for later comparison (in H5FD_multi_set_eoa) + */ + file->memb_eoa[mt] = memb_eoa[mt]; + } END_MEMBERS; return 0; } /* end H5FD_multi_sb_decode() */ /*------------------------------------------------------------------------- - * Function: H5FD_multi_fapl_get + * Function: H5FD_multi_fapl_get * - * Purpose: Returns a file access property list which indicates how the - * specified file is being accessed. The return list could be - * used to access another file the same way. + * Purpose: Returns a file access property list which indicates how the + * specified file is being accessed. The return list could be + * used to access another file the same way. * - * Return: Success: Ptr to new file access property list with all - * members copied from the file struct. + * Return: Success: Ptr to new file access property list with all + * members copied from the file struct. * - * Failure: NULL + * Failure: NULL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Friday, August 13, 1999 * *------------------------------------------------------------------------- @@ -870,15 +848,15 @@ H5FD_multi_fapl_get(H5FD_t *_file) } /*------------------------------------------------------------------------- - * Function: H5FD_multi_fapl_copy + * Function: H5FD_multi_fapl_copy * - * Purpose: Copies the multi-specific file access properties. + * Purpose: Copies the multi-specific file access properties. * - * Return: Success: Ptr to a new property list + * Return: Success: Ptr to a new property list * - * Failure: NULL + * Failure: NULL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- @@ -924,21 +902,21 @@ H5FD_multi_fapl_copy(const void *_old_fa) } END_MEMBERS; free(new_fa); - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "can't release object on error", NULL) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "can't release object on error", NULL); } return new_fa; } /*------------------------------------------------------------------------- - * Function: H5FD_multi_fapl_free + * Function: H5FD_multi_fapl_free * - * Purpose: Frees the multi-specific file access properties. + * Purpose: Frees the multi-specific file access properties. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- @@ -955,8 +933,9 @@ H5FD_multi_fapl_free(void *_fa) ALL_MEMBERS (mt) { if (fa->memb_fapl[mt] >= 0) if (H5Idec_ref(fa->memb_fapl[mt]) < 0) - H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_CANTCLOSEOBJ, "can't close property list", - -1) if (fa->memb_name[mt]) free(fa->memb_name[mt]); + H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_CANTCLOSEOBJ, "can't close property list", -1); + if (fa->memb_name[mt]) + free(fa->memb_name[mt]); } END_MEMBERS; free(fa); @@ -965,17 +944,17 @@ H5FD_multi_fapl_free(void *_fa) } /*------------------------------------------------------------------------- - * Function: H5FD_multi_open + * Function: H5FD_multi_open * - * Purpose: Creates and/or opens a multi HDF5 file. + * Purpose: Creates and/or opens a multi HDF5 file. * - * Return: Success: A pointer to a new file data structure. The - * public fields will be initialized by the - * caller, which is always H5FD_open(). + * Return: Success: A pointer to a new file data structure. The + * public fields will be initialized by the + * caller, which is always H5FD_open(). * - * Failure: NULL + * Failure: NULL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- @@ -994,24 +973,23 @@ H5FD_multi_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr /* Check arguments */ if (!name || !*name) - H5Epush_ret(func, H5E_ERR_CLS, H5E_ARGS, H5E_BADVALUE, "invalid file name", - NULL) if (0 == maxaddr || HADDR_UNDEF == maxaddr) - H5Epush_ret(func, H5E_ERR_CLS, H5E_ARGS, H5E_BADRANGE, "bogus maxaddr", NULL) + H5Epush_ret(func, H5E_ERR_CLS, H5E_ARGS, H5E_BADVALUE, "invalid file name", NULL); + if (0 == maxaddr || HADDR_UNDEF == maxaddr) + H5Epush_ret(func, H5E_ERR_CLS, H5E_ARGS, H5E_BADRANGE, "bogus maxaddr", NULL); - /* - * Initialize the file from the file access properties, using default - * values if necessary. Make sure to use CALLOC here because the code - * in H5FD_multi_set_eoa depends on the proper initialization of memb_eoa - * in H5FD_multi_t. - */ - if (NULL == (file = (H5FD_multi_t *)calloc((size_t)1, sizeof(H5FD_multi_t)))) H5Epush_ret( - func, H5E_ERR_CLS, H5E_RESOURCE, H5E_NOSPACE, "memory allocation failed", - NULL) if (H5P_FILE_ACCESS_DEFAULT == fapl_id || H5FD_MULTI != H5Pget_driver(fapl_id)) - { - close_fapl = fapl_id = H5Pcreate(H5P_FILE_ACCESS); - if (H5Pset_fapl_multi(fapl_id, NULL, NULL, NULL, NULL, TRUE) < 0) - H5Epush_goto(func, H5E_ERR_CLS, H5E_FILE, H5E_CANTSET, "can't set property value", error) - } + /* + * Initialize the file from the file access properties, using default + * values if necessary. Make sure to use CALLOC here because the code + * in H5FD_multi_set_eoa depends on the proper initialization of memb_eoa + * in H5FD_multi_t. + */ + if (NULL == (file = (H5FD_multi_t *)calloc((size_t)1, sizeof(H5FD_multi_t)))) + H5Epush_ret(func, H5E_ERR_CLS, H5E_RESOURCE, H5E_NOSPACE, "memory allocation failed", NULL); + if (H5P_FILE_ACCESS_DEFAULT == fapl_id || H5FD_MULTI != H5Pget_driver(fapl_id)) { + close_fapl = fapl_id = H5Pcreate(H5P_FILE_ACCESS); + if (H5Pset_fapl_multi(fapl_id, NULL, NULL, NULL, NULL, TRUE) < 0) + H5Epush_goto(func, H5E_ERR_CLS, H5E_FILE, H5E_CANTSET, "can't set property value", error) + } fa = (const H5FD_multi_fapl_t *)H5Pget_driver_info(fapl_id); assert(fa); ALL_MEMBERS (mt) { @@ -1067,17 +1045,17 @@ error: } /*------------------------------------------------------------------------- - * Function: H5FD_multi_close + * Function: H5FD_multi_close * - * Purpose: Closes a multi file. + * Purpose: Closes a multi file. * - * Return: Success: Non-negative + * Return: Success: Non-negative * - * Failure: Negative with as many members closed as - * possible. The only subsequent operation - * permitted on the file is a close operation. + * Failure: Negative with as many members closed as + * possible. The only subsequent operation + * permitted on the file is a close operation. * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- @@ -1105,16 +1083,15 @@ H5FD_multi_close(H5FD_t *_file) } END_MEMBERS; if (nerrors) - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "error closing member files", -1) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "error closing member files", -1); - /* Clean up other stuff */ - ALL_MEMBERS (mt) - { - if (file->fa.memb_fapl[mt] >= 0) - (void)H5Idec_ref(file->fa.memb_fapl[mt]); - if (file->fa.memb_name[mt]) - free(file->fa.memb_name[mt]); - } + /* Clean up other stuff */ + ALL_MEMBERS (mt) { + if (file->fa.memb_fapl[mt] >= 0) + (void)H5Idec_ref(file->fa.memb_fapl[mt]); + if (file->fa.memb_name[mt]) + free(file->fa.memb_name[mt]); + } END_MEMBERS; free(file->name); @@ -1123,20 +1100,19 @@ H5FD_multi_close(H5FD_t *_file) } /*------------------------------------------------------------------------- - * Function: H5FD_multi_cmp + * Function: H5FD_multi_cmp * - * Purpose: Compares two file families to see if they are the same. It - * does this by comparing the first common member of the two - * families. If the families have no members in common then the - * file with the earliest member is smaller than the other file. - * We abort if neither file has any members. + * Purpose: Compares two file families to see if they are the same. It + * does this by comparing the first common member of the two + * families. If the families have no members in common then the + * file with the earliest member is smaller than the other file. + * We abort if neither file has any members. * - * Return: Success: like strcmp() + * Return: Success: like strcmp() * - * Failure: never fails (arguments were checked by the - * caller). + * Failure: never fails (arguments were checked by th caller). * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- @@ -1172,16 +1148,16 @@ H5FD_multi_cmp(const H5FD_t *_f1, const H5FD_t *_f2) } /*------------------------------------------------------------------------- - * Function: H5FD_multi_query + * Function: H5FD_multi_query * - * Purpose: Set the flags that this VFL driver is capable of supporting. + * Purpose: Set the flags that this VFL driver is capable of supporting. * (listed in H5FDpublic.h) * - * Return: Success: non-negative + * Return: Success: non-negative * - * Failure: negative + * Failure: negative * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Tuesday, September 26, 2000 * *------------------------------------------------------------------------- @@ -1190,7 +1166,7 @@ static herr_t H5FD_multi_query(const H5FD_t *_f, unsigned long *flags /* out */) { /* Shut compiler up */ - _f = _f; + (void)_f; /* Set the VFL feature flags that this driver supports */ if (flags) { @@ -1205,14 +1181,14 @@ H5FD_multi_query(const H5FD_t *_f, unsigned long *flags /* out */) } /* end H5FD_multi_query() */ /*------------------------------------------------------------------------- - * Function: H5FD_multi_get_type_map + * Function: H5FD_multi_get_type_map * - * Purpose: Retrieve the memory type mapping for this file + * Purpose: Retrieve the memory type mapping for this file * - * Return: Success: non-negative - * Failure: negative + * Return: Success: non-negative + * Failure: negative * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Tuesday, October 9, 2008 * *------------------------------------------------------------------------- @@ -1229,17 +1205,17 @@ H5FD_multi_get_type_map(const H5FD_t *_file, H5FD_mem_t *type_map) } /* end H5FD_multi_get_type_map() */ /*------------------------------------------------------------------------- - * Function: H5FD_multi_get_eoa + * Function: H5FD_multi_get_eoa * - * Purpose: Returns the end-of-address marker for the file. The EOA - * marker is the first address past the last byte allocated in - * the format address space. + * Purpose: Returns the end-of-address marker for the file. The EOA + * marker is the first address past the last byte allocated in + * the format address space. * - * Return: Success: The end-of-address-marker + * Return: Success: The end-of-address-marker * - * Failure: HADDR_UNDEF + * Failure: HADDR_UNDEF * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- @@ -1274,7 +1250,9 @@ H5FD_multi_get_eoa(const H5FD_t *_file, H5FD_mem_t type) if (HADDR_UNDEF == memb_eoa) H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "member file has unknown eoa", - HADDR_UNDEF) if (memb_eoa > 0) memb_eoa += file->fa.memb_addr[mt]; + HADDR_UNDEF); + if (memb_eoa > 0) + memb_eoa += file->fa.memb_addr[mt]; } else if (file->fa.relax) { /* @@ -1285,7 +1263,7 @@ H5FD_multi_get_eoa(const H5FD_t *_file, H5FD_mem_t type) assert(HADDR_UNDEF != memb_eoa); } else { - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "bad eoa", HADDR_UNDEF) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "bad eoa", HADDR_UNDEF); } if (memb_eoa > eoa) @@ -1308,7 +1286,9 @@ H5FD_multi_get_eoa(const H5FD_t *_file, H5FD_mem_t type) if (HADDR_UNDEF == eoa) H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "member file has unknown eoa", - HADDR_UNDEF) if (eoa > 0) eoa += file->fa.memb_addr[mmt]; + HADDR_UNDEF); + if (eoa > 0) + eoa += file->fa.memb_addr[mmt]; } else if (file->fa.relax) { /* @@ -1319,7 +1299,7 @@ H5FD_multi_get_eoa(const H5FD_t *_file, H5FD_mem_t type) assert(HADDR_UNDEF != eoa); } else { - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "bad eoa", HADDR_UNDEF) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "bad eoa", HADDR_UNDEF); } } @@ -1327,18 +1307,18 @@ H5FD_multi_get_eoa(const H5FD_t *_file, H5FD_mem_t type) } /* end H5FD_multi_get_eoa() */ /*------------------------------------------------------------------------- - * Function: H5FD_multi_set_eoa + * Function: H5FD_multi_set_eoa * - * Purpose: Set the end-of-address marker for the file by savig the new - * EOA value in the file struct. Also set the EOA marker for the - * subfile in which the new EOA value falls. We don't set the - * EOA values of any other subfiles. + * Purpose: Set the end-of-address marker for the file by savig the new + * EOA value in the file struct. Also set the EOA marker for the + * subfile in which the new EOA value falls. We don't set the + * EOA values of any other subfiles. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- @@ -1385,24 +1365,24 @@ H5FD_multi_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t eoa) } H5E_END_TRY; if (status < 0) - H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_BADVALUE, "member H5FDset_eoa failed", -1) + H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_BADVALUE, "member H5FDset_eoa failed", -1); - return 0; + return 0; } /* end H5FD_multi_set_eoa() */ /*------------------------------------------------------------------------- - * Function: H5FD_multi_get_eof + * Function: H5FD_multi_get_eof * - * Purpose: Returns the end-of-file marker, which is the greater of - * either the total multi size or the current EOA marker. + * Purpose: Returns the end-of-file marker, which is the greater of + * either the total multi size or the current EOA marker. * - * Return: Success: End of file address, the first address past - * the end of the multi of files or the current - * EOA, whichever is larger. + * Return: Success: End of file address, the first address past + * the end of the multi of files or the current + * EOA, whichever is larger. * - * Failure: HADDR_UNDEF + * Failure: HADDR_UNDEF * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- @@ -1431,7 +1411,9 @@ H5FD_multi_get_eof(const H5FD_t *_file, H5FD_mem_t type) if (HADDR_UNDEF == tmp_eof) H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "member file has unknown eof", - HADDR_UNDEF) if (tmp_eof > 0) tmp_eof += file->fa.memb_addr[mt]; + HADDR_UNDEF); + if (tmp_eof > 0) + tmp_eof += file->fa.memb_addr[mt]; } else if (file->fa.relax) { /* @@ -1442,7 +1424,7 @@ H5FD_multi_get_eof(const H5FD_t *_file, H5FD_mem_t type) assert(HADDR_UNDEF != tmp_eof); } else { - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "bad eof", HADDR_UNDEF) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "bad eof", HADDR_UNDEF); } if (tmp_eof > eof) eof = tmp_eof; @@ -1465,7 +1447,9 @@ H5FD_multi_get_eof(const H5FD_t *_file, H5FD_mem_t type) if (HADDR_UNDEF == eof) H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "member file has unknown eof", - HADDR_UNDEF) if (eof > 0) eof += file->fa.memb_addr[mmt]; + HADDR_UNDEF); + if (eof > 0) + eof += file->fa.memb_addr[mmt]; } else if (file->fa.relax) { /* @@ -1476,7 +1460,7 @@ H5FD_multi_get_eof(const H5FD_t *_file, H5FD_mem_t type) assert(HADDR_UNDEF != eof); } else { - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "bad eof", HADDR_UNDEF) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "bad eof", HADDR_UNDEF); } } return eof; @@ -1504,9 +1488,10 @@ H5FD_multi_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle) /* Get data type for multi driver */ if (H5Pget_multi_type(fapl, &type) < 0) H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "can't get data type for multi driver", - -1) if (type < H5FD_MEM_DEFAULT || type >= H5FD_MEM_NTYPES) - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "data type is out of range", -1) mmt = - file->fa.memb_map[type]; + -1); + if (type < H5FD_MEM_DEFAULT || type >= H5FD_MEM_NTYPES) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "data type is out of range", -1); + mmt = file->fa.memb_map[type]; if (H5FD_MEM_DEFAULT == mmt) mmt = type; @@ -1514,15 +1499,15 @@ H5FD_multi_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle) } /*------------------------------------------------------------------------- - * Function: H5FD_multi_alloc + * Function: H5FD_multi_alloc * - * Purpose: Allocate file memory. + * Purpose: Allocate file memory. * - * Return: Success: Address of new memory + * Return: Success: Address of new memory * - * Failure: HADDR_UNDEF + * Failure: HADDR_UNDEF * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, August 12, 1999 * *------------------------------------------------------------------------- @@ -1549,36 +1534,36 @@ H5FD_multi_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size) } if (HADDR_UNDEF == (addr = H5FDalloc(file->memb[mmt], mmt, dxpl_id, size))) - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "member file can't alloc", HADDR_UNDEF) - addr += file->fa.memb_addr[mmt]; + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "member file can't alloc", HADDR_UNDEF); + addr += file->fa.memb_addr[mmt]; /*#ifdef TMP if ( addr + size > file->eoa ) { - if ( H5FD_multi_set_eoa(_file, addr + size) < 0 ) { + if ( H5FD_multi_set_eoa(_file, addr + size) < 0 ) { H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, \ - "can't set eoa", HADDR_UNDEF) - } + "can't set eoa", HADDR_UNDEF); + } } #else if ( addr + size > file->eoa ) - file->eoa = addr + size; + file->eoa = addr + size; #endif */ return addr; } /*------------------------------------------------------------------------- - * Function: H5FD_multi_free + * Function: H5FD_multi_free * - * Purpose: Frees memory + * Purpose: Frees memory * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, August 12, 1999 * *------------------------------------------------------------------------- @@ -1602,18 +1587,18 @@ H5FD_multi_free(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsi } /*------------------------------------------------------------------------- - * Function: H5FD_multi_read + * Function: H5FD_multi_read * - * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR - * into buffer BUF according to data transfer properties in - * DXPL_ID. + * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR + * into buffer BUF according to data transfer properties in + * DXPL_ID. * - * Return: Success: Zero. Result is stored in caller-supplied - * buffer BUF. + * Return: Success: Zero. Result is stored in caller-supplied + * buffer BUF. * - * Failure: -1, contents of buffer BUF are undefined. + * Failure: -1, contents of buffer BUF are undefined. * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- @@ -1649,17 +1634,17 @@ H5FD_multi_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, siz } /* end H5FD_multi_read() */ /*------------------------------------------------------------------------- - * Function: H5FD_multi_write + * Function: H5FD_multi_write * - * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR - * from buffer BUF according to data transfer properties in - * DXPL_ID. + * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR + * from buffer BUF according to data transfer properties in + * DXPL_ID. * - * Return: Success: Zero + * Return: Success: Zero * - * Failure: -1 + * Failure: -1 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- @@ -1695,15 +1680,15 @@ H5FD_multi_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, si } /* end H5FD_multi_write() */ /*------------------------------------------------------------------------- - * Function: H5FD_multi_flush + * Function: H5FD_multi_flush * - * Purpose: Flushes all multi members. + * Purpose: Flushes all multi members. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1, as many files flushed as possible. + * Failure: -1, as many files flushed as possible. * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- @@ -1717,7 +1702,7 @@ H5FD_multi_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing) static const char *func = "H5FD_multi_flush"; /* Function Name for error reporting */ #if 0 - H5FD_mem_t mmt; + H5FD_mem_t mmt; /* Debugging stuff... */ fprintf(stderr, "multifile access information:\n"); @@ -1725,9 +1710,9 @@ H5FD_multi_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing) /* print the map */ fprintf(stderr, " map="); for (mt=1; mtmemb_map[mt]; - if (H5FD_MEM_DEFAULT==mmt) mmt = mt; - fprintf(stderr, "%s%d", 1==mt?"":",", (int)mmt); + mmt = file->memb_map[mt]; + if (H5FD_MEM_DEFAULT==mmt) mmt = mt; + fprintf(stderr, "%s%d", 1==mt?"":",", (int)mmt); } fprintf(stderr, "\n"); @@ -1737,14 +1722,14 @@ H5FD_multi_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing) fprintf(stderr, " ------ -------------------- -------------------- -------------------- ------------------------------\n"); for (mt=1; mtmemb_addr[mt]) { - haddr_t eoa = H5FDget_eoa(file->memb[mt], mt); - fprintf(stderr, " %6d %20llu %20llu %20llu %s\n", - (int)mt, (unsigned long long)(file->memb_addr[mt]), - (unsigned long long)eoa, - (unsigned long long)(file->memb_next[mt]), - file->memb_name[mt]); - } + if (HADDR_UNDEF!=file->memb_addr[mt]) { + haddr_t eoa = H5FDget_eoa(file->memb[mt], mt); + fprintf(stderr, " %6d %20llu %20llu %20llu %s\n", + (int)mt, (unsigned long long)(file->memb_addr[mt]), + (unsigned long long)eoa, + (unsigned long long)(file->memb_next[mt]), + file->memb_name[mt]); + } } #endif @@ -1763,20 +1748,20 @@ H5FD_multi_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing) } } if (nerrors) - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "error flushing member files", -1) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "error flushing member files", -1); - return 0; + return 0; } /*------------------------------------------------------------------------- - * Function: H5FD_multi_truncate + * Function: H5FD_multi_truncate * - * Purpose: Truncates all multi members. + * Purpose: Truncates all multi members. * - * Return: Success: 0 - * Failure: -1, as many files truncated as possible. + * Return: Success: 0 + * Failure: -1, as many files truncated as possible. * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Thursday, January 31, 2008 * *------------------------------------------------------------------------- @@ -1804,23 +1789,23 @@ H5FD_multi_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing) } } if (nerrors) - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "error truncating member files", -1) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "error truncating member files", -1); - return 0; + return 0; } /* end H5FD_multi_truncate() */ /*------------------------------------------------------------------------- - * Function: H5FD_multi_lock + * Function: H5FD_multi_lock * - * Purpose: Place a lock on all multi members. - * When there is error in locking a member file, it will not - * proceed further and will try to remove the locks of those - * member files that are locked before error is encountered. + * Purpose: Place a lock on all multi members. + * When there is error in locking a member file, it will not + * proceed further and will try to remove the locks of those + * member files that are locked before error is encountered. * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * - * Programmer: Vailin Choi; March 2015 + * Programmer: Vailin Choi; March 2015 * *------------------------------------------------------------------------- */ @@ -1872,16 +1857,16 @@ H5FD_multi_lock(H5FD_t *_file, hbool_t rw) } /* H5FD_multi_lock() */ /*------------------------------------------------------------------------- - * Function: H5FD_multi_unlock + * Function: H5FD_multi_unlock * - * Purpose: Remove the lock on all multi members. - * It will try to unlock all member files but will record error - * encountered. + * Purpose: Remove the lock on all multi members. + * It will try to unlock all member files but will record error + * encountered. * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * - * Programmer: Vailin Choi; March 2015 + * Programmer: Vailin Choi; March 2015 * *------------------------------------------------------------------------- */ @@ -1909,16 +1894,16 @@ H5FD_multi_unlock(H5FD_t *_file) } /* H5FD_multi_unlock() */ /*------------------------------------------------------------------------- - * Function: compute_next + * Function: compute_next * - * Purpose: Compute the memb_next[] values of the file based on the - * file's member map and the member starting addresses. + * Purpose: Compute the memb_next[] values of the file based on the + * file's member map and the member starting addresses. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, August 23, 1999 * *------------------------------------------------------------------------- @@ -1953,21 +1938,21 @@ compute_next(H5FD_multi_t *file) } /*------------------------------------------------------------------------- - * Function: open_members + * Function: open_members * - * Purpose: Opens all members which are not opened yet. + * Purpose: Opens all members which are not opened yet. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, August 23, 1999 * *------------------------------------------------------------------------- */ -/* Disable warning for "format not a string literal" here -QAK */ -/* +/* Disable warning for "format not a string literal" here + * * This pragma only needs to surround the snprintf() call with * tmp in the code below, but early (4.4.7, at least) gcc only * allows diagnostic pragmas to be toggled outside of functions. @@ -1978,7 +1963,8 @@ open_members(H5FD_multi_t *file) { char tmp[H5FD_MULT_MAX_FILE_NAME_LEN]; int nerrors = 0; - static const char *func = "(H5FD_multi)open_members"; /* Function Name for error reporting */ + int nchars; + static const char *func = "(H5FD_multi)open_members"; /* Function Name for error reporting */ /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); @@ -1987,11 +1973,11 @@ open_members(H5FD_multi_t *file) if (file->memb[mt]) continue; /*already open*/ assert(file->fa.memb_name[mt]); - /* Note: This truncates the user's filename down to only sizeof(tmp) - * characters. -QK & JK, 2013/01/17 - */ - sprintf(tmp, file->fa.memb_name[mt], file->name); - tmp[sizeof(tmp) - 1] = '\0'; + + nchars = snprintf(tmp, sizeof(tmp), file->fa.memb_name[mt], file->name); + if (nchars < 0 || nchars >= (int)sizeof(tmp)) + H5Epush_ret(func, H5E_ERR_CLS, H5E_VFL, H5E_BADVALUE, + "filename is too long and would be truncated", -1); H5E_BEGIN_TRY { @@ -2005,9 +1991,9 @@ open_members(H5FD_multi_t *file) } END_MEMBERS; if (nerrors) - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "error opening member files", -1) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "error opening member files", -1); - return 0; + return 0; } H5_GCC_DIAG_ON("format-nonliteral") diff --git a/src/H5FDros3.c b/src/H5FDros3.c index a241180..e3c0794 100644 --- a/src/H5FDros3.c +++ b/src/H5FDros3.c @@ -214,59 +214,58 @@ typedef struct H5FD_ros3_t { #define ADDR_OVERFLOW(A) (HADDR_UNDEF == (A) || ((A) & ~(haddr_t)MAXADDR)) /* Prototypes */ -static herr_t H5FD_ros3_term(void); -static void * H5FD_ros3_fapl_get(H5FD_t *_file); -static void * H5FD_ros3_fapl_copy(const void *_old_fa); -static herr_t H5FD_ros3_fapl_free(void *_fa); -static H5FD_t *H5FD_ros3_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); -static herr_t H5FD_ros3_close(H5FD_t *_file); -static int H5FD_ros3_cmp(const H5FD_t *_f1, const H5FD_t *_f2); -static herr_t H5FD_ros3_query(const H5FD_t *_f1, unsigned long *flags); -static haddr_t H5FD_ros3_get_eoa(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD_ros3_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); -static haddr_t H5FD_ros3_get_eof(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD_ros3_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle); -static herr_t H5FD_ros3_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, - void *buf); -static herr_t H5FD_ros3_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, - const void *buf); -static herr_t H5FD_ros3_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); -static herr_t H5FD_ros3_lock(H5FD_t *_file, hbool_t rw); -static herr_t H5FD_ros3_unlock(H5FD_t *_file); -static herr_t H5FD_ros3_validate_config(const H5FD_ros3_fapl_t *fa); +static herr_t H5FD__ros3_term(void); +static void * H5FD__ros3_fapl_get(H5FD_t *_file); +static void * H5FD__ros3_fapl_copy(const void *_old_fa); +static herr_t H5FD__ros3_fapl_free(void *_fa); +static H5FD_t *H5FD__ros3_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); +static herr_t H5FD__ros3_close(H5FD_t *_file); +static int H5FD__ros3_cmp(const H5FD_t *_f1, const H5FD_t *_f2); +static herr_t H5FD__ros3_query(const H5FD_t *_f1, unsigned long *flags); +static haddr_t H5FD__ros3_get_eoa(const H5FD_t *_file, H5FD_mem_t type); +static herr_t H5FD__ros3_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); +static haddr_t H5FD__ros3_get_eof(const H5FD_t *_file, H5FD_mem_t type); +static herr_t H5FD__ros3_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle); +static herr_t H5FD__ros3_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + void *buf); +static herr_t H5FD__ros3_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + const void *buf); +static herr_t H5FD__ros3_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); + +static herr_t H5FD__ros3_validate_config(const H5FD_ros3_fapl_t *fa); static const H5FD_class_t H5FD_ros3_g = { "ros3", /* name */ MAXADDR, /* maxaddr */ H5F_CLOSE_WEAK, /* fc_degree */ - H5FD_ros3_term, /* terminate */ + H5FD__ros3_term, /* terminate */ NULL, /* sb_size */ NULL, /* sb_encode */ NULL, /* sb_decode */ sizeof(H5FD_ros3_fapl_t), /* fapl_size */ - H5FD_ros3_fapl_get, /* fapl_get */ - H5FD_ros3_fapl_copy, /* fapl_copy */ - H5FD_ros3_fapl_free, /* fapl_free */ + H5FD__ros3_fapl_get, /* fapl_get */ + H5FD__ros3_fapl_copy, /* fapl_copy */ + H5FD__ros3_fapl_free, /* fapl_free */ 0, /* dxpl_size */ NULL, /* dxpl_copy */ NULL, /* dxpl_free */ - H5FD_ros3_open, /* open */ - H5FD_ros3_close, /* close */ - H5FD_ros3_cmp, /* cmp */ - H5FD_ros3_query, /* query */ + H5FD__ros3_open, /* open */ + H5FD__ros3_close, /* close */ + H5FD__ros3_cmp, /* cmp */ + H5FD__ros3_query, /* query */ NULL, /* get_type_map */ NULL, /* alloc */ NULL, /* free */ - H5FD_ros3_get_eoa, /* get_eoa */ - H5FD_ros3_set_eoa, /* set_eoa */ - H5FD_ros3_get_eof, /* get_eof */ - H5FD_ros3_get_handle, /* get_handle */ - H5FD_ros3_read, /* read */ - H5FD_ros3_write, /* write */ + H5FD__ros3_get_eoa, /* get_eoa */ + H5FD__ros3_set_eoa, /* set_eoa */ + H5FD__ros3_get_eof, /* get_eof */ + H5FD__ros3_get_handle, /* get_handle */ + H5FD__ros3_read, /* read */ + H5FD__ros3_write, /* write */ NULL, /* flush */ - H5FD_ros3_truncate, /* truncate */ - H5FD_ros3_lock, /* lock */ - H5FD_ros3_unlock, /* unlock */ + H5FD__ros3_truncate, /* truncate */ + NULL, /* lock */ + NULL, /* unlock */ NULL, /* dedup */ H5FD_FLMAP_DICHOTOMY /* fl_map */ }; @@ -292,13 +291,11 @@ H5FD__init_package(void) FUNC_ENTER_STATIC - if (H5FD_ros3_init() < 0) { + if (H5FD_ros3_init() < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize ros3 VFD") - } done: FUNC_LEAVE_NOAPI(ret_value) - } /* end H5FD__init_package() */ /*------------------------------------------------------------------------- @@ -322,7 +319,7 @@ H5FD_ros3_init(void) unsigned int bin_i; #endif - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI(H5I_INVALID_HID) #if ROS3_DEBUG HDfprintf(stdout, "H5FD_ros3_init() called.\n"); @@ -336,21 +333,20 @@ H5FD_ros3_init(void) */ for (bin_i = 0; bin_i < ROS3_STATS_BIN_COUNT; bin_i++) { unsigned long long value = 0; + ROS3_STATS_POW(bin_i, &value) ros3_stats_boundaries[bin_i] = value; } #endif - /* Set return value */ ret_value = H5FD_ROS3_g; done: FUNC_LEAVE_NOAPI(ret_value) - } /* end H5FD_ros3_init() */ /*--------------------------------------------------------------------------- - * Function: H5FD_ros3_term + * Function: H5FD__ros3_term * * Purpose: Shut down the VFD * @@ -361,20 +357,19 @@ done: *--------------------------------------------------------------------------- */ static herr_t -H5FD_ros3_term(void) +H5FD__ros3_term(void) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR #if ROS3_DEBUG - HDfprintf(stdout, "H5FD_ros3_term() called.\n"); + HDfprintf(stdout, "H5FD__ros3_term() called.\n"); #endif /* Reset VFL ID */ H5FD_ROS3_g = 0; FUNC_LEAVE_NOAPI(SUCCEED) - -} /* end H5FD_ros3_term() */ +} /* end H5FD__ros3_term() */ /*------------------------------------------------------------------------- * Function: H5Pset_fapl_ros3 @@ -407,23 +402,20 @@ H5Pset_fapl_ros3(hid_t fapl_id, H5FD_ros3_fapl_t *fa) #endif plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS); - if (plist == NULL) { + if (plist == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") - } - if (FAIL == H5FD_ros3_validate_config(fa)) { + if (FAIL == H5FD__ros3_validate_config(fa)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid ros3 config") - } ret_value = H5P_set_driver(plist, H5FD_ROS3, (void *)fa); done: FUNC_LEAVE_API(ret_value) - } /* end H5Pset_fapl_ros3() */ /*------------------------------------------------------------------------- - * Function: H5FD_ros3_validate_config() + * Function: H5FD__ros3_validate_config() * * Purpose: Test to see if the supplied instance of H5FD_ros3_fapl_t * contains internally consistant data. Return SUCCEED if so, @@ -443,30 +435,25 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_ros3_validate_config(const H5FD_ros3_fapl_t *fa) +H5FD__ros3_validate_config(const H5FD_ros3_fapl_t *fa) { herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC HDassert(fa != NULL); - if (fa->version != H5FD_CURR_ROS3_FAPL_T_VERSION) { + if (fa->version != H5FD_CURR_ROS3_FAPL_T_VERSION) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Unknown H5FD_ros3_fapl_t version"); - } - /* if set to authenticate, region and id cannot be empty strings - */ - if (fa->authenticate == TRUE) { - if ((fa->aws_region[0] == '\0') || (fa->secret_id[0] == '\0')) { + /* if set to authenticate, region and id cannot be empty strings */ + if (fa->authenticate == TRUE) + if ((fa->aws_region[0] == '\0') || (fa->secret_id[0] == '\0')) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Inconsistent authentication information"); - } - } done: FUNC_LEAVE_NOAPI(ret_value) - -} /* end H5FD_ros3_validate_config() */ +} /* end H5FD__ros3_validate_config() */ /*------------------------------------------------------------------------- * Function: H5Pget_fapl_ros3 @@ -481,52 +468,45 @@ done: * Programmer: John Mainzer * 9/10/17 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t -H5Pget_fapl_ros3(hid_t fapl_id, H5FD_ros3_fapl_t *fa_out) +H5Pget_fapl_ros3(hid_t fapl_id, H5FD_ros3_fapl_t *fa_dst /*out*/) { - const H5FD_ros3_fapl_t *fa = NULL; + const H5FD_ros3_fapl_t *fa_src = NULL; H5P_genplist_t * plist = NULL; herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) - H5TRACE2("e", "i*#", fapl_id, fa_out); + H5TRACE2("e", "ix", fapl_id, fa_dst); #if ROS3_DEBUG HDfprintf(stdout, "H5Pget_fapl_ros3() called.\n"); #endif - if (fa_out == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "fa_out is NULL") - } + if (fa_dst == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "fa_dst is NULL") plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS); - if (plist == NULL) { + if (plist == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list") - } - if (H5FD_ROS3 != H5P_peek_driver(plist)) { + if (H5FD_ROS3 != H5P_peek_driver(plist)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver") - } - fa = (const H5FD_ros3_fapl_t *)H5P_peek_driver_info(plist); - if (fa == NULL) { + fa_src = (const H5FD_ros3_fapl_t *)H5P_peek_driver_info(plist); + if (fa_src == NULL) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info") - } /* Copy the ros3 fapl data out */ - HDmemcpy(fa_out, fa, sizeof(H5FD_ros3_fapl_t)); + H5MM_memcpy(fa_dst, fa_src, sizeof(H5FD_ros3_fapl_t)); done: FUNC_LEAVE_API(ret_value) - } /* end H5Pget_fapl_ros3() */ /*------------------------------------------------------------------------- - * Function: H5FD_ros3_fapl_get + * Function: H5FD__ros3_fapl_get * * Purpose: Gets a file access property list which could be used to * create an identical file. @@ -538,42 +518,37 @@ done: * Programmer: John Mainzer * 9/8/17 * - * Modifications: - * *------------------------------------------------------------------------- */ static void * -H5FD_ros3_fapl_get(H5FD_t *_file) +H5FD__ros3_fapl_get(H5FD_t *_file) { H5FD_ros3_t * file = (H5FD_ros3_t *)_file; H5FD_ros3_fapl_t *fa = NULL; void * ret_value = NULL; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC fa = (H5FD_ros3_fapl_t *)H5MM_calloc(sizeof(H5FD_ros3_fapl_t)); - if (fa == NULL) { + if (fa == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - } /* Copy the fields of the structure */ - HDmemcpy(fa, &(file->fa), sizeof(H5FD_ros3_fapl_t)); + H5MM_memcpy(fa, &(file->fa), sizeof(H5FD_ros3_fapl_t)); /* Set return value */ ret_value = fa; done: - if (ret_value == NULL) { - if (fa != NULL) { + if (ret_value == NULL) + if (fa != NULL) H5MM_xfree(fa); - } - } - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_ros3_fapl_get() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD__ros3_fapl_get() */ /*------------------------------------------------------------------------- - * Function: H5FD_ros3_fapl_copy + * Function: H5FD__ros3_fapl_copy * * Purpose: Copies the ros3-specific file access properties. * @@ -584,39 +559,34 @@ done: * Programmer: John Mainzer * 9/8/17 * - * Modifications: - * *------------------------------------------------------------------------- */ static void * -H5FD_ros3_fapl_copy(const void *_old_fa) +H5FD__ros3_fapl_copy(const void *_old_fa) { const H5FD_ros3_fapl_t *old_fa = (const H5FD_ros3_fapl_t *)_old_fa; H5FD_ros3_fapl_t * new_fa = NULL; void * ret_value = NULL; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC new_fa = (H5FD_ros3_fapl_t *)H5MM_malloc(sizeof(H5FD_ros3_fapl_t)); - if (new_fa == NULL) { + if (new_fa == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); - } - HDmemcpy(new_fa, old_fa, sizeof(H5FD_ros3_fapl_t)); + H5MM_memcpy(new_fa, old_fa, sizeof(H5FD_ros3_fapl_t)); ret_value = new_fa; done: - if (ret_value == NULL) { - if (new_fa != NULL) { + if (ret_value == NULL) + if (new_fa != NULL) H5MM_xfree(new_fa); - } - } - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_ros3_fapl_copy() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD__ros3_fapl_copy() */ /*------------------------------------------------------------------------- - * Function: H5FD_ros3_fapl_free + * Function: H5FD__ros3_fapl_free * * Purpose: Frees the ros3-specific file access properties. * @@ -625,27 +595,23 @@ done: * Programmer: John Mainzer * 9/8/17 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t -H5FD_ros3_fapl_free(void *_fa) +H5FD__ros3_fapl_free(void *_fa) { H5FD_ros3_fapl_t *fa = (H5FD_ros3_fapl_t *)_fa; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDassert(fa != NULL); /* sanity check */ H5MM_xfree(fa); FUNC_LEAVE_NOAPI(SUCCEED) - -} /* end H5FD_ros3_fapl_free() */ +} /* end H5FD__ros3_fapl_free() */ #if ROS3_STATS - /*---------------------------------------------------------------------------- * * Function: ros3_reset_stats() @@ -673,15 +639,14 @@ ros3_reset_stats(H5FD_ros3_t *file) unsigned i = 0; herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC #if ROS3_DEBUG HDprintf("ros3_reset_stats() called\n"); #endif - if (file == NULL) { + if (file == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file was null"); - } for (i = 0; i <= ROS3_STATS_BIN_COUNT; i++) { file->raw[i].bytes = 0; @@ -697,14 +662,12 @@ ros3_reset_stats(H5FD_ros3_t *file) done: FUNC_LEAVE_NOAPI(ret_value); - } /* end ros3_reset_stats() */ - #endif /* ROS3_STATS */ /*------------------------------------------------------------------------- * - * Function: H5FD_ros3_open() + * Function: H5FD__ros3_open() * * Purpose: * @@ -734,7 +697,7 @@ done: *------------------------------------------------------------------------- */ static H5FD_t * -H5FD_ros3_open(const char *url, unsigned flags, hid_t fapl_id, haddr_t maxaddr) +H5FD__ros3_open(const char *url, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { H5FD_ros3_t * file = NULL; struct tm * now = NULL; @@ -744,10 +707,10 @@ H5FD_ros3_open(const char *url, unsigned flags, hid_t fapl_id, haddr_t maxaddr) H5FD_ros3_fapl_t fa; H5FD_t * ret_value = NULL; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC #if ROS3_DEBUG - HDfprintf(stdout, "H5FD_ros3_open() called.\n"); + HDfprintf(stdout, "H5FD__ros3_open() called.\n"); #endif /* Sanity check on file offsets */ @@ -763,13 +726,11 @@ H5FD_ros3_open(const char *url, unsigned flags, hid_t fapl_id, haddr_t maxaddr) if (flags != H5F_ACC_RDONLY) HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, NULL, "only Read-Only access allowed") - if (FAIL == H5Pget_fapl_ros3(fapl_id, &fa)) { + if (FAIL == H5Pget_fapl_ros3(fapl_id, &fa)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "can't get property list") - } - if (CURLE_OK != curl_global_init(CURL_GLOBAL_DEFAULT)) { + if (CURLE_OK != curl_global_init(CURL_GLOBAL_DEFAULT)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "unable to initialize curl global (placeholder flags)") - } /* open file; procedure depends on whether or not the fapl instructs to * authenticate requests or not. @@ -781,66 +742,54 @@ H5FD_ros3_open(const char *url, unsigned flags, hid_t fapl_id, haddr_t maxaddr) */ now = gmnow(); HDassert(now != NULL); - if (ISO8601NOW(iso8601now, now) != (ISO8601_SIZE - 1)) { + if (ISO8601NOW(iso8601now, now) != (ISO8601_SIZE - 1)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "problem while writing iso8601 timestamp") - } if (FAIL == H5FD_s3comms_signing_key(signing_key, (const char *)fa.secret_key, - (const char *)fa.aws_region, (const char *)iso8601now)) { + (const char *)fa.aws_region, (const char *)iso8601now)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "problem while computing signing key") - } handle = H5FD_s3comms_s3r_open(url, (const char *)fa.aws_region, (const char *)fa.secret_id, (const unsigned char *)signing_key); } - else { + else handle = H5FD_s3comms_s3r_open(url, NULL, NULL, NULL); - } /* if/else should authenticate */ - if (handle == NULL) { + if (handle == NULL) /* If we want to check CURL's say on the matter in a controlled * fashion, this is the place to do it, but would need to make a * few minor changes to s3comms `s3r_t` and `s3r_read()`. */ HGOTO_ERROR(H5E_VFL, H5E_CANTOPENFILE, NULL, "could not open"); - } - /* create new file struct - */ + /* create new file struct */ file = H5FL_CALLOC(H5FD_ros3_t); - if (file == NULL) { + if (file == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate file struct") - } file->s3r_handle = handle; - HDmemcpy(&(file->fa), &fa, sizeof(H5FD_ros3_fapl_t)); + H5MM_memcpy(&(file->fa), &fa, sizeof(H5FD_ros3_fapl_t)); #if ROS3_STATS - if (FAIL == ros3_reset_stats(file)) { + if (FAIL == ros3_reset_stats(file)) HGOTO_ERROR(H5E_INTERNAL, H5E_UNINITIALIZED, NULL, "unable to reset file statistics") - } #endif /* ROS3_STATS */ ret_value = (H5FD_t *)file; done: if (ret_value == NULL) { - if (handle != NULL) { - if (FAIL == H5FD_s3comms_s3r_close(handle)) { + if (handle != NULL) + if (FAIL == H5FD_s3comms_s3r_close(handle)) HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, NULL, "unable to close s3 file handle") - } - } - if (file != NULL) { + if (file != NULL) file = H5FL_FREE(H5FD_ros3_t, file); - } curl_global_cleanup(); /* early cleanup because open failed */ } /* end if null return value (error) */ FUNC_LEAVE_NOAPI(ret_value) - -} /* end H5FD_ros3_open() */ +} /* end H5FD__ros3_open() */ #if ROS3_STATS - /*---------------------------------------------------------------------------- * * Function: ros3_fprint_stats() @@ -915,20 +864,16 @@ ros3_fprint_stats(FILE *stream, const H5FD_ros3_t *file) unsigned suffix_i = 0; const char suffixes[] = {' ', 'K', 'M', 'G', 'T', 'P'}; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC - if (stream == NULL) { + if (stream == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file stream cannot be null"); - } - if (file == NULL) { + if (file == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file cannot be null"); - } - if (file->s3r_handle == NULL) { + if (file->s3r_handle == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "s3 request handle cannot be null"); - } - if (file->s3r_handle->purl == NULL) { + if (file->s3r_handle->purl == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "parsed url structure cannot be null"); - } purl = file->s3r_handle->purl; /****************** @@ -995,9 +940,8 @@ ros3_fprint_stats(FILE *stream, const H5FD_ros3_t *file) HDfprintf(stream, "SIZES meta raw\n"); HDfprintf(stream, " min "); - if (count_meta == 0) { + if (count_meta == 0) HDfprintf(stream, " 0.000 "); - } else { re_dub = (double)min_meta; for (suffix_i = 0; re_dub >= 1024.0; suffix_i++) @@ -1006,9 +950,8 @@ ros3_fprint_stats(FILE *stream, const H5FD_ros3_t *file) HDfprintf(stream, "%8.3lf%c ", re_dub, suffixes[suffix_i]); } - if (count_raw == 0) { + if (count_raw == 0) HDfprintf(stream, " 0.000 \n"); - } else { re_dub = (double)min_raw; for (suffix_i = 0; re_dub >= 1024.0; suffix_i++) @@ -1074,9 +1017,8 @@ ros3_fprint_stats(FILE *stream, const H5FD_ros3_t *file) range_end = ros3_stats_boundaries[i - 1]; HDfprintf(stream, ">"); } - else { + else HDfprintf(stream, " "); - } bm_val = (double)m->bytes; for (suffix_i = 0; bm_val >= 1024.0; suffix_i++) @@ -1118,7 +1060,7 @@ ros3_fprint_stats(FILE *stream, const H5FD_ros3_t *file) am_val, am_suffix, /* metadata average */ ar_val, ar_suffix); /* rawdata average */ - fflush(stream); + HDfflush(stream); } done: @@ -1129,7 +1071,7 @@ done: /*------------------------------------------------------------------------- * - * Function: H5FD_ros3_close() + * Function: H5FD__ros3_close() * * Purpose: * @@ -1145,49 +1087,44 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_ros3_close(H5FD_t H5_ATTR_UNUSED *_file) +H5FD__ros3_close(H5FD_t H5_ATTR_UNUSED *_file) { H5FD_ros3_t *file = (H5FD_ros3_t *)_file; herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC #if ROS3_DEBUG - HDfprintf(stdout, "H5FD_ros3_close() called.\n"); + HDfprintf(stdout, "H5FD__ros3_close() called.\n"); #endif - /* Sanity checks - */ + /* Sanity checks */ HDassert(file != NULL); HDassert(file->s3r_handle != NULL); /* Close the underlying request handle */ - if (FAIL == H5FD_s3comms_s3r_close(file->s3r_handle)) { + if (FAIL == H5FD_s3comms_s3r_close(file->s3r_handle)) HGOTO_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, "unable to close S3 request handle") - } #if ROS3_STATS /* TODO: mechanism to re-target stats printout */ - if (ros3_fprint_stats(stdout, file) == FAIL) { + if (ros3_fprint_stats(stdout, file) == FAIL) HGOTO_ERROR(H5E_INTERNAL, H5E_ERROR, FAIL, "problem while writing file statistics") - } #endif /* ROS3_STATS */ - /* Release the file info - */ + /* Release the file info */ file = H5FL_FREE(H5FD_ros3_t, file); done: curl_global_cleanup(); /* cleanup to answer init on open */ FUNC_LEAVE_NOAPI(ret_value) - -} /* end H5FD_ros3_close() */ +} /* end H5FD__ros3_close() */ /*------------------------------------------------------------------------- * - * Function: H5FD_ros3_cmp() + * Function: H5FD__ros3_cmp() * * Purpose: * @@ -1216,7 +1153,7 @@ done: *------------------------------------------------------------------------- */ static int -H5FD_ros3_cmp(const H5FD_t *_f1, const H5FD_t *_f2) +H5FD__ros3_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { const H5FD_ros3_t * f1 = (const H5FD_ros3_t *)_f1; const H5FD_ros3_t * f2 = (const H5FD_ros3_t *)_f2; @@ -1224,10 +1161,10 @@ H5FD_ros3_cmp(const H5FD_t *_f1, const H5FD_t *_f2) const parsed_url_t *purl2 = NULL; int ret_value = 0; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR #if ROS3_DEBUG - HDfprintf(stdout, "H5FD_ros3_cmp() called.\n"); + HDfprintf(stdout, "H5FD__ros3_cmp() called.\n"); #endif HDassert(f1->s3r_handle != NULL); @@ -1243,100 +1180,79 @@ H5FD_ros3_cmp(const H5FD_t *_f1, const H5FD_t *_f2) HDassert(purl2->host != NULL); /* URL: SCHEME */ - if (HDstrcmp(purl1->scheme, purl2->scheme)) { - HGOTO_DONE(-1); - } + if (HDstrcmp(purl1->scheme, purl2->scheme)) + HGOTO_DONE(-1) /* URL: HOST */ - if (HDstrcmp(purl1->host, purl2->host)) { - HGOTO_DONE(-1); - } + if (HDstrcmp(purl1->host, purl2->host)) + HGOTO_DONE(-1) /* URL: PORT */ if (purl1->port && purl2->port) { - if (HDstrcmp(purl1->port, purl2->port)) { - HGOTO_DONE(-1); - } - } - else if (purl1->port) { - HGOTO_DONE(-1); - } - else if (purl2->port) { - HGOTO_DONE(-1); + if (HDstrcmp(purl1->port, purl2->port)) + HGOTO_DONE(-1) } + else if (purl1->port) + HGOTO_DONE(-1) + else if (purl2->port) + HGOTO_DONE(-1) /* URL: PATH */ if (purl1->path && purl2->path) { - if (HDstrcmp(purl1->path, purl2->path)) { - HGOTO_DONE(-1); - } - } - else if (purl1->path && !purl2->path) { - HGOTO_DONE(-1); - } - else if (purl2->path && !purl1->path) { - HGOTO_DONE(-1); + if (HDstrcmp(purl1->path, purl2->path)) + HGOTO_DONE(-1) } + else if (purl1->path && !purl2->path) + HGOTO_DONE(-1) + else if (purl2->path && !purl1->path) + HGOTO_DONE(-1) /* URL: QUERY */ if (purl1->query && purl2->query) { - if (HDstrcmp(purl1->query, purl2->query)) { - HGOTO_DONE(-1); - } - } - else if (purl1->query && !purl2->query) { - HGOTO_DONE(-1); - } - else if (purl2->query && !purl1->query) { - HGOTO_DONE(-1); + if (HDstrcmp(purl1->query, purl2->query)) + HGOTO_DONE(-1) } + else if (purl1->query && !purl2->query) + HGOTO_DONE(-1) + else if (purl2->query && !purl1->query) + HGOTO_DONE(-1) /* FAPL: AWS_REGION */ if (f1->fa.aws_region[0] != '\0' && f2->fa.aws_region[0] != '\0') { - if (HDstrcmp(f1->fa.aws_region, f2->fa.aws_region)) { - HGOTO_DONE(-1); - } - } - else if (f1->fa.aws_region[0] != '\0') { - HGOTO_DONE(-1); - } - else if (f2->fa.aws_region[0] != '\0') { - HGOTO_DONE(-1); + if (HDstrcmp(f1->fa.aws_region, f2->fa.aws_region)) + HGOTO_DONE(-1) } + else if (f1->fa.aws_region[0] != '\0') + HGOTO_DONE(-1) + else if (f2->fa.aws_region[0] != '\0') + HGOTO_DONE(-1) /* FAPL: SECRET_ID */ if (f1->fa.secret_id[0] != '\0' && f2->fa.secret_id[0] != '\0') { - if (HDstrcmp(f1->fa.secret_id, f2->fa.secret_id)) { - HGOTO_DONE(-1); - } - } - else if (f1->fa.secret_id[0] != '\0') { - HGOTO_DONE(-1); - } - else if (f2->fa.secret_id[0] != '\0') { - HGOTO_DONE(-1); + if (HDstrcmp(f1->fa.secret_id, f2->fa.secret_id)) + HGOTO_DONE(-1) } + else if (f1->fa.secret_id[0] != '\0') + HGOTO_DONE(-1) + else if (f2->fa.secret_id[0] != '\0') + HGOTO_DONE(-1) /* FAPL: SECRET_KEY */ if (f1->fa.secret_key[0] != '\0' && f2->fa.secret_key[0] != '\0') { - if (HDstrcmp(f1->fa.secret_key, f2->fa.secret_key)) { - HGOTO_DONE(-1); - } - } - else if (f1->fa.secret_key[0] != '\0') { - HGOTO_DONE(-1); - } - else if (f2->fa.secret_key[0] != '\0') { - HGOTO_DONE(-1); + if (HDstrcmp(f1->fa.secret_key, f2->fa.secret_key)) + HGOTO_DONE(-1) } + else if (f1->fa.secret_key[0] != '\0') + HGOTO_DONE(-1) + else if (f2->fa.secret_key[0] != '\0') + HGOTO_DONE(-1) done: FUNC_LEAVE_NOAPI(ret_value) - -} /* H5FD_ros3_cmp() */ +} /* H5FD__ros3_cmp() */ /*------------------------------------------------------------------------- - * Function: H5FD_ros3_query + * Function: H5FD__ros3_query * * Purpose: Set the flags that this VFL driver is capable of supporting. * (listed in H5FDpublic.h) @@ -1355,12 +1271,12 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_ros3_query(const H5FD_t H5_ATTR_UNUSED *_file, unsigned long *flags /* out */) +H5FD__ros3_query(const H5FD_t H5_ATTR_UNUSED *_file, unsigned long *flags) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR #if ROS3_DEBUG - HDfprintf(stdout, "H5FD_ros3_query() called.\n"); + HDfprintf(stdout, "H5FD__ros3_query() called.\n"); #endif /* Set the VFL feature flags that this driver supports */ @@ -1371,12 +1287,11 @@ H5FD_ros3_query(const H5FD_t H5_ATTR_UNUSED *_file, unsigned long *flags /* out } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) - -} /* H5FD_ros3_query() */ +} /* H5FD__ros3_query() */ /*------------------------------------------------------------------------- * - * Function: H5FD_ros3_get_eoa() + * Function: H5FD__ros3_get_eoa() * * Purpose: * @@ -1394,23 +1309,22 @@ H5FD_ros3_query(const H5FD_t H5_ATTR_UNUSED *_file, unsigned long *flags /* out *------------------------------------------------------------------------- */ static haddr_t -H5FD_ros3_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) +H5FD__ros3_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { const H5FD_ros3_t *file = (const H5FD_ros3_t *)_file; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR #if ROS3_DEBUG - HDfprintf(stdout, "H5FD_ros3_get_eoa() called.\n"); + HDfprintf(stdout, "H5FD__ros3_get_eoa() called.\n"); #endif FUNC_LEAVE_NOAPI(file->eoa) - -} /* end H5FD_ros3_get_eoa() */ +} /* end H5FD__ros3_get_eoa() */ /*------------------------------------------------------------------------- * - * Function: H5FD_ros3_set_eoa() + * Function: H5FD__ros3_set_eoa() * * Purpose: * @@ -1426,25 +1340,24 @@ H5FD_ros3_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) *------------------------------------------------------------------------- */ static herr_t -H5FD_ros3_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) +H5FD__ros3_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) { H5FD_ros3_t *file = (H5FD_ros3_t *)_file; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR #if ROS3_DEBUG - HDfprintf(stdout, "H5FD_ros3_set_eoa() called.\n"); + HDfprintf(stdout, "H5FD__ros3_set_eoa() called.\n"); #endif file->eoa = addr; FUNC_LEAVE_NOAPI(SUCCEED) - -} /* H5FD_ros3_set_eoa() */ +} /* H5FD__ros3_set_eoa() */ /*------------------------------------------------------------------------- * - * Function: H5FD_ros3_get_eof() + * Function: H5FD__ros3_get_eof() * * Purpose: * @@ -1461,23 +1374,22 @@ H5FD_ros3_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) *------------------------------------------------------------------------- */ static haddr_t -H5FD_ros3_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) +H5FD__ros3_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { const H5FD_ros3_t *file = (const H5FD_ros3_t *)_file; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR #if ROS3_DEBUG - HDfprintf(stdout, "H5FD_ros3_get_eof() called.\n"); + HDfprintf(stdout, "H5FD__ros3_get_eof() called.\n"); #endif FUNC_LEAVE_NOAPI(H5FD_s3comms_s3r_get_filesize(file->s3r_handle)) - -} /* end H5FD_ros3_get_eof() */ +} /* end H5FD__ros3_get_eof() */ /*------------------------------------------------------------------------- * - * Function: H5FD_ros3_get_handle() + * Function: H5FD__ros3_get_handle() * * Purpose: * @@ -1493,31 +1405,29 @@ H5FD_ros3_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) *------------------------------------------------------------------------- */ static herr_t -H5FD_ros3_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void **file_handle) +H5FD__ros3_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void **file_handle) { H5FD_ros3_t *file = (H5FD_ros3_t *)_file; herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC #if ROS3_DEBUG - HDfprintf(stdout, "H5FD_ros3_get_handle() called.\n"); + HDfprintf(stdout, "H5FD__ros3_get_handle() called.\n"); #endif - if (!file_handle) { + if (!file_handle) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file handle not valid") - } *file_handle = file->s3r_handle; done: FUNC_LEAVE_NOAPI(ret_value) - -} /* end H5FD_ros3_get_handle() */ +} /* end H5FD__ros3_get_handle() */ /*------------------------------------------------------------------------- * - * Function: H5FD_ros3_read() + * Function: H5FD__ros3_read() * * Purpose * @@ -1538,8 +1448,8 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_ros3_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, - size_t size, void *buf) +H5FD__ros3_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, + size_t size, void *buf) { H5FD_ros3_t *file = (H5FD_ros3_t *)_file; size_t filesize = 0; @@ -1550,10 +1460,10 @@ H5FD_ros3_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUS unsigned bin_i = 0; #endif /* ROS3_STATS */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC #if ROS3_DEBUG - HDfprintf(stdout, "H5FD_ros3_read() called.\n"); + HDfprintf(stdout, "H5FD__ros3_read() called.\n"); #endif HDassert(file != NULL); @@ -1562,38 +1472,30 @@ H5FD_ros3_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUS filesize = H5FD_s3comms_s3r_get_filesize(file->s3r_handle); - if ((addr > filesize) || ((addr + size) > filesize)) { + if ((addr > filesize) || ((addr + size) > filesize)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "range exceeds file address") - } - if (H5FD_s3comms_s3r_read(file->s3r_handle, addr, size, buf) == FAIL) { + if (H5FD_s3comms_s3r_read(file->s3r_handle, addr, size, buf) == FAIL) HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "unable to execute read") - } #if ROS3_STATS - /* Find which "bin" this read fits in. Can be "overflow" bin. - */ - for (bin_i = 0; bin_i < ROS3_STATS_BIN_COUNT; bin_i++) { - if ((unsigned long long)size < ros3_stats_boundaries[bin_i]) { + /* Find which "bin" this read fits in. Can be "overflow" bin. */ + for (bin_i = 0; bin_i < ROS3_STATS_BIN_COUNT; bin_i++) + if ((unsigned long long)size < ros3_stats_boundaries[bin_i]) break; - } - } bin = (type == H5FD_MEM_DRAW) ? &file->raw[bin_i] : &file->meta[bin_i]; - /* Store collected stats in appropriate bin - */ + /* Store collected stats in appropriate bin */ if (bin->count == 0) { bin->min = size; bin->max = size; } else { - if (size < bin->min) { + if (size < bin->min) bin->min = size; - } - if (size > bin->max) { + if (size > bin->max) bin->max = size; - } } bin->count++; bin->bytes += (unsigned long long)size; @@ -1602,12 +1504,11 @@ H5FD_ros3_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUS done: FUNC_LEAVE_NOAPI(ret_value) - -} /* end H5FD_ros3_read() */ +} /* end H5FD__ros3_read() */ /*------------------------------------------------------------------------- * - * Function: H5FD_ros3_write() + * Function: H5FD__ros3_write() * * Purpose: * @@ -1624,27 +1525,26 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_ros3_write(H5FD_t H5_ATTR_UNUSED *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, - haddr_t H5_ATTR_UNUSED addr, size_t H5_ATTR_UNUSED size, const void H5_ATTR_UNUSED *buf) +H5FD__ros3_write(H5FD_t H5_ATTR_UNUSED *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, + haddr_t H5_ATTR_UNUSED addr, size_t H5_ATTR_UNUSED size, const void H5_ATTR_UNUSED *buf) { herr_t ret_value = FAIL; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC #if ROS3_DEBUG - HDfprintf(stdout, "H5FD_ros3_write() called.\n"); + HDfprintf(stdout, "H5FD__ros3_write() called.\n"); #endif HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, FAIL, "cannot write to read-only file.") done: FUNC_LEAVE_NOAPI(ret_value) - -} /* H5FD_ros3_write() */ +} /* H5FD__ros3_write() */ /*------------------------------------------------------------------------- * - * Function: H5FD_ros3_truncate() + * Function: H5FD__ros3_truncate() * * Purpose: * @@ -1663,76 +1563,21 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_ros3_truncate(H5FD_t H5_ATTR_UNUSED *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_UNUSED closing) +H5FD__ros3_truncate(H5FD_t H5_ATTR_UNUSED *_file, hid_t H5_ATTR_UNUSED dxpl_id, + hbool_t H5_ATTR_UNUSED closing) { herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC #if ROS3_DEBUG - HDfprintf(stdout, "H5FD_ros3_truncate() called.\n"); + HDfprintf(stdout, "H5FD__ros3_truncate() called.\n"); #endif HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, FAIL, "cannot truncate read-only file.") done: FUNC_LEAVE_NOAPI(ret_value) - -} /* end H5FD_ros3_truncate() */ - -/*------------------------------------------------------------------------- - * - * Function: H5FD_ros3_lock() - * - * Purpose: - * - * Place an advisory lock on a file. - * No effect on Read-Only S3 file. - * - * Suggestion: remove lock/unlock from class - * > would result in error at H5FD_[un]lock() (H5FD.c) - * - * Return: - * - * SUCCEED (No-op always succeeds) - * - * Programmer: Jacob Smith - * 2017-11-03 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5FD_ros3_lock(H5FD_t H5_ATTR_UNUSED *_file, hbool_t H5_ATTR_UNUSED rw) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - FUNC_LEAVE_NOAPI(SUCCEED) - -} /* end H5FD_ros3_lock() */ - -/*------------------------------------------------------------------------- - * - * Function: H5FD_ros3_unlock() - * - * Purpose: - * - * Remove the existing lock on the file. - * No effect on Read-Only S3 file. - * - * Return: - * - * SUCCEED (No-op always succeeds) - * - * Programmer: Jacob Smith - * 2017-11-03 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5FD_ros3_unlock(H5FD_t H5_ATTR_UNUSED *_file) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - FUNC_LEAVE_NOAPI(SUCCEED) - -} /* end H5FD_ros3_unlock() */ +} /* end H5FD__ros3_truncate() */ #endif /* H5_HAVE_ROS3_VFD */ diff --git a/src/H5FDs3comms.c b/src/H5FDs3comms.c index d958675..ee5b5ec 100644 --- a/src/H5FDs3comms.c +++ b/src/H5FDs3comms.c @@ -140,18 +140,16 @@ curlwritecallback(char *ptr, size_t size, size_t nmemb, void *userdata) size_t product = (size * nmemb); size_t written = 0; - if (sds->magic != S3COMMS_CALLBACK_DATASTRUCT_MAGIC) { + if (sds->magic != S3COMMS_CALLBACK_DATASTRUCT_MAGIC) return written; - } if (size > 0) { - HDmemcpy(&(sds->data[sds->size]), ptr, product); + H5MM_memcpy(&(sds->data[sds->size]), ptr, product); sds->size += product; written = product; } return written; - } /* end curlwritecallback() */ /*---------------------------------------------------------------------------- @@ -224,21 +222,19 @@ H5FD_s3comms_hrb_node_set(hrb_node_t **L, const char *name, const char *value) FUNC_ENTER_NOAPI_NOINIT #if S3COMMS_DEBUG - HDfprintf(stdout, "called H5FD_s3comms_hrb_node_set.\n"); + HDfprintf(stdout, "called H5FD_s3comms_hrb_node_set."); HDprintf("NAME: %s\n", name); HDprintf("VALUE: %s\n", value); HDprintf("LIST:\n->"); - for (node_ptr = (*L); node_ptr != NULL; node_ptr = node_ptr->next) { + for (node_ptr = (*L); node_ptr != NULL; node_ptr = node_ptr->next) HDfprintf(stdout, "{%s}\n->", node_ptr->cat); - } HDprintf("(null)\n"); - fflush(stdout); + HDfflush(stdout); node_ptr = NULL; #endif - if (name == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to operate on null name.\n"); - } + if (name == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to operate on null name"); namelen = HDstrlen(name); /*********************** @@ -248,12 +244,10 @@ H5FD_s3comms_hrb_node_set(hrb_node_t **L, const char *name, const char *value) /* copy and lowercase name */ lowername = (char *)H5MM_malloc(sizeof(char) * (namelen + 1)); - if (lowername == NULL) { - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "cannot make space for lowercase name copy.\n"); - } - for (i = 0; i < namelen; i++) { - lowername[i] = (char)tolower((int)name[i]); - } + if (lowername == NULL) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "cannot make space for lowercase name copy."); + for (i = 0; i < namelen; i++) + lowername[i] = (char)HDtolower((int)name[i]); lowername[namelen] = 0; /* If value supplied, copy name, value, and concatenated "name: value". @@ -267,33 +261,28 @@ H5FD_s3comms_hrb_node_set(hrb_node_t **L, const char *name, const char *value) size_t catwrite = catlen + 3; /* 3 not 1 to quiet compiler warning */ namecpy = (char *)H5MM_malloc(sizeof(char) * (namelen + 1)); - if (namecpy == NULL) { - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "cannot make space for name copy.\n"); - } - HDmemcpy(namecpy, name, (namelen + 1)); + if (namecpy == NULL) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "cannot make space for name copy."); + H5MM_memcpy(namecpy, name, (namelen + 1)); valuecpy = (char *)H5MM_malloc(sizeof(char) * (valuelen + 1)); - if (valuecpy == NULL) { - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "cannot make space for value copy.\n"); - } - HDmemcpy(valuecpy, value, (valuelen + 1)); + if (valuecpy == NULL) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "cannot make space for value copy."); + H5MM_memcpy(valuecpy, value, (valuelen + 1)); nvcat = (char *)H5MM_malloc(sizeof(char) * catwrite); - if (nvcat == NULL) { - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "cannot make space for concatenated string.\n"); - } + if (nvcat == NULL) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "cannot make space for concatenated string."); ret = HDsnprintf(nvcat, catwrite, "%s: %s", name, value); - if (ret < 0 || (size_t)ret > catlen) { + if (ret < 0 || (size_t)ret > catlen) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cannot concatenate `%s: %s", name, value); - } HDassert(catlen == HDstrlen(nvcat)); /* create new_node, should we need it */ new_node = (hrb_node_t *)H5MM_malloc(sizeof(hrb_node_t)); - if (new_node == NULL) { - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "cannot make space for new set.\n"); - } + if (new_node == NULL) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "cannot make space for new set."); new_node->magic = S3COMMS_HRB_NODE_MAGIC; new_node->name = NULL; @@ -308,13 +297,12 @@ H5FD_s3comms_hrb_node_set(hrb_node_t **L, const char *name, const char *value) ***************/ if (*L == NULL) { - if (value == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "trying to remove node from empty list"); - } + if (value == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "trying to remove node from empty list") else { #if S3COMMS_DEBUG HDprintf("CREATE NEW\n"); - fflush(stdout); + HDfflush(stdout); #endif /******************* * CREATE NEW LIST * @@ -338,14 +326,14 @@ H5FD_s3comms_hrb_node_set(hrb_node_t **L, const char *name, const char *value) /* Check whether to modify/remove first node in list */ - if (strcmp(lowername, node_ptr->lowername) == 0) { + if (HDstrcmp(lowername, node_ptr->lowername) == 0) { is_looking = FALSE; if (value == NULL) { #if S3COMMS_DEBUG HDprintf("REMOVE HEAD\n"); - fflush(stdout); + HDfflush(stdout); #endif /*************** * REMOVE HEAD * @@ -355,39 +343,39 @@ H5FD_s3comms_hrb_node_set(hrb_node_t **L, const char *name, const char *value) #if S3COMMS_DEBUG HDprintf("FREEING CAT (node)\n"); - fflush(stdout); + HDfflush(stdout); #endif H5MM_xfree(node_ptr->cat); #if S3COMMS_DEBUG HDprintf("FREEING LOWERNAME (node)\n"); - fflush(stdout); + HDfflush(stdout); #endif H5MM_xfree(node_ptr->lowername); #if S3COMMS_DEBUG HDprintf("FREEING NAME (node)\n"); - fflush(stdout); + HDfflush(stdout); #endif H5MM_xfree(node_ptr->name); #if S3COMMS_DEBUG HDprintf("FREEING VALUE (node)\n"); - fflush(stdout); + HDfflush(stdout); #endif H5MM_xfree(node_ptr->value); #if S3COMMS_DEBUG HDprintf("MAGIC OK? %s\n", (node_ptr->magic == S3COMMS_HRB_NODE_MAGIC) ? "YES" : "NO"); - fflush(stdout); + HDfflush(stdout); #endif HDassert(node_ptr->magic == S3COMMS_HRB_NODE_MAGIC); node_ptr->magic += 1ul; #if S3COMMS_DEBUG HDprintf("FREEING POINTER\n"); - fflush(stdout); + HDfflush(stdout); #endif H5MM_xfree(node_ptr); #if S3COMMS_DEBUG HDprintf("FREEING WORKING LOWERNAME\n"); - fflush(stdout); + HDfflush(stdout); #endif H5MM_xfree(lowername); lowername = NULL; @@ -395,7 +383,7 @@ H5FD_s3comms_hrb_node_set(hrb_node_t **L, const char *name, const char *value) else { #if S3COMMS_DEBUG HDprintf("MODIFY HEAD\n"); - fflush(stdout); + HDfflush(stdout); #endif /*************** * MODIFY HEAD * @@ -416,17 +404,16 @@ H5FD_s3comms_hrb_node_set(hrb_node_t **L, const char *name, const char *value) new_node = NULL; } } - else if (strcmp(lowername, node_ptr->lowername) < 0) { + else if (HDstrcmp(lowername, node_ptr->lowername) < 0) { is_looking = FALSE; - if (value == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "trying to remove a node 'before' head"); - } + if (value == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "trying to remove a node 'before' head") else { #if S3COMMS_DEBUG HDprintf("PREPEND NEW HEAD\n"); - fflush(stdout); + HDfflush(stdout); #endif /******************* * INSERT NEW HEAD * @@ -450,19 +437,18 @@ H5FD_s3comms_hrb_node_set(hrb_node_t **L, const char *name, const char *value) is_looking = FALSE; - if (value == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "trying to remove absent node"); - } + if (value == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "trying to remove absent node") else { #if S3COMMS_DEBUG HDprintf("APPEND A NODE\n"); - fflush(stdout); + HDfflush(stdout); #endif /******************* * APPEND NEW NODE * *******************/ - HDassert(strcmp(lowername, node_ptr->lowername) > 0); + HDassert(HDstrcmp(lowername, node_ptr->lowername) > 0); new_node->name = namecpy; new_node->value = valuecpy; new_node->lowername = lowername; @@ -470,23 +456,22 @@ H5FD_s3comms_hrb_node_set(hrb_node_t **L, const char *name, const char *value) node_ptr->next = new_node; } } - else if (strcmp(lowername, node_ptr->next->lowername) < 0) { + else if (HDstrcmp(lowername, node_ptr->next->lowername) < 0) { is_looking = FALSE; - if (value == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "trying to remove absent node"); - } + if (value == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "trying to remove absent node") else { #if S3COMMS_DEBUG HDprintf("INSERT A NODE\n"); - fflush(stdout); + HDfflush(stdout); #endif /******************* * INSERT NEW NODE * *******************/ - HDassert(strcmp(lowername, node_ptr->lowername) > 0); + HDassert(HDstrcmp(lowername, node_ptr->lowername) > 0); new_node->name = namecpy; new_node->value = valuecpy; new_node->lowername = lowername; @@ -495,7 +480,7 @@ H5FD_s3comms_hrb_node_set(hrb_node_t **L, const char *name, const char *value) node_ptr->next = new_node; } } - else if (strcmp(lowername, node_ptr->next->lowername) == 0) { + else if (HDstrcmp(lowername, node_ptr->next->lowername) == 0) { is_looking = FALSE; @@ -509,7 +494,7 @@ H5FD_s3comms_hrb_node_set(hrb_node_t **L, const char *name, const char *value) #if S3COMMS_DEBUG HDprintf("REMOVE A NODE\n"); - fflush(stdout); + HDfflush(stdout); #endif H5MM_xfree(tmp->cat); H5MM_xfree(tmp->lowername); @@ -526,7 +511,7 @@ H5FD_s3comms_hrb_node_set(hrb_node_t **L, const char *name, const char *value) else { #if S3COMMS_DEBUG HDprintf("MODIFY A NODE\n"); - fflush(stdout); + HDfflush(stdout); #endif /***************** * MODIFY A NODE * @@ -560,20 +545,15 @@ H5FD_s3comms_hrb_node_set(hrb_node_t **L, const char *name, const char *value) done: if (ret_value == FAIL) { - /* clean up - */ - if (nvcat != NULL) { + /* clean up */ + if (nvcat != NULL) H5MM_xfree(nvcat); - } - if (namecpy != NULL) { + if (namecpy != NULL) H5MM_xfree(namecpy); - } - if (lowername != NULL) { + if (lowername != NULL) H5MM_xfree(lowername); - } - if (valuecpy != NULL) { + if (valuecpy != NULL) H5MM_xfree(valuecpy); - } if (new_node != NULL) { HDassert(new_node->magic == S3COMMS_HRB_NODE_MAGIC); new_node->magic += 1ul; @@ -634,9 +614,8 @@ H5FD_s3comms_hrb_destroy(hrb_t **_buf) if (_buf != NULL && *_buf != NULL) { buf = *_buf; - if (buf->magic != S3COMMS_HRB_MAGIC) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "pointer's magic does not match.\n"); - } + if (buf->magic != S3COMMS_HRB_MAGIC) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "pointer's magic does not match."); H5MM_xfree(buf->verb); H5MM_xfree(buf->version); @@ -697,68 +676,55 @@ H5FD_s3comms_hrb_init_request(const char *_verb, const char *_resource, const ch HDfprintf(stdout, "called H5FD_s3comms_hrb_init_request.\n"); #endif - if (_resource == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "resource string cannot be null.\n"); - } + if (_resource == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "resource string cannot be null."); - /* populate valid NULLs with defaults - */ - if (_verb == NULL) { + /* populate valid NULLs with defaults */ + if (_verb == NULL) _verb = "GET"; - } - - if (_http_version == NULL) { + if (_http_version == NULL) _http_version = "HTTP/1.1"; - } - /* malloc space for and prepare structure - */ + /* malloc space for and prepare structure */ request = (hrb_t *)H5MM_malloc(sizeof(hrb_t)); - if (request == NULL) { + if (request == NULL) HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, NULL, "no space for request structure"); - } request->magic = S3COMMS_HRB_MAGIC; request->body = NULL; request->body_len = 0; request->first_header = NULL; - /* malloc and copy strings for the structure - */ + /* malloc and copy strings for the structure */ reslen = HDstrlen(_resource); if (_resource[0] == '/') { res = (char *)H5MM_malloc(sizeof(char) * (reslen + 1)); - if (res == NULL) { + if (res == NULL) HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, NULL, "no space for resource string"); - } - HDmemcpy(res, _resource, (reslen + 1)); + H5MM_memcpy(res, _resource, (reslen + 1)); } else { res = (char *)H5MM_malloc(sizeof(char) * (reslen + 2)); - if (res == NULL) { + if (res == NULL) HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, NULL, "no space for resource string"); - } *res = '/'; - HDmemcpy((&res[1]), _resource, (reslen + 1)); + H5MM_memcpy((&res[1]), _resource, (reslen + 1)); HDassert((reslen + 1) == HDstrlen(res)); } /* end if (else resource string not starting with '/') */ verblen = HDstrlen(_verb) + 1; verb = (char *)H5MM_malloc(sizeof(char) * verblen); - if (verb == NULL) { + if (verb == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "no space for verb string"); - } HDstrncpy(verb, _verb, verblen); vrsnlen = HDstrlen(_http_version) + 1; vrsn = (char *)H5MM_malloc(sizeof(char) * vrsnlen); - if (vrsn == NULL) { + if (vrsn == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "no space for http-version string"); - } HDstrncpy(vrsn, _http_version, vrsnlen); - /* place new copies into structure - */ + /* place new copies into structure */ request->resource = res; request->verb = verb; request->version = vrsn; @@ -766,8 +732,7 @@ H5FD_s3comms_hrb_init_request(const char *_verb, const char *_resource, const ch ret_value = request; done: - /* if there is an error, clean up after ourselves - */ + /* if there is an error, clean up after ourselves */ if (ret_value == NULL) { if (request != NULL) H5MM_xfree(request); @@ -818,12 +783,10 @@ H5FD_s3comms_s3r_close(s3r_t *handle) HDfprintf(stdout, "called H5FD_s3comms_s3r_close.\n"); #endif - if (handle == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle cannot be null.\n"); - } - if (handle->magic != S3COMMS_S3R_MAGIC) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle has invalid magic.\n"); - } + if (handle == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle cannot be null."); + if (handle->magic != S3COMMS_S3R_MAGIC) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle has invalid magic."); curl_easy_cleanup(handle->curlhandle); @@ -834,9 +797,8 @@ H5FD_s3comms_s3r_close(s3r_t *handle) HDassert(handle->httpverb != NULL); H5MM_xfree(handle->httpverb); - if (FAIL == H5FD_s3comms_free_purl(handle->purl)) { + if (FAIL == H5FD_s3comms_free_purl(handle->purl)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to release parsed url structure") - } H5MM_xfree(handle); @@ -871,9 +833,8 @@ H5FD_s3comms_s3r_get_filesize(s3r_t *handle) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (handle != NULL) { + if (handle != NULL) ret_value = handle->filesize; - } FUNC_LEAVE_NOAPI(ret_value) } /* H5FD_s3comms_s3r_get_filesize */ @@ -927,45 +888,33 @@ H5FD_s3comms_s3r_getsize(s3r_t *handle) HDfprintf(stdout, "called H5FD_s3comms_s3r_getsize.\n"); #endif - if (handle == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle cannot be null.\n"); - } - if (handle->magic != S3COMMS_S3R_MAGIC) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle has invalid magic.\n"); - } - if (handle->curlhandle == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle has bad (null) curlhandle.\n") - } + if (handle == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle cannot be null."); + if (handle->magic != S3COMMS_S3R_MAGIC) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle has invalid magic."); + if (handle->curlhandle == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle has bad (null) curlhandle.") /******************** * PREPARE FOR HEAD * ********************/ curlh = handle->curlhandle; + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_NOBODY, 1L)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "error while setting CURL option (CURLOPT_NOBODY)."); - if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_NOBODY, 1L)) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "error while setting CURL option (CURLOPT_NOBODY). " - "(placeholder flags)"); - } - - if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_HEADERDATA, &sds)) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "error while setting CURL option (CURLOPT_HEADERDATA). " - "(placeholder flags)"); - } + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_HEADERDATA, &sds)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "error while setting CURL option (CURLOPT_HEADERDATA)."); HDassert(handle->httpverb == NULL); handle->httpverb = (char *)H5MM_malloc(sizeof(char) * 16); - if (handle->httpverb == NULL) { + if (handle->httpverb == NULL) HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, "unable to allocate space for S3 request HTTP verb"); - } - HDmemcpy(handle->httpverb, "HEAD", 5); + H5MM_memcpy(handle->httpverb, "HEAD", 5); headerresponse = (char *)H5MM_malloc(sizeof(char) * CURL_MAX_HTTP_HEADER); - if (headerresponse == NULL) { + if (headerresponse == NULL) HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, "unable to allocate space for curl header response"); - } sds.data = headerresponse; /******************* @@ -976,55 +925,44 @@ H5FD_s3comms_s3r_getsize(s3r_t *handle) * but, with a NULL destination and NOBODY and HEADERDATA supplied above, * only http metadata will be sent by server and recorded by s3comms */ - if (FAIL == H5FD_s3comms_s3r_read(handle, 0, 0, NULL)) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem in reading during getsize.\n"); - } + if (FAIL == H5FD_s3comms_s3r_read(handle, 0, 0, NULL)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem in reading during getsize."); - if (sds.size > CURL_MAX_HTTP_HEADER) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "HTTP metadata buffer overrun\n"); - } - else if (sds.size == 0) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "No HTTP metadata\n"); + if (sds.size > CURL_MAX_HTTP_HEADER) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "HTTP metadata buffer overrun") + else if (sds.size == 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "No HTTP metadata") #if S3COMMS_DEBUG - } - else { + else HDfprintf(stderr, "GETSIZE: OK\n"); #endif - } /****************** * PARSE RESPONSE * ******************/ - start = strstr(headerresponse, "\r\nContent-Length: "); - if (start == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not find \"Content-Length\" in response.\n"); - } + start = HDstrstr(headerresponse, "\r\nContent-Length: "); + if (start == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not find \"Content-Length\" in response."); - /* move "start" to beginning of value in line; find end of line - */ + /* move "start" to beginning of value in line; find end of line */ start = start + HDstrlen("\r\nContent-Length: "); - end = strstr(start, "\r\n"); - if (end == NULL) { + end = HDstrstr(start, "\r\n"); + if (end == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not find end of content length line"); - } /* place null terminator at end of numbers */ *end = '\0'; - content_length = strtoumax((const char *)start, NULL, 0); + content_length = HDstrtoumax((const char *)start, NULL, 0); + if (UINTMAX_MAX > SIZE_MAX && content_length > SIZE_MAX) + HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "content_length overflows size_t"); - if (UINTMAX_MAX > SIZE_MAX && content_length > SIZE_MAX) { - HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "content_length overflows size_t\n"); - } - - if (content_length == 0 || errno == ERANGE) /* errno set by strtoumax*/ - { + if (content_length == 0 || errno == ERANGE) /* errno set by HDstrtoumax*/ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not convert found \"Content-Length\" response (\"%s\")", start); /* range is null-terminated, remember */ - } handle->filesize = (size_t)content_length; @@ -1032,24 +970,17 @@ H5FD_s3comms_s3r_getsize(s3r_t *handle) * UNDO HEAD SETTINGS * **********************/ - if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_NOBODY, NULL)) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "error while setting CURL option (CURLOPT_NOBODY). " - "(placeholder flags)"); - } + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_NOBODY, NULL)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "error while setting CURL option (CURLOPT_NOBODY)."); - if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_HEADERDATA, NULL)) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "error while setting CURL option (CURLOPT_HEADERDATA). " - "(placeholder flags)"); - } + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_HEADERDATA, NULL)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "error while setting CURL option (CURLOPT_HEADERDATA)."); done: H5MM_xfree(headerresponse); sds.magic += 1; /* set to bad magic */ FUNC_LEAVE_NOAPI(ret_value); - } /* H5FD_s3comms_s3r_getsize */ /*---------------------------------------------------------------------------- @@ -1106,21 +1037,19 @@ H5FD_s3comms_s3r_open(const char *url, const char *region, const char *id, const HDfprintf(stdout, "called H5FD_s3comms_s3r_open.\n"); #endif - if (url == NULL || url[0] == '\0') { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "url cannot be null.\n"); - } + if (url == NULL || url[0] == '\0') + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "url cannot be null."); - if (FAIL == H5FD_s3comms_parse_url(url, &purl)) { + if (FAIL == H5FD_s3comms_parse_url(url, &purl)) /* probably a malformed url, but could be internal error */ HGOTO_ERROR(H5E_ARGS, H5E_CANTCREATE, NULL, "unable to create parsed url structure"); - } + HDassert(purl != NULL); /* if above passes, this must be true */ HDassert(purl->magic == S3COMMS_PARSED_URL_MAGIC); handle = (s3r_t *)H5MM_malloc(sizeof(s3r_t)); - if (handle == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, NULL, "could not malloc space for handle.\n"); - } + if (handle == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, NULL, "could not malloc space for handle."); handle->magic = S3COMMS_S3R_MAGIC; handle->purl = purl; @@ -1135,40 +1064,33 @@ H5FD_s3comms_s3r_open(const char *url, const char *region, const char *id, const *************************************/ if ((region != NULL && *region != '\0') || (id != NULL && *id != '\0') || (signing_key != NULL)) { - /* if one exists, all three must exist - */ - if (region == NULL || region[0] == '\0') { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "region cannot be null.\n"); - } - if (id == NULL || id[0] == '\0') { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "secret id cannot be null.\n"); - } - if (signing_key == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "signing key cannot be null.\n"); - } - /* copy strings - */ + /* if one exists, all three must exist */ + if (region == NULL || region[0] == '\0') + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "region cannot be null."); + if (id == NULL || id[0] == '\0') + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "secret id cannot be null."); + if (signing_key == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "signing key cannot be null."); + + /* copy strings */ tmplen = HDstrlen(region) + 1; handle->region = (char *)H5MM_malloc(sizeof(char) * tmplen); - if (handle->region == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "could not malloc space for handle region copy.\n"); - } - HDmemcpy(handle->region, region, tmplen); + if (handle->region == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "could not malloc space for handle region copy."); + H5MM_memcpy(handle->region, region, tmplen); tmplen = HDstrlen(id) + 1; handle->secret_id = (char *)H5MM_malloc(sizeof(char) * tmplen); - if (handle->secret_id == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "could not malloc space for handle ID copy.\n"); - } - HDmemcpy(handle->secret_id, id, tmplen); + if (handle->secret_id == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "could not malloc space for handle ID copy."); + H5MM_memcpy(handle->secret_id, id, tmplen); tmplen = SHA256_DIGEST_LENGTH; handle->signing_key = (unsigned char *)H5MM_malloc(sizeof(unsigned char) * tmplen); - if (handle->signing_key == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "could not malloc space for handle key copy.\n"); - } - HDmemcpy(handle->signing_key, signing_key, tmplen); + if (handle->signing_key == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "could not malloc space for handle key copy."); + H5MM_memcpy(handle->signing_key, signing_key, tmplen); } /* if authentication information provided */ /************************ @@ -1176,40 +1098,23 @@ H5FD_s3comms_s3r_open(const char *url, const char *region, const char *id, const ************************/ curlh = curl_easy_init(); + if (curlh == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "problem creating curl easy handle!"); - if (curlh == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "problem creating curl easy handle!\n"); - } - - if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_HTTPGET, 1L)) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, - "error while setting CURL option (CURLOPT_HTTPGET). " - "(placeholder flags)"); - } + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_HTTPGET, 1L)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "error while setting CURL option (CURLOPT_HTTPGET)."); - if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1)) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, - "error while setting CURL option (CURLOPT_HTTP_VERSION). " - "(placeholder flags)"); - } + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "error while setting CURL option (CURLOPT_HTTP_VERSION)."); - if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_FAILONERROR, 1L)) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, - "error while setting CURL option (CURLOPT_FAILONERROR). " - "(placeholder flags)"); - } + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_FAILONERROR, 1L)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "error while setting CURL option (CURLOPT_FAILONERROR)."); - if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_WRITEFUNCTION, curlwritecallback)) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, - "error while setting CURL option (CURLOPT_WRITEFUNCTION). " - "(placeholder flags)"); - } + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_WRITEFUNCTION, curlwritecallback)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "error while setting CURL option (CURLOPT_WRITEFUNCTION)."); - if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_URL, url)) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, - "error while setting CURL option (CURLOPT_URL). " - "(placeholder flags)"); - } + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_URL, url)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "error while setting CURL option (CURLOPT_URL)."); #if S3COMMS_CURL_VERBOSITY > 1 /* CURL will print (to stdout) information for each operation @@ -1225,40 +1130,35 @@ H5FD_s3comms_s3r_open(const char *url, const char *region, const char *id, const * GET FILE SIZE * *******************/ - if (FAIL == H5FD_s3comms_s3r_getsize(handle)) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "problem in H5FD_s3comms_s3r_getsize.\n"); - } + if (FAIL == H5FD_s3comms_s3r_getsize(handle)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "problem in H5FD_s3comms_s3r_getsize."); /********************* * FINAL PREPARATION * *********************/ HDassert(handle->httpverb != NULL); - HDmemcpy(handle->httpverb, "GET", 4); + H5MM_memcpy(handle->httpverb, "GET", 4); ret_value = handle; done: if (ret_value == NULL) { - if (curlh != NULL) { + if (curlh != NULL) curl_easy_cleanup(curlh); - } - if (FAIL == H5FD_s3comms_free_purl(purl)) { + if (FAIL == H5FD_s3comms_free_purl(purl)) HDONE_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "unable to free parsed url structure") - } if (handle != NULL) { H5MM_xfree(handle->region); H5MM_xfree(handle->secret_id); H5MM_xfree(handle->signing_key); - if (handle->httpverb != NULL) { + if (handle->httpverb != NULL) H5MM_xfree(handle->httpverb); - } H5MM_xfree(handle); } } FUNC_LEAVE_NOAPI(ret_value) - } /* H5FD_s3comms_s3r_open */ /*---------------------------------------------------------------------------- @@ -1328,22 +1228,17 @@ H5FD_s3comms_s3r_read(s3r_t *handle, haddr_t offset, size_t len, void *dest) * ABSOLUTELY NECESSARY SANITY-CHECKS * **************************************/ - if (handle == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle cannot be null.\n"); - } - if (handle->magic != S3COMMS_S3R_MAGIC) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle has invalid magic.\n"); - } - if (handle->curlhandle == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle has bad (null) curlhandle.\n") - } - if (handle->purl == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle has bad (null) url.\n") - } + if (handle == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle cannot be null."); + if (handle->magic != S3COMMS_S3R_MAGIC) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle has invalid magic."); + if (handle->curlhandle == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle has bad (null) curlhandle.") + if (handle->purl == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle has bad (null) url.") HDassert(handle->purl->magic == S3COMMS_PARSED_URL_MAGIC); - if (offset > handle->filesize || (len + offset) > handle->filesize) { + if (offset > handle->filesize || (len + offset) > handle->filesize) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to read past EoF") - } curlh = handle->curlhandle; @@ -1353,18 +1248,15 @@ H5FD_s3comms_s3r_read(s3r_t *handle, haddr_t offset, size_t len, void *dest) if (dest != NULL) { sds = (struct s3r_datastruct *)H5MM_malloc(sizeof(struct s3r_datastruct)); - if (sds == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, "could not malloc destination datastructure.\n"); - } + if (sds == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, "could not malloc destination datastructure."); sds->magic = S3COMMS_CALLBACK_DATASTRUCT_MAGIC; sds->data = (char *)dest; sds->size = 0; - if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_WRITEDATA, sds)) { + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_WRITEDATA, sds)) HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, FAIL, - "error while setting CURL option (CURLOPT_WRITEDATA). " - "(placeholder flags)"); - } + "error while setting CURL option (CURLOPT_WRITEDATA)."); } /********************* @@ -1373,21 +1265,18 @@ H5FD_s3comms_s3r_read(s3r_t *handle, haddr_t offset, size_t len, void *dest) if (len > 0) { rangebytesstr = (char *)H5MM_malloc(sizeof(char) * (S3COMMS_MAX_RANGE_STRING_SIZE + 1)); - if (rangebytesstr == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, "could not malloc range format string.\n"); - } - ret = HDsnprintf(rangebytesstr, (S3COMMS_MAX_RANGE_STRING_SIZE), - "bytes=" H5_PRINTF_HADDR_FMT "-" H5_PRINTF_HADDR_FMT, offset, offset + len - 1); + if (rangebytesstr == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, "could not malloc range format string."); + ret = HDsnprintf(rangebytesstr, (S3COMMS_MAX_RANGE_STRING_SIZE), "bytes=%" PRIuHADDR "-%" PRIuHADDR, + offset, offset + len - 1); if (ret <= 0 || ret >= S3COMMS_MAX_RANGE_STRING_SIZE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to format HTTP Range value"); } else if (offset > 0) { rangebytesstr = (char *)H5MM_malloc(sizeof(char) * (S3COMMS_MAX_RANGE_STRING_SIZE + 1)); - if (rangebytesstr == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, "could not malloc range format string.\n"); - } - ret = HDsnprintf(rangebytesstr, (S3COMMS_MAX_RANGE_STRING_SIZE), "bytes=" H5_PRINTF_HADDR_FMT "-", - offset); + if (rangebytesstr == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, "could not malloc range format string."); + ret = HDsnprintf(rangebytesstr, (S3COMMS_MAX_RANGE_STRING_SIZE), "bytes=%" PRIuHADDR "-", offset); if (ret <= 0 || ret >= S3COMMS_MAX_RANGE_STRING_SIZE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to format HTTP Range value"); } @@ -1397,22 +1286,19 @@ H5FD_s3comms_s3r_read(s3r_t *handle, haddr_t offset, size_t len, void *dest) *******************/ if (handle->signing_key == NULL) { - /* Do not authenticate. - */ + /* Do not authenticate. */ if (rangebytesstr != NULL) { - /* Pass in range directly - */ + /* Pass in range directly */ char *bytesrange_ptr = NULL; /* pointer past "bytes=" portion */ - bytesrange_ptr = strchr(rangebytesstr, '='); + bytesrange_ptr = HDstrchr(rangebytesstr, '='); HDassert(bytesrange_ptr != NULL); bytesrange_ptr++; /* move to first char past '=' */ HDassert(*bytesrange_ptr != '\0'); - if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_RANGE, bytesrange_ptr)) { + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_RANGE, bytesrange_ptr)) HGOTO_ERROR(H5E_VFL, H5E_UNINITIALIZED, FAIL, "error while setting CURL option (CURLOPT_RANGE). "); - } } } else { @@ -1446,98 +1332,71 @@ H5FD_s3comms_s3r_read(s3r_t *handle, haddr_t offset, size_t len, void *dest) /**** VERIFY INFORMATION EXISTS ****/ - if (handle->region == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle must have non-null region.\n"); - } - if (handle->secret_id == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle must have non-null secret_id.\n"); - } - if (handle->signing_key == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle must have non-null signing_key.\n"); - } - if (handle->httpverb == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle must have non-null httpverb.\n"); - } - if (handle->purl->host == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle must have non-null host.\n"); - } - if (handle->purl->path == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle must have non-null resource.\n"); - } + if (handle->region == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle must have non-null region."); + if (handle->secret_id == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle must have non-null secret_id."); + if (handle->signing_key == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle must have non-null signing_key."); + if (handle->httpverb == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle must have non-null httpverb."); + if (handle->purl->host == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle must have non-null host."); + if (handle->purl->path == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle must have non-null resource."); /**** CREATE HTTP REQUEST STRUCTURE (hrb_t) ****/ request = H5FD_s3comms_hrb_init_request((const char *)handle->httpverb, (const char *)handle->purl->path, "HTTP/1.1"); - if (request == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not allocate hrb_t request.\n"); - } + if (request == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not allocate hrb_t request."); HDassert(request->magic == S3COMMS_HRB_MAGIC); now = gmnow(); - if (ISO8601NOW(iso8601now, now) != (ISO8601_SIZE - 1)) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not format ISO8601 time.\n"); - } + if (ISO8601NOW(iso8601now, now) != (ISO8601_SIZE - 1)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not format ISO8601 time."); - if (FAIL == H5FD_s3comms_hrb_node_set(&headers, "x-amz-date", (const char *)iso8601now)) { + if (FAIL == H5FD_s3comms_hrb_node_set(&headers, "x-amz-date", (const char *)iso8601now)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to set x-amz-date header") - } - if (headers == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "problem building headers list. " - "(placeholder flags)\n"); - } + if (headers == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem building headers list."); HDassert(headers->magic == S3COMMS_HRB_NODE_MAGIC); - if (FAIL == H5FD_s3comms_hrb_node_set(&headers, "x-amz-content-sha256", (const char *)EMPTY_SHA256)) { + if (FAIL == H5FD_s3comms_hrb_node_set(&headers, "x-amz-content-sha256", (const char *)EMPTY_SHA256)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to set x-amz-content-sha256 header") - } - if (headers == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "problem building headers list. " - "(placeholder flags)\n"); - } + if (headers == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem building headers list."); HDassert(headers->magic == S3COMMS_HRB_NODE_MAGIC); if (rangebytesstr != NULL) { - if (FAIL == H5FD_s3comms_hrb_node_set(&headers, "Range", (const char *)rangebytesstr)) { + if (FAIL == H5FD_s3comms_hrb_node_set(&headers, "Range", rangebytesstr)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to set range header") - } - if (headers == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "problem building headers list. " - "(placeholder flags)\n"); - } + if (headers == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem building headers list."); HDassert(headers->magic == S3COMMS_HRB_NODE_MAGIC); } - if (FAIL == H5FD_s3comms_hrb_node_set(&headers, "Host", (const char *)handle->purl->host)) { + if (FAIL == H5FD_s3comms_hrb_node_set(&headers, "Host", handle->purl->host)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to set host header") - } - if (headers == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "problem building headers list. " - "(placeholder flags)\n"); - } + if (headers == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem building headers list."); HDassert(headers->magic == S3COMMS_HRB_NODE_MAGIC); request->first_header = headers; /**** COMPUTE AUTHORIZATION ****/ - if (FAIL == /* buffer1 -> canonical request */ - H5FD_s3comms_aws_canonical_request(buffer1, 512, signed_headers, 48, request)) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "(placeholder flags)\n"); - } - if (FAIL == /* buffer2->string-to-sign */ - H5FD_s3comms_tostringtosign(buffer2, buffer1, iso8601now, handle->region)) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "(placeholder flags)\n"); - } - if (FAIL == /* buffer1 -> signature */ - H5FD_s3comms_HMAC_SHA256(handle->signing_key, SHA256_DIGEST_LENGTH, buffer2, HDstrlen(buffer2), - buffer1)) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "(placeholder flags)\n"); - } + /* buffer1 -> canonical request */ + if (FAIL == H5FD_s3comms_aws_canonical_request(buffer1, 512, signed_headers, 48, request)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad canonical request"); + /* buffer2->string-to-sign */ + if (FAIL == H5FD_s3comms_tostringtosign(buffer2, buffer1, iso8601now, handle->region)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad string-to-sign"); + /* buffer1 -> signature */ + if (FAIL == H5FD_s3comms_HMAC_SHA256(handle->signing_key, SHA256_DIGEST_LENGTH, buffer2, + HDstrlen(buffer2), buffer1)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad signature"); iso8601now[8] = 0; /* trim to yyyyMMDD */ ret = S3COMMS_FORMAT_CREDENTIAL(buffer2, handle->secret_id, iso8601now, handle->region, "s3"); @@ -1546,23 +1405,16 @@ H5FD_s3comms_s3r_read(s3r_t *handle, haddr_t offset, size_t len, void *dest) ret = HDsnprintf(authorization, 512, "AWS4-HMAC-SHA256 Credential=%s,SignedHeaders=%s,Signature=%s", buffer2, signed_headers, buffer1); - if (ret <= 0 || ret >= 512) { + if (ret <= 0 || ret >= 512) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to format aws4 authorization string"); - } - /* append authorization header to http request buffer - */ - if (H5FD_s3comms_hrb_node_set(&headers, "Authorization", (const char *)authorization) == FAIL) { + /* append authorization header to http request buffer */ + if (H5FD_s3comms_hrb_node_set(&headers, "Authorization", (const char *)authorization) == FAIL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to set Authorization header") - } - if (headers == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "problem building headers list. " - "(placeholder flags)\n"); - } + if (headers == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem building headers list."); - /* update hrb's "first header" pointer - */ + /* update hrb's "first header" pointer */ request->first_header = headers; /**** SET CURLHANDLE HTTP HEADERS FROM GENERATED DATA ****/ @@ -1571,29 +1423,20 @@ H5FD_s3comms_s3r_read(s3r_t *handle, haddr_t offset, size_t len, void *dest) while (node != NULL) { HDassert(node->magic == S3COMMS_HRB_NODE_MAGIC); curlheaders = curl_slist_append(curlheaders, (const char *)node->cat); - if (curlheaders == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "could not append header to curl slist. " - "(placeholder flags)\n"); - } + if (curlheaders == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not append header to curl slist."); node = node->next; } - /* sanity-check - */ - if (curlheaders == NULL) { + /* sanity-check */ + if (curlheaders == NULL) /* above loop was probably never run */ - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "curlheaders was never populated.\n"); - } + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "curlheaders was never populated."); - /* finally, set http headers in curl handle - */ - if (curl_easy_setopt(curlh, CURLOPT_HTTPHEADER, curlheaders) != CURLE_OK) { + /* finally, set http headers in curl handle */ + if (curl_easy_setopt(curlh, CURLOPT_HTTPHEADER, curlheaders) != CURLE_OK) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "error while setting CURL option " - "(CURLOPT_HTTPHEADER). (placeholder flags)"); - } - + "error while setting CURL option (CURLOPT_HTTPHEADER)."); } /* end if should authenticate (info provided) */ /******************* @@ -1609,50 +1452,43 @@ H5FD_s3comms_s3r_read(s3r_t *handle, haddr_t offset, size_t len, void *dest) char curlerrbuf[CURL_ERROR_SIZE]; curlerrbuf[0] = '\0'; - if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_ERRORBUFFER, curlerrbuf)) { + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_ERRORBUFFER, curlerrbuf)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem setting error buffer") - } p_status = curl_easy_perform(curlh); if (p_status != CURLE_OK) { - if (CURLE_OK != curl_easy_getinfo(curlh, CURLINFO_RESPONSE_CODE, &httpcode)) { + if (CURLE_OK != curl_easy_getinfo(curlh, CURLINFO_RESPONSE_CODE, &httpcode)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem getting response code") - } HDfprintf(stderr, "CURL ERROR CODE: %d\nHTTP CODE: %d\n", p_status, httpcode); HDfprintf(stderr, "%s\n", curl_easy_strerror(p_status)); - HGOTO_ERROR(H5E_VFL, H5E_CANTOPENFILE, FAIL, "problem while performing request.\n"); + HGOTO_ERROR(H5E_VFL, H5E_CANTOPENFILE, FAIL, "problem while performing request."); } - if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_ERRORBUFFER, NULL)) { + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_ERRORBUFFER, NULL)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem unsetting error buffer") - } } /* verbose error reporting */ #else p_status = curl_easy_perform(curlh); - if (p_status != CURLE_OK) { - HGOTO_ERROR(H5E_VFL, H5E_CANTOPENFILE, FAIL, "curl cannot perform request\n") - } + if (p_status != CURLE_OK) + HGOTO_ERROR(H5E_VFL, H5E_CANTOPENFILE, FAIL, "curl cannot perform request") #endif #if S3COMMS_DEBUG if (dest != NULL) { HDfprintf(stderr, "len: %d\n", (int)len); HDfprintf(stderr, "CHECKING FOR BUFFER OVERFLOW\n"); - if (sds == NULL) { + if (sds == NULL) HDfprintf(stderr, "sds is NULL!\n"); - } else { HDfprintf(stderr, "sds: 0x%lx\n", (long long)sds); HDfprintf(stderr, "sds->size: %d\n", (int)sds->size); - if (len > sds->size) { + if (len > sds->size) HDfprintf(stderr, "buffer overwrite\n"); - } } } - else { + else HDfprintf(stderr, "performed on entire file\n"); - } #endif done: @@ -1672,26 +1508,22 @@ done: } if (request != NULL) { while (headers != NULL) - if (FAIL == H5FD_s3comms_hrb_node_set(&headers, headers->name, NULL)) { + if (FAIL == H5FD_s3comms_hrb_node_set(&headers, headers->name, NULL)) HDONE_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cannot release header node") - } HDassert(NULL == headers); - if (FAIL == H5FD_s3comms_hrb_destroy(&request)) { + if (FAIL == H5FD_s3comms_hrb_destroy(&request)) HDONE_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cannot release header request structure") - } HDassert(NULL == request); } if (curlh != NULL) { /* clear any Range */ - if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_RANGE, NULL)) { + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_RANGE, NULL)) HDONE_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cannot unset CURLOPT_RANGE") - } /* clear headers */ - if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_HTTPHEADER, NULL)) { + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_HTTPHEADER, NULL)) HDONE_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cannot unset CURLOPT_HTTPHEADER") - } } FUNC_LEAVE_NOAPI(ret_value); @@ -1727,9 +1559,8 @@ gmnow(void) struct tm *ret_value = NULL; /* Doctor assert, checks against error in time() */ - if ((time_t)(-1) != time(now_ptr)) { - ret_value = gmtime(now_ptr); - } + if ((time_t)(-1) != HDtime(now_ptr)) + ret_value = HDgmtime(now_ptr); HDassert(ret_value != NULL); @@ -1806,77 +1637,65 @@ H5FD_s3comms_aws_canonical_request(char *canonical_request_dest, int _cr_size, c HDfprintf(stdout, "called H5FD_s3comms_aws_canonical_request.\n"); #endif - if (http_request == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hrb object cannot be null.\n"); - } + if (http_request == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hrb object cannot be null."); HDassert(http_request->magic == S3COMMS_HRB_MAGIC); - if (canonical_request_dest == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "canonical request destination cannot be null.\n"); - } + if (canonical_request_dest == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "canonical request destination cannot be null."); - if (signed_headers_dest == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "signed headers destination cannot be null.\n"); - } + if (signed_headers_dest == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "signed headers destination cannot be null."); - /* HTTP verb, resource path, and query string lines - */ + /* HTTP verb, resource path, and query string lines */ cr_len = (HDstrlen(http_request->verb) + HDstrlen(http_request->resource) + HDstrlen(query_params) + (size_t)3); /* three newline chars */ - if (cr_len >= cr_size) { + if (cr_len >= cr_size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not enough space in canonical request"); - } - ret = HDsnprintf(/* TODO: compiler warning */ - canonical_request_dest, (cr_size - 1), "%s\n%s\n%s\n", http_request->verb, + /* TODO: compiler warning */ + ret = HDsnprintf(canonical_request_dest, (cr_size - 1), "%s\n%s\n%s\n", http_request->verb, http_request->resource, query_params); - if (ret < 0 || (size_t)ret >= cr_size) { + if (ret < 0 || (size_t)ret >= cr_size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to compose canonical request first line"); - } - /* write in canonical headers, building signed headers concurrently - */ + /* write in canonical headers, building signed headers concurrently */ node = http_request->first_header; /* assumed sorted */ while (node != NULL) { HDassert(node->magic == S3COMMS_HRB_NODE_MAGIC); ret = HDsnprintf(tmpstr, 256, "%s:%s\n", node->lowername, node->value); - if (ret < 0 || ret >= 256) { + if (ret < 0 || ret >= 256) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to concatenate HTTP header %s:%s", node->lowername, node->value); - } cr_len += HDstrlen(tmpstr); - if (cr_len + 1 > cr_size) { + if (cr_len + 1 > cr_size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not enough space in canonical request"); - } - strcat(canonical_request_dest, tmpstr); + HDstrcat(canonical_request_dest, tmpstr); ret = HDsnprintf(tmpstr, 256, "%s;", node->lowername); - if (ret < 0 || ret >= 256) { + if (ret < 0 || ret >= 256) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to append semicolon to lowername %s", node->lowername); - } sh_len += HDstrlen(tmpstr); - if (sh_len + 1 > sh_size) { + if (sh_len + 1 > sh_size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not enough space in signed headers"); - } - strcat(signed_headers_dest, tmpstr); + HDstrcat(signed_headers_dest, tmpstr); node = node->next; } /* end while node is not NULL */ - /* remove tailing ';' from signed headers sequence - */ + /* remove trailing ';' from signed headers sequence */ signed_headers_dest[HDstrlen(signed_headers_dest) - 1] = '\0'; /* append signed headers and payload hash * NOTE: at present, no HTTP body is handled, per the nature of * requests/range-gets */ - strcat(canonical_request_dest, "\n"); - strcat(canonical_request_dest, signed_headers_dest); - strcat(canonical_request_dest, "\n"); - strcat(canonical_request_dest, EMPTY_SHA256); + HDstrcat(canonical_request_dest, "\n"); + HDstrcat(canonical_request_dest, signed_headers_dest); + HDstrcat(canonical_request_dest, "\n"); + HDstrcat(canonical_request_dest, EMPTY_SHA256); done: FUNC_LEAVE_NOAPI(ret_value); @@ -1925,24 +1744,20 @@ H5FD_s3comms_bytes_to_hex(char *dest, const unsigned char *msg, size_t msg_len, HDfprintf(stdout, "called H5FD_s3comms_bytes_to_hex.\n"); #endif - if (dest == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hex destination cannot be null.\n") - } - if (msg == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bytes sequence cannot be null.\n") - } + if (dest == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hex destination cannot be null.") + if (msg == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bytes sequence cannot be null.") for (i = 0; i < msg_len; i++) { int chars_written = HDsnprintf(&(dest[i * 2]), 3, /* 'X', 'X', '\n' */ (lowercase == TRUE) ? "%02x" : "%02X", msg[i]); - if (chars_written != 2) { + if (chars_written != 2) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem while writing hex chars for %c", msg[i]); - } } done: FUNC_LEAVE_NOAPI(ret_value); - } /* end H5FD_s3comms_bytes_to_hex() */ /*---------------------------------------------------------------------------- @@ -1975,21 +1790,16 @@ H5FD_s3comms_free_purl(parsed_url_t *purl) if (purl != NULL) { HDassert(purl->magic == S3COMMS_PARSED_URL_MAGIC); - if (purl->scheme != NULL) { + if (purl->scheme != NULL) H5MM_xfree(purl->scheme); - } - if (purl->host != NULL) { + if (purl->host != NULL) H5MM_xfree(purl->host); - } - if (purl->port != NULL) { + if (purl->port != NULL) H5MM_xfree(purl->port); - } - if (purl->path != NULL) { + if (purl->path != NULL) H5MM_xfree(purl->path); - } - if (purl->query != NULL) { + if (purl->query != NULL) H5MM_xfree(purl->query); - } purl->magic += 1ul; H5MM_xfree(purl); } @@ -2041,15 +1851,13 @@ H5FD_s3comms_HMAC_SHA256(const unsigned char *key, size_t key_len, const char *m HDfprintf(stdout, "called H5FD_s3comms_HMAC_SHA256.\n"); #endif - if (dest == NULL) { + if (dest == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "destination cannot be null."); - } HMAC(EVP_sha256(), key, (int)key_len, (const unsigned char *)msg, msg_len, md, &md_len); - if (H5FD_s3comms_bytes_to_hex(dest, (const unsigned char *)md, (size_t)md_len, true) == FAIL) { + if (H5FD_s3comms_bytes_to_hex(dest, (const unsigned char *)md, (size_t)md_len, true) == FAIL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not convert to hex string."); - } done: FUNC_LEAVE_NOAPI(ret_value); @@ -2127,42 +1935,37 @@ H5FD__s3comms_load_aws_creds_from_file(FILE *file, const char *profile_name, cha int found_setting = 0; char * line_buffer = &(buffer[0]); - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC #if S3COMMS_DEBUG HDfprintf(stdout, "called load_aws_creds_from_file.\n"); #endif /* format target line for start of profile */ - if (32 < HDsnprintf(profile_line, 32, "[%s]", profile_name)) { + if (32 < HDsnprintf(profile_line, 32, "[%s]", profile_name)) HGOTO_ERROR(H5E_ARGS, H5E_CANTCOPY, FAIL, "unable to format profile label") - } /* look for start of profile */ do { /* clear buffer */ - for (buffer_i = 0; buffer_i < 128; buffer_i++) { + for (buffer_i = 0; buffer_i < 128; buffer_i++) buffer[buffer_i] = 0; - } - line_buffer = fgets(line_buffer, 128, file); - if (line_buffer == NULL) { /* reached end of file */ + line_buffer = HDfgets(line_buffer, 128, file); + if (line_buffer == NULL) /* reached end of file */ goto done; - } - } while (strncmp(line_buffer, profile_line, HDstrlen(profile_line))); + } while (HDstrncmp(line_buffer, profile_line, HDstrlen(profile_line))); /* extract credentials from lines */ do { /* clear buffer */ - for (buffer_i = 0; buffer_i < 128; buffer_i++) { + for (buffer_i = 0; buffer_i < 128; buffer_i++) buffer[buffer_i] = 0; - } /* collect a line from file */ - line_buffer = fgets(line_buffer, 128, file); - if (line_buffer == NULL) { + line_buffer = HDfgets(line_buffer, 128, file); + if (line_buffer == NULL) goto done; /* end of file */ - } /* loop over names to see if line looks like assignment */ for (setting_i = 0; setting_i < setting_count; setting_i++) { @@ -2172,40 +1975,33 @@ H5FD__s3comms_load_aws_creds_from_file(FILE *file, const char *profile_name, cha setting_name = setting_names[setting_i]; setting_name_len = HDstrlen(setting_name); - if (HDsnprintf(line_prefix, 128, "%s=", setting_name) < 0) { + if (HDsnprintf(line_prefix, 128, "%s=", setting_name) < 0) HGOTO_ERROR(H5E_ARGS, H5E_CANTCOPY, FAIL, "unable to format line prefix") - } /* found a matching name? */ if (!HDstrncmp(line_buffer, line_prefix, setting_name_len + 1)) { found_setting = 1; /* skip NULL destination buffer */ - if (setting_pointers[setting_i] == NULL) { + if (setting_pointers[setting_i] == NULL) break; - } /* advance to end of name in string */ do { line_buffer++; } while (*line_buffer != 0 && *line_buffer != '='); - if (*line_buffer == 0 || *(line_buffer + 1) == 0) { + if (*line_buffer == 0 || *(line_buffer + 1) == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "incomplete assignment in file") - } line_buffer++; /* was pointing at '='; advance */ /* copy line buffer into out pointer */ - if (HDstrncpy(setting_pointers[setting_i], (const char *)line_buffer, - HDstrlen(line_buffer)) == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_CANTCOPY, FAIL, "unable to copy line into pointer") - } + HDstrncpy(setting_pointers[setting_i], (const char *)line_buffer, HDstrlen(line_buffer)); /* "trim" tailing whitespace by replacing with null terminator*/ buffer_i = 0; - while (!isspace(setting_pointers[setting_i][buffer_i])) { + while (!HDisspace(setting_pointers[setting_i][buffer_i])) buffer_i++; - } setting_pointers[setting_i][buffer_i] = '\0'; break; /* have read setting; don't compare with others */ @@ -2266,59 +2062,50 @@ H5FD_s3comms_load_aws_profile(const char *profile_name, char *key_id_out, char * #endif #ifdef H5_HAVE_WIN32_API - ret = HDsnprintf(awspath, 117, "%s/.aws/", getenv("USERPROFILE")); + ret = HDsnprintf(awspath, 117, "%s/.aws/", HDgetenv("USERPROFILE")); #else - ret = HDsnprintf(awspath, 117, "%s/.aws/", getenv("HOME")); + ret = HDsnprintf(awspath, 117, "%s/.aws/", HDgetenv("HOME")); #endif - if (ret < 0 || (size_t)ret >= 117) { + if (ret < 0 || (size_t)ret >= 117) HGOTO_ERROR(H5E_ARGS, H5E_CANTCOPY, FAIL, "unable to format home-aws path") - } ret = HDsnprintf(filepath, 128, "%s%s", awspath, "credentials"); - if (ret < 0 || (size_t)ret >= 128) { + if (ret < 0 || (size_t)ret >= 128) HGOTO_ERROR(H5E_ARGS, H5E_CANTCOPY, FAIL, "unable to format credentials path") - } - credfile = fopen(filepath, "r"); + credfile = HDfopen(filepath, "r"); if (credfile != NULL) { if (H5FD__s3comms_load_aws_creds_from_file(credfile, profile_name, key_id_out, secret_access_key_out, - aws_region_out) == FAIL) { + aws_region_out) == FAIL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to load from aws credentials") - } - if (fclose(credfile) == EOF) { + if (HDfclose(credfile) == EOF) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close credentials file") - } credfile = NULL; } /* end if credential file opened */ ret = HDsnprintf(filepath, 128, "%s%s", awspath, "config"); - if (ret < 0 || (size_t)ret >= 128) { + if (ret < 0 || (size_t)ret >= 128) HGOTO_ERROR(H5E_ARGS, H5E_CANTCOPY, FAIL, "unable to format config path") - } - credfile = fopen(filepath, "r"); + credfile = HDfopen(filepath, "r"); if (credfile != NULL) { if (H5FD__s3comms_load_aws_creds_from_file( credfile, profile_name, (*key_id_out == 0) ? key_id_out : NULL, (*secret_access_key_out == 0) ? secret_access_key_out : NULL, - (*aws_region_out == 0) ? aws_region_out : NULL) == FAIL) { + (*aws_region_out == 0) ? aws_region_out : NULL) == FAIL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to load from aws config") - } - if (fclose(credfile) == EOF) { + if (HDfclose(credfile) == EOF) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close config file") - } credfile = NULL; } /* end if credential file opened */ /* fail if not all three settings were loaded */ - if (*key_id_out == 0 || *secret_access_key_out == 0 || *aws_region_out == 0) { + if (*key_id_out == 0 || *secret_access_key_out == 0 || *aws_region_out == 0) ret_value = FAIL; - } done: - if (credfile != NULL) { - if (fclose(credfile) == EOF) { + if (credfile != NULL) + if (HDfclose(credfile) == EOF) HDONE_ERROR(H5E_ARGS, H5E_ARGS, FAIL, "problem error-closing aws configuration file") - } - } + FUNC_LEAVE_NOAPI(ret_value); } /* end H5FD_s3comms_load_aws_profile() */ @@ -2359,15 +2146,14 @@ H5FD_s3comms_nlowercase(char *dest, const char *s, size_t len) HDfprintf(stdout, "called H5FD_s3comms_nlowercase.\n"); #endif - if (dest == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "destination cannot be null.\n"); - } + if (dest == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "destination cannot be null."); if (len > 0) { - HDmemcpy(dest, s, len); + H5MM_memcpy(dest, s, len); do { len--; - dest[len] = (char)tolower((int)dest[len]); + dest[len] = (char)HDtolower((int)dest[len]); } while (len > 0); } @@ -2423,16 +2209,14 @@ H5FD_s3comms_parse_url(const char *str, parsed_url_t **_purl) HDprintf("called H5FD_s3comms_parse_url.\n"); #endif - if (str == NULL || *str == '\0') { + if (str == NULL || *str == '\0') HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid url string"); - } urllen = (long int)HDstrlen(str); purl = (parsed_url_t *)H5MM_malloc(sizeof(parsed_url_t)); - if (purl == NULL) { + if (purl == NULL) HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, "can't allocate space for parsed_url_t"); - } purl->magic = S3COMMS_PARSED_URL_MAGIC; purl->scheme = NULL; purl->host = NULL; @@ -2445,31 +2229,26 @@ H5FD_s3comms_parse_url(const char *str, parsed_url_t **_purl) ***************/ tmpstr = HDstrchr(curstr, ':'); - if (tmpstr == NULL) { + if (tmpstr == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid SCHEME construction: probably not URL"); - } len = tmpstr - curstr; HDassert((0 <= len) && (len < urllen)); - /* check for restrictions - */ + /* check for restrictions */ for (i = 0; i < len; i++) { /* scheme = [a-zA-Z+-.]+ (terminated by ":") */ - if (!isalpha(curstr[i]) && '+' != curstr[i] && '-' != curstr[i] && '.' != curstr[i]) { + if (!HDisalpha(curstr[i]) && '+' != curstr[i] && '-' != curstr[i] && '.' != curstr[i]) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid SCHEME construction"); - } } - /* copy lowercased scheme to structure - */ + + /* copy lowercased scheme to structure */ purl->scheme = (char *)H5MM_malloc(sizeof(char) * (size_t)(len + 1)); - if (purl->scheme == NULL) { + if (purl->scheme == NULL) HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, "can't allocate space for SCHEME"); - } - (void)HDstrncpy(purl->scheme, curstr, (size_t)len); + HDstrncpy(purl->scheme, curstr, (size_t)len); purl->scheme[len] = '\0'; - for (i = 0; i < len; i++) { - purl->scheme[i] = (char)tolower(purl->scheme[i]); - } + for (i = 0; i < len; i++) + purl->scheme[i] = (char)HDtolower(purl->scheme[i]); /* Skip "://" */ tmpstr += 3; @@ -2482,36 +2261,31 @@ H5FD_s3comms_parse_url(const char *str, parsed_url_t **_purl) if (*curstr == '[') { /* IPv6 */ while (']' != *tmpstr) { - if (tmpstr == 0) { /* end of string reached! */ + /* end of string reached! */ + if (tmpstr == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "reached end of URL: incomplete IPv6 HOST"); - } tmpstr++; } tmpstr++; } /* end if (IPv6) */ else { while (0 != *tmpstr) { - if (':' == *tmpstr || '/' == *tmpstr || '?' == *tmpstr) { + if (':' == *tmpstr || '/' == *tmpstr || '?' == *tmpstr) break; - } tmpstr++; } } /* end else (IPv4) */ len = tmpstr - curstr; - if (len == 0) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "HOST substring cannot be empty"); - } - else if (len > urllen) { + if (len == 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "HOST substring cannot be empty") + else if (len > urllen) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem with length of HOST substring"); - } - /* copy host - */ + /* copy host */ purl->host = (char *)H5MM_malloc(sizeof(char) * (size_t)(len + 1)); - if (purl->host == NULL) { + if (purl->host == NULL) HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, "can't allocate space for HOST"); - } - (void)HDstrncpy(purl->host, curstr, (size_t)len); + HDstrncpy(purl->host, curstr, (size_t)len); purl->host[len] = 0; /************* @@ -2521,29 +2295,22 @@ H5FD_s3comms_parse_url(const char *str, parsed_url_t **_purl) if (':' == *tmpstr) { tmpstr += 1; /* advance past ':' */ curstr = tmpstr; - while ((0 != *tmpstr) && ('/' != *tmpstr) && ('?' != *tmpstr)) { + while ((0 != *tmpstr) && ('/' != *tmpstr) && ('?' != *tmpstr)) tmpstr++; - } len = tmpstr - curstr; - if (len == 0) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "PORT element cannot be empty"); - } - else if (len > urllen) { + if (len == 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "PORT element cannot be empty") + else if (len > urllen) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem with length of PORT substring"); - } - for (i = 0; i < len; i++) { - if (!isdigit(curstr[i])) { + for (i = 0; i < len; i++) + if (!HDisdigit(curstr[i])) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "PORT is not a decimal string"); - } - } - /* copy port - */ + /* copy port */ purl->port = (char *)H5MM_malloc(sizeof(char) * (size_t)(len + 1)); - if (purl->port == NULL) { /* cannot malloc */ + if (purl->port == NULL) HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, "can't allocate space for PORT"); - } - (void)HDstrncpy(purl->port, curstr, (size_t)len); + HDstrncpy(purl->port, curstr, (size_t)len); purl->port[len] = 0; } /* end if PORT element */ @@ -2556,21 +2323,17 @@ H5FD_s3comms_parse_url(const char *str, parsed_url_t **_purl) tmpstr += 1; curstr = tmpstr; - /* seek end of PATH - */ - while ((0 != *tmpstr) && ('?' != *tmpstr)) { + /* seek end of PATH */ + while ((0 != *tmpstr) && ('?' != *tmpstr)) tmpstr++; - } len = tmpstr - curstr; - if (len > urllen) { + if (len > urllen) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem with length of PATH substring"); - } if (len > 0) { purl->path = (char *)H5MM_malloc(sizeof(char) * (size_t)(len + 1)); - if (purl->path == NULL) { + if (purl->path == NULL) HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, "can't allocate space for PATH"); - } /* cannot malloc path pointer */ - (void)HDstrncpy(purl->path, curstr, (size_t)len); + HDstrncpy(purl->path, curstr, (size_t)len); purl->path[len] = 0; } } /* end if PATH element */ @@ -2582,21 +2345,17 @@ H5FD_s3comms_parse_url(const char *str, parsed_url_t **_purl) if ('?' == *tmpstr) { tmpstr += 1; curstr = tmpstr; - while (0 != *tmpstr) { + while (0 != *tmpstr) tmpstr++; - } len = tmpstr - curstr; - if (len == 0) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "QUERY cannot be empty"); - } - else if (len > urllen) { + if (len == 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "QUERY cannot be empty") + else if (len > urllen) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem with length of QUERY substring"); - } purl->query = (char *)H5MM_malloc(sizeof(char) * (size_t)(len + 1)); - if (purl->query == NULL) { + if (purl->query == NULL) HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, "can't allocate space for QUERY"); - } /* cannot malloc path pointer */ - (void)HDstrncpy(purl->query, curstr, (size_t)len); + HDstrncpy(purl->query, curstr, (size_t)len); purl->query[len] = 0; } /* end if QUERY exists */ @@ -2604,9 +2363,9 @@ H5FD_s3comms_parse_url(const char *str, parsed_url_t **_purl) ret_value = SUCCEED; done: - if (ret_value == FAIL) { + if (ret_value == FAIL) H5FD_s3comms_free_purl(purl); - } + FUNC_LEAVE_NOAPI(ret_value); } /* end H5FD_s3comms_parse_url() */ @@ -2666,9 +2425,8 @@ H5FD_s3comms_percent_encode_char(char *repr, const unsigned char c, size_t *repr HDfprintf(stdout, "called H5FD_s3comms_percent_encode_char.\n"); #endif - if (repr == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no destination `repr`.\n") - } + if (repr == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no destination `repr`.") #if S3COMMS_DEBUG H5FD_s3comms_bytes_to_hex((char *)hex, s, 1, FALSE); @@ -2685,9 +2443,8 @@ H5FD_s3comms_percent_encode_char(char *repr, const unsigned char c, size_t *repr #endif *repr_len = 3; chars_written = HDsnprintf(repr, 4, "%%%02X", c); - if (chars_written < 0) { + if (chars_written < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cannot write char %c", c); - } } /* end if single-byte unicode char */ else { /* multi-byte, multi-percent representation @@ -2737,9 +2494,8 @@ H5FD_s3comms_percent_encode_char(char *repr, const unsigned char c, size_t *repr acc += (stack_size > 3) ? 0x10 : 0; /* 0x00010000 */ stack_size--; chars_written = HDsnprintf(repr, 4, "%%%02X", (unsigned char)(acc + stack[stack_size])); - if (chars_written < 0) { + if (chars_written < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cannot write char %c", c); - } *repr_len += 3; /************************ @@ -2750,9 +2506,8 @@ H5FD_s3comms_percent_encode_char(char *repr, const unsigned char c, size_t *repr for (i = 0; i < stack_size; i++) { chars_written = HDsnprintf(&repr[i * 3 + 3], 4, "%%%02X", (unsigned char)(0x80 + stack[stack_size - 1 - i])); - if (chars_written < 0) { + if (chars_written < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cannot write char %c", c); - } *repr_len += 3; } /* end for each continuation byte */ } /* end else (multi-byte) */ @@ -2818,31 +2573,24 @@ H5FD_s3comms_signing_key(unsigned char *md, const char *secret, const char *regi HDfprintf(stdout, "called H5FD_s3comms_signing_key.\n"); #endif - if (md == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Destination `md` cannot be NULL.\n") - } - if (secret == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "`secret` cannot be NULL.\n") - } - if (region == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "`region` cannot be NULL.\n") - } - if (iso8601now == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "`iso8601now` cannot be NULL.\n") - } + if (md == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Destination `md` cannot be NULL.") + if (secret == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "`secret` cannot be NULL.") + if (region == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "`region` cannot be NULL.") + if (iso8601now == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "`iso8601now` cannot be NULL.") AWS4_secret_len = 4 + HDstrlen(secret) + 1; AWS4_secret = (char *)H5MM_malloc(sizeof(char *) * AWS4_secret_len); - if (AWS4_secret == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Could not allocate space.\n") - } + if (AWS4_secret == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Could not allocate space.") - /* prepend "AWS4" to start of the secret key - */ + /* prepend "AWS4" to start of the secret key */ ret = HDsnprintf(AWS4_secret, AWS4_secret_len, "%s%s", "AWS4", secret); - if ((size_t)ret != (AWS4_secret_len - 1)) { + if ((size_t)ret != (AWS4_secret_len - 1)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem writing AWS4+secret `%s`", secret); - } /* hash_func, key, len(key), msg, len(msg), digest_dest, digest_len_dest * we know digest length, so ignore via NULL @@ -2917,22 +2665,17 @@ H5FD_s3comms_tostringtosign(char *dest, const char *req, const char *now, const HDfprintf(stdout, "called H5FD_s3comms_tostringtosign.\n"); #endif - if (dest == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "destination buffer cannot be null.\n") - } - if (req == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "canonical request cannot be null.\n") - } - if (now == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Timestring cannot be NULL.\n") - } - if (region == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Region cannot be NULL.\n") - } + if (dest == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "destination buffer cannot be null.") + if (req == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "canonical request cannot be null.") + if (now == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Timestring cannot be NULL.") + if (region == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Region cannot be NULL.") - for (i = 0; i < 128; i++) { + for (i = 0; i < 128; i++) tmp[i] = '\0'; - } for (i = 0; i < SHA256_DIGEST_LENGTH * 2 + 1; i++) { checksum[i] = '\0'; hexsum[i] = '\0'; @@ -2940,31 +2683,28 @@ H5FD_s3comms_tostringtosign(char *dest, const char *req, const char *now, const HDstrncpy(day, now, 8); day[8] = '\0'; ret = HDsnprintf(tmp, 127, "%s/%s/s3/aws4_request", day, region); - if (ret <= 0 || ret >= 127) { + if (ret <= 0 || ret >= 127) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem adding day and region to string") - } - HDmemcpy((dest + d), "AWS4-HMAC-SHA256\n", 17); + H5MM_memcpy((dest + d), "AWS4-HMAC-SHA256\n", 17); d = 17; - HDmemcpy((dest + d), now, HDstrlen(now)); + H5MM_memcpy((dest + d), now, HDstrlen(now)); d += HDstrlen(now); dest[d++] = '\n'; - HDmemcpy((dest + d), tmp, HDstrlen(tmp)); + H5MM_memcpy((dest + d), tmp, HDstrlen(tmp)); d += HDstrlen(tmp); dest[d++] = '\n'; SHA256((const unsigned char *)req, HDstrlen(req), checksum); if (H5FD_s3comms_bytes_to_hex(hexsum, (const unsigned char *)checksum, SHA256_DIGEST_LENGTH, true) == - FAIL) { + FAIL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not create hex string"); - } - for (i = 0; i < SHA256_DIGEST_LENGTH * 2; i++) { + for (i = 0; i < SHA256_DIGEST_LENGTH * 2; i++) dest[d++] = hexsum[i]; - } dest[d] = '\0'; @@ -3012,18 +2752,16 @@ H5FD_s3comms_trim(char *dest, char *s, size_t s_len, size_t *n_written) HDfprintf(stdout, "called H5FD_s3comms_trim.\n"); #endif - if (dest == NULL) { + if (dest == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "destination cannot be null.") - } - if (s == NULL) { + if (s == NULL) s_len = 0; - } if (s_len > 0) { /* Find first non-whitespace character from start; * reduce total length per character. */ - while ((s_len > 0) && isspace((unsigned char)s[0]) && s_len > 0) { + while ((s_len > 0) && HDisspace((unsigned char)s[0]) && s_len > 0) { s++; s_len--; } @@ -3035,12 +2773,11 @@ H5FD_s3comms_trim(char *dest, char *s, size_t s_len, size_t *n_written) if (s_len > 0) { do { s_len--; - } while (isspace((unsigned char)s[s_len])); + } while (HDisspace((unsigned char)s[s_len])); s_len++; - /* write output into dest - */ - HDmemcpy(dest, s, s_len); + /* write output into dest */ + H5MM_memcpy(dest, s, s_len); } } @@ -3105,12 +2842,10 @@ H5FD_s3comms_uriencode(char *dest, const char *s, size_t s_len, hbool_t encode_s HDfprintf(stdout, "H5FD_s3comms_uriencode called.\n"); #endif - if (s == NULL) { + if (s == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source string cannot be NULL"); - } - if (dest == NULL) { + if (dest == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "destination cannot be NULL"); - } /* Write characters to destination, converting to percent-encoded * "hex-utf-8" strings if necessary. @@ -3118,10 +2853,9 @@ H5FD_s3comms_uriencode(char *dest, const char *s, size_t s_len, hbool_t encode_s */ for (s_off = 0; s_off < s_len; s_off++) { c = s[s_off]; - if (isalnum(c) || c == '.' || c == '-' || c == '_' || c == '~' || - (c == '/' && encode_slash == FALSE)) { + if (HDisalnum(c) || c == '.' || c == '-' || c == '_' || c == '~' || + (c == '/' && encode_slash == FALSE)) dest[dest_off++] = c; - } else { hex_off = 0; if (H5FD_s3comms_percent_encode_char(hex_buffer, (const unsigned char)c, &hex_len) == FAIL) { @@ -3133,9 +2867,8 @@ H5FD_s3comms_uriencode(char *dest, const char *s, size_t s_len, hbool_t encode_s hex_buffer, (int)s_off, s); } - for (hex_off = 0; hex_off < hex_len; hex_off++) { + for (hex_off = 0; hex_off < hex_len; hex_off++) dest[dest_off++] = hex_buffer[hex_off]; - } } /* end else (not a regular character) */ } /* end for each character */ diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c index 319089c..816381d 100644 --- a/src/H5FDsec2.c +++ b/src/H5FDsec2.c @@ -98,7 +98,6 @@ typedef struct H5FD_sec2_t { * a single file. */ hbool_t fam_to_single; - } H5FD_sec2_t; /* @@ -123,57 +122,57 @@ typedef struct H5FD_sec2_t { (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || HADDR_UNDEF == (A) + (Z) || (HDoff_t)((A) + (Z)) < (HDoff_t)(A)) /* Prototypes */ -static herr_t H5FD_sec2_term(void); -static H5FD_t *H5FD_sec2_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); -static herr_t H5FD_sec2_close(H5FD_t *_file); -static int H5FD_sec2_cmp(const H5FD_t *_f1, const H5FD_t *_f2); -static herr_t H5FD_sec2_query(const H5FD_t *_f1, unsigned long *flags); -static haddr_t H5FD_sec2_get_eoa(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD_sec2_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); -static haddr_t H5FD_sec2_get_eof(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD_sec2_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle); -static herr_t H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, - void *buf); -static herr_t H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, - const void *buf); -static herr_t H5FD_sec2_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); -static herr_t H5FD_sec2_lock(H5FD_t *_file, hbool_t rw); -static herr_t H5FD_sec2_unlock(H5FD_t *_file); +static herr_t H5FD__sec2_term(void); +static H5FD_t *H5FD__sec2_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); +static herr_t H5FD__sec2_close(H5FD_t *_file); +static int H5FD__sec2_cmp(const H5FD_t *_f1, const H5FD_t *_f2); +static herr_t H5FD__sec2_query(const H5FD_t *_f1, unsigned long *flags); +static haddr_t H5FD__sec2_get_eoa(const H5FD_t *_file, H5FD_mem_t type); +static herr_t H5FD__sec2_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); +static haddr_t H5FD__sec2_get_eof(const H5FD_t *_file, H5FD_mem_t type); +static herr_t H5FD__sec2_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle); +static herr_t H5FD__sec2_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + void *buf); +static herr_t H5FD__sec2_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + const void *buf); +static herr_t H5FD__sec2_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); +static herr_t H5FD__sec2_lock(H5FD_t *_file, hbool_t rw); +static herr_t H5FD__sec2_unlock(H5FD_t *_file); static const H5FD_class_t H5FD_sec2_g = { - "sec2", /* name */ - MAXADDR, /* maxaddr */ - H5F_CLOSE_WEAK, /* fc_degree */ - H5FD_sec2_term, /* terminate */ - NULL, /* sb_size */ - NULL, /* sb_encode */ - NULL, /* sb_decode */ - 0, /* fapl_size */ - NULL, /* fapl_get */ - NULL, /* fapl_copy */ - NULL, /* fapl_free */ - 0, /* dxpl_size */ - NULL, /* dxpl_copy */ - NULL, /* dxpl_free */ - H5FD_sec2_open, /* open */ - H5FD_sec2_close, /* close */ - H5FD_sec2_cmp, /* cmp */ - H5FD_sec2_query, /* query */ - NULL, /* get_type_map */ - NULL, /* alloc */ - NULL, /* free */ - H5FD_sec2_get_eoa, /* get_eoa */ - H5FD_sec2_set_eoa, /* set_eoa */ - H5FD_sec2_get_eof, /* get_eof */ - H5FD_sec2_get_handle, /* get_handle */ - H5FD_sec2_read, /* read */ - H5FD_sec2_write, /* write */ - NULL, /* flush */ - H5FD_sec2_truncate, /* truncate */ - H5FD_sec2_lock, /* lock */ - H5FD_sec2_unlock, /* unlock */ + "sec2", /* name */ + MAXADDR, /* maxaddr */ + H5F_CLOSE_WEAK, /* fc_degree */ + H5FD__sec2_term, /* terminate */ + NULL, /* sb_size */ + NULL, /* sb_encode */ + NULL, /* sb_decode */ + 0, /* fapl_size */ + NULL, /* fapl_get */ + NULL, /* fapl_copy */ + NULL, /* fapl_free */ + 0, /* dxpl_size */ + NULL, /* dxpl_copy */ + NULL, /* dxpl_free */ + H5FD__sec2_open, /* open */ + H5FD__sec2_close, /* close */ + H5FD__sec2_cmp, /* cmp */ + H5FD__sec2_query, /* query */ + NULL, /* get_type_map */ + NULL, /* alloc */ + NULL, /* free */ + H5FD__sec2_get_eoa, /* get_eoa */ + H5FD__sec2_set_eoa, /* set_eoa */ + H5FD__sec2_get_eof, /* get_eof */ + H5FD__sec2_get_handle, /* get_handle */ + H5FD__sec2_read, /* read */ + H5FD__sec2_write, /* write */ + NULL, /* flush */ + H5FD__sec2_truncate, /* truncate */ + H5FD__sec2_lock, /* lock */ + H5FD__sec2_unlock, /* unlock */ NULL, /* dedup */ - H5FD_FLMAP_DICHOTOMY /* fl_map */ + H5FD_FLMAP_DICHOTOMY /* fl_map */ }; /* Declare a free list to manage the H5FD_sec2_t struct */ @@ -244,7 +243,7 @@ done: } /* end H5FD_sec2_init() */ /*--------------------------------------------------------------------------- - * Function: H5FD_sec2_term + * Function: H5FD__sec2_term * * Purpose: Shut down the VFD * @@ -256,15 +255,15 @@ done: *--------------------------------------------------------------------------- */ static herr_t -H5FD_sec2_term(void) +H5FD__sec2_term(void) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Reset VFL ID */ H5FD_SEC2_g = 0; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5FD_sec2_term() */ +} /* end H5FD__sec2_term() */ /*------------------------------------------------------------------------- * Function: H5Pset_fapl_sec2 @@ -299,7 +298,7 @@ done: } /* end H5Pset_fapl_sec2() */ /*------------------------------------------------------------------------- - * Function: H5FD_sec2_open + * Function: H5FD__sec2_open * * Purpose: Create and/or opens a file as an HDF5 file. * @@ -314,7 +313,7 @@ done: *------------------------------------------------------------------------- */ static H5FD_t * -H5FD_sec2_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) +H5FD__sec2_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { H5FD_sec2_t *file = NULL; /* sec2 VFD info */ int fd = -1; /* File descriptor */ @@ -326,7 +325,7 @@ H5FD_sec2_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) H5P_genplist_t *plist; /* Property list pointer */ H5FD_t * ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Sanity check on file offsets */ HDcompile_assert(sizeof(HDoff_t) >= sizeof(size_t)); @@ -427,10 +426,10 @@ done: } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_sec2_open() */ +} /* end H5FD__sec2_open() */ /*------------------------------------------------------------------------- - * Function: H5FD_sec2_close + * Function: H5FD__sec2_close * * Purpose: Closes an HDF5 file. * @@ -443,12 +442,12 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_sec2_close(H5FD_t *_file) +H5FD__sec2_close(H5FD_t *_file) { H5FD_sec2_t *file = (H5FD_sec2_t *)_file; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Sanity check */ HDassert(file); @@ -462,10 +461,10 @@ H5FD_sec2_close(H5FD_t *_file) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_sec2_close() */ +} /* end H5FD__sec2_close() */ /*------------------------------------------------------------------------- - * Function: H5FD_sec2_cmp + * Function: H5FD__sec2_cmp * * Purpose: Compares two files belonging to this driver using an * arbitrary (but consistent) ordering. @@ -480,13 +479,13 @@ done: *------------------------------------------------------------------------- */ static int -H5FD_sec2_cmp(const H5FD_t *_f1, const H5FD_t *_f2) +H5FD__sec2_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { const H5FD_sec2_t *f1 = (const H5FD_sec2_t *)_f1; const H5FD_sec2_t *f2 = (const H5FD_sec2_t *)_f2; int ret_value = 0; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR #ifdef H5_HAVE_WIN32_API if (f1->dwVolumeSerialNumber < f2->dwVolumeSerialNumber) @@ -527,10 +526,10 @@ H5FD_sec2_cmp(const H5FD_t *_f1, const H5FD_t *_f2) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_sec2_cmp() */ +} /* end H5FD__sec2_cmp() */ /*------------------------------------------------------------------------- - * Function: H5FD_sec2_query + * Function: H5FD__sec2_query * * Purpose: Set the flags that this VFL driver is capable of supporting. * (listed in H5FDpublic.h) @@ -543,11 +542,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_sec2_query(const H5FD_t *_file, unsigned long *flags /* out */) +H5FD__sec2_query(const H5FD_t *_file, unsigned long *flags /* out */) { const H5FD_sec2_t *file = (const H5FD_sec2_t *)_file; /* sec2 VFD info */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Set the VFL feature flags that this driver supports */ /* Notice: the Mirror VFD Writer currently uses only the Sec2 driver as @@ -575,10 +574,10 @@ H5FD_sec2_query(const H5FD_t *_file, unsigned long *flags /* out */) } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5FD_sec2_query() */ +} /* end H5FD__sec2_query() */ /*------------------------------------------------------------------------- - * Function: H5FD_sec2_get_eoa + * Function: H5FD__sec2_get_eoa * * Purpose: Gets the end-of-address marker for the file. The EOA marker * is the first address past the last byte allocated in the @@ -592,17 +591,17 @@ H5FD_sec2_query(const H5FD_t *_file, unsigned long *flags /* out */) *------------------------------------------------------------------------- */ static haddr_t -H5FD_sec2_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) +H5FD__sec2_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { const H5FD_sec2_t *file = (const H5FD_sec2_t *)_file; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR FUNC_LEAVE_NOAPI(file->eoa) -} /* end H5FD_sec2_get_eoa() */ +} /* end H5FD__sec2_get_eoa() */ /*------------------------------------------------------------------------- - * Function: H5FD_sec2_set_eoa + * Function: H5FD__sec2_set_eoa * * Purpose: Set the end-of-address marker for the file. This function is * called shortly after an existing HDF5 file is opened in order @@ -616,19 +615,19 @@ H5FD_sec2_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) *------------------------------------------------------------------------- */ static herr_t -H5FD_sec2_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) +H5FD__sec2_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) { H5FD_sec2_t *file = (H5FD_sec2_t *)_file; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR file->eoa = addr; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5FD_sec2_set_eoa() */ +} /* end H5FD__sec2_set_eoa() */ /*------------------------------------------------------------------------- - * Function: H5FD_sec2_get_eof + * Function: H5FD__sec2_get_eof * * Purpose: Returns the end-of-file marker, which is the greater of * either the filesystem end-of-file or the HDF5 end-of-address @@ -643,17 +642,17 @@ H5FD_sec2_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) *------------------------------------------------------------------------- */ static haddr_t -H5FD_sec2_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) +H5FD__sec2_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { const H5FD_sec2_t *file = (const H5FD_sec2_t *)_file; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR FUNC_LEAVE_NOAPI(file->eof) -} /* end H5FD_sec2_get_eof() */ +} /* end H5FD__sec2_get_eof() */ /*------------------------------------------------------------------------- - * Function: H5FD_sec2_get_handle + * Function: H5FD__sec2_get_handle * * Purpose: Returns the file handle of sec2 file driver. * @@ -665,12 +664,12 @@ H5FD_sec2_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) *------------------------------------------------------------------------- */ static herr_t -H5FD_sec2_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void **file_handle) +H5FD__sec2_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void **file_handle) { H5FD_sec2_t *file = (H5FD_sec2_t *)_file; herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC if (!file_handle) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file handle not valid") @@ -679,10 +678,10 @@ H5FD_sec2_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void **file_handl done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_sec2_get_handle() */ +} /* end H5FD__sec2_get_handle() */ /*------------------------------------------------------------------------- - * Function: H5FD_sec2_read + * Function: H5FD__sec2_read * * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR * into buffer BUF according to data transfer properties in @@ -698,14 +697,14 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, - size_t size, void *buf /*out*/) +H5FD__sec2_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, + size_t size, void *buf /*out*/) { H5FD_sec2_t *file = (H5FD_sec2_t *)_file; HDoff_t offset = (HDoff_t)addr; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC HDassert(file && file->pub.cls); HDassert(buf); @@ -718,17 +717,15 @@ H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUS #ifndef H5_HAVE_PREADWRITE /* Seek to the correct location (if we don't have pread) */ - if (addr != file->pos || OP_READ != file->op) { + if (addr != file->pos || OP_READ != file->op) if (HDlseek(file->fd, (HDoff_t)addr, SEEK_SET) < 0) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") - } #endif /* H5_HAVE_PREADWRITE */ /* Read data, being careful of interrupted system calls, partial results, * and the end of the file. */ while (size > 0) { - h5_posix_io_t bytes_in = 0; /* # of bytes to read */ h5_posix_io_ret_t bytes_read = -1; /* # of bytes actually read */ @@ -791,10 +788,10 @@ done: } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_sec2_read() */ +} /* end H5FD__sec2_read() */ /*------------------------------------------------------------------------- - * Function: H5FD_sec2_write + * Function: H5FD__sec2_write * * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR * from buffer BUF according to data transfer properties in @@ -808,14 +805,14 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, - size_t size, const void *buf) +H5FD__sec2_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, + size_t size, const void *buf) { H5FD_sec2_t *file = (H5FD_sec2_t *)_file; HDoff_t offset = (HDoff_t)addr; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC HDassert(file && file->pub.cls); HDassert(buf); @@ -829,17 +826,15 @@ H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU #ifndef H5_HAVE_PREADWRITE /* Seek to the correct location (if we don't have pwrite) */ - if (addr != file->pos || OP_WRITE != file->op) { + if (addr != file->pos || OP_WRITE != file->op) if (HDlseek(file->fd, (HDoff_t)addr, SEEK_SET) < 0) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") - } #endif /* H5_HAVE_PREADWRITE */ /* Write the data, being careful of interrupted system calls and partial * results */ while (size > 0) { - h5_posix_io_t bytes_in = 0; /* # of bytes to write */ h5_posix_io_ret_t bytes_wrote = -1; /* # of bytes written */ @@ -898,10 +893,10 @@ done: } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_sec2_write() */ +} /* end H5FD__sec2_write() */ /*------------------------------------------------------------------------- - * Function: H5FD_sec2_truncate + * Function: H5FD__sec2_truncate * * Purpose: Makes sure that the true file size is the same (or larger) * than the end-of-address. @@ -914,12 +909,12 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_sec2_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_UNUSED closing) +H5FD__sec2_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_UNUSED closing) { H5FD_sec2_t *file = (H5FD_sec2_t *)_file; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC HDassert(file); @@ -966,10 +961,10 @@ H5FD_sec2_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_sec2_truncate() */ +} /* end H5FD__sec2_truncate() */ /*------------------------------------------------------------------------- - * Function: H5FD_sec2_lock + * Function: H5FD__sec2_lock * * Purpose: To place an advisory lock on a file. * The lock type to apply depends on the parameter "rw": @@ -983,13 +978,13 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_sec2_lock(H5FD_t *_file, hbool_t rw) +H5FD__sec2_lock(H5FD_t *_file, hbool_t rw) { H5FD_sec2_t *file = (H5FD_sec2_t *)_file; /* VFD file struct */ int lock_flags; /* file locking flags */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC HDassert(file); @@ -1010,10 +1005,10 @@ H5FD_sec2_lock(H5FD_t *_file, hbool_t rw) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_sec2_lock() */ +} /* end H5FD__sec2_lock() */ /*------------------------------------------------------------------------- - * Function: H5FD_sec2_unlock + * Function: H5FD__sec2_unlock * * Purpose: To remove the existing lock on the file * @@ -1024,12 +1019,12 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_sec2_unlock(H5FD_t *_file) +H5FD__sec2_unlock(H5FD_t *_file) { H5FD_sec2_t *file = (H5FD_sec2_t *)_file; /* VFD file struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC HDassert(file); @@ -1046,4 +1041,4 @@ H5FD_sec2_unlock(H5FD_t *_file) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_sec2_unlock() */ +} /* end H5FD__sec2_unlock() */ diff --git a/src/H5FDspace.c b/src/H5FDspace.c index 5692b24..339c413 100644 --- a/src/H5FDspace.c +++ b/src/H5FDspace.c @@ -15,7 +15,7 @@ * * Created: H5FDspace.c * Jan 3 2008 - * Quincey Koziol + * Quincey Koziol * * Purpose: Space allocation routines for the file driver code. * @@ -74,7 +74,7 @@ H5FL_DEFINE(H5FD_free_t); /*------------------------------------------------------------------------- - * Function: H5FD_extend + * Function: H5FD__extend * * Purpose: Extend the EOA space of a file. * @@ -89,12 +89,12 @@ H5FL_DEFINE(H5FD_free_t); *------------------------------------------------------------------------- */ static haddr_t -H5FD_extend(H5FD_t *file, H5FD_mem_t type, hsize_t size) +H5FD__extend(H5FD_t *file, H5FD_mem_t type, hsize_t size) { haddr_t eoa; /* Address of end-of-allocated space */ haddr_t ret_value = HADDR_UNDEF; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* check args */ HDassert(file); @@ -119,7 +119,7 @@ H5FD_extend(H5FD_t *file, H5FD_mem_t type, hsize_t size) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_extend() */ +} /* end H5FD__extend() */ /*------------------------------------------------------------------------- * Function: H5FD__alloc_real @@ -193,7 +193,7 @@ H5FD__alloc_real(H5FD_t *file, H5FD_mem_t type, hsize_t size, haddr_t *frag_addr HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, HADDR_UNDEF, "driver allocation request failed") } /* end if */ else { - ret_value = H5FD_extend(file, type, size + extra); + ret_value = H5FD__extend(file, type, size + extra); if (!H5F_addr_defined(ret_value)) HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, HADDR_UNDEF, "driver eoa update request failed") } /* end else */ @@ -425,7 +425,7 @@ H5FD_try_extend(H5FD_t *file, H5FD_mem_t type, H5F_t *f, haddr_t blk_end, hsize_ /* Check if the block is exactly at the end of the file */ if (H5F_addr_eq(blk_end, eoa)) { /* Extend the object by extending the underlying file */ - if (HADDR_UNDEF == H5FD_extend(file, type, extra_requested)) + if (HADDR_UNDEF == H5FD__extend(file, type, extra_requested)) HGOTO_ERROR(H5E_VFL, H5E_CANTEXTEND, FAIL, "driver extend request failed") /* Mark EOA info dirty in cache, so change will get encoded */ diff --git a/src/H5FDsplitter.c b/src/H5FDsplitter.c index 790b953..a839441 100644 --- a/src/H5FDsplitter.c +++ b/src/H5FDsplitter.c @@ -27,8 +27,6 @@ #include "H5FLprivate.h" /* Free Lists */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ -#include "H5FDsec2.h" /* Generic Functions */ -#include "H5FDstdio.h" /* Generic Functions */ #include "H5Pprivate.h" /* Property lists */ /* The driver identification number, initialized at runtime */ @@ -82,9 +80,8 @@ typedef struct H5FD_splitter_t { #define H5FD_SPLITTER_WO_ERROR(file, funcname, errmajor, errminor, ret, mesg) \ { \ H5FD__splitter_log_error((file), (funcname), (mesg)); \ - if (FALSE == (file)->fa.ignore_wo_errs) { \ + if (FALSE == (file)->fa.ignore_wo_errs) \ HGOTO_ERROR((errmajor), (errminor), (ret), (mesg)) \ - } \ } #define H5FD_SPLITTER_DEBUG_OP_CALLS 0 /* debugging print toggle; 0 disables */ @@ -93,7 +90,7 @@ typedef struct H5FD_splitter_t { #define H5FD_SPLITTER_LOG_CALL(name) \ do { \ HDprintf("called %s()\n", (name)); \ - fflush(stdout); \ + HDfflush(stdout); \ } while (0) #else #define H5FD_SPLITTER_LOG_CALL(name) /* no-op */ @@ -103,69 +100,68 @@ typedef struct H5FD_splitter_t { /* Print error messages from W/O channel to log file */ static herr_t H5FD__splitter_log_error(const H5FD_splitter_t *file, const char *atfunc, const char *msg); - -static int H5FD__copy_plist(hid_t fapl_id, hid_t *id_out_ptr); +static int H5FD__copy_plist(hid_t fapl_id, hid_t *id_out_ptr); /* Prototypes */ -static herr_t H5FD_splitter_term(void); -static hsize_t H5FD_splitter_sb_size(H5FD_t *_file); -static herr_t H5FD_splitter_sb_encode(H5FD_t *_file, char *name /*out*/, unsigned char *buf /*out*/); -static herr_t H5FD_splitter_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf); -static void * H5FD_splitter_fapl_get(H5FD_t *_file); -static void * H5FD_splitter_fapl_copy(const void *_old_fa); -static herr_t H5FD_splitter_fapl_free(void *_fapl); -static H5FD_t *H5FD_splitter_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); -static herr_t H5FD_splitter_close(H5FD_t *_file); -static int H5FD_splitter_cmp(const H5FD_t *_f1, const H5FD_t *_f2); -static herr_t H5FD_splitter_query(const H5FD_t *_file, unsigned long *flags /* out */); -static herr_t H5FD_splitter_get_type_map(const H5FD_t *_file, H5FD_mem_t *type_map); -static haddr_t H5FD_splitter_alloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size); -static herr_t H5FD_splitter_free(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size); -static haddr_t H5FD_splitter_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type); -static herr_t H5FD_splitter_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr); -static haddr_t H5FD_splitter_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type); -static herr_t H5FD_splitter_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void **file_handle); -static herr_t H5FD_splitter_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, - void *buf); -static herr_t H5FD_splitter_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, - const void *buf); -static herr_t H5FD_splitter_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); -static herr_t H5FD_splitter_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); -static herr_t H5FD_splitter_lock(H5FD_t *_file, hbool_t rw); -static herr_t H5FD_splitter_unlock(H5FD_t *_file); +static herr_t H5FD__splitter_term(void); +static hsize_t H5FD__splitter_sb_size(H5FD_t *_file); +static herr_t H5FD__splitter_sb_encode(H5FD_t *_file, char *name /*out*/, unsigned char *buf /*out*/); +static herr_t H5FD__splitter_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf); +static void * H5FD__splitter_fapl_get(H5FD_t *_file); +static void * H5FD__splitter_fapl_copy(const void *_old_fa); +static herr_t H5FD__splitter_fapl_free(void *_fapl); +static H5FD_t *H5FD__splitter_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); +static herr_t H5FD__splitter_close(H5FD_t *_file); +static int H5FD__splitter_cmp(const H5FD_t *_f1, const H5FD_t *_f2); +static herr_t H5FD__splitter_query(const H5FD_t *_file, unsigned long *flags /* out */); +static herr_t H5FD__splitter_get_type_map(const H5FD_t *_file, H5FD_mem_t *type_map); +static haddr_t H5FD__splitter_alloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size); +static herr_t H5FD__splitter_free(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size); +static haddr_t H5FD__splitter_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type); +static herr_t H5FD__splitter_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr); +static haddr_t H5FD__splitter_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type); +static herr_t H5FD__splitter_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void **file_handle); +static herr_t H5FD__splitter_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, + void *buf); +static herr_t H5FD__splitter_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, + const void *buf); +static herr_t H5FD__splitter_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); +static herr_t H5FD__splitter_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); +static herr_t H5FD__splitter_lock(H5FD_t *_file, hbool_t rw); +static herr_t H5FD__splitter_unlock(H5FD_t *_file); static const H5FD_class_t H5FD_splitter_g = { "splitter", /* name */ MAXADDR, /* maxaddr */ H5F_CLOSE_WEAK, /* fc_degree */ - H5FD_splitter_term, /* terminate */ - H5FD_splitter_sb_size, /* sb_size */ - H5FD_splitter_sb_encode, /* sb_encode */ - H5FD_splitter_sb_decode, /* sb_decode */ + H5FD__splitter_term, /* terminate */ + H5FD__splitter_sb_size, /* sb_size */ + H5FD__splitter_sb_encode, /* sb_encode */ + H5FD__splitter_sb_decode, /* sb_decode */ sizeof(H5FD_splitter_fapl_t), /* fapl_size */ - H5FD_splitter_fapl_get, /* fapl_get */ - H5FD_splitter_fapl_copy, /* fapl_copy */ - H5FD_splitter_fapl_free, /* fapl_free */ + H5FD__splitter_fapl_get, /* fapl_get */ + H5FD__splitter_fapl_copy, /* fapl_copy */ + H5FD__splitter_fapl_free, /* fapl_free */ 0, /* dxpl_size */ NULL, /* dxpl_copy */ NULL, /* dxpl_free */ - H5FD_splitter_open, /* open */ - H5FD_splitter_close, /* close */ - H5FD_splitter_cmp, /* cmp */ - H5FD_splitter_query, /* query */ - H5FD_splitter_get_type_map, /* get_type_map */ - H5FD_splitter_alloc, /* alloc */ - H5FD_splitter_free, /* free */ - H5FD_splitter_get_eoa, /* get_eoa */ - H5FD_splitter_set_eoa, /* set_eoa */ - H5FD_splitter_get_eof, /* get_eof */ - H5FD_splitter_get_handle, /* get_handle */ - H5FD_splitter_read, /* read */ - H5FD_splitter_write, /* write */ - H5FD_splitter_flush, /* flush */ - H5FD_splitter_truncate, /* truncate */ - H5FD_splitter_lock, /* lock */ - H5FD_splitter_unlock, /* unlock */ + H5FD__splitter_open, /* open */ + H5FD__splitter_close, /* close */ + H5FD__splitter_cmp, /* cmp */ + H5FD__splitter_query, /* query */ + H5FD__splitter_get_type_map, /* get_type_map */ + H5FD__splitter_alloc, /* alloc */ + H5FD__splitter_free, /* free */ + H5FD__splitter_get_eoa, /* get_eoa */ + H5FD__splitter_set_eoa, /* set_eoa */ + H5FD__splitter_get_eof, /* get_eof */ + H5FD__splitter_get_handle, /* get_handle */ + H5FD__splitter_read, /* read */ + H5FD__splitter_write, /* write */ + H5FD__splitter_flush, /* flush */ + H5FD__splitter_truncate, /* truncate */ + H5FD__splitter_lock, /* lock */ + H5FD__splitter_unlock, /* unlock */ NULL, /* dedup */ H5FD_FLMAP_DICHOTOMY /* fl_map */ }; @@ -173,6 +169,9 @@ static const H5FD_class_t H5FD_splitter_g = { /* Declare a free list to manage the H5FD_splitter_t struct */ H5FL_DEFINE_STATIC(H5FD_splitter_t); +/* Declare a free list to manage the H5FD_splitter_fapl_t struct */ +H5FL_DEFINE_STATIC(H5FD_splitter_fapl_t); + /*------------------------------------------------------------------------- * Function: H5FD__init_package * @@ -188,11 +187,10 @@ H5FD__init_package(void) FUNC_ENTER_STATIC - H5FD_SPLITTER_LOG_CALL("H5FD__init_package"); + H5FD_SPLITTER_LOG_CALL(FUNC); - if (H5FD_splitter_init() < 0) { + if (H5FD_splitter_init() < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize splitter VFD") - } done: FUNC_LEAVE_NOAPI(ret_value) @@ -213,13 +211,12 @@ H5FD_splitter_init(void) { hid_t ret_value = H5I_INVALID_HID; - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI(H5I_INVALID_HID) - H5FD_SPLITTER_LOG_CALL("H5FD_splitter_init"); + H5FD_SPLITTER_LOG_CALL(FUNC); - if (H5I_VFL != H5I_get_type(H5FD_SPLITTER_g)) { + if (H5I_VFL != H5I_get_type(H5FD_SPLITTER_g)) H5FD_SPLITTER_g = H5FDregister(&H5FD_splitter_g); - } ret_value = H5FD_SPLITTER_g; @@ -228,7 +225,7 @@ done: } /* end H5FD_splitter_init() */ /*--------------------------------------------------------------------------- - * Function: H5FD_splitter_term + * Function: H5FD__splitter_term * * Purpose: Shut down the splitter VFD. * @@ -236,17 +233,17 @@ done: *--------------------------------------------------------------------------- */ static herr_t -H5FD_splitter_term(void) +H5FD__splitter_term(void) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR - H5FD_SPLITTER_LOG_CALL("H5FD_splitter_term"); + H5FD_SPLITTER_LOG_CALL(FUNC); /* Reset VFL ID */ H5FD_SPLITTER_g = 0; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5FD_splitter_term() */ +} /* end H5FD__splitter_term() */ /*------------------------------------------------------------------------- * Function: H5FD__copy_plist @@ -263,25 +260,22 @@ H5FD__copy_plist(hid_t fapl_id, hid_t *id_out_ptr) int ret_value = 0; H5P_genplist_t *plist_ptr = NULL; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC - H5FD_SPLITTER_LOG_CALL("H5FD__copy_plist"); + H5FD_SPLITTER_LOG_CALL(FUNC); HDassert(id_out_ptr != NULL); - if (FALSE == H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) { + if (FALSE == H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, -1, "not a file access property list"); - } plist_ptr = (H5P_genplist_t *)H5I_object(fapl_id); - if (NULL == plist_ptr) { + if (NULL == plist_ptr) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, -1, "unable to get property list"); - } *id_out_ptr = H5P_copy_plist(plist_ptr, FALSE); - if (H5I_INVALID_HID == *id_out_ptr) { + if (H5I_INVALID_HID == *id_out_ptr) HGOTO_ERROR(H5E_VFL, H5E_BADTYPE, -1, "unable to copy file access property list"); - } done: FUNC_LEAVE_NOAPI(ret_value); @@ -299,27 +293,21 @@ done: herr_t H5Pset_fapl_splitter(hid_t fapl_id, H5FD_splitter_vfd_config_t *vfd_config) { - H5FD_splitter_fapl_t info; - H5P_genplist_t * plist_ptr = NULL; - herr_t ret_value = SUCCEED; - - H5Eclear2(H5E_DEFAULT); + H5FD_splitter_fapl_t *info = NULL; + H5P_genplist_t * plist_ptr = NULL; + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*#", fapl_id, vfd_config); - H5FD_SPLITTER_LOG_CALL("H5Pset_fapl_splitter"); + H5FD_SPLITTER_LOG_CALL(FUNC); - if (H5FD_SPLITTER_MAGIC != vfd_config->magic) { + if (H5FD_SPLITTER_MAGIC != vfd_config->magic) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid configuration (magic number mismatch)") - } - if (H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION != vfd_config->version) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invlaid config (version number mismatch)") - } - - if (NULL == (plist_ptr = (H5P_genplist_t *)H5I_object(fapl_id))) { + if (H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION != vfd_config->version) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid config (version number mismatch)") + if (NULL == (plist_ptr = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a valid property list") - } /* Make sure that the W/O channel supports write-only capability. * Some drivers (e.g. family or multi) do revision of the superblock @@ -334,47 +322,47 @@ H5Pset_fapl_splitter(hid_t fapl_id, H5FD_splitter_vfd_config_t *vfd_config) unsigned long wo_driver_flags = 0; wo_plist_ptr = (H5P_genplist_t *)H5I_object(vfd_config->wo_fapl_id); - if (NULL == wo_plist_ptr) { + if (NULL == wo_plist_ptr) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") - } - if (H5P_peek(wo_plist_ptr, H5F_ACS_FILE_DRV_NAME, &wo_driver_prop) < 0) { + if (H5P_peek(wo_plist_ptr, H5F_ACS_FILE_DRV_NAME, &wo_driver_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get driver ID & info") - } wo_driver = (H5FD_class_t *)H5I_object(wo_driver_prop.driver_id); - if (NULL == wo_driver) { + if (NULL == wo_driver) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "invalid driver ID in file access property list") - } - if (H5FD_driver_query(wo_driver, &wo_driver_flags) < 0) { + if (H5FD_driver_query(wo_driver, &wo_driver_flags) < 0) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "can't query VFD flags") - } - if (0 == (H5FD_FEAT_DEFAULT_VFD_COMPATIBLE & wo_driver_flags)) { + if (0 == (H5FD_FEAT_DEFAULT_VFD_COMPATIBLE & wo_driver_flags)) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "unsuitable W/O driver") - } } /* end if W/O VFD is non-default */ - info.ignore_wo_errs = vfd_config->ignore_wo_errs; - HDstrncpy(info.wo_path, vfd_config->wo_path, H5FD_SPLITTER_PATH_MAX); - HDstrncpy(info.log_file_path, vfd_config->log_file_path, H5FD_SPLITTER_PATH_MAX); - info.rw_fapl_id = H5P_FILE_ACCESS_DEFAULT; /* pre-set value */ - info.wo_fapl_id = H5P_FILE_ACCESS_DEFAULT; /* pre-set value */ + info = H5FL_CALLOC(H5FD_splitter_fapl_t); + if (NULL == info) + HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, "unable to allocate file access property list struct") + + info->ignore_wo_errs = vfd_config->ignore_wo_errs; + HDstrncpy(info->wo_path, vfd_config->wo_path, H5FD_SPLITTER_PATH_MAX); + HDstrncpy(info->log_file_path, vfd_config->log_file_path, H5FD_SPLITTER_PATH_MAX); + info->rw_fapl_id = H5P_FILE_ACCESS_DEFAULT; /* pre-set value */ + info->wo_fapl_id = H5P_FILE_ACCESS_DEFAULT; /* pre-set value */ /* Set non-default channel FAPL IDs in splitter configuration info */ if (H5P_DEFAULT != vfd_config->rw_fapl_id) { - if (FALSE == H5P_isa_class(vfd_config->rw_fapl_id, H5P_FILE_ACCESS)) { + if (FALSE == H5P_isa_class(vfd_config->rw_fapl_id, H5P_FILE_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list") - } - info.rw_fapl_id = vfd_config->rw_fapl_id; + info->rw_fapl_id = vfd_config->rw_fapl_id; } if (H5P_DEFAULT != vfd_config->wo_fapl_id) { - if (FALSE == H5P_isa_class(vfd_config->wo_fapl_id, H5P_FILE_ACCESS)) { + if (FALSE == H5P_isa_class(vfd_config->wo_fapl_id, H5P_FILE_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list") - } - info.wo_fapl_id = vfd_config->wo_fapl_id; + info->wo_fapl_id = vfd_config->wo_fapl_id; } - ret_value = H5P_set_driver(plist_ptr, H5FD_SPLITTER, &info); + ret_value = H5P_set_driver(plist_ptr, H5FD_SPLITTER, info); done: + if (info) + info = H5FL_FREE(H5FD_splitter_fapl_t, info); + FUNC_LEAVE_API(ret_value) } /* end H5Pset_fapl_splitter() */ @@ -382,73 +370,64 @@ done: * Function: H5Pget_fapl_splitter * * Purpose: Returns information about the splitter file access property - * list through the structure config_out. + * list through the structure config. * - * Will fail if config_out is received without pre-set valid + * Will fail if config is received without pre-set valid * magic and version information. * * Return: SUCCEED/FAIL *------------------------------------------------------------------------- */ herr_t -H5Pget_fapl_splitter(hid_t fapl_id, H5FD_splitter_vfd_config_t *config_out) +H5Pget_fapl_splitter(hid_t fapl_id, H5FD_splitter_vfd_config_t *config /*out*/) { const H5FD_splitter_fapl_t *fapl_ptr = NULL; H5P_genplist_t * plist_ptr = NULL; herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) - H5TRACE2("e", "i*#", fapl_id, config_out); + H5TRACE2("e", "ix", fapl_id, config); - H5FD_SPLITTER_LOG_CALL("H5Pget_fapl_splitter"); + H5FD_SPLITTER_LOG_CALL(FUNC); /* Check arguments */ - if (TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) { + if (TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") - } - if (config_out == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "config_out pointer is null") - } - if (H5FD_SPLITTER_MAGIC != config_out->magic) { + if (config == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "config pointer is null") + if (H5FD_SPLITTER_MAGIC != config->magic) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "info-out pointer invalid (magic number mismatch)") - } - if (H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION != config_out->version) { + if (H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION != config->version) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "info-out pointer invalid (version unsafe)") - } /* Pre-set out FAPL IDs with intent to replace these values */ - config_out->rw_fapl_id = H5I_INVALID_HID; - config_out->wo_fapl_id = H5I_INVALID_HID; + config->rw_fapl_id = H5I_INVALID_HID; + config->wo_fapl_id = H5I_INVALID_HID; /* Check and get the splitter fapl */ - if (NULL == (plist_ptr = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) { + if (NULL == (plist_ptr = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") - } - if (H5FD_SPLITTER != H5P_peek_driver(plist_ptr)) { + if (H5FD_SPLITTER != H5P_peek_driver(plist_ptr)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver") - } - if (NULL == (fapl_ptr = (const H5FD_splitter_fapl_t *)H5P_peek_driver_info(plist_ptr))) { + if (NULL == (fapl_ptr = (const H5FD_splitter_fapl_t *)H5P_peek_driver_info(plist_ptr))) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "unable to get specific-driver info") - } - HDstrncpy(config_out->wo_path, fapl_ptr->wo_path, H5FD_SPLITTER_PATH_MAX); - HDstrncpy(config_out->log_file_path, fapl_ptr->log_file_path, H5FD_SPLITTER_PATH_MAX); - config_out->ignore_wo_errs = fapl_ptr->ignore_wo_errs; + HDstrncpy(config->wo_path, fapl_ptr->wo_path, H5FD_SPLITTER_PATH_MAX); + HDstrncpy(config->log_file_path, fapl_ptr->log_file_path, H5FD_SPLITTER_PATH_MAX); + config->ignore_wo_errs = fapl_ptr->ignore_wo_errs; /* Copy R/W and W/O FAPLs */ - if (H5FD__copy_plist(fapl_ptr->rw_fapl_id, &(config_out->rw_fapl_id)) < 0) { + if (H5FD__copy_plist(fapl_ptr->rw_fapl_id, &(config->rw_fapl_id)) < 0) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "can't copy R/W FAPL"); - } - if (H5FD__copy_plist(fapl_ptr->wo_fapl_id, &(config_out->wo_fapl_id)) < 0) { + if (H5FD__copy_plist(fapl_ptr->wo_fapl_id, &(config->wo_fapl_id)) < 0) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "can't copy W/O FAPL"); - } done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_fapl_splitter() */ /*------------------------------------------------------------------------- - * Function: H5FD_splitter_flush + * Function: H5FD__splitter_flush * * Purpose: Flushes all data to disk for both channels. * @@ -456,30 +435,27 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_splitter_flush(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t closing) +H5FD__splitter_flush(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t closing) { H5FD_splitter_t *file = (H5FD_splitter_t *)_file; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC - H5FD_SPLITTER_LOG_CALL("H5FD_splitter_flush"); + H5FD_SPLITTER_LOG_CALL(FUNC); /* Public API for dxpl "context" */ - if (H5FDflush(file->rw_file, dxpl_id, closing) < 0) { + if (H5FDflush(file->rw_file, dxpl_id, closing) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTFLUSH, FAIL, "unable to flush R/W file") - } - if (H5FDflush(file->wo_file, dxpl_id, closing) < 0) { - H5FD_SPLITTER_WO_ERROR(file, "H5FD_splitter_flush", H5E_VFL, H5E_CANTFLUSH, FAIL, - "unable to flush W/O file") - } + if (H5FDflush(file->wo_file, dxpl_id, closing) < 0) + H5FD_SPLITTER_WO_ERROR(file, FUNC, H5E_VFL, H5E_CANTFLUSH, FAIL, "unable to flush W/O file") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_splitter_flush() */ +} /* end H5FD__splitter_flush() */ /*------------------------------------------------------------------------- - * Function: H5FD_splitter_read + * Function: H5FD__splitter_read * * Purpose: Reads SIZE bytes of data from the R/W channel, beginning at * address ADDR into buffer BUF according to data transfer @@ -493,39 +469,36 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_splitter_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, - size_t size, void *buf /*out*/) +H5FD__splitter_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, + size_t size, void *buf) { H5FD_splitter_t *file = (H5FD_splitter_t *)_file; herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC - H5FD_SPLITTER_LOG_CALL("H5FD_splitter_read"); + H5FD_SPLITTER_LOG_CALL(FUNC); HDassert(file && file->pub.cls); HDassert(buf); /* Check for overflow conditions */ - if (!H5F_addr_defined(addr)) { + if (!H5F_addr_defined(addr)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined, addr = %llu", (unsigned long long)addr) - } - if (REGION_OVERFLOW(addr, size)) { + if (REGION_OVERFLOW(addr, size)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu", (unsigned long long)addr) - } /* Only read from R/W channel */ /* Public API for dxpl "context" */ - if (H5FDread(file->rw_file, type, dxpl_id, addr, size, buf) < 0) { + if (H5FDread(file->rw_file, type, dxpl_id, addr, size, buf) < 0) HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "Reading from R/W channel failed") - } done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_splitter_read() */ +} /* end H5FD__splitter_read() */ /*------------------------------------------------------------------------- - * Function: H5FD_splitter_write + * Function: H5FD__splitter_write * * Purpose: Writes SIZE bytes of data to R/W and W/O channels, beginning * at address ADDR from buffer BUF according to data transfer @@ -535,36 +508,33 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_splitter_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, const void *buf) +H5FD__splitter_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, + const void *buf) { H5FD_splitter_t *file = (H5FD_splitter_t *)_file; H5P_genplist_t * plist_ptr = NULL; herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC - H5FD_SPLITTER_LOG_CALL("H5FD_splitter_write"); + H5FD_SPLITTER_LOG_CALL(FUNC); - if (NULL == (plist_ptr = (H5P_genplist_t *)H5I_object(dxpl_id))) { + if (NULL == (plist_ptr = (H5P_genplist_t *)H5I_object(dxpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") - } /* Write to each file */ /* Public API for dxpl "context" */ - if (H5FDwrite(file->rw_file, type, dxpl_id, addr, size, buf) < 0) { + if (H5FDwrite(file->rw_file, type, dxpl_id, addr, size, buf) < 0) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "R/W file write failed") - } - if (H5FDwrite(file->wo_file, type, dxpl_id, addr, size, buf) < 0) { - H5FD_SPLITTER_WO_ERROR(file, "H5FD_splitter_write", H5E_VFL, H5E_WRITEERROR, FAIL, - "unable to write W/O file") - } + if (H5FDwrite(file->wo_file, type, dxpl_id, addr, size, buf) < 0) + H5FD_SPLITTER_WO_ERROR(file, FUNC, H5E_VFL, H5E_WRITEERROR, FAIL, "unable to write W/O file") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_splitter_write() */ +} /* end H5FD__splitter_write() */ /*------------------------------------------------------------------------- - * Function: H5FD_splitter_fapl_get + * Function: H5FD__splitter_fapl_get * * Purpose: Returns a file access property list which indicates how the * specified file is being accessed. The return list could be @@ -576,22 +546,22 @@ done: *------------------------------------------------------------------------- */ static void * -H5FD_splitter_fapl_get(H5FD_t *_file) +H5FD__splitter_fapl_get(H5FD_t *_file) { H5FD_splitter_t *file = (H5FD_splitter_t *)_file; void * ret_value = NULL; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR - H5FD_SPLITTER_LOG_CALL("H5FD_splitter_fapl_get"); + H5FD_SPLITTER_LOG_CALL(FUNC); - ret_value = H5FD_splitter_fapl_copy(&(file->fa)); + ret_value = H5FD__splitter_fapl_copy(&(file->fa)); FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5FD__splitter_fapl_get() */ /*------------------------------------------------------------------------- - * Function: H5FD_splitter_fapl_copy + * Function: H5FD__splitter_fapl_copy * * Purpose: Copies the file access properties. * @@ -600,55 +570,44 @@ H5FD_splitter_fapl_get(H5FD_t *_file) *------------------------------------------------------------------------- */ static void * -H5FD_splitter_fapl_copy(const void *_old_fa) +H5FD__splitter_fapl_copy(const void *_old_fa) { const H5FD_splitter_fapl_t *old_fa_ptr = (const H5FD_splitter_fapl_t *)_old_fa; H5FD_splitter_fapl_t * new_fa_ptr = NULL; void * ret_value = NULL; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC - H5FD_SPLITTER_LOG_CALL("H5FD_splitter_fapl_copy"); + H5FD_SPLITTER_LOG_CALL(FUNC); HDassert(old_fa_ptr); - new_fa_ptr = (H5FD_splitter_fapl_t *)H5MM_calloc(sizeof(H5FD_splitter_fapl_t)); - if (NULL == new_fa_ptr) { + new_fa_ptr = H5FL_CALLOC(H5FD_splitter_fapl_t); + if (NULL == new_fa_ptr) HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, NULL, "unable to allocate log file FAPL") - } - if (HDmemcpy(new_fa_ptr, old_fa_ptr, sizeof(H5FD_splitter_fapl_t)) == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_CANTCOPY, NULL, "unable to shallow-copy info") - } - if (HDstrncpy(new_fa_ptr->wo_path, old_fa_ptr->wo_path, H5FD_SPLITTER_PATH_MAX) == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_CANTCOPY, NULL, "unable to copy write-only channel file path") - } - if (HDstrncpy(new_fa_ptr->log_file_path, old_fa_ptr->log_file_path, H5FD_SPLITTER_PATH_MAX) == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_CANTCOPY, NULL, "unable to copy log file path") - } + H5MM_memcpy(new_fa_ptr, old_fa_ptr, sizeof(H5FD_splitter_fapl_t)); + HDstrncpy(new_fa_ptr->wo_path, old_fa_ptr->wo_path, H5FD_SPLITTER_PATH_MAX); + HDstrncpy(new_fa_ptr->log_file_path, old_fa_ptr->log_file_path, H5FD_SPLITTER_PATH_MAX); /* Copy R/W and W/O FAPLs */ - if (H5FD__copy_plist(old_fa_ptr->rw_fapl_id, &(new_fa_ptr->rw_fapl_id)) < 0) { + if (H5FD__copy_plist(old_fa_ptr->rw_fapl_id, &(new_fa_ptr->rw_fapl_id)) < 0) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, NULL, "can't copy R/W FAPL"); - } - if (H5FD__copy_plist(old_fa_ptr->wo_fapl_id, &(new_fa_ptr->wo_fapl_id)) < 0) { + if (H5FD__copy_plist(old_fa_ptr->wo_fapl_id, &(new_fa_ptr->wo_fapl_id)) < 0) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, NULL, "can't copy W/O FAPL"); - } ret_value = (void *)new_fa_ptr; done: - if (NULL == ret_value) { - if (new_fa_ptr) { - H5MM_free(new_fa_ptr); - } - } + if (NULL == ret_value) + if (new_fa_ptr) + new_fa_ptr = H5FL_FREE(H5FD_splitter_fapl_t, new_fa_ptr); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_splitter_fapl_copy() */ +} /* end H5FD__splitter_fapl_copy() */ /*-------------------------------------------------------------------------- - * Function: H5FD_splitter_fapl_free + * Function: H5FD__splitter_fapl_free * * Purpose: Releases the file access lists * @@ -656,34 +615,32 @@ done: *-------------------------------------------------------------------------- */ static herr_t -H5FD_splitter_fapl_free(void *_fapl) +H5FD__splitter_fapl_free(void *_fapl) { H5FD_splitter_fapl_t *fapl = (H5FD_splitter_fapl_t *)_fapl; herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC - H5FD_SPLITTER_LOG_CALL("H5FD_splitter_fapl_free"); + H5FD_SPLITTER_LOG_CALL(FUNC); /* Check arguments */ HDassert(fapl); - if (H5I_dec_ref(fapl->rw_fapl_id) < 0) { + if (H5I_dec_ref(fapl->rw_fapl_id) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't close R/W FAPL ID") - } - if (H5I_dec_ref(fapl->wo_fapl_id) < 0) { + if (H5I_dec_ref(fapl->wo_fapl_id) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't close W/O FAPL ID") - } /* Free the property list */ - H5MM_free(fapl); + fapl = H5FL_FREE(H5FD_splitter_fapl_t, fapl); done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_splitter_fapl_free() */ +} /* end H5FD__splitter_fapl_free() */ /*------------------------------------------------------------------------- - * Function: H5FD_splitter_open + * Function: H5FD__splitter_open * * Purpose: Create and/or opens a file as an HDF5 file. * @@ -694,65 +651,52 @@ done: *------------------------------------------------------------------------- */ static H5FD_t * -H5FD_splitter_open(const char *name, unsigned flags, hid_t splitter_fapl_id, haddr_t maxaddr) +H5FD__splitter_open(const char *name, unsigned flags, hid_t splitter_fapl_id, haddr_t maxaddr) { H5FD_splitter_t * file_ptr = NULL; /* Splitter VFD info */ const H5FD_splitter_fapl_t *fapl_ptr = NULL; /* Driver-specific property list */ H5P_genplist_t * plist_ptr = NULL; H5FD_t * ret_value = NULL; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC - H5FD_SPLITTER_LOG_CALL("H5FD_splitter_open"); + H5FD_SPLITTER_LOG_CALL(FUNC); /* Check arguments */ - if (!name || !*name) { + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name") - } - if (0 == maxaddr || HADDR_UNDEF == maxaddr) { + if (0 == maxaddr || HADDR_UNDEF == maxaddr) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr") - } - if (ADDR_OVERFLOW(maxaddr)) { + if (ADDR_OVERFLOW(maxaddr)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "bogus maxaddr") - } - if ((H5P_FILE_ACCESS_DEFAULT == splitter_fapl_id) || (H5FD_SPLITTER != H5Pget_driver(splitter_fapl_id))) { + if ((H5P_FILE_ACCESS_DEFAULT == splitter_fapl_id) || (H5FD_SPLITTER != H5Pget_driver(splitter_fapl_id))) /* presupposes that H5P_FILE_ACCESS_DEFAULT is not a splitter */ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "driver is not splitter") - } file_ptr = (H5FD_splitter_t *)H5FL_CALLOC(H5FD_splitter_t); - if (NULL == file_ptr) { - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate file struct") - } + if (NULL == file_ptr) + HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, NULL, "unable to allocate file struct") file_ptr->fa.rw_fapl_id = H5I_INVALID_HID; file_ptr->fa.wo_fapl_id = H5I_INVALID_HID; /* Get the driver-specific file access properties */ plist_ptr = (H5P_genplist_t *)H5I_object(splitter_fapl_id); - if (NULL == plist_ptr) { + if (NULL == plist_ptr) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") - } fapl_ptr = (const H5FD_splitter_fapl_t *)H5P_peek_driver_info(plist_ptr); - if (NULL == fapl_ptr) { + if (NULL == fapl_ptr) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "unable to get VFL driver info") - } /* Copy simpler info */ - if (HDstrncpy(file_ptr->fa.wo_path, fapl_ptr->wo_path, H5FD_SPLITTER_PATH_MAX) == NULL) { - HGOTO_ERROR(H5E_VFL, H5E_CANTCOPY, NULL, "unable to copy write-only path") - } - if (HDstrncpy(file_ptr->fa.log_file_path, fapl_ptr->log_file_path, H5FD_SPLITTER_PATH_MAX) == NULL) { - HGOTO_ERROR(H5E_VFL, H5E_CANTCOPY, NULL, "unable to copy logfile path") - } + HDstrncpy(file_ptr->fa.wo_path, fapl_ptr->wo_path, H5FD_SPLITTER_PATH_MAX); + HDstrncpy(file_ptr->fa.log_file_path, fapl_ptr->log_file_path, H5FD_SPLITTER_PATH_MAX); file_ptr->fa.ignore_wo_errs = fapl_ptr->ignore_wo_errs; /* Copy R/W and W/O channel FAPLs. */ - if (H5FD__copy_plist(fapl_ptr->rw_fapl_id, &(file_ptr->fa.rw_fapl_id)) < 0) { + if (H5FD__copy_plist(fapl_ptr->rw_fapl_id, &(file_ptr->fa.rw_fapl_id)) < 0) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, NULL, "can't copy R/W FAPL"); - } - if (H5FD__copy_plist(fapl_ptr->wo_fapl_id, &(file_ptr->fa.wo_fapl_id)) < 0) { + if (H5FD__copy_plist(fapl_ptr->wo_fapl_id, &(file_ptr->fa.wo_fapl_id)) < 0) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, NULL, "can't copy W/O FAPL"); - } /* Prepare log file if necessary. * If application wants to ignore the errors from W/O channel and @@ -761,52 +705,43 @@ H5FD_splitter_open(const char *name, unsigned flags, hid_t splitter_fapl_id, had if (!file_ptr->logfp) { if (file_ptr->fa.log_file_path[0] != '\0') { file_ptr->logfp = HDfopen(file_ptr->fa.log_file_path, "w"); - if (file_ptr->logfp == NULL) { + if (file_ptr->logfp == NULL) HGOTO_ERROR(H5E_VFL, H5E_CANTOPENFILE, NULL, "unable to open log file") - } } /* end if logfile path given */ } /* end if logfile pointer/handle does not exist */ file_ptr->rw_file = H5FD_open(name, flags, fapl_ptr->rw_fapl_id, HADDR_UNDEF); - if (!file_ptr->rw_file) { + if (!file_ptr->rw_file) HGOTO_ERROR(H5E_VFL, H5E_CANTOPENFILE, NULL, "unable to open R/W file") - } file_ptr->wo_file = H5FD_open(fapl_ptr->wo_path, flags, fapl_ptr->wo_fapl_id, HADDR_UNDEF); - if (!file_ptr->wo_file) { - H5FD_SPLITTER_WO_ERROR(file_ptr, "H5FD_splitter_open", H5E_VFL, H5E_CANTOPENFILE, NULL, - "unable to open W/O file") - } + if (!file_ptr->wo_file) + H5FD_SPLITTER_WO_ERROR(file_ptr, FUNC, H5E_VFL, H5E_CANTOPENFILE, NULL, "unable to open W/O file") ret_value = (H5FD_t *)file_ptr; done: if (NULL == ret_value) { if (file_ptr) { - if (H5I_INVALID_HID != file_ptr->fa.rw_fapl_id) { + if (H5I_INVALID_HID != file_ptr->fa.rw_fapl_id) H5I_dec_ref(file_ptr->fa.rw_fapl_id); - } - if (H5I_INVALID_HID != file_ptr->fa.wo_fapl_id) { + if (H5I_INVALID_HID != file_ptr->fa.wo_fapl_id) H5I_dec_ref(file_ptr->fa.wo_fapl_id); - } - if (file_ptr->rw_file) { + if (file_ptr->rw_file) H5FD_close(file_ptr->rw_file); - } - if (file_ptr->wo_file) { + if (file_ptr->wo_file) H5FD_close(file_ptr->wo_file); - } - if (file_ptr->logfp) { + if (file_ptr->logfp) HDfclose(file_ptr->logfp); - } H5FL_FREE(H5FD_splitter_t, file_ptr); } } /* end if error */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_splitter_open() */ +} /* end H5FD__splitter_open() */ /*------------------------------------------------------------------------- - * Function: H5FD_splitter_close + * Function: H5FD__splitter_close * * Purpose: Closes files on both read-write and write-only channels. * @@ -815,36 +750,29 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_splitter_close(H5FD_t *_file) +H5FD__splitter_close(H5FD_t *_file) { H5FD_splitter_t *file = (H5FD_splitter_t *)_file; herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC - H5FD_SPLITTER_LOG_CALL("H5FD_splitter_close"); + H5FD_SPLITTER_LOG_CALL(FUNC); /* Sanity check */ HDassert(file); - if (H5I_dec_ref(file->fa.rw_fapl_id) < 0) { + if (H5I_dec_ref(file->fa.rw_fapl_id) < 0) HGOTO_ERROR(H5E_VFL, H5E_ARGS, FAIL, "can't close R/W FAPL") - } - if (H5I_dec_ref(file->fa.wo_fapl_id) < 0) { + if (H5I_dec_ref(file->fa.wo_fapl_id) < 0) HGOTO_ERROR(H5E_VFL, H5E_ARGS, FAIL, "can't close W/O FAPL") - } - if (file->rw_file) { - if (H5FD_close(file->rw_file) == FAIL) { + if (file->rw_file) + if (H5FD_close(file->rw_file) == FAIL) HGOTO_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, "unable to close R/W file") - } - } - if (file->wo_file) { - if (H5FD_close(file->wo_file) == FAIL) { - H5FD_SPLITTER_WO_ERROR(file, "H5FD_splitter_close", H5E_VFL, H5E_CANTCLOSEFILE, FAIL, - "unable to close W/O file") - } - } + if (file->wo_file) + if (H5FD_close(file->wo_file) == FAIL) + H5FD_SPLITTER_WO_ERROR(file, FUNC, H5E_VFL, H5E_CANTCLOSEFILE, FAIL, "unable to close W/O file") if (file->logfp) { HDfclose(file->logfp); @@ -857,10 +785,10 @@ H5FD_splitter_close(H5FD_t *_file) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_splitter_close() */ +} /* end H5FD__splitter_close() */ /*------------------------------------------------------------------------- - * Function: H5FD_splitter_get_eoa + * Function: H5FD__splitter_get_eoa * * Purpose: Returns the end-of-address marker for the file. The EOA * marker is the first address past the last byte allocated in @@ -872,29 +800,28 @@ done: *------------------------------------------------------------------------- */ static haddr_t -H5FD_splitter_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) +H5FD__splitter_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { const H5FD_splitter_t *file = (const H5FD_splitter_t *)_file; haddr_t ret_value = HADDR_UNDEF; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC - H5FD_SPLITTER_LOG_CALL("H5FD_splitter_get_eoa"); + H5FD_SPLITTER_LOG_CALL(FUNC); /* Sanity check */ HDassert(file); HDassert(file->rw_file); - if ((ret_value = H5FD_get_eoa(file->rw_file, type)) == HADDR_UNDEF) { + if ((ret_value = H5FD_get_eoa(file->rw_file, type)) == HADDR_UNDEF) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, HADDR_UNDEF, "unable to get eoa") - } done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_splitter_get_eoa */ +} /* end H5FD__splitter_get_eoa */ /*------------------------------------------------------------------------- - * Function: H5FD_splitter_set_eoa + * Function: H5FD__splitter_set_eoa * * Purpose: Set the end-of-address marker for the file. This function is * called shortly after an existing HDF5 file is opened in order @@ -904,35 +831,32 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_splitter_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) +H5FD__splitter_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) { H5FD_splitter_t *file = (H5FD_splitter_t *)_file; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC - H5FD_SPLITTER_LOG_CALL("H5FD_splitter_set_eoa";) + H5FD_SPLITTER_LOG_CALL(FUNC) /* Sanity check */ HDassert(file); HDassert(file->rw_file); HDassert(file->wo_file); - if (H5FD_set_eoa(file->rw_file, type, addr) < 0) { + if (H5FD_set_eoa(file->rw_file, type, addr) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTSET, FAIL, "H5FDset_eoa failed for R/W file") - } - if (H5FD_set_eoa(file->wo_file, type, addr) < 0) { - H5FD_SPLITTER_WO_ERROR(file, "H5FD_splitter_set_eoa", H5E_VFL, H5E_CANTSET, FAIL, - "unable to set EOA for W/O file") - } + if (H5FD_set_eoa(file->wo_file, type, addr) < 0) + H5FD_SPLITTER_WO_ERROR(file, FUNC, H5E_VFL, H5E_CANTSET, FAIL, "unable to set EOA for W/O file") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_splitter_set_eoa() */ +} /* end H5FD__splitter_set_eoa() */ /*------------------------------------------------------------------------- - * Function: H5FD_splitter_get_eof + * Function: H5FD__splitter_get_eof * * Purpose: Returns the end-of-address marker for the file. The EOA * marker is the first address past the last byte allocated in @@ -944,29 +868,28 @@ done: *------------------------------------------------------------------------- */ static haddr_t -H5FD_splitter_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) +H5FD__splitter_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { const H5FD_splitter_t *file = (const H5FD_splitter_t *)_file; haddr_t ret_value = HADDR_UNDEF; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC - H5FD_SPLITTER_LOG_CALL("H5FD_splitter_get_eof"); + H5FD_SPLITTER_LOG_CALL(FUNC); /* Sanity check */ HDassert(file); HDassert(file->rw_file); - if (HADDR_UNDEF == (ret_value = H5FD_get_eof(file->rw_file, type))) { + if (HADDR_UNDEF == (ret_value = H5FD_get_eof(file->rw_file, type))) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, HADDR_UNDEF, "unable to get eof") - } done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_splitter_get_eof */ +} /* end H5FD__splitter_get_eof */ /*------------------------------------------------------------------------- - * Function: H5FD_splitter_truncate + * Function: H5FD__splitter_truncate * * Purpose: Notify driver to truncate the file back to the allocated size. * @@ -974,34 +897,31 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_splitter_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing) +H5FD__splitter_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing) { H5FD_splitter_t *file = (H5FD_splitter_t *)_file; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC - H5FD_SPLITTER_LOG_CALL("H5FD_splitter_truncate"); + H5FD_SPLITTER_LOG_CALL(FUNC); HDassert(file); HDassert(file->rw_file); HDassert(file->wo_file); - if (H5FDtruncate(file->rw_file, dxpl_id, closing) < 0) { + if (H5FDtruncate(file->rw_file, dxpl_id, closing) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTUPDATE, FAIL, "unable to truncate R/W file") - } - if (H5FDtruncate(file->wo_file, dxpl_id, closing) < 0) { - H5FD_SPLITTER_WO_ERROR(file, "H5FD_splitter_truncate", H5E_VFL, H5E_CANTUPDATE, FAIL, - "unable to truncate W/O file") - } + if (H5FDtruncate(file->wo_file, dxpl_id, closing) < 0) + H5FD_SPLITTER_WO_ERROR(file, FUNC, H5E_VFL, H5E_CANTUPDATE, FAIL, "unable to truncate W/O file") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_splitter_truncate */ +} /* end H5FD__splitter_truncate */ /*------------------------------------------------------------------------- - * Function: H5FD_splitter_sb_size + * Function: H5FD__splitter_sb_size * * Purpose: Obtains the number of bytes required to store the driver file * access data in the HDF5 superblock. @@ -1015,28 +935,27 @@ done: *------------------------------------------------------------------------- */ static hsize_t -H5FD_splitter_sb_size(H5FD_t *_file) +H5FD__splitter_sb_size(H5FD_t *_file) { H5FD_splitter_t *file = (H5FD_splitter_t *)_file; hsize_t ret_value = 0; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR - H5FD_SPLITTER_LOG_CALL("H5FD_splitter_sb_size"); + H5FD_SPLITTER_LOG_CALL(FUNC); /* Sanity check */ HDassert(file); HDassert(file->rw_file); - if (file->rw_file) { + if (file->rw_file) ret_value = H5FD_sb_size(file->rw_file); - } FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_splitter_sb_size */ +} /* end H5FD__splitter_sb_size */ /*------------------------------------------------------------------------- - * Function: H5FD_splitter_sb_encode + * Function: H5FD__splitter_sb_encode * * Purpose: Encode driver-specific data into the output arguments. * @@ -1044,29 +963,28 @@ H5FD_splitter_sb_size(H5FD_t *_file) *------------------------------------------------------------------------- */ static herr_t -H5FD_splitter_sb_encode(H5FD_t *_file, char *name /*out*/, unsigned char *buf /*out*/) +H5FD__splitter_sb_encode(H5FD_t *_file, char *name /*out*/, unsigned char *buf /*out*/) { H5FD_splitter_t *file = (H5FD_splitter_t *)_file; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC - H5FD_SPLITTER_LOG_CALL("H5FD_splitter_sb_encode"); + H5FD_SPLITTER_LOG_CALL(FUNC); /* Sanity check */ HDassert(file); HDassert(file->rw_file); - if (file->rw_file && H5FD_sb_encode(file->rw_file, name, buf) < 0) { + if (file->rw_file && H5FD_sb_encode(file->rw_file, name, buf) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTENCODE, FAIL, "unable to encode the superblock in R/W file") - } done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_splitter_sb_encode */ +} /* end H5FD__splitter_sb_encode */ /*------------------------------------------------------------------------- - * Function: H5FD_splitter_sb_decode + * Function: H5FD__splitter_sb_decode * * Purpose: Decodes the driver information block. * @@ -1076,29 +994,28 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_splitter_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf) +H5FD__splitter_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf) { H5FD_splitter_t *file = (H5FD_splitter_t *)_file; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC - H5FD_SPLITTER_LOG_CALL("H5FD_splitter_sb_decode"); + H5FD_SPLITTER_LOG_CALL(FUNC); /* Sanity check */ HDassert(file); HDassert(file->rw_file); - if (H5FD_sb_load(file->rw_file, name, buf) < 0) { + if (H5FD_sb_load(file->rw_file, name, buf) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTDECODE, FAIL, "unable to decode the superblock in R/W file") - } done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_splitter_sb_decode */ +} /* end H5FD__splitter_sb_decode */ /*------------------------------------------------------------------------- - * Function: H5FD_splitter_cmp + * Function: H5FD__splitter_cmp * * Purpose: Compare the keys of two files. * @@ -1107,15 +1024,15 @@ done: *------------------------------------------------------------------------- */ static int -H5FD_splitter_cmp(const H5FD_t *_f1, const H5FD_t *_f2) +H5FD__splitter_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { const H5FD_splitter_t *f1 = (const H5FD_splitter_t *)_f1; const H5FD_splitter_t *f2 = (const H5FD_splitter_t *)_f2; herr_t ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR - H5FD_SPLITTER_LOG_CALL("H5FD_splitter_cmp"); + H5FD_SPLITTER_LOG_CALL(FUNC); HDassert(f1); HDassert(f2); @@ -1123,10 +1040,10 @@ H5FD_splitter_cmp(const H5FD_t *_f1, const H5FD_t *_f2) ret_value = H5FD_cmp(f1->rw_file, f2->rw_file); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_splitter_cmp */ +} /* end H5FD__splitter_cmp */ /*-------------------------------------------------------------------------- - * Function: H5FD_splitter_get_handle + * Function: H5FD__splitter_get_handle * * Purpose: Returns a pointer to the file handle of low-level virtual * file driver. @@ -1135,14 +1052,14 @@ H5FD_splitter_cmp(const H5FD_t *_f1, const H5FD_t *_f2) *-------------------------------------------------------------------------- */ static herr_t -H5FD_splitter_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void **file_handle) +H5FD__splitter_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void **file_handle) { H5FD_splitter_t *file = (H5FD_splitter_t *)_file; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC - H5FD_SPLITTER_LOG_CALL("H5FD_splitter_get_handle"); + H5FD_SPLITTER_LOG_CALL(FUNC); /* Check arguments */ HDassert(file); @@ -1150,16 +1067,15 @@ H5FD_splitter_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void **file_h HDassert(file_handle); /* Only do for R/W channel */ - if (H5FD_get_vfd_handle(file->rw_file, file->fa.rw_fapl_id, file_handle) < 0) { + if (H5FD_get_vfd_handle(file->rw_file, file->fa.rw_fapl_id, file_handle) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "unable to get handle of R/W file") - } done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_splitter_get_handle */ +} /* end H5FD__splitter_get_handle */ /*-------------------------------------------------------------------------- - * Function: H5FD_splitter_lock + * Function: H5FD__splitter_lock * * Purpose: Sets a file lock. * @@ -1167,35 +1083,32 @@ done: *-------------------------------------------------------------------------- */ static herr_t -H5FD_splitter_lock(H5FD_t *_file, hbool_t rw) +H5FD__splitter_lock(H5FD_t *_file, hbool_t rw) { H5FD_splitter_t *file = (H5FD_splitter_t *)_file; /* VFD file struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC - H5FD_SPLITTER_LOG_CALL("H5FD_splitter_lock"); + H5FD_SPLITTER_LOG_CALL(FUNC); HDassert(file); HDassert(file->rw_file); /* Place the lock on each file */ - if (H5FD_lock(file->rw_file, rw) < 0) { - HGOTO_ERROR(H5E_VFL, H5E_CANTLOCK, FAIL, "unable to lock R/W file") - } - if (file->wo_file != NULL) { - if (H5FD_lock(file->wo_file, rw) < 0) { - H5FD_SPLITTER_WO_ERROR(file, "H5FD_splitter_lock", H5E_VFL, H5E_CANTLOCK, FAIL, - "unable to lock W/O file") - } - } + if (H5FD_lock(file->rw_file, rw) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTLOCKFILE, FAIL, "unable to lock R/W file") + + if (file->wo_file != NULL) + if (H5FD_lock(file->wo_file, rw) < 0) + H5FD_SPLITTER_WO_ERROR(file, FUNC, H5E_VFL, H5E_CANTLOCKFILE, FAIL, "unable to lock W/O file") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_splitter_lock */ +} /* end H5FD__splitter_lock */ /*-------------------------------------------------------------------------- - * Function: H5FD_splitter_unlock + * Function: H5FD__splitter_unlock * * Purpose: Removes a file lock. * @@ -1203,35 +1116,33 @@ done: *-------------------------------------------------------------------------- */ static herr_t -H5FD_splitter_unlock(H5FD_t *_file) +H5FD__splitter_unlock(H5FD_t *_file) { H5FD_splitter_t *file = (H5FD_splitter_t *)_file; /* VFD file struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC - H5FD_SPLITTER_LOG_CALL("H5FD_splitter_unlock"); + H5FD_SPLITTER_LOG_CALL(FUNC); /* Check arguments */ HDassert(file); HDassert(file->rw_file); /* Remove the lock on each file */ - if (H5FD_unlock(file->rw_file) < 0) { - HGOTO_ERROR(H5E_VFL, H5E_CANTUNLOCK, FAIL, "unable to unlock R/W file") - } - if (file->wo_file != NULL) { - if (H5FD_unlock(file->wo_file) < 0) { - HGOTO_ERROR(H5E_VFL, H5E_CANTUNLOCK, FAIL, "unable to unlock W/O file") - } - } + if (H5FD_unlock(file->rw_file) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTUNLOCKFILE, FAIL, "unable to unlock R/W file") + + if (file->wo_file != NULL) + if (H5FD_unlock(file->wo_file) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTUNLOCKFILE, FAIL, "unable to unlock W/O file") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_splitter_unlock */ +} /* end H5FD__splitter_unlock */ /*------------------------------------------------------------------------- - * Function: H5FD_splitter_query + * Function: H5FD__splitter_query * * Purpose: Set the flags that this VFL driver is capable of supporting. * (listed in H5FDpublic.h) @@ -1240,38 +1151,36 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_splitter_query(const H5FD_t *_file, unsigned long *flags /* out */) +H5FD__splitter_query(const H5FD_t *_file, unsigned long *flags /* out */) { const H5FD_splitter_t *file = (const H5FD_splitter_t *)_file; herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC - H5FD_SPLITTER_LOG_CALL("H5FD_splitter_query"); + H5FD_SPLITTER_LOG_CALL(FUNC); if (file) { HDassert(file); HDassert(file->rw_file); - if (H5FDquery(file->rw_file, flags) < 0) { + if (H5FDquery(file->rw_file, flags) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTLOCK, FAIL, "unable to query R/W file"); - } } else { /* There is no file. Because this is a pure passthrough VFD, * it has no features of its own. */ - if (flags) { + if (flags) *flags = 0; - } } done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_splitter_query() */ +} /* end H5FD__splitter_query() */ /*------------------------------------------------------------------------- - * Function: H5FD_splitter_alloc + * Function: H5FD__splitter_alloc * * Purpose: Allocate file memory. * @@ -1279,35 +1188,32 @@ done: *------------------------------------------------------------------------- */ static haddr_t -H5FD_splitter_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size) +H5FD__splitter_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size) { H5FD_splitter_t *file = (H5FD_splitter_t *)_file; /* VFD file struct */ haddr_t ret_value = HADDR_UNDEF; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC - H5FD_SPLITTER_LOG_CALL("H5FD_splitter_alloc"); + H5FD_SPLITTER_LOG_CALL(FUNC); /* Check arguments */ HDassert(file); HDassert(file->rw_file); /* Allocate memory for each file, only return the return value for R/W file. */ - if ((ret_value = H5FDalloc(file->rw_file, type, dxpl_id, size)) == HADDR_UNDEF) { + if ((ret_value = H5FDalloc(file->rw_file, type, dxpl_id, size)) == HADDR_UNDEF) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "unable to allocate for R/W file") - } - if (H5FDalloc(file->wo_file, type, dxpl_id, size) == HADDR_UNDEF) { - H5FD_SPLITTER_WO_ERROR(file, "H5FD_splitter_alloc", H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, - "unable to alloc for W/O file") - } + if (H5FDalloc(file->wo_file, type, dxpl_id, size) == HADDR_UNDEF) + H5FD_SPLITTER_WO_ERROR(file, FUNC, H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "unable to alloc for W/O file") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_splitter_alloc() */ +} /* end H5FD__splitter_alloc() */ /*------------------------------------------------------------------------- - * Function: H5FD_splitter_get_type_map + * Function: H5FD__splitter_get_type_map * * Purpose: Retrieve the memory type mapping for this file * @@ -1315,30 +1221,29 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_splitter_get_type_map(const H5FD_t *_file, H5FD_mem_t *type_map) +H5FD__splitter_get_type_map(const H5FD_t *_file, H5FD_mem_t *type_map) { const H5FD_splitter_t *file = (const H5FD_splitter_t *)_file; herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC - H5FD_SPLITTER_LOG_CALL("H5FD_splitter_get_type_map"); + H5FD_SPLITTER_LOG_CALL(FUNC); /* Check arguments */ HDassert(file); HDassert(file->rw_file); /* Retrieve memory type mapping for R/W channel only */ - if (H5FD_get_fs_type_map(file->rw_file, type_map) < 0) { + if (H5FD_get_fs_type_map(file->rw_file, type_map) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "unable to allocate for R/W file") - } done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_splitter_get_type_map() */ +} /* end H5FD__splitter_get_type_map() */ /*------------------------------------------------------------------------- - * Function: H5FD_splitter_free + * Function: H5FD__splitter_free * * Purpose: Free the resources for the splitter VFD. * @@ -1346,31 +1251,28 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_splitter_free(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size) +H5FD__splitter_free(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size) { H5FD_splitter_t *file = (H5FD_splitter_t *)_file; /* VFD file struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC - H5FD_SPLITTER_LOG_CALL("H5FD_splitter_free"); + H5FD_SPLITTER_LOG_CALL(FUNC); /* Check arguments */ HDassert(file); HDassert(file->rw_file); - if (H5FDfree(file->rw_file, type, dxpl_id, addr, size) < 0) { + if (H5FDfree(file->rw_file, type, dxpl_id, addr, size) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "unable to free for R/W file") - } - if (H5FDfree(file->wo_file, type, dxpl_id, addr, size) < 0) { - H5FD_SPLITTER_WO_ERROR(file, "H5FD_splitter_free", H5E_VFL, H5E_CANTINIT, FAIL, - "unable to free for W/O file") - } + if (H5FDfree(file->wo_file, type, dxpl_id, addr, size) < 0) + H5FD_SPLITTER_WO_ERROR(file, FUNC, H5E_VFL, H5E_CANTINIT, FAIL, "unable to free for W/O file") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_splitter_free() */ +} /* end H5FD__splitter_free() */ /*------------------------------------------------------------------------- * Function: H5FD__splitter_log_error @@ -1383,13 +1285,11 @@ done: static herr_t H5FD__splitter_log_error(const H5FD_splitter_t *file, const char *atfunc, const char *msg) { - size_t size = 0; - char * s = NULL; herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC_NOERR - H5FD_SPLITTER_LOG_CALL("H5FD__splitter_log_error"); + H5FD_SPLITTER_LOG_CALL(FUNC); /* Check arguments */ HDassert(file); @@ -1397,18 +1297,18 @@ H5FD__splitter_log_error(const H5FD_splitter_t *file, const char *atfunc, const HDassert(msg && *msg); if (file->logfp != NULL) { - size = strlen(atfunc) + strlen(msg) + 3; /* ':', ' ', '\n' */ - s = (char *)malloc(sizeof(char) * (size + 1)); - if (NULL == s) { + size_t size; + char * s; + + size = HDstrlen(atfunc) + HDstrlen(msg) + 3; /* ':', ' ', '\n' */ + s = (char *)H5MM_malloc(sizeof(char) * (size + 1)); + if (NULL == s) ret_value = FAIL; - } - else if (size < (size_t)HDsnprintf(s, size + 1, "%s: %s\n", atfunc, msg)) { + else if (size < (size_t)HDsnprintf(s, size + 1, "%s: %s\n", atfunc, msg)) ret_value = FAIL; - } - else if (size != HDfwrite(s, 1, size, file->logfp)) { + else if (size != HDfwrite(s, 1, size, file->logfp)) ret_value = FAIL; - } - HDfree(s); + H5MM_free(s); } FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5FDstdio.c b/src/H5FDstdio.c index 230f5e1..12475e7 100644 --- a/src/H5FDstdio.c +++ b/src/H5FDstdio.c @@ -331,7 +331,7 @@ H5Pset_fapl_stdio(hid_t fapl_id) *------------------------------------------------------------------------- */ static H5FD_t * -H5FD_stdio_open(const char *name, unsigned flags, hid_t /*UNUSED*/ fapl_id, haddr_t maxaddr) +H5FD_stdio_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { FILE * f = NULL; unsigned write_access = 0; /* File opened with write access? */ @@ -347,21 +347,22 @@ H5FD_stdio_open(const char *name, unsigned flags, hid_t /*UNUSED*/ fapl_id, hadd assert(sizeof(file_offset_t) >= sizeof(size_t)); /* Quiet compiler */ - fapl_id = fapl_id; + (void)fapl_id; /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); /* Check arguments */ if (!name || !*name) - H5Epush_ret(func, H5E_ERR_CLS, H5E_ARGS, H5E_BADVALUE, "invalid file name", - NULL) if (0 == maxaddr || HADDR_UNDEF == maxaddr) - H5Epush_ret(func, H5E_ERR_CLS, H5E_ARGS, H5E_BADRANGE, "bogus maxaddr", - NULL) if (ADDR_OVERFLOW(maxaddr)) - H5Epush_ret(func, H5E_ERR_CLS, H5E_ARGS, H5E_OVERFLOW, "maxaddr too large", NULL) - - /* Tentatively open file in read-only mode, to check for existence */ - if (flags & H5F_ACC_RDWR) f = fopen(name, "rb+"); + H5Epush_ret(func, H5E_ERR_CLS, H5E_ARGS, H5E_BADVALUE, "invalid file name", NULL); + if (0 == maxaddr || HADDR_UNDEF == maxaddr) + H5Epush_ret(func, H5E_ERR_CLS, H5E_ARGS, H5E_BADRANGE, "bogus maxaddr", NULL); + if (ADDR_OVERFLOW(maxaddr)) + H5Epush_ret(func, H5E_ERR_CLS, H5E_ARGS, H5E_OVERFLOW, "maxaddr too large", NULL); + + /* Tentatively open file in read-only mode, to check for existence */ + if (flags & H5F_ACC_RDWR) + f = fopen(name, "rb+"); else f = fopen(name, "rb"); @@ -374,14 +375,14 @@ H5FD_stdio_open(const char *name, unsigned flags, hid_t /*UNUSED*/ fapl_id, hadd } else H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_CANTOPENFILE, - "file doesn't exist and CREAT wasn't specified", NULL) + "file doesn't exist and CREAT wasn't specified", NULL); } else if (flags & H5F_ACC_EXCL) { /* File exists, but EXCL is passed. Fail. */ assert(flags & H5F_ACC_CREAT); fclose(f); H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_FILEEXISTS, - "file exists but CREAT and EXCL were specified", NULL) + "file exists but CREAT and EXCL were specified", NULL); } else if (flags & H5F_ACC_RDWR) { if (flags & H5F_ACC_TRUNC) @@ -392,14 +393,13 @@ H5FD_stdio_open(const char *name, unsigned flags, hid_t /*UNUSED*/ fapl_id, hadd * as the tentative open will work */ if (!f) - H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_CANTOPENFILE, "fopen failed", NULL) + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_CANTOPENFILE, "fopen failed", NULL); - /* Build the return value */ - if (NULL == (file = (H5FD_stdio_t *)calloc((size_t)1, sizeof(H5FD_stdio_t)))) - { - fclose(f); - H5Epush_ret(func, H5E_ERR_CLS, H5E_RESOURCE, H5E_NOSPACE, "memory allocation failed", NULL) - } /* end if */ + /* Build the return value */ + if (NULL == (file = (H5FD_stdio_t *)calloc((size_t)1, sizeof(H5FD_stdio_t)))) { + fclose(f); + H5Epush_ret(func, H5E_ERR_CLS, H5E_RESOURCE, H5E_NOSPACE, "memory allocation failed", NULL); + } /* end if */ file->fp = f; file->op = H5FD_STDIO_OP_SEEK; file->pos = HADDR_UNDEF; @@ -463,7 +463,7 @@ H5FD_stdio_open(const char *name, unsigned flags, hid_t /*UNUSED*/ fapl_id, hadd if (fstat(file->fd, &sb) < 0) { free(file); fclose(f); - H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_BADFILE, "unable to fstat file", NULL) + H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_BADFILE, "unable to fstat file", NULL); } /* end if */ file->device = sb.st_dev; file->inode = sb.st_ino; @@ -497,9 +497,9 @@ H5FD_stdio_close(H5FD_t *_file) H5Eclear2(H5E_DEFAULT); if (fclose(file->fp) < 0) - H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_CLOSEERROR, "fclose failed", -1) + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_CLOSEERROR, "fclose failed", -1); - free(file); + free(file); return 0; } /* end H5FD_stdio_close() */ @@ -770,9 +770,9 @@ H5FD_stdio_get_handle(H5FD_t *_file, hid_t /*UNUSED*/ fapl, void **file_handle) *file_handle = &(file->fp); if (*file_handle == NULL) - H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_WRITEERROR, "get handle failed", -1) + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_WRITEERROR, "get handle failed", -1); - return 0; + return 0; } /* end H5FD_stdio_get_handle() */ /*------------------------------------------------------------------------- @@ -809,12 +809,13 @@ H5FD_stdio_read(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, hid_t /*UNUSED*/ dxpl /* Check for overflow */ if (HADDR_UNDEF == addr) - H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_OVERFLOW, "file address overflowed", - -1) if (REGION_OVERFLOW(addr, size)) - H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1) + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1); + if (REGION_OVERFLOW(addr, size)) + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1); - /* Check easy cases */ - if (0 == size) return 0; + /* Check easy cases */ + if (0 == size) + return 0; if ((haddr_t)addr >= file->eof) { memset(buf, 0, size); return 0; @@ -825,7 +826,7 @@ H5FD_stdio_read(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, hid_t /*UNUSED*/ dxpl if (file_fseek(file->fp, (file_offset_t)addr, SEEK_SET) < 0) { file->op = H5FD_STDIO_OP_UNKNOWN; file->pos = HADDR_UNDEF; - H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_SEEKERROR, "fseek failed", -1) + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_SEEKERROR, "fseek failed", -1); } file->pos = addr; } @@ -857,7 +858,7 @@ H5FD_stdio_read(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, hid_t /*UNUSED*/ dxpl if (0 == bytes_read && ferror(file->fp)) { /* error */ file->op = H5FD_STDIO_OP_UNKNOWN; file->pos = HADDR_UNDEF; - H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_READERROR, "fread failed", -1) + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_READERROR, "fread failed", -1); } /* end if */ if (0 == bytes_read && feof(file->fp)) { @@ -911,20 +912,19 @@ H5FD_stdio_write(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, hid_t /*UNUSED*/ dxp /* Check for overflow conditions */ if (HADDR_UNDEF == addr) - H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_OVERFLOW, "file address overflowed", - -1) if (REGION_OVERFLOW(addr, size)) - H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1) - - /* Seek to the correct file position. */ - if ((file->op != H5FD_STDIO_OP_WRITE && file->op != H5FD_STDIO_OP_SEEK) || file->pos != addr) - { - if (file_fseek(file->fp, (file_offset_t)addr, SEEK_SET) < 0) { - file->op = H5FD_STDIO_OP_UNKNOWN; - file->pos = HADDR_UNDEF; - H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_SEEKERROR, "fseek failed", -1) - } - file->pos = addr; + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1); + if (REGION_OVERFLOW(addr, size)) + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1); + + /* Seek to the correct file position. */ + if ((file->op != H5FD_STDIO_OP_WRITE && file->op != H5FD_STDIO_OP_SEEK) || file->pos != addr) { + if (file_fseek(file->fp, (file_offset_t)addr, SEEK_SET) < 0) { + file->op = H5FD_STDIO_OP_UNKNOWN; + file->pos = HADDR_UNDEF; + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_SEEKERROR, "fseek failed", -1); } + file->pos = addr; + } /* Write the buffer. On successful return, the file position will be * advanced by the number of bytes read. On failure, the file position is @@ -946,7 +946,7 @@ H5FD_stdio_write(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, hid_t /*UNUSED*/ dxp if (bytes_wrote != bytes_in || (0 == bytes_wrote && ferror(file->fp))) { /* error */ file->op = H5FD_STDIO_OP_UNKNOWN; file->pos = HADDR_UNDEF; - H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_WRITEERROR, "fwrite failed", -1) + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_WRITEERROR, "fwrite failed", -1); } /* end if */ assert(bytes_wrote > 0); @@ -1000,11 +1000,11 @@ H5FD_stdio_flush(H5FD_t *_file, hid_t /*UNUSED*/ dxpl_id, hbool_t closing) if (file->write_access) { if (!closing) { if (fflush(file->fp) < 0) - H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_WRITEERROR, "fflush failed", -1) + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_WRITEERROR, "fflush failed", -1); - /* Reset last file I/O information */ - file->pos = HADDR_UNDEF; - file->op = H5FD_STDIO_OP_UNKNOWN; + /* Reset last file I/O information */ + file->pos = HADDR_UNDEF; + file->op = H5FD_STDIO_OP_UNKNOWN; } /* end if */ } /* end if */ @@ -1069,13 +1069,13 @@ H5FD_stdio_truncate(H5FD_t *_file, hid_t /*UNUSED*/ dxpl_id, hbool_t /*UNUSED*/ if (INVALID_SET_FILE_POINTER == dwPtrLow) { dwError = GetLastError(); if (dwError != NO_ERROR) - H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_FILEOPEN, "unable to set file pointer", -1) + H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_FILEOPEN, "unable to set file pointer", -1); } bError = SetEndOfFile(file->hFile); if (0 == bError) H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_SEEKERROR, - "unable to truncate/extend file properly", -1) + "unable to truncate/extend file properly", -1); #else /* H5_HAVE_WIN32_API */ /* Reset seek offset to beginning of file, so that file isn't re-extended later */ rewind(file->fp); @@ -1083,11 +1083,11 @@ H5FD_stdio_truncate(H5FD_t *_file, hid_t /*UNUSED*/ dxpl_id, hbool_t /*UNUSED*/ /* Truncate file to proper length */ if (-1 == file_ftruncate(file->fd, (file_offset_t)file->eoa)) H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_SEEKERROR, - "unable to truncate/extend file properly", -1) + "unable to truncate/extend file properly", -1); #endif /* H5_HAVE_WIN32_API */ - /* Update the eof value */ - file->eof = file->eoa; + /* Update the eof value */ + file->eof = file->eoa; /* Reset last file I/O information */ file->pos = HADDR_UNDEF; @@ -1097,7 +1097,7 @@ H5FD_stdio_truncate(H5FD_t *_file, hid_t /*UNUSED*/ dxpl_id, hbool_t /*UNUSED*/ else { /* Double-check for problems */ if (file->eoa > file->eof) - H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_TRUNCATED, "eoa > eof!", -1) + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_TRUNCATED, "eoa > eof!", -1); } /* end else */ return 0; diff --git a/src/H5FL.c b/src/H5FL.c index 21d3655..95188d5 100644 --- a/src/H5FL.c +++ b/src/H5FL.c @@ -12,7 +12,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Thursday, March 23, 2000 * * Purpose: Manage priority queues of free-lists (of blocks of bytes). diff --git a/src/H5FS.c b/src/H5FS.c index 170d427..c85790c 100644 --- a/src/H5FS.c +++ b/src/H5FS.c @@ -12,7 +12,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Tuesday, May 2, 2006 * * Purpose: Free space tracking functions. @@ -793,9 +793,6 @@ H5FS__dirty(H5FS_t *fspace) herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE -#ifdef QAK - HDfprintf(stderr, "%s: Marking free space header as dirty\n", FUNC); -#endif /* QAK */ /* Sanity check */ HDassert(fspace); @@ -1209,9 +1206,6 @@ void H5FS__assert(const H5FS_t *fspace) { FUNC_ENTER_PACKAGE_NOERR -#ifdef QAK - HDfprintf(stderr, "%s: fspace->tot_sect_count = %Hu\n", "H5FS__assert", fspace->tot_sect_count); -#endif /* QAK */ /* Checks for section info, if it's available */ if (fspace->sinfo) { @@ -1227,9 +1221,6 @@ H5FS__assert(const H5FS_t *fspace) HDassert(fspace->tot_sect_count >= fspace->serial_sect_count); HDassert(fspace->tot_sect_count >= fspace->ghost_sect_count); HDassert(fspace->tot_sect_count == (fspace->serial_sect_count + fspace->ghost_sect_count)); -#ifdef QAK - HDassert(fspace->serial_sect_count > 0 || fspace->ghost_sect_count == 0); -#endif /* QAK */ FUNC_LEAVE_NOAPI_VOID } /* end H5FS__assert() */ diff --git a/src/H5FScache.c b/src/H5FScache.c index 244a3b6..8d94075 100644 --- a/src/H5FScache.c +++ b/src/H5FScache.c @@ -15,7 +15,7 @@ * * Created: H5FScache.c * May 2 2006 - * Quincey Koziol + * Quincey Koziol * * Purpose: Implement file free space metadata cache methods. * @@ -151,7 +151,6 @@ const H5AC_class_t H5AC_FSPACE_SINFO[1] = {{ * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * August 14, 2013 * *------------------------------------------------------------------------- @@ -221,7 +220,6 @@ H5FS__cache_hdr_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSE * Failure: NULL * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * August 18 2013 * *------------------------------------------------------------------------- @@ -252,7 +250,7 @@ H5FS__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len fspace->addr = udata->addr; /* Magic number */ - if (HDmemcmp(image, H5FS_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + if (HDmemcmp(image, H5FS_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, NULL, "wrong free space header signature") image += H5_SIZEOF_MAGIC; @@ -335,7 +333,6 @@ done: * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * August 14, 2013 * *------------------------------------------------------------------------- @@ -785,7 +782,6 @@ H5FS__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UN * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol - * koziol@lbl.gov * January 3, 2017 * *------------------------------------------------------------------------- @@ -848,7 +844,6 @@ done: * Failure: FAIL * * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu * May 2 2006 * *------------------------------------------------------------------------- @@ -995,7 +990,7 @@ H5FS__cache_sinfo_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED l H5_CHECKED_ASSIGN(old_sect_size, size_t, fspace->sect_size, hsize_t); /* Magic number */ - if (HDmemcmp(image, H5FS_SINFO_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + if (HDmemcmp(image, H5FS_SINFO_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, NULL, "wrong free space sections signature") image += H5_SIZEOF_MAGIC; @@ -1119,7 +1114,6 @@ done: * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * August 14, 2013 * *------------------------------------------------------------------------- diff --git a/src/H5FSdbg.c b/src/H5FSdbg.c index fcc1fa4..ecf0eb8 100644 --- a/src/H5FSdbg.c +++ b/src/H5FSdbg.c @@ -15,7 +15,7 @@ * * Created: H5FSdbg.c * May 9 2006 - * Quincey Koziol + * Quincey Koziol * * Purpose: Dump debugging information about a free space manager * diff --git a/src/H5FSint.c b/src/H5FSint.c index 829ba75..0ab975b 100644 --- a/src/H5FSint.c +++ b/src/H5FSint.c @@ -15,7 +15,7 @@ * * Created: H5FSint.c * Fall 2012 - * Dana Robinson + * Dana Robinson * * Purpose: Internal routines for free space managers. * diff --git a/src/H5FSsection.c b/src/H5FSsection.c index 0653cbc..14870b4 100644 --- a/src/H5FSsection.c +++ b/src/H5FSsection.c @@ -12,7 +12,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Monday, July 31, 2006 * * Purpose: Free space tracking functions. @@ -526,16 +526,6 @@ H5FS__sect_serialize_size(H5FS_t *fspace) /* Check arguments. */ HDassert(fspace); -#ifdef QAK - HDfprintf(stderr, "%s: Check 1.0 - fspace->sect_size = %Hu\n", "H5FS__sect_serialize_size", - fspace->sect_size); - HDfprintf(stderr, "%s: fspace->serial_sect_count = %Zu\n", "H5FS__sect_serialize_size", - fspace->serial_sect_count); - HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu\n", "H5FS__sect_serialize_size", - fspace->alloc_sect_size); - HDfprintf(stderr, "%s: fspace->sinfo->serial_size_count = %Zu\n", "H5FS__sect_serialize_size", - fspace->sinfo->serial_size_count); -#endif /* QAK */ /* Compute the size of the buffer required to serialize all the sections */ if (fspace->serial_sect_count > 0) { @@ -545,12 +535,6 @@ H5FS__sect_serialize_size(H5FS_t *fspace) sect_buf_size = fspace->sinfo->sect_prefix_size; /* Count for each differently sized serializable section */ -#ifdef QAK - HDfprintf(stderr, "%s: fspace->sinfo->serial_size_count = %Zu\n", "H5FS__sect_serialize_size", - fspace->sinfo->serial_size_count); - HDfprintf(stderr, "%s: fspace->serial_sect_count = %Hu\n", "H5FS__sect_serialize_size", - fspace->serial_sect_count); -#endif /* QAK */ sect_buf_size += fspace->sinfo->serial_size_count * H5VM_limit_enc_size((uint64_t)fspace->serial_sect_count); @@ -617,10 +601,6 @@ H5FS__sect_increase(H5FS_t *fspace, const H5FS_section_class_t *cls, unsigned fl fspace->serial_sect_count++; /* Increment amount of space required to serialize all sections */ -#ifdef QAK - HDfprintf(stderr, "%s: sinfo->serial_size = %Zu\n", FUNC, fspace->sinfo->serial_size); - HDfprintf(stderr, "%s: cls->serial_size = %Zu\n", FUNC, cls->serial_size); -#endif /* QAK */ fspace->sinfo->serial_size += cls->serial_size; /* Update the free space sections' serialized size */ @@ -676,10 +656,6 @@ H5FS__sect_decrease(H5FS_t *fspace, const H5FS_section_class_t *cls) fspace->serial_sect_count--; /* Decrement amount of space required to serialize all sections */ -#ifdef QAK - HDfprintf(stderr, "%s: fspace->serial_size = %Zu\n", FUNC, fspace->sinfo->serial_size); - HDfprintf(stderr, "%s: cls->serial_size = %Zu\n", FUNC, cls->serial_size); -#endif /* QAK */ fspace->sinfo->serial_size -= cls->serial_size; /* Update the free space sections' serialized size */ @@ -721,9 +697,6 @@ H5FS__size_node_decr(H5FS_sinfo_t *sinfo, unsigned bin, H5FS_node_t *fspace_node * the bin's skiplist is also a skiplist...) */ sinfo->bins[bin].tot_sect_count--; -#ifdef QAK - HDfprintf(stderr, "%s: sinfo->bins[%u].sect_count = %Zu\n", FUNC, bin, sinfo->bins[bin].sect_count); -#endif /* QAK */ /* Check for 'ghost' or 'serializable' section */ if (cls->flags & H5FS_CLS_GHOST_OBJ) { @@ -861,10 +834,6 @@ H5FS__sect_unlink_rest(H5FS_t *fspace, const H5FS_section_class_t *cls, H5FS_sec if (!(cls->flags & H5FS_CLS_SEPAR_OBJ)) { H5FS_section_info_t *tmp_sect_node; /* Temporary section node */ -#ifdef QAK - HDfprintf(stderr, "%s: removing object from merge list, sect->type = %u\n", FUNC, - (unsigned)sect->type); -#endif /* QAK */ tmp_sect_node = (H5FS_section_info_t *)H5SL_remove(fspace->sinfo->merge_list, §->addr); if (tmp_sect_node == NULL || tmp_sect_node != sect) HGOTO_ERROR(H5E_FSPACE, H5E_NOTFOUND, FAIL, "can't find section node on size list") @@ -874,10 +843,7 @@ H5FS__sect_unlink_rest(H5FS_t *fspace, const H5FS_section_class_t *cls, H5FS_sec if (H5FS__sect_decrease(fspace, cls) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't increase free space section size on disk") - /* Decrement amount of free space managed */ -#ifdef QAK - HDfprintf(stderr, "%s: fspace->tot_space = %Hu\n", FUNC, fspace->tot_space); -#endif /* QAK */ + /* Decrement amount of free space managed */ fspace->tot_space -= sect->size; done: @@ -988,9 +954,6 @@ H5FS__sect_link_size(H5FS_sinfo_t *sinfo, const H5FS_section_class_t *cls, H5FS_ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC -#ifdef QAK - HDfprintf(stderr, "%s: sect->size = %Hu, sect->addr = %a\n", FUNC, sect->size, sect->addr); -#endif /* QAK */ /* Check arguments. */ HDassert(sinfo); @@ -1005,10 +968,9 @@ H5FS__sect_link_size(H5FS_sinfo_t *sinfo, const H5FS_section_class_t *cls, H5FS_ if (NULL == (sinfo->bins[bin].bin_list = H5SL_create(H5SL_TYPE_HSIZE, NULL))) HGOTO_ERROR(H5E_FSPACE, H5E_CANTCREATE, FAIL, "can't create skip list for free space nodes") } /* end if */ - else { + else /* Check for node list of the correct size already */ fspace_node = (H5FS_node_t *)H5SL_search(sinfo->bins[bin].bin_list, §->size); - } /* end else */ /* Check if we need to create a new skip list for nodes of this size */ if (fspace_node == NULL) { @@ -1036,9 +998,6 @@ H5FS__sect_link_size(H5FS_sinfo_t *sinfo, const H5FS_section_class_t *cls, H5FS_ /* (Different from the # of items in the bin's skiplist, since each node on * the bin's skiplist is also a skiplist...) */ -#ifdef QAK - HDfprintf(stderr, "%s: sinfo->bins[%u].sect_count = %Zu\n", FUNC, bin, sinfo->bins[bin].sect_count); -#endif /* QAK */ sinfo->bins[bin].tot_sect_count++; if (cls->flags & H5FS_CLS_GHOST_OBJ) { sinfo->bins[bin].ghost_sect_count++; @@ -1101,10 +1060,6 @@ H5FS__sect_link_rest(H5FS_t *fspace, const H5FS_section_class_t *cls, H5FS_secti /* Add section to the address-ordered list of sections, if allowed */ if (!(cls->flags & H5FS_CLS_SEPAR_OBJ)) { -#ifdef QAK - HDfprintf(stderr, "%s: inserting object into merge list, sect->type = %u\n", FUNC, - (unsigned)sect->type); -#endif /* QAK */ if (fspace->sinfo->merge_list == NULL) if (NULL == (fspace->sinfo->merge_list = H5SL_create(H5SL_TYPE_HADDR, NULL))) HGOTO_ERROR(H5E_FSPACE, H5E_CANTCREATE, FAIL, @@ -1154,22 +1109,13 @@ H5FS__sect_link(H5FS_t *fspace, H5FS_section_info_t *sect, unsigned flags) cls = &fspace->sect_cls[sect->type]; /* Add section to size tracked data structures */ -#ifdef QAK - HDfprintf(stderr, "%s: Check 1.0 - fspace->tot_space = %Hu\n", FUNC, fspace->tot_space); -#endif /* QAK */ if (H5FS__sect_link_size(fspace->sinfo, cls, sect) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't add section to size tracking data structures") -#ifdef QAK - HDfprintf(stderr, "%s: Check 2.0 - fspace->tot_space = %Hu\n", FUNC, fspace->tot_space); -#endif /* QAK */ /* Update rest of free space manager data structures for section addition */ if (H5FS__sect_link_rest(fspace, cls, sect, flags) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't add section to non-size tracking data structures") -#ifdef QAK - HDfprintf(stderr, "%s: Check 3.0 - fspace->tot_space = %Hu\n", FUNC, fspace->tot_space); -#endif /* QAK */ done: FUNC_LEAVE_NOAPI(ret_value) @@ -1208,8 +1154,8 @@ H5FS__sect_merge(H5FS_t *fspace, H5FS_section_info_t **sect, void *op_data) /* Loop until no more merging */ if (fspace->sinfo->merge_list) { do { - H5SL_node_t * less_sect_node; /* Skip list node for section less than new section */ - H5SL_node_t * greater_sect_node; /* Skip list node for section greater than new section */ + H5SL_node_t *less_sect_node; /* Skip list node for section less than new section */ + H5SL_node_t *greater_sect_node = NULL; /* Skip list node for section greater than new section */ H5FS_section_info_t * tmp_sect; /* Temporary free space section */ H5FS_section_class_t *tmp_sect_cls; /* Temporary section's class */ hbool_t greater_sect_node_valid = FALSE; /* Indicate if 'greater than' section node is valid */ @@ -1315,10 +1261,6 @@ H5FS__sect_merge(H5FS_t *fspace, H5FS_section_info_t **sect, void *op_data) } while (modified); } /* end if */ HDassert(*sect); -#ifdef QAK - HDfprintf(stderr, "%s: Done merging, (*sect) = {%a, %Hu, %u, %s}\n", FUNC, (*sect)->addr, (*sect)->size, - (*sect)->type, ((*sect)->state == H5FS_SECT_LIVE ? "H5FS_SECT_LIVE" : "H5FS_SECT_SERIALIZED")); -#endif /* QAK */ /* Loop until no more shrinking */ do { @@ -1331,10 +1273,6 @@ H5FS__sect_merge(H5FS_t *fspace, H5FS_section_info_t **sect, void *op_data) if ((status = (*sect_cls->can_shrink)(*sect, op_data)) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTSHRINK, FAIL, "can't check for shrinking container") if (status > 0) { -#ifdef QAK - HDfprintf(stderr, "%s: Can shrink!\n", FUNC); -#endif /* QAK */ - /* Remove SECT from free-space manager */ /* (only possible to happen on second+ pass through loop) */ if (remove_sect) { @@ -1378,20 +1316,7 @@ H5FS__sect_merge(H5FS_t *fspace, H5FS_section_info_t **sect, void *op_data) if (remove_sect && (*sect != NULL)) *sect = NULL; -#ifdef QAK - HDfprintf(stderr, "%s: Done shrinking\n", FUNC); - if (*sect) - HDfprintf(stderr, "%s: (*sect) = {%a, %Hu, %u, %s}\n", FUNC, (*sect)->addr, (*sect)->size, - (*sect)->type, - ((*sect)->state == H5FS_SECT_LIVE ? "H5FS_SECT_LIVE" : "H5FS_SECT_SERIALIZED")); - else - HDfprintf(stderr, "%s: *sect = %p\n", FUNC, *sect); -#endif /* QAK */ - done: -#ifdef QAK - HDfprintf(stderr, "%s: Leaving, ret_value = %d\n", FUNC, ret_value); -#endif /* QAK */ FUNC_LEAVE_NOAPI(ret_value) } /* H5FS__sect_merge() */ @@ -1720,10 +1645,6 @@ H5FS__sect_find_node(H5FS_t *fspace, hsize_t request, H5FS_section_info_t **node /* Determine correct bin which holds items of at least the section's size */ bin = H5VM_log2_gen(request); HDassert(bin < fspace->sinfo->nbins); -#ifdef QAK - HDfprintf(stderr, "%s: fspace->sinfo->nbins = %u\n", FUNC, fspace->sinfo->nbins); - HDfprintf(stderr, "%s: bin = %u\n", FUNC, bin); -#endif /* QAK */ alignment = fspace->alignment; if (!((alignment > 1) && (request >= fspace->align_thres))) alignment = 0; /* no alignment */ @@ -1863,10 +1784,6 @@ H5FS_sect_find(H5F_t *f, H5FS_t *fspace, hsize_t request, H5FS_section_info_t ** FUNC_ENTER_NOAPI(FAIL) -#ifdef QAK - HDfprintf(stderr, "%s: request = %Hu\n", FUNC, request); -#endif /* QAK */ - /* Check arguments. */ HDassert(fspace); HDassert(fspace->nclasses); @@ -1874,11 +1791,6 @@ H5FS_sect_find(H5F_t *f, H5FS_t *fspace, hsize_t request, H5FS_section_info_t ** HDassert(node); /* Check for any sections on free space list */ -#ifdef QAK - HDfprintf(stderr, "%s: fspace->tot_sect_count = %Hu\n", FUNC, fspace->tot_sect_count); - HDfprintf(stderr, "%s: fspace->serial_sect_count = %Hu\n", FUNC, fspace->serial_sect_count); - HDfprintf(stderr, "%s: fspace->ghost_sect_count = %Hu\n", FUNC, fspace->ghost_sect_count); -#endif /* QAK */ if (fspace->tot_sect_count > 0) { /* Get a pointer to the section info */ if (H5FS__sinfo_lock(f, fspace, H5AC__NO_FLAGS_SET) < 0) @@ -1893,10 +1805,6 @@ H5FS_sect_find(H5F_t *f, H5FS_t *fspace, hsize_t request, H5FS_section_info_t ** if (ret_value > 0) { /* Note that we've modified the section info */ sinfo_modified = TRUE; -#ifdef QAK - HDfprintf(stderr, "%s: (*node)->size = %Hu, (*node)->addr = %a, (*node)->type = %u\n", FUNC, - (*node)->size, (*node)->addr, (*node)->type); -#endif /* QAK */ } /* end if */ } /* end if */ @@ -1912,7 +1820,7 @@ done: } /* H5FS_sect_find() */ /*------------------------------------------------------------------------- - * Function: H5FS_iterate_sect_cb + * Function: H5FS__iterate_sect_cb * * Purpose: Skip list iterator callback to iterate over free space sections * of a particular size @@ -1925,13 +1833,13 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FS_iterate_sect_cb(void *_item, void H5_ATTR_UNUSED *key, void *_udata) +H5FS__iterate_sect_cb(void *_item, void H5_ATTR_UNUSED *key, void *_udata) { H5FS_section_info_t *sect_info = (H5FS_section_info_t *)_item; /* Free space section to work on */ H5FS_iter_ud_t * udata = (H5FS_iter_ud_t *)_udata; /* Callback info */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check arguments. */ HDassert(sect_info); @@ -1944,10 +1852,10 @@ H5FS_iterate_sect_cb(void *_item, void H5_ATTR_UNUSED *key, void *_udata) done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5FS_iterate_sect_cb() */ +} /* H5FS__iterate_sect_cb() */ /*------------------------------------------------------------------------- - * Function: H5FS_iterate_node_cb + * Function: H5FS__iterate_node_cb * * Purpose: Skip list iterator callback to iterate over free space sections * in a bin @@ -1960,13 +1868,13 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FS_iterate_node_cb(void *_item, void H5_ATTR_UNUSED *key, void *_udata) +H5FS__iterate_node_cb(void *_item, void H5_ATTR_UNUSED *key, void *_udata) { H5FS_node_t * fspace_node = (H5FS_node_t *)_item; /* Free space size node to work on */ H5FS_iter_ud_t *udata = (H5FS_iter_ud_t *)_udata; /* Callback info */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check arguments. */ HDassert(fspace_node); @@ -1975,12 +1883,12 @@ H5FS_iterate_node_cb(void *_item, void H5_ATTR_UNUSED *key, void *_udata) /* Iterate through all the sections of this size */ HDassert(fspace_node->sect_list); - if (H5SL_iterate(fspace_node->sect_list, H5FS_iterate_sect_cb, udata) < 0) + if (H5SL_iterate(fspace_node->sect_list, H5FS__iterate_sect_cb, udata) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_BADITER, FAIL, "can't iterate over section nodes") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5FS_iterate_node_cb() */ +} /* H5FS__iterate_node_cb() */ /*------------------------------------------------------------------------- * Function: H5FS_sect_iterate @@ -2007,10 +1915,6 @@ H5FS_sect_iterate(H5F_t *f, H5FS_t *fspace, H5FS_operator_t op, void *op_data) HDassert(fspace); HDassert(op); -#ifdef QAK - HDfprintf(stderr, "%s: fspace->tot_sect_count = %Hu\n", FUNC, fspace->tot_sect_count); -#endif /* QAK */ - /* Set up user data for iterator */ udata.fspace = fspace; udata.op = op; @@ -2026,14 +1930,11 @@ H5FS_sect_iterate(H5F_t *f, H5FS_t *fspace, H5FS_operator_t op, void *op_data) sinfo_valid = TRUE; /* Iterate over all the bins */ -#ifdef QAK - HDfprintf(stderr, "%s: Iterate over section bins\n", FUNC); -#endif /* QAK */ for (bin = 0; bin < fspace->sinfo->nbins; bin++) { /* Check if there are any sections in this bin */ if (fspace->sinfo->bins[bin].bin_list) { /* Iterate over list of section size nodes for bin */ - if (H5SL_iterate(fspace->sinfo->bins[bin].bin_list, H5FS_iterate_node_cb, &udata) < 0) + if (H5SL_iterate(fspace->sinfo->bins[bin].bin_list, H5FS__iterate_node_cb, &udata) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_BADITER, FAIL, "can't iterate over section size nodes") } /* end if */ } /* end for */ @@ -2115,10 +2016,6 @@ H5FS_sect_change_class(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect, uint old_class = sect->type; old_cls = &fspace->sect_cls[sect->type]; new_cls = &fspace->sect_cls[new_class]; -#ifdef QAK - HDfprintf(stderr, "%s: old_cls->flags = %x\n", FUNC, old_cls->flags); - HDfprintf(stderr, "%s: new_cls->flags = %x\n", FUNC, new_cls->flags); -#endif /* QAK */ /* Check if the section's class change will affect the # of serializable or ghost sections */ if ((old_cls->flags & H5FS_CLS_GHOST_OBJ) != (new_cls->flags & H5FS_CLS_GHOST_OBJ)) { @@ -2131,9 +2028,6 @@ H5FS_sect_change_class(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect, uint to_ghost = FALSE; else to_ghost = TRUE; -#ifdef QAK - HDfprintf(stderr, "%s: to_ghost = %u\n", FUNC, to_ghost); -#endif /* QAK */ /* Sanity check */ HDassert(fspace->sinfo->bins); @@ -2197,16 +2091,9 @@ H5FS_sect_change_class(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect, uint to_mergable = TRUE; else to_mergable = FALSE; -#ifdef QAK - HDfprintf(stderr, "%s: to_mergable = %u\n", FUNC, to_mergable); -#endif /* QAK */ /* Add or remove section from merge list, as appropriate */ if (to_mergable) { -#ifdef QAK - HDfprintf(stderr, "%s: inserting object into merge list, sect->type = %u\n", FUNC, - (unsigned)sect->type); -#endif /* QAK */ if (fspace->sinfo->merge_list == NULL) if (NULL == (fspace->sinfo->merge_list = H5SL_create(H5SL_TYPE_HADDR, NULL))) HGOTO_ERROR(H5E_FSPACE, H5E_CANTCREATE, FAIL, @@ -2218,10 +2105,6 @@ H5FS_sect_change_class(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect, uint else { H5FS_section_info_t *tmp_sect_node; /* Temporary section node */ -#ifdef QAK - HDfprintf(stderr, "%s: removing object from merge list, sect->type = %u\n", FUNC, - (unsigned)sect->type); -#endif /* QAK */ tmp_sect_node = (H5FS_section_info_t *)H5SL_remove(fspace->sinfo->merge_list, §->addr); if (tmp_sect_node == NULL || tmp_sect_node != sect) HGOTO_ERROR(H5E_FSPACE, H5E_NOTFOUND, FAIL, "can't find section node on size list") @@ -2267,9 +2150,6 @@ H5FS__sect_assert(const H5FS_t *fspace) hsize_t separate_obj; /* The number of separate objects managed */ FUNC_ENTER_PACKAGE_NOERR -#ifdef QAK - HDfprintf(stderr, "%s: fspace->tot_sect_count = %Hu\n", "H5FS__sect_assert", fspace->tot_sect_count); -#endif /* QAK */ /* Initialize state */ separate_obj = 0; @@ -2326,10 +2206,6 @@ H5FS__sect_assert(const H5FS_t *fspace) /* Get section node & it's class */ sect = (H5FS_section_info_t *)H5SL_item(curr_sect_node); cls = &fspace->sect_cls[sect->type]; -#ifdef QAK - HDfprintf(stderr, "%s: sect->size = %Hu, sect->addr = %a, sect->type = %u\n", - "H5FS__sect_assert", sect->size, sect->addr, sect->type); -#endif /* QAK */ /* Sanity check section */ HDassert(H5F_addr_defined(sect->addr)); @@ -2407,7 +2283,7 @@ H5FS__sect_assert(const H5FS_t *fspace) * * Return: TRUE/FALSE/FAIL * - * Programmer: Vailin Choi + * Programmer: Vailin Choi * *------------------------------------------------------------------------- */ diff --git a/src/H5HFspace.c b/src/H5HFspace.c index 1994891..c198c8b 100644 --- a/src/H5HFspace.c +++ b/src/H5HFspace.c @@ -15,7 +15,7 @@ * * Created: H5HFspace.c * May 2 2006 - * Quincey Koziol + * Quincey Koziol * * Purpose: Space allocation routines for fractal heaps. * @@ -142,7 +142,6 @@ done: * Failure: negative * * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu * May 15 2006 * *------------------------------------------------------------------------- @@ -186,7 +185,6 @@ done: * Failure: negative * * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu * May 2 2006 * *------------------------------------------------------------------------- @@ -234,7 +232,6 @@ done: * Failure: negative * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Feb 24 2012 * *------------------------------------------------------------------------- @@ -279,7 +276,6 @@ done: * Failure: negative * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Feb 23 2012 * *------------------------------------------------------------------------- @@ -317,7 +313,6 @@ done: * Failure: negative * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Feb 24 2012 * *------------------------------------------------------------------------- @@ -370,7 +365,6 @@ done: * Failure: negative * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Feb 24 2012 * *------------------------------------------------------------------------- @@ -408,7 +402,6 @@ done: * Failure: negative * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * August 14 2007 * *------------------------------------------------------------------------- @@ -452,7 +445,6 @@ done: * Failure: negative * * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu * July 24 2006 * *------------------------------------------------------------------------- @@ -489,7 +481,6 @@ done: * Failure: negative * * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu * May 2 2006 * *------------------------------------------------------------------------- @@ -513,9 +504,6 @@ H5HF__space_close(H5HF_hdr_t *hdr) /* Retrieve the number of sections for this heap */ if (H5FS_sect_stats(hdr->fspace, NULL, &nsects) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTCOUNT, FAIL, "can't query free space section count") -#ifdef QAK - HDfprintf(stderr, "%s: nsects = %Hu\n", FUNC, nsects); -#endif /* QAK */ /* Close the free space for the heap */ if (H5FS_close(hdr->f, hdr->fspace) < 0) @@ -543,7 +531,6 @@ done: * Failure: negative * * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu * Aug 7 2006 * *------------------------------------------------------------------------- @@ -578,7 +565,6 @@ done: * Failure: negative * * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu * July 10 2006 * *------------------------------------------------------------------------- @@ -589,9 +575,6 @@ H5HF__space_sect_change_class(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, uint16 herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE -#ifdef QAK - HDfprintf(stderr, "%s: Called\n", FUNC); -#endif /* QAK */ /* * Check arguments. diff --git a/src/H5HFstat.c b/src/H5HFstat.c index cd06595..5e5d06a 100644 --- a/src/H5HFstat.c +++ b/src/H5HFstat.c @@ -11,7 +11,7 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* Programmer: Quincey Koziol +/* Programmer: Quincey Koziol * Monday, March 6, 2006 * * Purpose: Fractal heap metadata statistics functions. diff --git a/src/H5HFtest.c b/src/H5HFtest.c index df77926..66cf4c3 100644 --- a/src/H5HFtest.c +++ b/src/H5HFtest.c @@ -11,7 +11,7 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* Programmer: Quincey Koziol +/* Programmer: Quincey Koziol * Thursday, February 3, 2006 * * Purpose: Fractal heap testing functions. @@ -178,9 +178,9 @@ H5HF_cmp_cparam_test(const H5HF_create_t *cparam1, const H5HF_create_t *cparam2) /* Don't worry about comparing the filter names right now... */ /* (they are expanded during the encode/decode process, but aren't copied - * during the H5Z_append operation, generating false positive failures) + * during the H5Z_append operation, generating false positive failures -QAK) */ -#ifdef QAK +#if 0 /* Check filter name */ HDfprintf(stderr, "%s: Check 1.0\n", "H5HF_cmp_cparam_test"); HDfprintf(stderr, "%s: cparam1->pline.filter[%Zu].name = %s\n", "H5HF_cmp_cparam_test", u, @@ -195,7 +195,7 @@ H5HF_cmp_cparam_test(const H5HF_create_t *cparam1, const H5HF_create_t *cparam2) if ((ret_value = HDstrcmp(cparam1->pline.filter[u].name, cparam2->pline.filter[u].name))) HGOTO_DONE(ret_value) } /* end if */ -#endif /* QAK */ +#endif /* Check # of filter parameters */ if (cparam1->pline.filter[u].cd_nelmts < cparam2->pline.filter[u].cd_nelmts) diff --git a/src/H5HFtiny.c b/src/H5HFtiny.c index 44575d0..9c5708d 100644 --- a/src/H5HFtiny.c +++ b/src/H5HFtiny.c @@ -15,7 +15,7 @@ * * Created: H5HFtiny.c * Aug 14 2006 - * Quincey Koziol + * Quincey Koziol * * Purpose: Routines for "tiny" objects in fractal heap * @@ -80,7 +80,6 @@ static herr_t H5HF_tiny_op_real(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operato * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Aug 14 2006 * *------------------------------------------------------------------------- @@ -126,7 +125,6 @@ H5HF_tiny_init(H5HF_hdr_t *hdr) * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Aug 14 2006 * *------------------------------------------------------------------------- @@ -139,9 +137,6 @@ H5HF_tiny_insert(H5HF_hdr_t *hdr, size_t obj_size, const void *obj, void *_id) herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT -#ifdef QAK - HDfprintf(stderr, "%s: obj_size = %Zu\n", FUNC, obj_size); -#endif /* QAK */ /* * Check arguments. @@ -188,7 +183,6 @@ done: * Return: SUCCEED (Can't fail) * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Aug 14 2006 * *------------------------------------------------------------------------- @@ -230,7 +224,6 @@ H5HF_tiny_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, size_t *obj_len_p) * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Sep 11 2006 * *------------------------------------------------------------------------- @@ -281,7 +274,6 @@ done: * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Aug 8 2006 * *------------------------------------------------------------------------- @@ -316,7 +308,6 @@ done: * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Sept 11 2006 * *------------------------------------------------------------------------- @@ -351,7 +342,6 @@ done: * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Aug 14 2006 * *------------------------------------------------------------------------- diff --git a/src/H5HG.c b/src/H5HG.c index 23dbce2..c1c574c 100644 --- a/src/H5HG.c +++ b/src/H5HG.c @@ -12,7 +12,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Friday, March 27, 1998 * * Purpose: Operations on the global heap. The global heap is the set of diff --git a/src/H5HGcache.c b/src/H5HGcache.c index dd7d1cd..a4c55bb 100644 --- a/src/H5HGcache.c +++ b/src/H5HGcache.c @@ -15,7 +15,7 @@ * * Created: H5HGcache.c * Feb 5 2008 - * Quincey Koziol + * Quincey Koziol * * Purpose: Implement global heap metadata cache methods. * @@ -123,7 +123,7 @@ H5HG__hdr_deserialize(H5HG_heap_t *heap, const uint8_t *image, const H5F_t *f) HDassert(f); /* Magic number */ - if (HDmemcmp(image, H5HG_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + if (HDmemcmp(image, H5HG_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, FAIL, "bad global heap collection signature") image += H5_SIZEOF_MAGIC; diff --git a/src/H5HGdbg.c b/src/H5HGdbg.c index 8c1ae47..51a74ec 100644 --- a/src/H5HGdbg.c +++ b/src/H5HGdbg.c @@ -11,7 +11,7 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* Programmer: Quincey Koziol +/* Programmer: Quincey Koziol * Wednesday, July 9, 2003 * * Purpose: Global Heap object debugging functions. @@ -68,7 +68,6 @@ * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke - * matzke@llnl.gov * Mar 27, 1998 * *------------------------------------------------------------------------- diff --git a/src/H5HGquery.c b/src/H5HGquery.c index 2239031..c24a414 100644 --- a/src/H5HGquery.c +++ b/src/H5HGquery.c @@ -12,7 +12,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Wednesday, July 20, 2011 * * Purpose: Query routines for global heaps. diff --git a/src/H5HL.c b/src/H5HL.c index 43c6033..50d24c3 100644 --- a/src/H5HL.c +++ b/src/H5HL.c @@ -15,7 +15,7 @@ * * Created: H5HL.c * Jul 16 1997 - * Robb Matzke + * Robb Matzke * * Purpose: Heap functions for the local heaps used by symbol * tables to store names (among other things). @@ -392,7 +392,7 @@ BEGIN_FUNC(PRIV, ERR, void *, NULL, NULL, H5HL_offset_into(const H5HL_t *heap, s ret_value = heap->dblk_image + offset; CATCH - /* No special processing on errors */ +/* No special processing on errors */ END_FUNC(PRIV) /* end H5HL_offset_into() */ /*------------------------------------------------------------------------- @@ -930,7 +930,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_get_size(H5F_t *f, haddr_t add H5HL_cache_prfx_ud_t prfx_udata; /* User data for protecting local heap prefix */ H5HL_prfx_t * prfx = NULL; /* Local heap prefix */ - H5HL_t * heap; /* Heap data structure */ + H5HL_t * heap = NULL; /* Heap data structure */ /* check arguments */ HDassert(f); @@ -977,7 +977,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_heapsize(H5F_t *f, haddr_t add H5HL_cache_prfx_ud_t prfx_udata; /* User data for protecting local heap prefix */ H5HL_prfx_t * prfx = NULL; /* Local heap prefix */ - H5HL_t * heap; /* Heap data structure */ + H5HL_t * heap = NULL; /* Heap data structure */ /* check arguments */ HDassert(f); diff --git a/src/H5HLcache.c b/src/H5HLcache.c index fb5c7a0..989a4f5 100644 --- a/src/H5HLcache.c +++ b/src/H5HLcache.c @@ -15,7 +15,7 @@ * * Created: H5HLcache.c * Feb 5 2008 - * Quincey Koziol + * Quincey Koziol * * Purpose: Implement local heap metadata cache methods. * @@ -163,7 +163,7 @@ H5HL__hdr_deserialize(H5HL_t *heap, const uint8_t *image, H5HL_cache_prfx_ud_t * HDassert(udata); /* Check magic number */ - if (HDmemcmp(image, H5HL_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + if (HDmemcmp(image, H5HL_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, FAIL, "bad local heap signature") image += H5_SIZEOF_MAGIC; @@ -468,11 +468,11 @@ done: if (!ret_value) { if (prfx) { if (FAIL == H5HL__prfx_dest(prfx)) - HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, NULL, "unable to destroy local heap prefix"); + HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, NULL, "unable to destroy local heap prefix"); } /* end if */ else { if (heap && FAIL == H5HL__dest(heap)) - HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, NULL, "unable to destroy local heap"); + HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, NULL, "unable to destroy local heap"); } /* end else */ } /* end if */ @@ -747,7 +747,7 @@ done: /* Release the [possibly partially initialized] local heap on errors */ if (!ret_value && dblk) if (FAIL == H5HL__dblk_dest(dblk)) - HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, NULL, "unable to destroy local heap data block"); + HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, NULL, "unable to destroy local heap data block"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HL__cache_datablock_deserialize() */ diff --git a/src/H5HLdbg.c b/src/H5HLdbg.c index c3bfef7..b4aeaa2 100644 --- a/src/H5HLdbg.c +++ b/src/H5HLdbg.c @@ -11,7 +11,7 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* Programmer: Quincey Koziol +/* Programmer: Quincey Koziol * Wednesday, July 9, 2003 * * Purpose: Local Heap object debugging functions. diff --git a/src/H5HLdblk.c b/src/H5HLdblk.c index b40d4d6..f771de5 100644 --- a/src/H5HLdblk.c +++ b/src/H5HLdblk.c @@ -15,7 +15,7 @@ * * Created: H5HLdblk.c * Summer 2012 - * Dana Robinson + * Dana Robinson * * Purpose: Data block routines for local heaps. * diff --git a/src/H5HLint.c b/src/H5HLint.c index ace6a76..069bad8 100644 --- a/src/H5HLint.c +++ b/src/H5HLint.c @@ -15,7 +15,7 @@ * * Created: H5HLint.c * Oct 12 2008 - * Quincey Koziol + * Quincey Koziol * * Purpose: Local heap internal routines. * diff --git a/src/H5HLprfx.c b/src/H5HLprfx.c index 3a8bcc7..90f6c74 100644 --- a/src/H5HLprfx.c +++ b/src/H5HLprfx.c @@ -15,7 +15,7 @@ * * Created: H5HLprfx.c * Summer 2012 - * Dana Robinson + * Dana Robinson * * Purpose: Prefix routines for local heaps. * diff --git a/src/H5HP.c b/src/H5HP.c index d5bff56..d164223 100644 --- a/src/H5HP.c +++ b/src/H5HP.c @@ -45,10 +45,10 @@ struct H5HP_t { }; /* Static functions */ -static herr_t H5HP_swim_max(H5HP_t *heap, size_t loc); -static herr_t H5HP_swim_min(H5HP_t *heap, size_t loc); -static herr_t H5HP_sink_max(H5HP_t *heap, size_t loc); -static herr_t H5HP_sink_min(H5HP_t *heap, size_t loc); +static herr_t H5HP__swim_max(H5HP_t *heap, size_t loc); +static herr_t H5HP__swim_min(H5HP_t *heap, size_t loc); +static herr_t H5HP__sink_max(H5HP_t *heap, size_t loc); +static herr_t H5HP__sink_min(H5HP_t *heap, size_t loc); /* Declare a free list to manage the H5HP_t struct */ H5FL_DEFINE_STATIC(H5HP_t); @@ -58,11 +58,11 @@ H5FL_SEQ_DEFINE_STATIC(H5HP_ent_t); /*-------------------------------------------------------------------------- NAME - H5HP_swim_max + H5HP__swim_max PURPOSE Restore heap condition by moving an object upward USAGE - herr_t H5HP_swim_max(heap, loc) + herr_t H5HP__swim_max(heap, loc) H5HP_t *heap; IN/OUT: Pointer to heap to modify size_t loc; IN: Location to start from @@ -78,13 +78,13 @@ H5FL_SEQ_DEFINE_STATIC(H5HP_ent_t); REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5HP_swim_max(H5HP_t *heap, size_t loc) +H5HP__swim_max(H5HP_t *heap, size_t loc) { int val; /* Temporary copy value of object to move in heap */ H5HP_info_t *obj; /* Temporary pointer to object to move in heap */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Get copies of the information about the object to move in the heap */ val = heap->heap[loc].val; @@ -111,15 +111,15 @@ H5HP_swim_max(H5HP_t *heap, size_t loc) heap->heap[loc].obj->heap_loc = loc; FUNC_LEAVE_NOAPI(ret_value); -} /* end H5HP_swim_max() */ +} /* end H5HP__swim_max() */ /*-------------------------------------------------------------------------- NAME - H5HP_swim_min + H5HP__swim_min PURPOSE Restore heap condition by moving an object upward USAGE - herr_t H5HP_swim_min(heap, loc) + herr_t H5HP__swim_min(heap, loc) H5HP_t *heap; IN/OUT: Pointer to heap to modify size_t loc; IN: Location to start from @@ -135,13 +135,13 @@ H5HP_swim_max(H5HP_t *heap, size_t loc) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5HP_swim_min(H5HP_t *heap, size_t loc) +H5HP__swim_min(H5HP_t *heap, size_t loc) { int val; /* Temporary copy value of object to move in heap */ H5HP_info_t *obj; /* Temporary pointer to object to move in heap */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Get copies of the information about the object to move in the heap */ val = heap->heap[loc].val; @@ -168,15 +168,15 @@ H5HP_swim_min(H5HP_t *heap, size_t loc) heap->heap[loc].obj->heap_loc = loc; FUNC_LEAVE_NOAPI(ret_value); -} /* end H5HP_swim_min() */ +} /* end H5HP__swim_min() */ /*-------------------------------------------------------------------------- NAME - H5HP_sink_max + H5HP__sink_max PURPOSE Restore heap condition by moving an object downward USAGE - herr_t H5HP_sink_max(heap, loc) + herr_t H5HP__sink_max(heap, loc) H5HP_t *heap; IN/OUT: Pointer to heap to modify size_t loc; IN: Location to start from @@ -192,13 +192,13 @@ H5HP_swim_min(H5HP_t *heap, size_t loc) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5HP_sink_max(H5HP_t *heap, size_t loc) +H5HP__sink_max(H5HP_t *heap, size_t loc) { int val; /* Temporary copy value of object to move in heap */ void * obj; /* Temporary pointer to object to move in heap */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Get copies of the information about the object to move in the heap */ val = heap->heap[loc].val; @@ -236,15 +236,15 @@ H5HP_sink_max(H5HP_t *heap, size_t loc) heap->heap[loc].obj->heap_loc = loc; FUNC_LEAVE_NOAPI(ret_value); -} /* end H5HP_sink_max() */ +} /* end H5HP__sink_max() */ /*-------------------------------------------------------------------------- NAME - H5HP_sink_min + H5HP__sink_min PURPOSE Restore heap condition by moving an object downward USAGE - herr_t H5HP_sink_min(heap, loc) + herr_t H5HP__sink_min(heap, loc) H5HP_t *heap; IN/OUT: Pointer to heap to modify size_t loc; IN: Location to start from @@ -260,13 +260,13 @@ H5HP_sink_max(H5HP_t *heap, size_t loc) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5HP_sink_min(H5HP_t *heap, size_t loc) +H5HP__sink_min(H5HP_t *heap, size_t loc) { int val; /* Temporary copy value of object to move in heap */ void * obj; /* Temporary pointer to object to move in heap */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Get copies of the information about the object to move in the heap */ val = heap->heap[loc].val; @@ -304,7 +304,7 @@ H5HP_sink_min(H5HP_t *heap, size_t loc) heap->heap[loc].obj->heap_loc = loc; FUNC_LEAVE_NOAPI(ret_value); -} /* end H5HP_sink_min() */ +} /* end H5HP__sink_min() */ /*-------------------------------------------------------------------------- NAME @@ -485,11 +485,11 @@ H5HP_insert(H5HP_t *heap, int val, void *obj) /* Restore heap condition */ if (heap->type == H5HP_MAX_HEAP) { - if (H5HP_swim_max(heap, heap->nobjs) < 0) + if (H5HP__swim_max(heap, heap->nobjs) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, FAIL, "unable to restore heap condition"); } /* end if */ else { - if (H5HP_swim_min(heap, heap->nobjs) < 0) + if (H5HP__swim_min(heap, heap->nobjs) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, FAIL, "unable to restore heap condition"); } /* end else */ @@ -609,11 +609,11 @@ H5HP_remove(H5HP_t *heap, int *val, void **obj) /* Restore heap condition, if there are objects on the heap */ if (heap->nobjs > 0) { if (heap->type == H5HP_MAX_HEAP) { - if (H5HP_sink_max(heap, (size_t)1) < 0) + if (H5HP__sink_max(heap, (size_t)1) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDELETE, FAIL, "unable to restore heap condition"); } /* end if */ else { - if (H5HP_sink_min(heap, (size_t)1) < 0) + if (H5HP__sink_min(heap, (size_t)1) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDELETE, FAIL, "unable to restore heap condition"); } /* end else */ } /* end if */ @@ -684,21 +684,21 @@ H5HP_change(H5HP_t *heap, int val, void *_obj) /* Restore heap condition */ if (val < old_val) { if (heap->type == H5HP_MAX_HEAP) { - if (H5HP_sink_max(heap, obj_loc) < 0) + if (H5HP__sink_max(heap, obj_loc) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition"); } /* end if */ else { - if (H5HP_swim_min(heap, obj_loc) < 0) + if (H5HP__swim_min(heap, obj_loc) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition"); } /* end else */ } /* end if */ else { if (heap->type == H5HP_MAX_HEAP) { - if (H5HP_swim_max(heap, obj_loc) < 0) + if (H5HP__swim_max(heap, obj_loc) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition"); } /* end if */ else { - if (H5HP_sink_min(heap, obj_loc) < 0) + if (H5HP__sink_min(heap, obj_loc) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition"); } /* end else */ } /* end else */ @@ -766,11 +766,11 @@ H5HP_incr(H5HP_t *heap, unsigned amt, void *_obj) /* Restore heap condition */ if (H5HP_MAX_HEAP == heap->type) { - if (H5HP_swim_max(heap, obj_loc) < 0) + if (H5HP__swim_max(heap, obj_loc) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition") } /* end if */ else { - if (H5HP_sink_min(heap, obj_loc) < 0) + if (H5HP__sink_min(heap, obj_loc) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition") } /* end else */ @@ -838,11 +838,11 @@ H5HP_decr(H5HP_t *heap, unsigned amt, void *_obj) /* Restore heap condition */ if (heap->type == H5HP_MAX_HEAP) { - if (H5HP_sink_max(heap, obj_loc) < 0) + if (H5HP__sink_max(heap, obj_loc) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition"); } /* end if */ else { - if (H5HP_swim_min(heap, obj_loc) < 0) + if (H5HP__swim_min(heap, obj_loc) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition"); } /* end else */ diff --git a/src/H5M.c b/src/H5M.c index dc85812..24f3a9a 100644 --- a/src/H5M.c +++ b/src/H5M.c @@ -108,7 +108,7 @@ H5M__init_package(void) FUNC_ENTER_PACKAGE - /* Initialize the atom group for the map IDs */ + /* Initialize the ID group for the map IDs */ if (H5I_register_type(H5I_MAP_CLS) < 0) HGOTO_ERROR(H5E_MAP, H5E_CANTINIT, FAIL, "unable to initialize interface") @@ -354,7 +354,7 @@ H5Mcreate_anon(hid_t loc_id, hid_t key_type_id, hid_t val_type_id, hid_t mcpl_id H5P_LINK_CREATE_DEFAULT, key_type_id, val_type_id, mcpl_id, mapl_id, &map) < 0) HGOTO_ERROR(H5E_MAP, H5E_CANTINIT, H5I_INVALID_HID, "unable to create map") - /* Get an atom for the map */ + /* Get an ID for the map */ if ((ret_value = H5VL_register(H5I_MAP, map, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_MAP, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register map") diff --git a/src/H5MM.c b/src/H5MM.c index 313f900..b4447f6 100644 --- a/src/H5MM.c +++ b/src/H5MM.c @@ -15,7 +15,7 @@ * * Created: H5MM.c * Jul 10 1997 - * Robb Matzke + * Robb Matzke * * Purpose: Memory management functions * @@ -449,11 +449,17 @@ H5MM_xstrdup(const char *s) FUNC_ENTER_NOAPI(NULL) +#if defined H5_MEMORY_ALLOC_SANITY_CHECK if (s) { if (NULL == (ret_value = (char *)H5MM_malloc(HDstrlen(s) + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") HDstrcpy(ret_value, s); - } /* end if */ + } +#else + if (s) + if (NULL == (ret_value = HDstrdup(s))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "string duplication failed") +#endif done: FUNC_LEAVE_NOAPI(ret_value) @@ -483,10 +489,15 @@ H5MM_strdup(const char *s) FUNC_ENTER_NOAPI(NULL) if (!s) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "null string") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "NULL string not allowed") +#if defined H5_MEMORY_ALLOC_SANITY_CHECK if (NULL == (ret_value = (char *)H5MM_malloc(HDstrlen(s) + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") HDstrcpy(ret_value, s); +#else + if (NULL == (ret_value = HDstrdup(s))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "string duplication failed") +#endif done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5MMpublic.h b/src/H5MMpublic.h index ebfb377..70ac644 100644 --- a/src/H5MMpublic.h +++ b/src/H5MMpublic.h @@ -29,8 +29,13 @@ #include "H5public.h" /* These typedefs are currently used for VL datatype allocation/freeing */ +//! typedef void *(*H5MM_allocate_t)(size_t size, void *alloc_info); +//! + +//! typedef void (*H5MM_free_t)(void *mem, void *free_info); +//! #ifdef __cplusplus extern "C" { diff --git a/src/H5MP.c b/src/H5MP.c index 1ce4c6d..474a995 100644 --- a/src/H5MP.c +++ b/src/H5MP.c @@ -15,7 +15,7 @@ * * Created: H5MP.c * May 2 2005 - * Quincey Koziol + * Quincey Koziol * * Purpose: Implements memory pools. (Similar to Apache's APR * memory pools) @@ -76,7 +76,6 @@ H5FL_DEFINE(H5MP_pool_t); * Return: Pointer to the memory pool "header" on success/NULL on failure * * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu * May 2 2005 * *------------------------------------------------------------------------- @@ -118,26 +117,25 @@ done: } /* end H5MP_create() */ /*------------------------------------------------------------------------- - * Function: H5MP_new_page + * Function: H5MP__new_page * * Purpose: Allocate new page for a memory pool * * Return: Pointer to the page allocated on success/NULL on failure * * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu * May 4 2005 * *------------------------------------------------------------------------- */ static H5MP_page_t * -H5MP_new_page(H5MP_pool_t *mp, size_t page_size) +H5MP__new_page(H5MP_pool_t *mp, size_t page_size) { H5MP_page_t * new_page; /* New page created */ H5MP_page_blk_t *first_blk; /* Pointer to first block in page */ H5MP_page_t * ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Sanity check */ HDassert(mp); @@ -156,9 +154,6 @@ H5MP_new_page(H5MP_pool_t *mp, size_t page_size) new_page->free_size = mp->max_size; new_page->fac_alloc = TRUE; } /* end else */ -#ifdef QAK - HDfprintf(stderr, "%s: Allocating new page = %p\n", FUNC, new_page); -#endif /* QAK */ /* Initialize page information */ first_blk = H5MP_PAGE_FIRST_BLOCK(new_page); @@ -184,7 +179,7 @@ H5MP_new_page(H5MP_pool_t *mp, size_t page_size) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5MP_new_page() */ +} /* end H5MP__new_page() */ /*------------------------------------------------------------------------- * Function: H5MP_malloc @@ -194,7 +189,6 @@ done: * Return: Pointer to the space allocated on success/NULL on failure * * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu * May 2 2005 * *------------------------------------------------------------------------- @@ -215,10 +209,6 @@ H5MP_malloc(H5MP_pool_t *mp, size_t request) /* Compute actual size needed */ needed = H5MP_BLOCK_ALIGN(request) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)); -#ifdef QAK - HDfprintf(stderr, "%s: sizeof(H5MP_page_blk_t) = %Zu\n", FUNC, sizeof(H5MP_page_blk_t)); - HDfprintf(stderr, "%s: request = %Zu, needed = %Zu\n", FUNC, request, needed); -#endif /* QAK */ /* See if the request can be handled by existing free space */ if (needed <= mp->free_size) { @@ -267,7 +257,7 @@ H5MP_malloc(H5MP_pool_t *mp, size_t request) (needed > mp->max_size) ? (needed + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t))) : mp->page_size; /* Allocate new page */ - if (NULL == (alloc_page = H5MP_new_page(mp, page_size))) + if (NULL == (alloc_page = H5MP__new_page(mp, page_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for page") /* Set the block to allocate from */ @@ -315,9 +305,6 @@ found: /* Set new space pointer for the return value */ ret_value = ((unsigned char *)alloc_free) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)); -#ifdef QAK - HDfprintf(stderr, "%s: Allocating space from page, ret_value = %p\n", FUNC, ret_value); -#endif /* QAK */ done: FUNC_LEAVE_NOAPI(ret_value) @@ -331,7 +318,6 @@ done: * Return: NULL on success/NULL on failure * * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu * May 3 2005 * * Note: Should we release pages that have no used blocks? @@ -361,9 +347,6 @@ H5MP_free(H5MP_pool_t *mp, void *spc) /* Add it's space to the amount of free space in the page & pool */ spc_page = spc_blk->page; -#ifdef QAK - HDfprintf(stderr, "%s: Freeing from page = %p\n", "H5MP_free", spc_page); -#endif /* QAK */ spc_page->free_size += spc_blk->size; mp->free_size += spc_blk->size; @@ -420,7 +403,6 @@ H5MP_free(H5MP_pool_t *mp, void *spc) * Return: Non-negative on success/negative on failure * * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu * May 3 2005 * *------------------------------------------------------------------------- diff --git a/src/H5MPtest.c b/src/H5MPtest.c index df1c153..27e7bbe 100644 --- a/src/H5MPtest.c +++ b/src/H5MPtest.c @@ -11,7 +11,7 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* Programmer: Quincey Koziol +/* Programmer: Quincey Koziol * Tuesday, May 3, 2005 * * Purpose: Memory pool testing functions. @@ -41,8 +41,6 @@ * Programmer: Quincey Koziol * Tuesday, May 3, 2005 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t @@ -72,8 +70,6 @@ H5MP_get_pool_free_size(const H5MP_pool_t *mp, size_t *free_size) * Programmer: Quincey Koziol * Tuesday, May 3, 2005 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t @@ -106,8 +102,6 @@ H5MP_get_pool_first_page(const H5MP_pool_t *mp, H5MP_page_t **page) * Programmer: Quincey Koziol * Wednesday, May 3, 2005 * - * Modifications: - * *------------------------------------------------------------------------- */ htri_t @@ -141,10 +135,6 @@ H5MP_pool_is_free_size_correct(const H5MP_pool_t *mp) /* Check that the free space from the blocks on the free list * corresponds to space in page */ -#ifdef QAK - HDfprintf(stderr, "%s: page_free = %Zu, page->free_size = %Zu\n", "H5MP_pool_is_free_size_correct", - page_free, page->free_size); -#endif /* QAK */ if (page_free != page->free_size) HGOTO_DONE(FALSE) @@ -157,10 +147,6 @@ H5MP_pool_is_free_size_correct(const H5MP_pool_t *mp) /* Check that the free space from the pages * corresponds to free space in pool */ -#ifdef QAK - HDfprintf(stderr, "%s: pool_free = %Zu, mp->free_size = %Zu\n", "H5MP_pool_is_free_size_correct", - pool_free, mp->free_size); -#endif /* QAK */ if (pool_free != mp->free_size) HGOTO_DONE(FALSE) @@ -180,8 +166,6 @@ done: * Programmer: Quincey Koziol * Tuesday, May 3, 2005 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t @@ -211,8 +195,6 @@ H5MP_get_page_free_size(const H5MP_page_t *page, size_t *free_size) * Programmer: Quincey Koziol * Tuesday, May 3, 2005 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t diff --git a/src/H5VM.c b/src/H5VM.c index 20b2707..aaea491 100644 --- a/src/H5VM.c +++ b/src/H5VM.c @@ -12,7 +12,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Friday, October 10, 1997 */ @@ -58,8 +58,6 @@ static void H5VM_stride_copy2(hsize_t nelmts, hsize_t elmt_size, unsigned dst_n, * Programmer: Robb Matzke * Saturday, October 11, 1997 * - * Modifications: - * *------------------------------------------------------------------------- */ static void @@ -102,11 +100,6 @@ H5VM_stride_optimize1(unsigned *np /*in,out*/, hsize_t *elmt_size /*in,out*/, co * Programmer: Robb Matzke * Saturday, October 11, 1997 * - * Modifications: - * Unrolled loops for common cases - * Quincey Koziol - * ?, ? ?, 2001? - * *------------------------------------------------------------------------- */ static void @@ -237,11 +230,6 @@ H5VM_stride_optimize2(unsigned *np /*in,out*/, hsize_t *elmt_size /*in,out*/, co * Programmer: Robb Matzke * Saturday, October 11, 1997 * - * Modifications: - * Unrolled loops for common cases - * Quincey Koziol - * ?, ? ?, 2001? - * *------------------------------------------------------------------------- */ hsize_t @@ -338,8 +326,6 @@ H5VM_hyper_stride(unsigned n, const hsize_t *size, const hsize_t *total_size, co * Programmer: Robb Matzke * Friday, October 17, 1997 * - * Modifications: - * *------------------------------------------------------------------------- */ htri_t @@ -388,8 +374,6 @@ done: * Programmer: Robb Matzke * Friday, October 10, 1997 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t @@ -460,11 +444,6 @@ H5VM_hyper_fill(unsigned n, const hsize_t *_size, const hsize_t *total_size, con * Programmer: Robb Matzke * Friday, October 10, 1997 * - * Modifications: - * Unrolled loops for common cases - * Quincey Koziol - * ?, ? ?, 2001? - * *------------------------------------------------------------------------- */ herr_t @@ -621,8 +600,6 @@ H5VM_hyper_copy(unsigned n, const hsize_t *_size, const hsize_t *dst_size, const * Programmer: Robb Matzke * Saturday, October 11, 1997 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t @@ -680,8 +657,6 @@ H5VM_stride_fill(unsigned n, hsize_t elmt_size, const hsize_t *size, const hsize * Programmer: Robb Matzke * Saturday, October 11, 1997 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t @@ -748,8 +723,6 @@ H5VM_stride_copy(unsigned n, hsize_t elmt_size, const hsize_t *size, const hsize * Programmer: Robb Matzke * Saturday, October 11, 1997 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t @@ -814,8 +787,6 @@ H5VM_stride_copy_s(unsigned n, hsize_t elmt_size, const hsize_t *size, const hss * Programmer: Robb Matzke * Saturday, October 11, 1997 * - * Modifications: - * *------------------------------------------------------------------------- */ static void @@ -883,8 +854,6 @@ H5VM__stride_copy2(hsize_t nelmts, hsize_t elmt_size, unsigned dst_n, const hsiz * Programmer: Quincey Koziol * Thursday, June 18, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t @@ -938,8 +907,6 @@ H5VM_array_fill(void *_dst, const void *src, size_t size, size_t count) * Programmer: Quincey Koziol * Monday, April 28, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t @@ -1017,8 +984,6 @@ H5VM_array_offset_pre(unsigned n, const hsize_t *acc, const hsize_t *offset) * Programmer: Quincey Koziol * Tuesday, June 22, 1999 * - * Modifications: - * *------------------------------------------------------------------------- */ hsize_t @@ -1098,8 +1063,6 @@ H5VM_array_calc_pre(hsize_t offset, unsigned n, const hsize_t *down, hsize_t *co * Programmer: Quincey Koziol * Wednesday, April 16, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t diff --git a/src/H5WB.c b/src/H5WB.c index 93d4080..df7627f 100644 --- a/src/H5WB.c +++ b/src/H5WB.c @@ -15,7 +15,7 @@ * * Created: H5WB.c * Jun 26 2007 - * Quincey Koziol + * Quincey Koziol * * Purpose: Implements the "wrapped buffer" code for wrapping * an existing [staticly sized] buffer, in order to @@ -88,7 +88,6 @@ H5FL_BLK_DEFINE_STATIC(extra_buf); * NULL on failure * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Jun 26 2007 * *------------------------------------------------------------------------- @@ -141,7 +140,6 @@ done: * NULL on failure * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Jun 26 2007 * *------------------------------------------------------------------------- @@ -208,7 +206,6 @@ done: * NULL on failure * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Jun 26 2007 * *------------------------------------------------------------------------- @@ -245,7 +242,6 @@ done: * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Jun 26 2007 * *------------------------------------------------------------------------- -- cgit v0.12