aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorhexcoder- <heiko@hexco.de>2020-04-02 17:00:58 +0200
committerhexcoder- <heiko@hexco.de>2020-04-02 17:00:58 +0200
commit71f0bd003fed0867b1d5e8d3e75dd8a4721cd00a (patch)
tree83c9596a0a70bb46e1cbe86c37ffac8f1492bf04 /include
parentcc65e91eeba541aa9e3b42e81df3d752814eff21 (diff)
parent2ae0208d3be8ffba76f6cf370c99efa05429ad69 (diff)
downloadafl++-71f0bd003fed0867b1d5e8d3e75dd8a4721cd00a.tar.gz
Merge branch 'dev' of https://github.com/vanhauser-thc/AFLplusplus into dev
Diffstat (limited to 'include')
-rw-r--r--include/afl-fuzz.h6
-rw-r--r--include/list.h35
2 files changed, 20 insertions, 21 deletions
diff --git a/include/afl-fuzz.h b/include/afl-fuzz.h
index a9165064..56135d0e 100644
--- a/include/afl-fuzz.h
+++ b/include/afl-fuzz.h
@@ -935,13 +935,13 @@ u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len,
static inline u32 rand_below(afl_state_t *afl, u32 limit) {
#ifdef HAVE_ARC4RANDOM
- if (afl->fixed_seed) { return random() % limit; }
+ if (unlikely(afl->fixed_seed)) { return random() % limit; }
/* The boundary not being necessarily a power of 2,
we need to ensure the result uniformity. */
return arc4random_uniform(limit);
#else
- if (!afl->fixed_seed && unlikely(!afl->rand_cnt--)) {
+ if (unlikely(!afl->rand_cnt--) && likely(!afl->fixed_seed)) {
ck_read(afl->fsrv.dev_urandom_fd, &afl->rand_seed, sizeof(afl->rand_seed),
"/dev/urandom");
@@ -957,7 +957,7 @@ static inline u32 rand_below(afl_state_t *afl, u32 limit) {
static inline u32 get_rand_seed(afl_state_t *afl) {
- if (afl->fixed_seed) return (u32)afl->init_seed;
+ if (unlikely(afl->fixed_seed)) return (u32)afl->init_seed;
return afl->rand_seed[0];
}
diff --git a/include/list.h b/include/list.h
index d9cd9d34..e93b4e8f 100644
--- a/include/list.h
+++ b/include/list.h
@@ -98,24 +98,23 @@ static inline void list_append(list_t *list, void *el) {
A return from this block will return from calling func.
*/
-#define LIST_FOREACH(list, type, block) \
- do { \
- \
- list_t * li = (list); \
- element_t *head = get_head((li)); \
- element_t *el_box = (head)->next; \
- if (!el_box) FATAL("foreach over uninitialized list"); \
- while (el_box != head) { \
- \
- __attribute__((unused)) \
- type *el = (type *)((el_box)->data); \
- /* get next so el_box can be unlinked */ \
- element_t *next = el_box->next; \
- {block}; \
- el_box = next; \
- \
- } \
- \
+#define LIST_FOREACH(list, type, block) \
+ do { \
+ \
+ list_t * li = (list); \
+ element_t *head = get_head((li)); \
+ element_t *el_box = (head)->next; \
+ if (!el_box) FATAL("foreach over uninitialized list"); \
+ while (el_box != head) { \
+ \
+ __attribute__((unused)) type *el = (type *)((el_box)->data); \
+ /* get next so el_box can be unlinked */ \
+ element_t *next = el_box->next; \
+ {block}; \
+ el_box = next; \
+ \
+ } \
+ \
} while (0);
/* In foreach: remove the current el from the list */