From 490c6927e0a997c48a9c21649491272b777b70d3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Wed, 1 Mar 2017 08:59:51 +0100 Subject: [PATCH] TP 9 exo2: Simplify the return value handling in the list counting function. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- TP_9/exo2/clist.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/TP_9/exo2/clist.c b/TP_9/exo2/clist.c index db08117..2857042 100644 --- a/TP_9/exo2/clist.c +++ b/TP_9/exo2/clist.c @@ -32,9 +32,10 @@ link_t* list_prepend(link_t* head, int value) { } unsigned list_count(link_t* head) { - int count = 1; + int count = 0; - if (head == NULL) { return 0; } + if (head == NULL) { return count; } + count = 1; while (head->next != NULL) { ++count; head = head->next; -- 2.34.1