From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp62.i.mail.ru (smtp62.i.mail.ru [217.69.128.42]) (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 9B74646970F for ; Thu, 28 Nov 2019 02:40:03 +0300 (MSK) References: <20191127213037.94837-1-k.sosnin@tarantool.org> <20191127213037.94837-2-k.sosnin@tarantool.org> From: Vladislav Shpilevoy Message-ID: <5afb26c7-a167-593d-dda8-65461de27731@tarantool.org> Date: Thu, 28 Nov 2019 00:40:00 +0100 MIME-Version: 1.0 In-Reply-To: <20191127213037.94837-2-k.sosnin@tarantool.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [Tarantool-patches] [PATCH v2] build: GCC warning on strncpy List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Chris Sosnin , tarantool-patches@dev.tarantool.org, Kirill Yukhin Thanks for the patch! I see, that you've sent this patch in the same email thread as another totally unrelated patch about 4262 ticket. Please, don't try to batch not related emails. If a patch consists of one commit, it should be sent as one thread with a single email in it. This patch LGTM. On 27/11/2019 22:30, Chris Sosnin wrote: > Thank you for the review! > See second version below. > branch: https://github.com/tarantool/tarantool/tree/ksosnin/gh-4515-build-warning > issue: https://github.com/tarantool/tarantool/issues/4515 > > As long as we are sure, that strlen(sd_unix_path) < sizeof(sa.sun_path) > we can assume that there is always enough space and the path will be > null-terminated. Thus, copy 1 byte less to get rid of the warning. > > Closes #4515 > --- > src/systemd.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/src/systemd.c b/src/systemd.c > index 6686c3ce0..c80259f06 100644 > --- a/src/systemd.c > +++ b/src/systemd.c > @@ -67,7 +67,7 @@ int systemd_init() { > .sun_path = { '\0' } > }; > if (strlen(sd_unix_path) >= sizeof(sa.sun_path)) { > - say_error("systemd: NOTIFY_SOCKET is longer that MAX_UNIX_PATH"); > + say_error("systemd: NOTIFY_SOCKET is longer than MAX_UNIX_PATH"); > goto error; > } > if ((systemd_fd = socket(AF_UNIX, SOCK_DGRAM, 0)) == -1) { > @@ -117,7 +117,7 @@ int systemd_notify(const char *message) { > .sun_family = AF_UNIX, > }; > > - strncpy(sa.sun_path, sd_unix_path, sizeof(sa.sun_path)); > + strncpy(sa.sun_path, sd_unix_path, sizeof(sa.sun_path) - 1); > if (sa.sun_path[0] == '@') > sa.sun_path[0] = '\0'; > > -- > 2.21.0 (Apple Git-122.2) >