summaryrefslogtreecommitdiffstats
path: root/src/H5Zfletcher32.c
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2020-09-30 14:27:10 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2020-09-30 14:27:10 (GMT)
commitb2d661b508a7fc7a2592c13bc6bdc175551f075d (patch)
tree13baeb0d83a7c2a4c6299993c182b1227c2f6114 /src/H5Zfletcher32.c
parent29ab58b58dce556639ea3154e262895773a8a8df (diff)
downloadhdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.zip
hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.gz
hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.bz2
Clang-format of source files
Diffstat (limited to 'src/H5Zfletcher32.c')
-rw-r--r--src/H5Zfletcher32.c93
1 files changed, 46 insertions, 47 deletions
diff --git a/src/H5Zfletcher32.c b/src/H5Zfletcher32.c
index 07e2f79..235030b 100644
--- a/src/H5Zfletcher32.c
+++ b/src/H5Zfletcher32.c
@@ -16,34 +16,32 @@
* Jan 3, 2003
*/
-#include "H5Zmodule.h" /* This source code file is part of the H5Z module */
+#include "H5Zmodule.h" /* This source code file is part of the H5Z module */
-
-#include "H5private.h" /* Generic Functions */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5Fprivate.h" /* File access */
-#include "H5MMprivate.h" /* Memory management */
-#include "H5Zpkg.h" /* Data filters */
+#include "H5private.h" /* Generic Functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5Fprivate.h" /* File access */
+#include "H5MMprivate.h" /* Memory management */
+#include "H5Zpkg.h" /* Data filters */
/* Local function prototypes */
-static size_t H5Z__filter_fletcher32(unsigned flags, size_t cd_nelmts,
- const unsigned cd_values[], size_t nbytes, size_t *buf_size, void **buf);
+static size_t H5Z__filter_fletcher32(unsigned flags, size_t cd_nelmts, const unsigned cd_values[],
+ size_t nbytes, size_t *buf_size, void **buf);
/* This message derives from H5Z */
const H5Z_class2_t H5Z_FLETCHER32[1] = {{
- H5Z_CLASS_T_VERS, /* H5Z_class_t version */
- H5Z_FILTER_FLETCHER32, /* Filter id number */
- 1, /* encoder_present flag (set to true) */
- 1, /* decoder_present flag (set to true) */
- "fletcher32", /* Filter name for debugging */
- NULL, /* The "can apply" callback */
- NULL, /* The "set local" callback */
- H5Z__filter_fletcher32, /* The actual filter function */
+ H5Z_CLASS_T_VERS, /* H5Z_class_t version */
+ H5Z_FILTER_FLETCHER32, /* Filter id number */
+ 1, /* encoder_present flag (set to true) */
+ 1, /* decoder_present flag (set to true) */
+ "fletcher32", /* Filter name for debugging */
+ NULL, /* The "can apply" callback */
+ NULL, /* The "set local" callback */
+ H5Z__filter_fletcher32, /* The actual filter function */
}};
-#define FLETCHER_LEN 4
+#define FLETCHER_LEN 4
-
/*-------------------------------------------------------------------------
* Function: H5Z__filter_fletcher32
*
@@ -58,32 +56,32 @@ const H5Z_class2_t H5Z_FLETCHER32[1] = {{
*-------------------------------------------------------------------------
*/
static size_t
-H5Z__filter_fletcher32(unsigned flags, size_t H5_ATTR_UNUSED cd_nelmts, const unsigned H5_ATTR_UNUSED cd_values[],
- size_t nbytes, size_t *buf_size, void **buf)
+H5Z__filter_fletcher32(unsigned flags, size_t H5_ATTR_UNUSED cd_nelmts,
+ const unsigned H5_ATTR_UNUSED cd_values[], size_t nbytes, size_t *buf_size, void **buf)
{
- void *outbuf = NULL; /* Pointer to new buffer */
- unsigned char *src = (unsigned char*)(*buf);
- uint32_t fletcher; /* Checksum value */
- uint32_t reversed_fletcher; /* Possible wrong checksum value */
- uint8_t c[4];
- uint8_t tmp;
- size_t ret_value = 0; /* Return value */
+ void * outbuf = NULL; /* Pointer to new buffer */
+ unsigned char *src = (unsigned char *)(*buf);
+ uint32_t fletcher; /* Checksum value */
+ uint32_t reversed_fletcher; /* Possible wrong checksum value */
+ uint8_t c[4];
+ uint8_t tmp;
+ size_t ret_value = 0; /* Return value */
FUNC_ENTER_STATIC
- HDassert(sizeof(uint32_t)>=4);
+ HDassert(sizeof(uint32_t) >= 4);
if (flags & H5Z_FLAG_REVERSE) { /* Read */
/* Do checksum if it's enabled for read; otherwise skip it
* to save performance. */
if (!(flags & H5Z_FLAG_SKIP_EDC)) {
unsigned char *tmp_src; /* Pointer to checksum in buffer */
- size_t src_nbytes = nbytes; /* Original number of bytes */
- uint32_t stored_fletcher; /* Stored checksum value */
+ size_t src_nbytes = nbytes; /* Original number of bytes */
+ uint32_t stored_fletcher; /* Stored checksum value */
/* Get the stored checksum */
src_nbytes -= FLETCHER_LEN;
- tmp_src=src+src_nbytes;
+ tmp_src = src + src_nbytes;
UINT32DECODE(tmp_src, stored_fletcher);
/* Compute checksum (can't fail) */
@@ -110,44 +108,45 @@ H5Z__filter_fletcher32(unsigned flags, size_t H5_ATTR_UNUSED cd_nelmts, const un
H5MM_memcpy(&reversed_fletcher, c, (size_t)4);
/* Verify computed checksum matches stored checksum */
- if(stored_fletcher != fletcher && stored_fletcher != reversed_fletcher)
- HGOTO_ERROR(H5E_STORAGE, H5E_READERROR, 0, "data error detected by Fletcher32 checksum")
+ if (stored_fletcher != fletcher && stored_fletcher != reversed_fletcher)
+ HGOTO_ERROR(H5E_STORAGE, H5E_READERROR, 0, "data error detected by Fletcher32 checksum")
}
/* Set return values */
/* (Re-use the input buffer, just note that the size is smaller by the size of the checksum) */
- ret_value = nbytes-FLETCHER_LEN;
- } else { /* Write */
- unsigned char *dst; /* Temporary pointer to destination buffer */
+ ret_value = nbytes - FLETCHER_LEN;
+ }
+ else { /* Write */
+ unsigned char *dst; /* Temporary pointer to destination buffer */
/* Compute checksum (can't fail) */
fletcher = H5_checksum_fletcher32(src, nbytes);
- if (NULL == (outbuf = H5MM_malloc(nbytes + FLETCHER_LEN)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "unable to allocate Fletcher32 checksum destination buffer")
+ if (NULL == (outbuf = H5MM_malloc(nbytes + FLETCHER_LEN)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0,
+ "unable to allocate Fletcher32 checksum destination buffer")
- dst = (unsigned char *) outbuf;
+ dst = (unsigned char *)outbuf;
/* Copy raw data */
- H5MM_memcpy((void*)dst, (void*)(*buf), nbytes);
+ H5MM_memcpy((void *)dst, (void *)(*buf), nbytes);
/* Append checksum to raw data for storage */
dst += nbytes;
UINT32ENCODE(dst, fletcher);
/* Free input buffer */
- H5MM_xfree(*buf);
+ H5MM_xfree(*buf);
/* Set return values */
*buf_size = nbytes + FLETCHER_LEN;
- *buf = outbuf;
- outbuf = NULL;
- ret_value = *buf_size;
+ *buf = outbuf;
+ outbuf = NULL;
+ ret_value = *buf_size;
}
done:
- if(outbuf)
+ if (outbuf)
H5MM_xfree(outbuf);
FUNC_LEAVE_NOAPI(ret_value)
}
-