From: Sascha Hauer <sha@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH master 1/2] file_list: factor out file_list_new
Date: Mon, 8 Aug 2022 15:13:43 +0200 [thread overview]
Message-ID: <20220808131343.GO31528@pengutronix.de> (raw)
In-Reply-To: <20220730094615.1762042-1-a.fatoum@pengutronix.de>
On Sat, Jul 30, 2022 at 11:46:14AM +0200, Ahmad Fatoum wrote:
> We have the sequence for creating a new file_list at two places and
> follow-up commit will add a third one outside of the file, so it's a
> good occasion to use a common helper. No functional change.
>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> common/file-list.c | 19 +++++++++++++------
> include/file-list.h | 1 +
> 2 files changed, 14 insertions(+), 6 deletions(-)
Applied, thanks
Sascha
>
> diff --git a/common/file-list.c b/common/file-list.c
> index 407b31283373..11db7c6e44c7 100644
> --- a/common/file-list.c
> +++ b/common/file-list.c
> @@ -130,16 +130,25 @@ static const char *flags_to_str(int flags)
> return str;
> }
>
> -struct file_list *file_list_parse(const char *str)
> +struct file_list *file_list_new(void)
> {
> struct file_list *files;
> - int ret;
> - const char *endptr;
>
> files = xzalloc(sizeof(*files));
>
> INIT_LIST_HEAD(&files->list);
>
> + return files;
> +}
> +
> +struct file_list *file_list_parse(const char *str)
> +{
> + struct file_list *files;
> + int ret;
> + const char *endptr;
> +
> + files = file_list_new();
> +
> while (*str) {
> ret = file_list_parse_one(files, str, &endptr);
> if (ret) {
> @@ -195,9 +204,7 @@ struct file_list *file_list_dup(struct file_list *old)
> struct file_list_entry *old_entry;
> struct file_list *new;
>
> - new = xzalloc(sizeof(*new));
> -
> - INIT_LIST_HEAD(&new->list);
> + new = file_list_new();
>
> list_for_each_entry(old_entry, &old->list, list) {
> (void)file_list_add_entry(new, old_entry->name, old_entry->filename,
> diff --git a/include/file-list.h b/include/file-list.h
> index 5090313739b8..af0dd7bbf108 100644
> --- a/include/file-list.h
> +++ b/include/file-list.h
> @@ -29,6 +29,7 @@ void file_list_free(struct file_list *);
> int file_list_add_entry(struct file_list *files, const char *name, const char *filename,
> unsigned long flags);
>
> +struct file_list *file_list_new(void);
> struct file_list *file_list_dup(struct file_list *old);
>
> int file_list_detect_all(const struct file_list *files);
> --
> 2.30.2
>
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
prev parent reply other threads:[~2022-08-08 13:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-30 9:46 Ahmad Fatoum
2022-07-30 9:46 ` [PATCH master 2/2] USB: gadget: fastboot: allow exporting only barebox update handler Ahmad Fatoum
2022-08-08 13:13 ` Sascha Hauer [this message]
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=20220808131343.GO31528@pengutronix.de \
--to=sha@pengutronix.de \
--cc=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/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