From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Cc: Marco Felsch <m.felsch@pengutronix.de>
Subject: [PATCH] file-list: remove unused variable
Date: Wed, 17 Apr 2024 08:19:36 +0200 [thread overview]
Message-ID: <20240417061936.3104764-1-s.hauer@pengutronix.de> (raw)
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
next reply other threads:[~2024-04-17 6:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-17 6:19 Sascha Hauer [this message]
2024-04-17 6:45 ` Marco Felsch
2024-04-19 6:25 ` Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240417061936.3104764-1-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=m.felsch@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox