slist: Clean up the slist.h header file

Fix indentation, align backslashes, surround multiline macros with
do { } while (0) and remove the unused ISCSI_LIST_LENGTH() macro.
This commit is contained in:
Bart Van Assche
2021-08-25 20:38:57 -07:00
parent 6b93325b39
commit 3f9735b3a4

View File

@@ -19,12 +19,13 @@
#define __iscsi_slist_h__ #define __iscsi_slist_h__
#define ISCSI_LIST_ADD(list, item) \ #define ISCSI_LIST_ADD(list, item) \
do { \ do { \
(item)->next = (*list); \ (item)->next = (*list); \
(*list) = (item); \ (*list) = (item); \
} while (0); } while (0)
#define ISCSI_LIST_ADD_END(list, item) \ #define ISCSI_LIST_ADD_END(list, item) \
do { \
if ((*list) == NULL) { \ if ((*list) == NULL) { \
ISCSI_LIST_ADD((list), (item)); \ ISCSI_LIST_ADD((list), (item)); \
} else { \ } else { \
@@ -34,9 +35,11 @@
(*list)->next = (item); \ (*list)->next = (item); \
(item)->next = NULL; \ (item)->next = NULL; \
(*list) = head; \ (*list) = head; \
} } \
} while (0)
#define ISCSI_LIST_REMOVE(list, item) \ #define ISCSI_LIST_REMOVE(list, item) \
do { \
if ((*list) == (item)) { \ if ((*list) == (item)) { \
(*list) = (item)->next; \ (*list) = (item)->next; \
} else { \ } else { \
@@ -47,17 +50,7 @@
(*list)->next = (*list)->next->next; \ (*list)->next = (*list)->next->next; \
} \ } \
(*list) = head; \ (*list) = head; \
}
#define ISCSI_LIST_LENGTH(list,length) \
do { \
(length) = 0; \
typeof(*list) head = (*list); \
while ((*list)) { \
(*list) = (*list)->next; \
(length)++; \
} \ } \
(*list) = head; \ } while (0)
} while (0);
#endif /* __iscsi_slist_h__ */ #endif /* __iscsi_slist_h__ */