From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 596BCCC308; Mon, 18 Jan 2021 23:37:35 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 596BCCC308 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1611002255; bh=UDYXpl36keV4ecyfqfS0+2QNrZfuNTCaIP/zmqbi6ko=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=gLWzLXr/OdOzQU23kVfGeMPRjJzWd9tEp3njel6lgJ9loafJpJawK48DHQ7KJcsFx Pwfzww6AurzZ2fN2JYXVB3PqpFTi/s5KCArnPKycBYrYpHVHhXjABhPowiqdAroy49 nd1lZ9RoQ8EV7TW9QMDUPm+eyrKWTMJNJ987rMAg= Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 4E44485DEC for ; Mon, 18 Jan 2021 23:36:38 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 4E44485DEC Received: by mail-lf1-f48.google.com with SMTP id 23so25894874lfg.10 for ; Mon, 18 Jan 2021 12:36:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dm1UEoftrdgRFZG+wldAgPahi+jI2oP44pe9hdg+Djw=; b=Oy0Wb6cDspSQCzcIPygA7AL+0qX+PDFOgi49fFeK3B8dgCRnmXDcsmPTG1Up0l/A7U fSGHdq03hRoKHHFNGxbDks9LVo+VKcViJ3LGyns/EgLrA2ZZpdwGJMciyCZd+6p47ntD LipI3Oth2xoPonJhTkqAewUrno/YA7tBJEt7Rd0HMY700iw4l37vtgVLIBttKXKuPDk+ mM2MKDk2whMr75FUJeZ4MC8+L6lR+2K0JiAG86BFMj39QJcPeKqFEBDqIHh0iYU5ZMrX e719qASUk2x6Fu8yp5lkNMMap5DKsXse55ddoxz04jZRr/Osj3lA3leKgIAtbA3r3FaY pj5w== X-Gm-Message-State: AOAM531CE9V6GyGO+gjjIzCZop9tAelxwlqKw5Zn+ecctKj2rRyIgvTX cTbMEni7d/c+pxPySOqK8NIoQT9x0r0= X-Google-Smtp-Source: ABdhPJzsFDcFIu0IW1CFI1saCK5GALiWwKeFviFGlfS+q8g5arWrBsCcEEVHy15CoRAIfBVOHE0nzg== X-Received: by 2002:a19:416:: with SMTP id 22mr374356lfe.507.1611002197004; Mon, 18 Jan 2021 12:36:37 -0800 (PST) Received: from grain.localdomain ([5.18.91.94]) by smtp.gmail.com with ESMTPSA id p13sm2018573lft.162.2021.01.18.12.36.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Jan 2021 12:36:35 -0800 (PST) Received: by grain.localdomain (Postfix, from userid 1000) id 63A3D560139; Mon, 18 Jan 2021 23:35:59 +0300 (MSK) To: tml Date: Mon, 18 Jan 2021 23:35:51 +0300 Message-Id: <20210118203556.281700-4-gorcunov@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210118203556.281700-1-gorcunov@gmail.com> References: <20210118203556.281700-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v12 3/8] module_cache: improve naming X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Cyrill Gorcunov via Tarantool-patches Reply-To: Cyrill Gorcunov Cc: Vladislav Shpilevoy Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" - rename func_name to func_name_desc because it is not just a name but rather a name descriptor which includes symbol address - rename func_split_name to parse_func_name because the action of splitting name to parts is not what the function about, the function parses specification to fetch a descriptor Part-of #4642 Signed-off-by: Cyrill Gorcunov --- src/box/module_cache.c | 52 +++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/box/module_cache.c b/src/box/module_cache.c index 9fe316807..8ae61a883 100644 --- a/src/box/module_cache.c +++ b/src/box/module_cache.c @@ -26,9 +26,9 @@ static struct mh_strnptr_t *mod_hash = NULL; /** - * Parsed symbol and package names. + * Function name descriptor: a symbol and a package. */ -struct func_name { +struct func_name_desc { /** * Null-terminated symbol name, e.g. * "func" for "mod.submod.func". @@ -46,25 +46,25 @@ struct func_name { }; /*** - * Split function name to symbol and package names. + * Parse function name into a name descriptor. * * For example, str = foo.bar.baz => sym = baz, package = foo.bar * * @param str function name, e.g. "module.submodule.function". - * @param[out] name parsed symbol and a package name. + * @param[out] d parsed symbol and a package name. */ static void -func_split_name(const char *str, struct func_name *name) +parse_func_name(const char *str, struct func_name_desc *d) { - name->package = str; - name->package_end = strrchr(str, '.'); - if (name->package_end != NULL) { + d->package = str; + d->package_end = strrchr(str, '.'); + if (d->package_end != NULL) { /* module.submodule.function => module.submodule, function */ - name->sym = name->package_end + 1; /* skip '.' */ + d->sym = d->package_end + 1; /* skip '.' */ } else { /* package == function => function, function */ - name->sym = name->package; - name->package_end = str + strlen(str); + d->sym = d->package; + d->package_end = str + strlen(str); } } @@ -335,12 +335,12 @@ module_sym_load(struct module_sym *mod_sym) { assert(mod_sym->addr == NULL); - struct func_name name; - func_split_name(mod_sym->name, &name); + struct func_name_desc d; + parse_func_name(mod_sym->name, &d); - struct module *module = module_cache_find(name.package, name.package_end); + struct module *module = module_cache_find(d.package, d.package_end); if (module == NULL) { - module = module_load(name.package, name.package_end); + module = module_load(d.package, d.package_end); if (module == NULL) return -1; if (module_cache_add(module) != 0) { @@ -349,7 +349,7 @@ module_sym_load(struct module_sym *mod_sym) } } - mod_sym->addr = module_sym(module, name.sym); + mod_sym->addr = module_sym(module, d.sym); if (mod_sym->addr == NULL) return -1; @@ -366,9 +366,9 @@ module_sym_unload(struct module_sym *mod_sym) rlist_del(&mod_sym->item); if (rlist_empty(&mod_sym->module->funcs_list)) { - struct func_name name; - func_split_name(mod_sym->name, &name); - module_cache_del(name.package, name.package_end); + struct func_name_desc d; + parse_func_name(mod_sym->name, &d); + module_cache_del(d.package, d.package_end); } module_gc(mod_sym->module); @@ -439,13 +439,13 @@ module_reload(const char *package, const char *package_end, struct module_sym *mod_sym, *tmp; rlist_foreach_entry_safe(mod_sym, &old->funcs_list, item, tmp) { - struct func_name name; - func_split_name(mod_sym->name, &name); + struct func_name_desc d; + parse_func_name(mod_sym->name, &d); - mod_sym->addr = module_sym(new, name.sym); + mod_sym->addr = module_sym(new, d.sym); if (mod_sym->addr == NULL) { say_error("module: reload %s, symbol %s not found", - package, name.sym); + package, d.sym); goto restore; } @@ -467,9 +467,9 @@ module_reload(const char *package, const char *package_end, * restore old functions. */ do { - struct func_name name; - func_split_name(mod_sym->name, &name); - mod_sym->addr = module_sym(old, name.sym); + struct func_name_desc d; + parse_func_name(mod_sym->name, &d); + mod_sym->addr = module_sym(old, d.sym); if (mod_sym->addr == NULL) { /* * Something strange was happen, an early loaden -- 2.29.2