Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
No build reason found for SLE-Module-Basesystem:ppc64le
SUSE:SLE-15:Update
grub2.20933
0025-kern-parser-Refactor-grub_parser_split_cmd...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0025-kern-parser-Refactor-grub_parser_split_cmdline-clean.patch of Package grub2.20933
From 8b7392e91fad0affed613907c2a34a9de48bfaa6 Mon Sep 17 00:00:00 2001 From: Chris Coulson <chris.coulson@canonical.com> Date: Wed, 6 Jan 2021 13:54:26 +0000 Subject: [PATCH 25/41] kern/parser: Refactor grub_parser_split_cmdline() cleanup Introduce a common function epilogue used for cleaning up on all return paths, which will simplify additional error handling to be introduced in a subsequent commit. Signed-off-by: Chris Coulson <chris.coulson@canonical.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com> --- grub-core/kern/parser.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/grub-core/kern/parser.c b/grub-core/kern/parser.c index 572c67089..e010eaa1f 100644 --- a/grub-core/kern/parser.c +++ b/grub-core/kern/parser.c @@ -221,19 +221,13 @@ grub_parser_split_cmdline (const char *cmdline, if (process_char (*rp, buffer, &bp, varname, &vp, state, argc, &newstate) != GRUB_ERR_NONE) - { - if (rd != cmdline) - grub_free (rd); - return grub_errno; - } + goto fail; + state = newstate; } } while (state != GRUB_PARSER_STATE_TEXT && !check_varstate (state)); - if (rd != cmdline) - grub_free (rd); - /* A special case for when the last character was part of a variable. */ add_var (varname, &bp, &vp, state, GRUB_PARSER_STATE_TEXT); @@ -243,20 +237,20 @@ grub_parser_split_cmdline (const char *cmdline, /* If there are no args, then we're done. */ if (!*argc) - return 0; + { + grub_errno = GRUB_ERR_NONE; + goto out; + } /* Reserve memory for the return values. */ args = grub_malloc (bp - buffer); if (!args) - return grub_errno; + goto fail; grub_memcpy (args, buffer, bp - buffer); *argv = grub_calloc (*argc + 1, sizeof (char *)); if (!*argv) - { - grub_free (args); - return grub_errno; - } + goto fail; /* The arguments are separated with 0's, setup argv so it points to the right values. */ @@ -269,7 +263,18 @@ grub_parser_split_cmdline (const char *cmdline, bp++; } - return 0; + grub_errno = GRUB_ERR_NONE; + + out: + if (rd != cmdline) + grub_free (rd); + + return grub_errno; + + fail: + grub_free (*argv); + grub_free (args); + goto out; } /* Helper for grub_parser_execute. */ -- 2.26.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor