From 861ba2a6cb2a9691b7fd70f17be89b68833d70b4 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Thu, 12 Mar 2020 10:10:08 -0700 Subject: [PATCH] vtest: replace gotos by a loop in main Get rid of gotos so that it will be easier when we turn vtest_server_run_renderer into the main loop. Signed-off-by: Chia-I Wu Reviewed-By: Gert Wollny Reviewed-By: Gurchetan Singh --- vtest/vtest_server.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/vtest/vtest_server.c b/vtest/vtest_server.c index ad3f026..d24ed83 100644 --- a/vtest/vtest_server.c +++ b/vtest/vtest_server.c @@ -117,32 +117,28 @@ while (__AFL_LOOP(1000)) { vtest_server_getenv(); vtest_server_parse_args(argc, argv); - if (server.read_file != NULL) { - vtest_server_open_read_file(); - goto start; - } - if (server.do_fork) { vtest_server_set_signal_child(); } else { vtest_server_set_signal_segv(); } - vtest_server_open_socket(); -restart: - vtest_server_wait_for_socket_accept(); - -start: - vtest_server_run_renderer(&server.client); + if (server.read_file != NULL) { + vtest_server_open_read_file(); + vtest_server_run_renderer(&server.client); + vtest_server_tidy_fds(); + } else { + vtest_server_open_socket(); - vtest_server_tidy_fds(); + do { + vtest_server_wait_for_socket_accept(); + vtest_server_run_renderer(&server.client); + vtest_server_tidy_fds(); + } while (server.loop); - if (server.loop) { - goto restart; + vtest_server_close_socket(); } - vtest_server_close_socket(); - #ifdef __AFL_LOOP if (!server.main_server) { exit(0);