Skip to content

Commit edb54d8

Browse files
authored
Merge pull request #615 from JohnSanpe/fixup-bfdev
fixup bfdev: fixed some style issue
2 parents 21ae7b3 + 6a5dd38 commit edb54d8

File tree

7 files changed

+32
-170
lines changed

7 files changed

+32
-170
lines changed

include/bfdev/align.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ BFDEV_BEGIN_DECLS
4747
* @align: alignment size.
4848
*/
4949
#define bfdev_align_high(value, align) ({ \
50-
typeof(align) _align = (align); \
51-
((value) + (_align - 1)) & ~(_align - 1); \
50+
typeof(align) __align = (align); \
51+
((value) + (__align - 1)) & ~(__align - 1); \
5252
})
5353

5454
/**

include/bfdev/jhash.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ BFDEV_BEGIN_DECLS
1717

1818
/* Mix 3 32-bit values reversibly */
1919
#define bfdev_jhash_mix(a, b, c) { \
20-
a -= c; a ^= bfdev_rol32(c, 4); c += b; \
21-
b -= a; b ^= bfdev_rol32(a, 6); a += c; \
22-
c -= b; c ^= bfdev_rol32(b, 8); b += a; \
20+
a -= c; a ^= bfdev_rol32(c, 4); c += b; \
21+
b -= a; b ^= bfdev_rol32(a, 6); a += c; \
22+
c -= b; c ^= bfdev_rol32(b, 8); b += a; \
2323
a -= c; a ^= bfdev_rol32(c, 16); c += b; \
2424
b -= a; b ^= bfdev_rol32(a, 19); a += c; \
25-
c -= b; c ^= bfdev_rol32(b, 4); b += a; \
25+
c -= b; c ^= bfdev_rol32(b, 4); b += a; \
2626
}
2727

2828
/* Final mixing of 3 32-bit values (a,b,c) into c */
@@ -31,7 +31,7 @@ BFDEV_BEGIN_DECLS
3131
a ^= c; a -= bfdev_rol32(c, 11); \
3232
b ^= a; b -= bfdev_rol32(a, 25); \
3333
c ^= b; c -= bfdev_rol32(b, 16); \
34-
a ^= c; a -= bfdev_rol32(c, 4); \
34+
a ^= c; a -= bfdev_rol32(c, 4); \
3535
b ^= a; b -= bfdev_rol32(a, 14); \
3636
c ^= b; c -= bfdev_rol32(b, 24); \
3737
}

include/bfdev/minmax.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@ BFDEV_BEGIN_DECLS
1616
* @b: second value.
1717
*/
1818
#define bfdev_min(a, b) ({ \
19-
typeof(a) _amin = (a); \
20-
typeof(a) _bmin = (b); \
21-
(void)(&_amin == &_bmin); \
22-
_amin < _bmin ? _amin : _bmin; \
19+
typeof(a) __amin = (a); \
20+
typeof(a) __bmin = (b); \
21+
__amin < __bmin ? __amin : __bmin; \
2322
})
2423

2524
/**
@@ -28,10 +27,9 @@ BFDEV_BEGIN_DECLS
2827
* @b: second value.
2928
*/
3029
#define bfdev_max(a, b) ({ \
31-
typeof(a) _amax = (a); \
32-
typeof(a) _bmax = (b); \
33-
(void)(&_amax == &_bmax); \
34-
_amax > _bmax ? _amax : _bmax; \
30+
typeof(a) __amax = (a); \
31+
typeof(a) __bmax = (b); \
32+
__amax > __bmax ? __amax : __bmax; \
3533
})
3634

3735
/**

include/bfdev/prandom.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,12 @@ bfdev_prandom_value(bfdev_prandom_t *pstate);
6565
static inline uint64_t
6666
bfdev_prandom_u64(bfdev_prandom_t *pstate)
6767
{
68-
uint32_t high = bfdev_prandom_value(pstate);
69-
return ((uint64_t)high << 32) + bfdev_prandom_value(pstate);
68+
uint32_t high, low;
69+
70+
high = bfdev_prandom_value(pstate);
71+
low = bfdev_prandom_value(pstate);
72+
73+
return ((uint64_t)high << 32) | low;
7074
}
7175

7276
static inline unsigned long

src/allocator.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,15 @@
77
#include <bfdev/allocator.h>
88
#include <export.h>
99

10-
export bfdev_alloc_t
11-
bfdev_alloc_default;
10+
BFDEV_DEFINE_ALLOC(
11+
bfdev_alloc_default,
12+
NULL, NULL
13+
);
1214

13-
export bfdev_alloc_ops_t
14-
bfdev_alloc_default_ops;
15+
BFDEV_DEFINE_ALLOC_OPS(
16+
bfdev_alloc_default_ops,
17+
NULL, NULL, NULL, NULL
18+
);
1519

1620
#define __INSIDE_ALLOCATOR__
1721
#include <port/allocator.h>
@@ -75,10 +79,10 @@ bfdev_realloc(const bfdev_alloc_t *alloc, const void *block, size_t resize)
7579
const bfdev_alloc_ops_t *ops;
7680
void *pdata, *retval;
7781

78-
if (!block)
82+
if (bfdev_unlikely(!block))
7983
return bfdev_malloc(alloc, resize);
8084

81-
if (!resize) {
85+
if (bfdev_unlikely(!resize)) {
8286
bfdev_free(alloc, block);
8387
return NULL;
8488
}
@@ -98,7 +102,7 @@ bfdev_free(const bfdev_alloc_t *alloc, const void *block)
98102
const bfdev_alloc_ops_t *ops;
99103
void *pdata;
100104

101-
if (!block)
105+
if (bfdev_unlikely(!block))
102106
return;
103107

104108
ops = alloc_ops(alloc, &pdata);

src/sort.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ parent(size_t cells, unsigned int lsbit, size_t index)
3131
export int
3232
bfdev_sort(void *base, size_t num, size_t cells, bfdev_cmp_t cmp, void *pdata)
3333
{
34-
size_t size, idx1, idx2, idx3, idx4;
35-
unsigned int lsbit;
34+
size_t idx1, idx2, idx3, idx4;
35+
size_t size, lsbit;
3636

3737
idx1 = (num >> 1) * cells;
3838
if (bfdev_unlikely(!base || !cmp || !idx1))

testsuite/robustness.h

Lines changed: 0 additions & 144 deletions
This file was deleted.

0 commit comments

Comments
 (0)