From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-f66.google.com (mail-lf1-f66.google.com [209.85.167.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 9C853469710 for ; Fri, 29 May 2020 13:59:10 +0300 (MSK) Received: by mail-lf1-f66.google.com with SMTP id c21so1051348lfb.3 for ; Fri, 29 May 2020 03:59:10 -0700 (PDT) Date: Fri, 29 May 2020 13:59:07 +0300 From: Cyrill Gorcunov Message-ID: <20200529105907.GK215590@grain> References: <17830780bc75041a478126ee3d13c96bbd5f8b04.1589968157.git.kyukhin@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <17830780bc75041a478126ee3d13c96bbd5f8b04.1589968157.git.kyukhin@tarantool.org> Subject: Re: [Tarantool-patches] [PATCH 2/2] Allow to set directory for copying DSO before load List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kirill Yukhin Cc: tarantool-patches@dev.tarantool.org On Wed, May 20, 2020 at 12:51:18PM +0300, Kirill Yukhin wrote: ... > --- a/src/box/call.c > +++ b/src/box/call.c > @@ -129,10 +129,14 @@ box_module_reload(const char *name) > return -1; > } > struct module *module = NULL; > - if (module_reload(name, name + strlen(name), &module) == 0 && > - module != NULL) > - return 0; > - diag_set(ClientError, ER_NO_SUCH_MODULE, name); > + if (module_reload(name, name + strlen(name), &module) == 0) { > + if (module != NULL) > + return 0; > + else { > + diag_set(ClientError, ER_NO_SUCH_MODULE, name); > + return -1; Redundant return -1? Since we're gonna return -1 a few lines lower anyway. I might be missing something obvious but I don't get why have you moved module != NULL into a separate block. If you prefer this form I don't mind though. > + } > + } > return -1; > } > > diff --git a/src/box/func.c b/src/box/func.c > index a42a269..0405eb9 100644 > --- a/src/box/func.c > +++ b/src/box/func.c > @@ -261,14 +261,29 @@ module_load(const char *package, const char *package_end) > module->package[package_len] = 0; > rlist_create(&module->funcs); > module->calls = 0; > - char dir_name[] = "/tmp/tntXXXXXX"; > + > + const char *tmpdir = getenv("TMPDIR"); > + if (tmpdir == NULL) > + tmpdir = "/tmp"; > + char dir_name[PATH_MAX + 1]; No need for PATH_MAX + 1, PATH_MAX should be enough. Other than this -- Ack.