diff options
author | Tiago Vignatti <tiago.vignatti@nokia.com> | 2011-03-31 17:46:42 +0300 |
---|---|---|
committer | Tiago Vignatti <tiago.vignatti@nokia.com> | 2011-04-07 19:55:29 +0300 |
commit | 74476b700f1e499a731ba2ddbba87b12b9b5139b (patch) | |
tree | c4e835c404b3ca67b9128220863c8261ef26edf2 /hw/xfree86/loader | |
parent | 7aad7dbf409eaa16a2c80d76ba2a42dc84501919 (diff) |
xfree86: loader: use one exit code only for readability
No functional changes. Spaghetti code for the win! \o/
Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Reviewed-by: Nicolas Peninguy <nico@lostgeeks.org>
Diffstat (limited to 'hw/xfree86/loader')
-rw-r--r-- | hw/xfree86/loader/loadmod.c | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c index 46ce68b86..9f820993a 100644 --- a/hw/xfree86/loader/loadmod.c +++ b/hw/xfree86/loader/loadmod.c @@ -483,19 +483,15 @@ LoaderListDirs(const char **subdirlist, const char **patternlist) char *fp; char **listing = NULL; char **save; + char **ret = NULL; int n = 0; if (!(pathlist = InitPathList(NULL))) return NULL; - if (!(subdirs = InitSubdirs(subdirlist))) { - FreePathList(pathlist); - return NULL; - } - if (!(patterns = InitPatterns(patternlist))) { - FreePathList(pathlist); - FreeSubdirs(subdirs); - return NULL; - } + if (!(subdirs = InitSubdirs(subdirlist))) + goto bail; + if (!(patterns = InitPatterns(patternlist))) + goto bail; for (elem = pathlist; *elem; elem++) { for (s = subdirs; *s; s++) { @@ -529,20 +525,14 @@ LoaderListDirs(const char **subdirlist, const char **patternlist) save[n] = NULL; FreeStringList(save); } - FreePathList(pathlist); - FreeSubdirs(subdirs); - FreePatterns(patterns); closedir(d); - return NULL; + goto bail; } listing[n] = malloc(len + 1); if (!listing[n]) { FreeStringList(listing); - FreePathList(pathlist); - FreeSubdirs(subdirs); - FreePatterns(patterns); closedir(d); - return NULL; + goto bail; } strncpy(listing[n], dp->d_name + match[1].rm_so, len); @@ -558,11 +548,13 @@ LoaderListDirs(const char **subdirlist, const char **patternlist) } if (listing) listing[n] = NULL; + ret = listing; - FreePathList(pathlist); - FreeSubdirs(subdirs); +bail: FreePatterns(patterns); - return listing; + FreeSubdirs(subdirs); + FreePathList(pathlist); + return ret; } void |