From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp49.i.mail.ru (smtp49.i.mail.ru [94.100.177.109]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 9DD954696C7 for ; Fri, 10 Apr 2020 05:51:07 +0300 (MSK) From: Alexander Turenko Date: Fri, 10 Apr 2020 05:50:40 +0300 Message-Id: <08253f9ff92aaff6b7017f6139a0c3679888e2d4.1586486220.git.alexander.turenko@tarantool.org> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 02/13] popen: remove retval from popen_state() List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Cyrill Gorcunov Cc: tarantool-patches@dev.tarantool.org After the previous commit ('popen: require popen handle to be non-NULL') it turns out that popen_state() function always succeeds. There is no reason to return a success / failure value from it. Part of #4031 --- src/lib/core/popen.c | 4 +--- src/lib/core/popen.h | 2 +- test/unit/popen.c | 8 +++----- test/unit/popen.result | 13 ++++++------- 4 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/lib/core/popen.c b/src/lib/core/popen.c index 5f74bc3ce..3a0ac4b53 100644 --- a/src/lib/core/popen.c +++ b/src/lib/core/popen.c @@ -374,7 +374,7 @@ popen_sigchld_handler(EV_P_ ev_child *w, int revents) /** * Get current child state. */ -int +void popen_state(struct popen_handle *handle, int *state, int *exit_code) { assert(handle != NULL); @@ -391,8 +391,6 @@ popen_state(struct popen_handle *handle, int *state, int *exit_code) *exit_code = WTERMSIG(handle->wstatus); } } - - return 0; } /** diff --git a/src/lib/core/popen.h b/src/lib/core/popen.h index 9cbfed60c..587d6f7df 100644 --- a/src/lib/core/popen.h +++ b/src/lib/core/popen.h @@ -163,7 +163,7 @@ popen_read_timeout(struct popen_handle *handle, void *buf, size_t count, unsigned int flags, ev_tstamp timeout); -extern int +extern void popen_state(struct popen_handle *handle, int *state, int *exit_code); extern const char * diff --git a/test/unit/popen.c b/test/unit/popen.c index caea9d552..b71e5485b 100644 --- a/test/unit/popen.c +++ b/test/unit/popen.c @@ -26,8 +26,7 @@ static int wait_exit(struct popen_handle *handle, int *state, int *exit_code) { for (;;) { - if (popen_state(handle, state, exit_code)) - return -1; + popen_state(handle, state, exit_code); if (*state == POPEN_STATE_EXITED || *state == POPEN_STATE_SIGNALED) break; @@ -61,7 +60,7 @@ popen_write_exit(void) }; int rc; - plan(7); + plan(6); header(); handle = popen_new(&opts); @@ -69,8 +68,7 @@ popen_write_exit(void) if (handle == NULL) goto out; - rc = popen_state(handle, &state, &exit_code); - ok(rc == 0, "popen_state"); + popen_state(handle, &state, &exit_code); ok(state == POPEN_STATE_ALIVE, "state %s", popen_state_str(state)); diff --git a/test/unit/popen.result b/test/unit/popen.result index d7894d1db..f5e6bc2ca 100644 --- a/test/unit/popen.result +++ b/test/unit/popen.result @@ -1,14 +1,13 @@ 1..3 *** main_f *** - 1..7 + 1..6 *** popen_write_exit *** ok 1 - popen_new - ok 2 - popen_state - ok 3 - state alive - ok 4 - write flag check - ok 5 - write to pipe - ok 6 - child exited - ok 7 - popen_delete + ok 2 - state alive + ok 3 - write flag check + ok 4 - write to pipe + ok 5 - child exited + ok 6 - popen_delete *** popen_write_exit: done *** ok 1 - subtests 1..5 -- 2.25.0