From 662eaf1b0be528020b10311fc9c130f4039d4f81 Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Sun, 9 Jul 2017 22:43:40 +0200 Subject: include: Fix formatting in list.h --- include/ouroboros/hash.h | 1 - include/ouroboros/list.h | 24 ++++++++++++++---------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/include/ouroboros/hash.h b/include/ouroboros/hash.h index eeca8a28..456a93f3 100644 --- a/include/ouroboros/hash.h +++ b/include/ouroboros/hash.h @@ -31,7 +31,6 @@ #include #include - #define HASH_FMT "%02x%02x%02x%02x" #define HASH_VAL(hash) \ (betoh32(*(uint32_t *) hash) & 0xFF000000) >> 24, \ diff --git a/include/ouroboros/list.h b/include/ouroboros/list.h index 5da93b9a..8811e291 100644 --- a/include/ouroboros/list.h +++ b/include/ouroboros/list.h @@ -21,28 +21,32 @@ * 02110-1301 USA */ -#ifndef OUROBOROS_LIST_H -#define OUROBOROS_LIST_H +#ifndef OUROBOROS_LIB_LIST_H +#define OUROBOROS_LIB_LIST_H #include +#include #include struct list_head { - struct list_head * nxt, * prv; + struct list_head * nxt; + struct list_head * prv; }; #define list_entry(ptr, type, mbr) \ - ((type *)((char *)(ptr)-(size_t)(&((type *)0)->mbr))) + ((type *)((uint8_t *)(ptr)-(size_t)(&((type *)0)->mbr))) -#define list_first_entry(ptr, type, mbr) \ +#define list_first_entry(ptr, type, mbr) \ list_entry((ptr)->nxt, type, mbr) -#define list_for_each(p, h) \ +#define list_last_entry(ptr, type, mbr) \ + list_entry((ptr)->prv, type, mbr) + +#define list_for_each(p, h) \ for (p = (h)->nxt; p != (h); p = p->nxt) -#define list_for_each_safe(p, t, h) \ - for (p = (h)->nxt, t = p->nxt; p != (h); \ - p = t, t = p->nxt) +#define list_for_each_safe(p, t, h) \ + for (p = (h)->nxt, t = p->nxt; p != (h); p = t, t = p->nxt) void list_head_init(struct list_head * h); @@ -59,4 +63,4 @@ void list_move(struct list_head * dst, bool list_is_empty(struct list_head * h); -#endif +#endif /* OUROBOROS_LIB_LIST_H */ -- cgit v1.2.3