diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-06-13 06:18:15 +0200 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-06-21 10:04:00 +0200 |
| commit | a90e2c0fce7ce74478c3a5e497daafa9effdc4a5 (patch) | |
| tree | 7735a7e522f20e1e606399b1309bda2cb935e21c | |
| parent | e9a15348b7783140834f3b2ccf968afa3068eae0 (diff) | |
| download | sparse-dev-a90e2c0fce7ce74478c3a5e497daafa9effdc4a5.tar.gz | |
ptrlist: keep declaration of head-list-nr together
The list walking macros need to keep some state:
- the head of the list: head
- the current list 'block': list
- the current position in the block: nr
Make this clear by keeping their declaration together.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
| -rw-r--r-- | ptrlist.h | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -124,9 +124,10 @@ extern void __free_ptr_list(struct ptr_list **); #define DO_FOR_EACH(head, ptr, __head, __list, __nr, PTR_ENTRY) do { \ __typeof__(head) __head = (head); \ __typeof__(head) __list = __head; \ + int __nr; \ if (!__head) \ break; \ - do { int __nr; \ + do { \ for (__nr = 0; __nr < __list->nr; __nr++) { \ ptr = PTR_ENTRY(__list,__nr); \ if (__list->rm && !ptr) \ @@ -140,9 +141,10 @@ extern void __free_ptr_list(struct ptr_list **); #define DO_FOR_EACH_REVERSE(head, ptr, __head, __list, __nr, PTR_ENTRY) do { \ __typeof__(head) __head = (head); \ __typeof__(head) __list = __head; \ + int __nr; \ if (!head) \ break; \ - do { int __nr; \ + do { \ __list = __list->prev; \ __nr = __list->nr; \ while (--__nr >= 0) { \ |
