From 6ced2a50056acbf7caec404a1edfa3b07fa1ac5d Mon Sep 17 00:00:00 2001 From: Thomas Schmucker Date: Wed, 29 Dec 2021 10:48:03 +0100 Subject: feat: remove NULL-checks --- list.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'list.c') diff --git a/list.c b/list.c index 6117670..5a6c732 100644 --- a/list.c +++ b/list.c @@ -25,7 +25,7 @@ list_add(struct list_item *next, T data) struct list_item *new_item; new_item = malloc(sizeof *new_item); - if ( new_item != NULL ) { + if ( new_item ) { new_item->data = data; new_item->next = next; } @@ -44,7 +44,7 @@ list_insert_next(struct list_item *list, T data) struct list_item *new_item; new_item = malloc(sizeof *new_item); - if ( new_item != NULL ) { + if ( new_item ) { new_item->data = data; new_item->next = list->next; list->next = new_item; @@ -76,7 +76,7 @@ list_delete(struct list_item *list, T data) } prev = p; } -#if LIST_REPORT_ERROR +#ifdef LIST_REPORT_ERROR ERROR("data not found"); #endif return list; @@ -87,7 +87,7 @@ list_delete(struct list_item *list, T data) void list_delete_next(struct list_item *list) { - if ( list->next != NULL ) { + if ( list->next ) { struct list_item *temp = list->next; list->next = list->next->next; @@ -119,7 +119,7 @@ list_copy(struct list_item *list) for ( ; list; list = list->next ) { *p = malloc(sizeof **p); - if ( *p != NULL ) { + if ( *p ) { (*p)->data = list->data; // copy elements p = &(*p)->next; } @@ -164,7 +164,7 @@ list_merge(struct list_item *a, struct list_item *b) struct list_item dummy = { .next = NULL }; struct list_item *head = &dummy, *c = head; - while ( a != NULL && b != NULL ) + while ( a && b ) if ( a->data < b->data ) { c->next = a, c = a, a = a->next; } @@ -172,7 +172,7 @@ list_merge(struct list_item *a, struct list_item *b) c->next = b, c = b, b = b->next; } - c->next = (a != NULL) ? a : b; + c->next = a ? a : b; return head->next; } @@ -188,7 +188,7 @@ list_sort(struct list_item *c) struct list_item *a = c, *b = c->next; - while ( b != NULL && b->next != NULL ) { + while ( b && b->next ) { c = c->next, b = b->next->next; } -- cgit v1.3