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.ha...@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


Reply via email to