summaryrefslogtreecommitdiffstats
path: root/src/H5Tbit.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Tbit.c')
-rw-r--r--src/H5Tbit.c35
1 files changed, 15 insertions, 20 deletions
diff --git a/src/H5Tbit.c b/src/H5Tbit.c
index 0813f46..abc39b0 100644
--- a/src/H5Tbit.c
+++ b/src/H5Tbit.c
@@ -317,6 +317,7 @@ H5T_bit_find (uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction,
ssize_t base=(ssize_t)offset;
ssize_t idx, i;
size_t iu;
+ ssize_t ret_value=(-1); /* Return value */
/* Use FUNC_ENTER_NOINIT here to avoid performance issues */
FUNC_ENTER_NOINIT(H5T_bit_find);
@@ -333,9 +334,8 @@ H5T_bit_find (uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction,
/* Beginning */
if (offset) {
for (iu=offset; iu<8 && size>0; iu++, size--) {
- if (value==(hbool_t)((buf[idx]>>iu) & 0x01)) {
- HRETURN(8*idx+(ssize_t)iu - base);
- }
+ if (value==(hbool_t)((buf[idx]>>iu) & 0x01))
+ HGOTO_DONE(8*idx+(ssize_t)iu - base);
}
offset = 0;
idx++;
@@ -344,9 +344,8 @@ H5T_bit_find (uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction,
while (size>=8) {
if ((value?0x00:0xff)!=buf[idx]) {
for (i=0; i<8; i++) {
- if (value==(hbool_t)((buf[idx]>>i) & 0x01)) {
- HRETURN(8*idx+i - base);
- }
+ if (value==(hbool_t)((buf[idx]>>i) & 0x01))
+ HGOTO_DONE(8*idx+i - base);
}
}
size -= 8;
@@ -354,9 +353,8 @@ H5T_bit_find (uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction,
}
/* End */
for (i=0; i<(ssize_t)size; i++) {
- if (value==(hbool_t)((buf[idx]>>i) & 0x01)) {
- HRETURN(8*idx+i - base);
- }
+ if (value==(hbool_t)((buf[idx]>>i) & 0x01))
+ HGOTO_DONE(8*idx+i - base);
}
break;
@@ -368,9 +366,8 @@ H5T_bit_find (uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction,
/* Beginning */
if (size>8-offset && (offset+size)%8) {
for (iu=(offset+size)%8; iu>0; --iu, --size) {
- if (value==(hbool_t)((buf[idx]>>(iu-1)) & 0x01)) {
- HRETURN(8*idx+(ssize_t)(iu-1) - base);
- }
+ if (value==(hbool_t)((buf[idx]>>(iu-1)) & 0x01))
+ HGOTO_DONE(8*idx+(ssize_t)(iu-1) - base);
}
--idx;
}
@@ -378,9 +375,8 @@ H5T_bit_find (uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction,
while (size>=8) {
if ((value?0x00:0xff)!=buf[idx]) {
for (i=7; i>=0; --i) {
- if (value==(hbool_t)((buf[idx]>>i) & 0x01)) {
- HRETURN(8*idx+i - base);
- }
+ if (value==(hbool_t)((buf[idx]>>i) & 0x01))
+ HGOTO_DONE(8*idx+i - base);
}
}
size -= 8;
@@ -389,16 +385,15 @@ H5T_bit_find (uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction,
/* End */
if (size>0) {
for (iu=offset+size; iu>offset; --iu) {
- if (value==(hbool_t)((buf[idx]>>(iu-1)) & 0x01)) {
- HRETURN(8*idx+(ssize_t)(iu-1) - base);
- }
+ if (value==(hbool_t)((buf[idx]>>(iu-1)) & 0x01))
+ HGOTO_DONE(8*idx+(ssize_t)(iu-1) - base);
}
}
break;
}
-
- FUNC_LEAVE(-1);
+done:
+ FUNC_LEAVE(ret_value);
}