From 3f9735b3a48beef751b4b02240c3cab188f61c6c Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 25 Aug 2021 20:38:57 -0700 Subject: [PATCH] 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. --- include/slist.h | 71 ++++++++++++++++++++++--------------------------- 1 file changed, 32 insertions(+), 39 deletions(-) diff --git a/include/slist.h b/include/slist.h index 3a9a86f..e7e9eaf 100644 --- a/include/slist.h +++ b/include/slist.h @@ -18,46 +18,39 @@ #ifndef __iscsi_slist_h__ #define __iscsi_slist_h__ -#define ISCSI_LIST_ADD(list, item) \ - do { \ - (item)->next = (*list); \ - (*list) = (item); \ - } while (0); +#define ISCSI_LIST_ADD(list, item) \ +do { \ + (item)->next = (*list); \ + (*list) = (item); \ +} while (0) -#define ISCSI_LIST_ADD_END(list, item) \ - if ((*list) == NULL) { \ - ISCSI_LIST_ADD((list), (item)); \ - } else { \ - typeof(*list) head = (*list); \ - while ((*list)->next) \ - (*list) = (*list)->next; \ - (*list)->next = (item); \ - (item)->next = NULL; \ - (*list) = head; \ - } +#define ISCSI_LIST_ADD_END(list, item) \ +do { \ + if ((*list) == NULL) { \ + ISCSI_LIST_ADD((list), (item)); \ + } else { \ + typeof(*list) head = (*list); \ + while ((*list)->next) \ + (*list) = (*list)->next; \ + (*list)->next = (item); \ + (item)->next = NULL; \ + (*list) = head; \ + } \ +} while (0) -#define ISCSI_LIST_REMOVE(list, item) \ - if ((*list) == (item)) { \ - (*list) = (item)->next; \ - } else { \ - typeof(*list) head = (*list); \ - while ((*list)->next && (*list)->next != (item)) \ - (*list) = (*list)->next; \ - if ((*list)->next != NULL) { \ - (*list)->next = (*list)->next->next; \ - } \ - (*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); +#define ISCSI_LIST_REMOVE(list, item) \ +do { \ + if ((*list) == (item)) { \ + (*list) = (item)->next; \ + } else { \ + typeof(*list) head = (*list); \ + while ((*list)->next && (*list)->next != (item)) \ + (*list) = (*list)->next; \ + if ((*list)->next != NULL) { \ + (*list)->next = (*list)->next->next; \ + } \ + (*list) = head; \ + } \ +} while (0) #endif /* __iscsi_slist_h__ */