[Tarantool-patches] [PATCH v20 2/7] box/func: module_reload -- drop redundant argument
Serge Petrenko
sergepetrenko at tarantool.org
Mon Apr 5 13:26:03 MSK 2021
05.04.2021 13:23, Serge Petrenko via Tarantool-patches пишет:
>
>
> 02.04.2021 15:34, Cyrill Gorcunov пишет:
>> The only purpose of the module argument is to
>> notify the caller that the module doesn't exist.
>> Lets simply the code and drop this argument.
typo: simply -> simplify
>>
>> Part-of #4642
>>
>> Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
>> ---
>
> Thanks for the patch! LGTM.
>
>> src/box/call.c | 9 +--------
>> src/box/func.c | 7 +++----
>> src/box/func.h | 3 +--
>> 3 files changed, 5 insertions(+), 14 deletions(-)
>>
>> diff --git a/src/box/call.c b/src/box/call.c
>> index 9c291260e..7839e1f3e 100644
>> --- a/src/box/call.c
>> +++ b/src/box/call.c
>> @@ -128,14 +128,7 @@ box_module_reload(const char *name)
>> user->def->name);
>> return -1;
>> }
>> - struct module *module = NULL;
>> - 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;
>> + return module_reload(name, name + strlen(name));
>> }
>> int
>> diff --git a/src/box/func.c b/src/box/func.c
>> index 9909cee45..233696a4f 100644
>> --- a/src/box/func.c
>> +++ b/src/box/func.c
>> @@ -372,13 +372,13 @@ module_sym(struct module *module, const char
>> *name)
>> }
>> int
>> -module_reload(const char *package, const char *package_end, struct
>> module **module)
>> +module_reload(const char *package, const char *package_end)
>> {
>> struct module *old_module = module_cache_find(package,
>> package_end);
>> if (old_module == NULL) {
>> /* Module wasn't loaded - do nothing. */
>> - *module = NULL;
>> - return 0;
>> + diag_set(ClientError, ER_NO_SUCH_MODULE, package);
>> + return -1;
>> }
>> struct module *new_module = module_load(package, package_end);
>> @@ -399,7 +399,6 @@ module_reload(const char *package, const char
>> *package_end, struct module **modu
>> if (module_cache_put(new_module) != 0)
>> goto restore;
>> module_gc(old_module);
>> - *module = new_module;
>> return 0;
>> restore:
>> /*
>> diff --git a/src/box/func.h b/src/box/func.h
>> index 581e468cb..0a08fa465 100644
>> --- a/src/box/func.h
>> +++ b/src/box/func.h
>> @@ -113,12 +113,11 @@ func_call(struct func *func, struct port *args,
>> struct port *ret);
>> *
>> * @param package name begin pointer.
>> * @param package_end package_end name end pointer.
>> - * @param[out] module a pointer to store module object on success.
>> * @retval -1 on error.
>> * @retval 0 on success.
>> */
>> int
>> -module_reload(const char *package, const char *package_end, struct
>> module **module);
>> +module_reload(const char *package, const char *package_end);
>> #if defined(__cplusplus)
>> } /* extern "C" */
>
--
Serge Petrenko
More information about the Tarantool-patches
mailing list