From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp45.i.mail.ru (smtp45.i.mail.ru [94.100.177.105]) (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 569284696C3 for ; Wed, 15 Apr 2020 07:53:02 +0300 (MSK) From: Alexander Turenko Date: Wed, 15 Apr 2020 07:52:55 +0300 Message-Id: <1a4540cd925a1cefb41013d15f90b3883ff3e302.1586926230.git.alexander.turenko@tarantool.org> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 14/14] popen: fix popen_write_timeout retval type List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Cyrill Gorcunov Cc: tarantool-patches@dev.tarantool.org On Linux x86_64 `ssize_t` is 64 bit, while `int` is 32 bit wide (at least typically). Let's return `ssize_t` from popen_write_timeout() to prevent data loss. Part of #4031 Reported-by: Cyrill Gorcunov Acked-by: Cyrill Gorcunov --- src/lib/core/popen.c | 6 +++--- src/lib/core/popen.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/core/popen.c b/src/lib/core/popen.c index cbf2fd690..bb55a80e7 100644 --- a/src/lib/core/popen.c +++ b/src/lib/core/popen.c @@ -370,7 +370,7 @@ stdX_str(unsigned int index) * FIXME: Provide an info re amount written bytes in the case. * Say, return -(written) in the case. */ -int +ssize_t popen_write_timeout(struct popen_handle *handle, const void *buf, size_t count, unsigned int flags, ev_tstamp timeout) @@ -397,8 +397,8 @@ popen_write_timeout(struct popen_handle *handle, const void *buf, handle->pid, stdX_str(idx), idx, buf, count, handle->ios[idx].fd, timeout); - int rc = coio_write_timeout_noxc(&handle->ios[idx], buf, count, - timeout); + ssize_t rc = coio_write_timeout_noxc(&handle->ios[idx], buf, + count, timeout); assert(rc < 0 || rc == (ssize_t)count); return rc; } diff --git a/src/lib/core/popen.h b/src/lib/core/popen.h index cffb53933..4f4a6d99d 100644 --- a/src/lib/core/popen.h +++ b/src/lib/core/popen.h @@ -167,7 +167,7 @@ popen_stat(struct popen_handle *handle, struct popen_stat *st); extern const char * popen_command(struct popen_handle *handle); -extern int +extern ssize_t popen_write_timeout(struct popen_handle *handle, const void *buf, size_t count, unsigned int flags, ev_tstamp timeout); -- 2.25.0