summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2022-05-11 14:01:46 -0400
committerTavian Barnes <tavianator@tavianator.com>2022-05-11 14:01:46 -0400
commit4a326416b078de06f1cf542963dab57a20846f95 (patch)
tree02e9d715b562e94c233cc85fc5a401a51d2b3af0
parent885189800c124ed7d7d3223c4d3dde1a3537cecf (diff)
downloadbfs-4a326416b078de06f1cf542963dab57a20846f95.tar.xz
main: Avoid a goto
-rw-r--r--src/main.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/main.c b/src/main.c
index 9dc96e4..b8ee6d0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -117,25 +117,24 @@ static int open_std_streams(void) {
* bfs entry point.
*/
int main(int argc, char *argv[]) {
- int ret = EXIT_FAILURE;
-
// Make sure the standard streams are open
if (open_std_streams() != 0) {
- goto done;
+ return EXIT_FAILURE;
}
// Use the system locale instead of "C"
setlocale(LC_ALL, "");
struct bfs_ctx *ctx = bfs_parse_cmdline(argc, argv);
- if (ctx) {
- ret = bfs_eval(ctx);
+ if (!ctx) {
+ return EXIT_FAILURE;
}
+ int ret = bfs_eval(ctx);
+
if (bfs_ctx_free(ctx) != 0 && ret == EXIT_SUCCESS) {
ret = EXIT_FAILURE;
}
-done:
return ret;
}