Changed return from int to bool

This commit is contained in:
carlosgp143@gmail.com 2018-05-31 10:11:56 +02:00
parent 259f6c06d7
commit 2049ce09ed
3 changed files with 7 additions and 5 deletions

View File

@ -334,16 +334,16 @@ list_item_next(void *item)
* 0 if the list does not contain the item, and 1 if the item
* is present in the list.
*/
int
bool
list_contains(list_t list, void *item)
{
struct list *l;
for(l = *list; l != NULL; l = l->next) {
if(item == l) {
return 1;
return true;
}
}
return 0;
return false;
}
/*---------------------------------------------------------------------------*/
/** @} */

View File

@ -66,6 +66,8 @@
#ifndef LIST_H_
#define LIST_H_
#include <stdbool.h>
#define LIST_CONCAT2(s1, s2) s1##s2
#define LIST_CONCAT(s1, s2) LIST_CONCAT2(s1, s2)
@ -151,7 +153,7 @@ void list_insert(list_t list, void *previtem, void *newitem);
void * list_item_next(void *item);
int list_contains(list_t list, void *item);
bool list_contains(list_t list, void *item);
#endif /* LIST_H_ */

View File

@ -167,7 +167,7 @@ UNIT_TEST(test_list)
UNIT_TEST_ASSERT(list_contains(lst, &elements[3]));
int i;
for(i=4; i<ELEMENT_COUNT; i++) {
UNIT_TEST_ASSERT(list_contains(lst, &elements[i]) == 0);
UNIT_TEST_ASSERT(!list_contains(lst, &elements[i]));
}
/*
* Remove the tail