diff options
Diffstat (limited to 'src/H5Gent.c')
-rw-r--r-- | src/H5Gent.c | 130 |
1 files changed, 53 insertions, 77 deletions
diff --git a/src/H5Gent.c b/src/H5Gent.c index d56d3c0..2b499fe 100644 --- a/src/H5Gent.c +++ b/src/H5Gent.c @@ -28,15 +28,10 @@ #include "H5FLprivate.h" /* Free Lists */ #include "H5Gpkg.h" /* Groups */ #include "H5HLprivate.h" /* Local Heaps */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory Management */ /* Private macros */ /* Private prototypes */ -static herr_t H5G_ent_encode(const H5F_t *f, uint8_t **pp, const H5G_entry_t *ent); -static herr_t H5G_ent_decode(const H5F_t *f, const uint8_t **pp, - H5G_entry_t *ent/*out*/); /* Declare extern the PQ free list for the wrapped strings */ H5FL_BLK_EXTERN(str_buf); @@ -48,9 +43,6 @@ H5FL_BLK_EXTERN(str_buf); * Purpose: Same as H5G_ent_decode() except it does it for an array of * symbol table entries. * - * Errors: - * SYM CANTDECODE Can't decode. - * * Return: Success: Non-negative, with *pp pointing to the first byte * after the last symbol. * @@ -60,31 +52,29 @@ H5FL_BLK_EXTERN(str_buf); * matzke@llnl.gov * Jul 18 1997 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t H5G_ent_decode_vec(const H5F_t *f, const uint8_t **pp, H5G_entry_t *ent, unsigned n) { - unsigned u; - herr_t ret_value=SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5G_ent_decode_vec, FAIL); + FUNC_ENTER_NOAPI(H5G_ent_decode_vec, FAIL) /* check arguments */ - assert(f); - assert(pp); - assert(ent); + HDassert(f); + HDassert(pp); + HDassert(ent); /* decode entries */ - for (u = 0; u < n; u++) - if (H5G_ent_decode(f, pp, ent + u) < 0) + for(u = 0; u < n; u++) + if(H5G_ent_decode(f, pp, ent + u) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "can't decode") done: - FUNC_LEAVE_NOAPI(ret_value); -} + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G_ent_decode_vec() */ /*------------------------------------------------------------------------- @@ -92,8 +82,6 @@ done: * * Purpose: Decodes a symbol table entry pointed to by `*pp'. * - * Errors: - * * Return: Success: Non-negative with *pp pointing to the first byte * following the symbol table entry. * @@ -103,25 +91,23 @@ done: * matzke@llnl.gov * Jul 18 1997 * - * Modifications: - * Robb Matzke, 17 Jul 1998 - * Added a 4-byte padding field for alignment and future expansion. - * *------------------------------------------------------------------------- */ -static herr_t +herr_t H5G_ent_decode(const H5F_t *f, const uint8_t **pp, H5G_entry_t *ent) { const uint8_t *p_ret = *pp; uint32_t tmp; + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_ent_decode) + FUNC_ENTER_NOAPI(H5G_ent_decode, FAIL) /* check arguments */ HDassert(f); HDassert(pp); HDassert(ent); + /* Set the entry's file pointer */ ent->file = f; /* decode header */ @@ -129,31 +115,31 @@ H5G_ent_decode(const H5F_t *f, const uint8_t **pp, H5G_entry_t *ent) H5F_addr_decode(f, pp, &(ent->header)); UINT32DECODE(*pp, tmp); *pp += 4; /*reserved*/ - ent->type=(H5G_cache_type_t)tmp; + ent->type = (H5G_cache_type_t)tmp; /* decode scratch-pad */ - switch (ent->type) { + switch(ent->type) { case H5G_NOTHING_CACHED: break; case H5G_CACHED_STAB: - assert(2 * H5F_SIZEOF_ADDR(f) <= H5G_SIZEOF_SCRATCH); + HDassert(2 * H5F_SIZEOF_ADDR(f) <= H5G_SIZEOF_SCRATCH); H5F_addr_decode(f, pp, &(ent->cache.stab.btree_addr)); H5F_addr_decode(f, pp, &(ent->cache.stab.heap_addr)); break; case H5G_CACHED_SLINK: - UINT32DECODE (*pp, ent->cache.slink.lval_offset); + UINT32DECODE(*pp, ent->cache.slink.lval_offset); break; default: - /* Error or unknown type. Bail out. */ - return -1; - } + HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unknown symbol table entry cache type") + } /* end switch */ *pp = p_ret + H5G_SIZEOF_ENTRY(f); - FUNC_LEAVE_NOAPI(SUCCEED) +done: + FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_ent_decode() */ @@ -163,9 +149,6 @@ H5G_ent_decode(const H5F_t *f, const uint8_t **pp, H5G_entry_t *ent) * Purpose: Same as H5G_ent_encode() except it does it for an array of * symbol table entries. * - * Errors: - * SYM CANTENCODE Can't encode. - * * Return: Success: Non-negative, with *pp pointing to the first byte * after the last symbol. * @@ -175,31 +158,29 @@ H5G_ent_decode(const H5F_t *f, const uint8_t **pp, H5G_entry_t *ent) * matzke@llnl.gov * Jul 18 1997 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t H5G_ent_encode_vec(const H5F_t *f, uint8_t **pp, const H5G_entry_t *ent, unsigned n) { - unsigned u; - herr_t ret_value=SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5G_ent_encode_vec, FAIL); + FUNC_ENTER_NOAPI(H5G_ent_encode_vec, FAIL) /* check arguments */ - assert(f); - assert(pp); - assert(ent); + HDassert(f); + HDassert(pp); + HDassert(ent); /* encode entries */ - for (u = 0; u < n; u++) - if (H5G_ent_encode(f, pp, ent + u) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "can't encode"); + for(u = 0; u < n; u++) + if(H5G_ent_encode(f, pp, ent + u) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "can't encode") done: - FUNC_LEAVE_NOAPI(ret_value); -} + FUNC_LEAVE_NOAPI(ret_value) +} /* H5G_ent_encode_vec() */ /*------------------------------------------------------------------------- @@ -208,8 +189,6 @@ done: * Purpose: Encodes the specified symbol table entry into the buffer * pointed to by *pp. * - * Errors: - * * Return: Success: Non-negative, with *pp pointing to the first byte * after the symbol table entry. * @@ -219,26 +198,22 @@ done: * matzke@llnl.gov * Jul 18 1997 * - * Modifications: - * - * Robb Matzke, 8 Aug 1997 - * Writes zeros for the bytes that aren't used so the file doesn't - * contain junk. - * *------------------------------------------------------------------------- */ -static herr_t +herr_t H5G_ent_encode(const H5F_t *f, uint8_t **pp, const H5G_entry_t *ent) { - uint8_t *p_ret = *pp + H5G_SIZEOF_ENTRY(f); + uint8_t *p_ret = *pp + H5G_SIZEOF_ENTRY(f); + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_ent_encode); + FUNC_ENTER_NOAPI(H5G_ent_encode, FAIL) /* check arguments */ - assert(f); - assert(pp); + HDassert(f); + HDassert(pp); - if (ent) { + /* Check for actual entry to encode */ + if(ent) { /* encode header */ H5F_ENCODE_LENGTH(f, *pp, ent->name_off); H5F_addr_encode(f, pp, ent->header); @@ -246,38 +221,39 @@ H5G_ent_encode(const H5F_t *f, uint8_t **pp, const H5G_entry_t *ent) UINT32ENCODE(*pp, 0); /*reserved*/ /* encode scratch-pad */ - switch (ent->type) { + switch(ent->type) { case H5G_NOTHING_CACHED: break; case H5G_CACHED_STAB: - assert(2 * H5F_SIZEOF_ADDR(f) <= H5G_SIZEOF_SCRATCH); + HDassert(2 * H5F_SIZEOF_ADDR(f) <= H5G_SIZEOF_SCRATCH); H5F_addr_encode(f, pp, ent->cache.stab.btree_addr); H5F_addr_encode(f, pp, ent->cache.stab.heap_addr); break; case H5G_CACHED_SLINK: - UINT32ENCODE (*pp, ent->cache.slink.lval_offset); + UINT32ENCODE(*pp, ent->cache.slink.lval_offset); break; default: - /* Unknown cached type. Bail out. */ - return -1; - } - } else { + HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unknown symbol table entry cache type") + } /* end switch */ + } /* end if */ + else { H5F_ENCODE_LENGTH(f, *pp, 0); H5F_addr_encode(f, pp, HADDR_UNDEF); UINT32ENCODE(*pp, H5G_NOTHING_CACHED); UINT32ENCODE(*pp, 0); /*reserved*/ - } + } /* end else */ /* fill with zero */ while(*pp < p_ret) *(*pp)++ = 0; *pp = p_ret; - FUNC_LEAVE_NOAPI(SUCCEED); -} +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G_ent_encode() */ /*------------------------------------------------------------------------- @@ -495,7 +471,7 @@ H5G_ent_debug(const H5G_entry_t *ent, FILE *stream, int indent, int fwidth, "Link value offset:", (unsigned long)(ent->cache.slink.lval_offset)); if(heap) { - lval = H5HL_offset_into(ent->file, heap, ent->cache.slink.lval_offset); + lval = (const char *)H5HL_offset_into(ent->file, heap, ent->cache.slink.lval_offset); HDfprintf(stream, "%*s%-*s %s\n", nested_indent, "", nested_fwidth, "Link value:", lval); |