diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2020-10-01 16:47:45 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2020-10-01 16:47:45 (GMT) |
commit | 1ba1f2f3222cbe8df0bf601929a4bffd478d7e02 (patch) | |
tree | ae51dfc33cf40432dad25a5088767115a98f195e /src/H5SMmessage.c | |
parent | 8eef7d295cc3dd134aef0a826f1de4287629996d (diff) | |
download | hdf5-1ba1f2f3222cbe8df0bf601929a4bffd478d7e02.zip hdf5-1ba1f2f3222cbe8df0bf601929a4bffd478d7e02.tar.gz hdf5-1ba1f2f3222cbe8df0bf601929a4bffd478d7e02.tar.bz2 |
Source formatted
Diffstat (limited to 'src/H5SMmessage.c')
-rw-r--r-- | src/H5SMmessage.c | 109 |
1 files changed, 48 insertions, 61 deletions
diff --git a/src/H5SMmessage.c b/src/H5SMmessage.c index f342e28..b143c6a 100644 --- a/src/H5SMmessage.c +++ b/src/H5SMmessage.c @@ -15,24 +15,21 @@ /* Module Setup */ /****************/ -#define H5O_PACKAGE /*suppress error about including H5Opkg */ -#define H5SM_PACKAGE /*suppress error about including H5SMpkg */ - +#define H5O_PACKAGE /*suppress error about including H5Opkg */ +#define H5SM_PACKAGE /*suppress error about including H5SMpkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Opkg.h" /* Object Headers */ -#include "H5SMpkg.h" /* Shared object header messages */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Opkg.h" /* Object Headers */ +#include "H5SMpkg.h" /* Shared object header messages */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ @@ -40,35 +37,29 @@ /* Udata struct for calls to H5SM_compare_cb and H5SM_compare_iter_op*/ typedef struct H5SM_compare_udata_t { const H5SM_mesg_key_t *key; /* Key; compare this against stored message */ - H5O_msg_crt_idx_t idx; /* Index of the message in the OH, if applicable */ - herr_t ret; /* Return value; set this to result of memcmp */ + H5O_msg_crt_idx_t idx; /* Index of the message in the OH, if applicable */ + herr_t ret; /* Return value; set this to result of memcmp */ } H5SM_compare_udata_t; - /********************/ /* Local Prototypes */ /********************/ static herr_t H5SM_compare_cb(const void *obj, size_t obj_len, void *udata); -static herr_t H5SM_compare_iter_op(H5O_t *oh, H5O_mesg_t *mesg, unsigned sequence, - unsigned *oh_modified, void *udata); - +static herr_t H5SM_compare_iter_op(H5O_t *oh, H5O_mesg_t *mesg, unsigned sequence, unsigned *oh_modified, + void *udata); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5SM_compare_cb * @@ -93,9 +84,9 @@ H5SM_compare_cb(const void *obj, size_t obj_len, void *_udata) FUNC_ENTER_NOAPI_NOINIT_NOERR /* If the encoding sizes are different, it's not the same object */ - if(udata->key->encoding_size > obj_len) + if (udata->key->encoding_size > obj_len) udata->ret = 1; - else if(udata->key->encoding_size < obj_len) + else if (udata->key->encoding_size < obj_len) udata->ret = -1; else /* Sizes are the same. Return result of memcmp */ @@ -104,7 +95,6 @@ H5SM_compare_cb(const void *obj, size_t obj_len, void *_udata) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5SM_compare_cb() */ - /*------------------------------------------------------------------------- * Function: H5SM_compare_iter_op * @@ -126,11 +116,11 @@ H5SM_compare_cb(const void *obj, size_t obj_len, void *_udata) *------------------------------------------------------------------------- */ static herr_t -H5SM_compare_iter_op(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, unsigned sequence, - unsigned H5_ATTR_UNUSED *oh_modified, void *_udata/*in,out*/) +H5SM_compare_iter_op(H5O_t *oh, H5O_mesg_t *mesg /*in,out*/, unsigned sequence, + unsigned H5_ATTR_UNUSED *oh_modified, void *_udata /*in,out*/) { - H5SM_compare_udata_t *udata = (H5SM_compare_udata_t *) _udata; - herr_t ret_value = H5_ITER_CONT; + H5SM_compare_udata_t *udata = (H5SM_compare_udata_t *)_udata; + herr_t ret_value = H5_ITER_CONT; FUNC_ENTER_NOAPI_NOINIT @@ -142,21 +132,22 @@ H5SM_compare_iter_op(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, unsigned sequence, HDassert(udata && udata->key); /* Check the creation index for this message */ - if(sequence == udata->idx) { + if (sequence == udata->idx) { size_t aligned_encoded_size = H5O_ALIGN_OH(oh, udata->key->encoding_size); /* Sanity check the message's length */ HDassert(mesg->raw_size > 0); - if(aligned_encoded_size > mesg->raw_size) + if (aligned_encoded_size > mesg->raw_size) udata->ret = 1; - else if(aligned_encoded_size < mesg->raw_size) + else if (aligned_encoded_size < mesg->raw_size) udata->ret = -1; else { /* Check if the message is dirty & flush it to the object header if so */ - if(mesg->dirty) - if(H5O_msg_flush(udata->key->file, oh, mesg) < 0) - HGOTO_ERROR(H5E_SOHM, H5E_CANTENCODE, H5_ITER_ERROR, "unable to encode object header message") + if (mesg->dirty) + if (H5O_msg_flush(udata->key->file, oh, mesg) < 0) + HGOTO_ERROR(H5E_SOHM, H5E_CANTENCODE, H5_ITER_ERROR, + "unable to encode object header message") HDassert(udata->key->encoding_size <= mesg->raw_size); udata->ret = HDmemcmp(udata->key->encoding, mesg->raw, udata->key->encoding_size); @@ -170,7 +161,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM_compare_iter_op() */ - /*------------------------------------------------------------------------- * Function: H5SM_message_compare * @@ -190,9 +180,9 @@ done: herr_t H5SM_message_compare(const void *rec1, const void *rec2, int *result) { - const H5SM_mesg_key_t *key = (const H5SM_mesg_key_t *) rec1; - const H5SM_sohm_t *mesg = (const H5SM_sohm_t *) rec2; - herr_t ret_value = SUCCEED; + const H5SM_mesg_key_t *key = (const H5SM_mesg_key_t *)rec1; + const H5SM_sohm_t * mesg = (const H5SM_sohm_t *)rec2; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT @@ -202,25 +192,25 @@ H5SM_message_compare(const void *rec1, const void *rec2, int *result) * Likewise, if the message has an OH location that is matched by the * message in the index, we've found the message. */ - if(mesg->location == H5SM_IN_HEAP && key->message.location == H5SM_IN_HEAP) { - if(key->message.u.heap_loc.fheap_id.val == mesg->u.heap_loc.fheap_id.val) { + if (mesg->location == H5SM_IN_HEAP && key->message.location == H5SM_IN_HEAP) { + if (key->message.u.heap_loc.fheap_id.val == mesg->u.heap_loc.fheap_id.val) { *result = 0; HGOTO_DONE(SUCCEED); } } /* end if */ - else if(mesg->location == H5SM_IN_OH && key->message.location == H5SM_IN_OH) { - if(key->message.u.mesg_loc.oh_addr == mesg->u.mesg_loc.oh_addr && - key->message.u.mesg_loc.index == mesg->u.mesg_loc.index && - key->message.msg_type_id == mesg->msg_type_id) { + else if (mesg->location == H5SM_IN_OH && key->message.location == H5SM_IN_OH) { + if (key->message.u.mesg_loc.oh_addr == mesg->u.mesg_loc.oh_addr && + key->message.u.mesg_loc.index == mesg->u.mesg_loc.index && + key->message.msg_type_id == mesg->msg_type_id) { *result = 0; HGOTO_DONE(SUCCEED); } } /* end if */ /* Compare hash values */ - if(key->message.hash > mesg->hash) + if (key->message.hash > mesg->hash) *result = 1; - else if(key->message.hash < mesg->hash) + else if (key->message.hash < mesg->hash) *result = -1; /* If the hash values match, make sure the messages are really the same */ else { @@ -238,21 +228,21 @@ H5SM_message_compare(const void *rec1, const void *rec2, int *result) /* Compare the encoded message with either the message in the heap or * the message in an object header. */ - if(mesg->location == H5SM_IN_HEAP) { + if (mesg->location == H5SM_IN_HEAP) { /* Call heap op routine with comparison callback */ - if(H5HF_op(key->fheap, key->dxpl_id, &(mesg->u.heap_loc.fheap_id), H5SM_compare_cb, &udata) < 0) + if (H5HF_op(key->fheap, key->dxpl_id, &(mesg->u.heap_loc.fheap_id), H5SM_compare_cb, &udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") } /* end if */ else { - H5O_loc_t oloc; /* Object owning the message */ - H5O_mesg_operator_t op; /* Message operator */ + H5O_loc_t oloc; /* Object owning the message */ + H5O_mesg_operator_t op; /* Message operator */ /* Sanity checks */ HDassert(key->file); HDassert(mesg->location == H5SM_IN_OH); /* Reset the object location */ - if(H5O_loc_reset(&oloc) < 0) + if (H5O_loc_reset(&oloc) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "unable to initialize target location") /* Set up object location */ @@ -263,9 +253,9 @@ H5SM_message_compare(const void *rec1, const void *rec2, int *result) udata.idx = mesg->u.mesg_loc.index; /* Locate the right message and compare with it */ - op.op_type = H5O_MESG_OP_LIB; + op.op_type = H5O_MESG_OP_LIB; op.u.lib_op = H5SM_compare_iter_op; - if(H5O_msg_iterate(&oloc, mesg->msg_type_id, &op, &udata, key->dxpl_id) < 0) + if (H5O_msg_iterate(&oloc, mesg->msg_type_id, &op, &udata, key->dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "error iterating over links") } /* end else */ @@ -276,7 +266,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM_message_compare */ - /*------------------------------------------------------------------------- * Function: H5SM_message_encode * @@ -293,7 +282,7 @@ done: herr_t H5SM_message_encode(uint8_t *raw, const void *_nrecord, void *_ctx) { - H5SM_bt2_ctx_t *ctx = (H5SM_bt2_ctx_t *)_ctx; /* Callback context structure */ + H5SM_bt2_ctx_t * ctx = (H5SM_bt2_ctx_t *)_ctx; /* Callback context structure */ const H5SM_sohm_t *message = (const H5SM_sohm_t *)_nrecord; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -304,14 +293,14 @@ H5SM_message_encode(uint8_t *raw, const void *_nrecord, void *_ctx) *raw++ = (uint8_t)message->location; UINT32ENCODE(raw, message->hash); - if(message->location == H5SM_IN_HEAP) { + if (message->location == H5SM_IN_HEAP) { UINT32ENCODE(raw, message->u.heap_loc.ref_count); HDmemcpy(raw, message->u.heap_loc.fheap_id.id, (size_t)H5O_FHEAP_ID_LEN); } /* end if */ else { HDassert(message->location == H5SM_IN_OH); - *raw++ = 0; /* reserved (possible flags byte) */ + *raw++ = 0; /* reserved (possible flags byte) */ *raw++ = (uint8_t)message->msg_type_id; UINT16ENCODE(raw, message->u.mesg_loc.index); H5F_addr_encode_len((size_t)ctx->sizeof_addr, &raw, message->u.mesg_loc.oh_addr); @@ -320,7 +309,6 @@ H5SM_message_encode(uint8_t *raw, const void *_nrecord, void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5SM_message_encode */ - /*------------------------------------------------------------------------- * Function: H5SM_message_decode * @@ -337,22 +325,22 @@ H5SM_message_encode(uint8_t *raw, const void *_nrecord, void *_ctx) herr_t H5SM_message_decode(const uint8_t *raw, void *_nrecord, void *_ctx) { - H5SM_bt2_ctx_t *ctx = (H5SM_bt2_ctx_t *)_ctx; /* Callback context structure */ - H5SM_sohm_t *message = (H5SM_sohm_t *)_nrecord; + H5SM_bt2_ctx_t *ctx = (H5SM_bt2_ctx_t *)_ctx; /* Callback context structure */ + H5SM_sohm_t * message = (H5SM_sohm_t *)_nrecord; FUNC_ENTER_NOAPI_NOINIT_NOERR message->location = (H5SM_storage_loc_t)*raw++; UINT32DECODE(raw, message->hash); - if(message->location == H5SM_IN_HEAP) { + if (message->location == H5SM_IN_HEAP) { UINT32DECODE(raw, message->u.heap_loc.ref_count); HDmemcpy(message->u.heap_loc.fheap_id.id, raw, (size_t)H5O_FHEAP_ID_LEN); } /* end if */ else { HDassert(message->location == H5SM_IN_OH); - raw++; /* reserved */ + raw++; /* reserved */ message->msg_type_id = *raw++; UINT16DECODE(raw, message->u.mesg_loc.index); H5F_addr_decode_len((size_t)ctx->sizeof_addr, &raw, &message->u.mesg_loc.oh_addr); @@ -360,4 +348,3 @@ H5SM_message_decode(const uint8_t *raw, void *_nrecord, void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5SM_message_decode */ - |