From 4a326416b078de06f1cf542963dab57a20846f95 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Wed, 11 May 2022 14:01:46 -0400 Subject: main: Avoid a goto --- src/main.c | 11 +++++------ 1 file 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; } -- cgit v1.2.3