From: Rouven Czerwinski <r.czerwinski@pengutronix.de> To: barebox@lists.infradead.org Cc: Rouven Czerwinski <r.czerwinski@pengutronix.de> Subject: [PATCH v2 1/2] file_list: add file_list_parse_null() Date: Tue, 10 Aug 2021 07:29:27 +0200 Message-ID: <20210810052928.101783-1-r.czerwinski@pengutronix.de> (raw) Move the usbgadget parse() function to file_list and rename it to file_list_parse_null() which will return a NULL pointer instead of an error. Also adjust the callers in the usbgadget code. Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> --- v2: rebase on master to fix USB mass storage conflict --- common/file-list.c | 16 ++++++++++++++++ common/usbgadget.c | 24 ++++-------------------- include/file-list.h | 1 + 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/common/file-list.c b/common/file-list.c index 05f44514fb..407b312833 100644 --- a/common/file-list.c +++ b/common/file-list.c @@ -158,6 +158,22 @@ out: return ERR_PTR(ret); } +struct file_list *file_list_parse_null(const char *files) +{ + struct file_list *list; + + if (!files) + return NULL; + + list = file_list_parse(files); + if (IS_ERR(list)) { + pr_err("Parsing file list \"%s\" failed: %pe\n", files, list); + return NULL; + } + + return list; +} + void file_list_free(struct file_list *files) { struct file_list_entry *entry, *tmp; diff --git a/common/usbgadget.c b/common/usbgadget.c index 34a685234b..e8c9f7d236 100644 --- a/common/usbgadget.c +++ b/common/usbgadget.c @@ -23,26 +23,10 @@ static int autostart; static int acm; static char *dfu_function; -static struct file_list *parse(const char *files) -{ - struct file_list *list; - - if (!files) - return NULL; - - list = file_list_parse(files); - if (IS_ERR(list)) { - pr_err("Parsing file list \"%s\" failed: %pe\n", files, list); - return NULL; - } - - return list; -} - static inline struct file_list *get_dfu_function(void) { if (dfu_function && *dfu_function) - return file_list_parse(dfu_function); + return file_list_parse_null(dfu_function); if (!system_partitions_empty()) return system_partitions_get(); return NULL; @@ -59,7 +43,7 @@ int usbgadget_register(const struct usbgadget_funcs *funcs) opts->release = usb_multi_opts_release; if (flags & USBGADGET_DFU) { - opts->dfu_opts.files = parse(funcs->dfu_opts); + opts->dfu_opts.files = file_list_parse_null(funcs->dfu_opts); if (IS_ENABLED(CONFIG_USB_GADGET_DFU) && file_list_empty(opts->dfu_opts.files)) { file_list_free(opts->dfu_opts.files); opts->dfu_opts.files = get_dfu_function(); @@ -67,7 +51,7 @@ int usbgadget_register(const struct usbgadget_funcs *funcs) } if (flags & USBGADGET_MASS_STORAGE) { - opts->ums_opts.files = parse(funcs->ums_opts); + opts->ums_opts.files = file_list_parse_null(funcs->ums_opts); if (IS_ENABLED(CONFIG_USB_GADGET_MASS_STORAGE) && file_list_empty(opts->ums_opts.files)) { file_list_free(opts->ums_opts.files); opts->ums_opts.files = system_partitions_get(); @@ -75,7 +59,7 @@ int usbgadget_register(const struct usbgadget_funcs *funcs) } if (flags & USBGADGET_FASTBOOT) { - opts->fastboot_opts.files = parse(funcs->fastboot_opts); + opts->fastboot_opts.files = file_list_parse_null(funcs->fastboot_opts); if (IS_ENABLED(CONFIG_FASTBOOT_BASE) && file_list_empty(opts->fastboot_opts.files)) { file_list_free(opts->fastboot_opts.files); opts->fastboot_opts.files = get_fastboot_partitions(); diff --git a/include/file-list.h b/include/file-list.h index 7e2a4d9205..5090313739 100644 --- a/include/file-list.h +++ b/include/file-list.h @@ -22,6 +22,7 @@ struct file_list { }; struct file_list *file_list_parse(const char *str); +struct file_list *file_list_parse_null(const char *str); char *file_list_to_str(const struct file_list *files); void file_list_free(struct file_list *); -- 2.32.0 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
next reply other threads:[~2021-08-10 5:32 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-08-10 5:29 Rouven Czerwinski [this message] 2021-08-10 5:29 ` [PATCH v2 2/2] fastboot: use file_list_parse_null() Rouven Czerwinski 2021-08-23 13:48 ` [PATCH v2 1/2] file_list: add file_list_parse_null() 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=20210810052928.101783-1-r.czerwinski@pengutronix.de \ --to=r.czerwinski@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
mail archive of the barebox mailing list This inbox may be cloned and mirrored by anyone: git clone --mirror https://lore.barebox.org/barebox/0 barebox/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 barebox barebox/ https://lore.barebox.org/barebox \ barebox@lists.infradead.org barebox@lists.infradead.org public-inbox-index barebox Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git