diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2022-05-11 14:01:46 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2022-05-11 14:01:46 -0400 |
commit | 4a326416b078de06f1cf542963dab57a20846f95 (patch) | |
tree | 02e9d715b562e94c233cc85fc5a401a51d2b3af0 | |
parent | 885189800c124ed7d7d3223c4d3dde1a3537cecf (diff) | |
download | bfs-4a326416b078de06f1cf542963dab57a20846f95.tar.xz |
main: Avoid a goto
-rw-r--r-- | src/main.c | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -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; } |