[Tarantool-patches] [PATCH v14 06/12] module_cache: module_reload - drop redundant parameter

Cyrill Gorcunov gorcunov at gmail.com
Wed Feb 3 01:12:01 MSK 2021


There is no need to return new module pointer, it is
only used in a caller code to find if there was no
such module at all.

Instead call diag_set by self and drop this useless
argument.

Part-of #4642

Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
---
 src/box/call.c         | 10 ++--------
 src/box/module_cache.c |  9 +++------
 src/box/module_cache.h |  4 +---
 3 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/src/box/call.c b/src/box/call.c
index 9c291260e..2a1a2c5bb 100644
--- a/src/box/call.c
+++ b/src/box/call.c
@@ -128,14 +128,8 @@ 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/module_cache.c b/src/box/module_cache.c
index 60af290ae..4c64a6dc5 100644
--- a/src/box/module_cache.c
+++ b/src/box/module_cache.c
@@ -473,14 +473,12 @@ module_sym_call(struct module_sym *mod_sym, struct port *args,
 }
 
 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_cache_find(package, package_end);
 	if (old == 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_load(package, package_end);
@@ -514,7 +512,6 @@ module_reload(const char *package, const char *package_end,
 	}
 
 	module_gc(old);
-	*module = new;
 	return 0;
 
 restore:
diff --git a/src/box/module_cache.h b/src/box/module_cache.h
index 0d56aea92..fa62628c3 100644
--- a/src/box/module_cache.h
+++ b/src/box/module_cache.h
@@ -112,13 +112,11 @@ module_sym_call(struct module_sym *mod_sym, struct port *args,
  *
  * @param package shared library path start.
  * @param package_end shared library path end.
- * @param[out] module pointer to the reloaded module.
  *
  * @return 0 on succes, -1 otherwise, diag is set.
  */
 int
-module_reload(const char *package, const char *package_end,
-	      struct module **module);
+module_reload(const char *package, const char *package_end);
 
 /**
  * Initialize modules subsystem.
-- 
2.29.2



More information about the Tarantool-patches mailing list