mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] file-list: remove unused variable
@ 2024-04-17  6:19 Sascha Hauer
  2024-04-17  6:45 ` Marco Felsch
  2024-04-19  6:25 ` Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Sascha Hauer @ 2024-04-17  6:19 UTC (permalink / raw)
  To: Barebox List; +Cc: Marco Felsch

struct file_list::num_entries is only ever used to check if a file list
is empty. Do this check with list_empty() instead and remove the unused
member.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 common/file-list.c  | 6 +-----
 include/file-list.h | 3 +--
 2 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/common/file-list.c b/common/file-list.c
index 7ecc8d00bb..3867e79c09 100644
--- a/common/file-list.c
+++ b/common/file-list.c
@@ -194,8 +194,6 @@ struct file_list *file_list_parse(const char *str)
 			goto out;
 		}
 		str = endptr;
-
-		files->num_entries++;
 	}
 
 	return files;
@@ -244,11 +242,9 @@ struct file_list *file_list_dup(struct file_list *old)
 
 	new = file_list_new();
 
-	list_for_each_entry(old_entry, &old->list, list) {
+	list_for_each_entry(old_entry, &old->list, list)
 		(void)file_list_add_entry(new, old_entry->name, old_entry->filename,
 					  old_entry->flags); /* can't fail */
-		new->num_entries++;
-	}
 
 	return new;
 }
diff --git a/include/file-list.h b/include/file-list.h
index 79190b0f19..1625f116a0 100644
--- a/include/file-list.h
+++ b/include/file-list.h
@@ -21,7 +21,6 @@ struct file_list_entry {
 
 struct file_list {
 	struct list_head list;
-	int num_entries;
 };
 
 struct file_list *file_list_parse(const char *str);
@@ -47,7 +46,7 @@ struct file_list_entry *file_list_entry_by_name(struct file_list *files, const c
 
 static inline bool file_list_empty(struct file_list *files)
 {
-	return !files || !files->num_entries;
+	return !files || list_empty(&files->list);
 }
 
 #endif /* __FILE_LIST */
-- 
2.39.2




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-04-19  6:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-17  6:19 [PATCH] file-list: remove unused variable Sascha Hauer
2024-04-17  6:45 ` Marco Felsch
2024-04-19  6:25 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox