From: Cyrill Gorcunov via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> Cc: tml <tarantool-patches@dev.tarantool.org> Subject: Re: [Tarantool-patches] [PATCH v21 5/6] box: implement box.lib module Date: Tue, 13 Apr 2021 01:34:45 +0300 [thread overview] Message-ID: <YHTLBU3HnhkI1DaJ@grain> (raw) In-Reply-To: <c8d436d0-3ba1-ea4c-916b-e9f2e120ec85@tarantool.org> On Tue, Apr 13, 2021 at 12:08:49AM +0200, Vladislav Shpilevoy wrote: > > You don't need any of the 'm' object attributes in the hash if > the 'm' pointer is already included. It is unique. There can't be > 2 objects with the same pointer in the memory. Yeah. What about even simplier? On top of your patch since we don't need to call strlen. --- diff --git a/src/box/lua/lib.c b/src/box/lua/lib.c index f8ce1be80..fa44163e0 100644 --- a/src/box/lua/lib.c +++ b/src/box/lua/lib.c @@ -418,9 +418,8 @@ lbox_module_load_func(struct lua_State *L) * Make sure there is enough space for key, and formatting. */ char key[max_sym_len + 32]; - int bytes = snprintf(key, sizeof(key), "%p.%s", m, sym) + 1; - assert(bytes <= (int)sizeof(key)); - size_t len = strlen(key); + size_t len = (size_t)snprintf(key, sizeof(key), "%p.%s", m, sym); + assert(len > 1 && len < sizeof(key)); struct box_module_func *cf = cache_find(key, len); if (cf == NULL) {
next prev parent reply other threads:[~2021-04-12 22:34 UTC|newest] Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-04-08 16:41 [Tarantool-patches] [PATCH v21 0/6] box: implement box.lib Lua module Cyrill Gorcunov via Tarantool-patches 2021-04-08 16:41 ` [Tarantool-patches] [PATCH v21 1/6] box/func: fix modules functions restore Cyrill Gorcunov via Tarantool-patches 2021-04-09 23:31 ` Vladislav Shpilevoy via Tarantool-patches 2021-04-10 15:02 ` Cyrill Gorcunov via Tarantool-patches 2021-04-08 16:41 ` [Tarantool-patches] [PATCH v21 2/6] box/func: module_reload -- drop redundant argument Cyrill Gorcunov via Tarantool-patches 2021-04-08 16:41 ` [Tarantool-patches] [PATCH v21 3/6] box/module_cache: introduce modules subsystem Cyrill Gorcunov via Tarantool-patches 2021-04-09 23:54 ` Vladislav Shpilevoy via Tarantool-patches 2021-04-10 14:59 ` Cyrill Gorcunov via Tarantool-patches 2021-04-08 16:41 ` [Tarantool-patches] [PATCH v21 4/6] box/schema.func: switch to new module api Cyrill Gorcunov via Tarantool-patches 2021-04-09 23:55 ` Vladislav Shpilevoy via Tarantool-patches 2021-04-10 15:00 ` Cyrill Gorcunov via Tarantool-patches 2021-04-08 16:41 ` [Tarantool-patches] [PATCH v21 5/6] box: implement box.lib module Cyrill Gorcunov via Tarantool-patches 2021-04-11 15:38 ` Vladislav Shpilevoy via Tarantool-patches 2021-04-11 22:38 ` Cyrill Gorcunov via Tarantool-patches 2021-04-12 22:08 ` Vladislav Shpilevoy via Tarantool-patches 2021-04-12 22:34 ` Cyrill Gorcunov via Tarantool-patches [this message] 2021-04-08 16:41 ` [Tarantool-patches] [PATCH v21 6/6] test: add box.lib test Cyrill Gorcunov via Tarantool-patches 2021-04-08 18:53 ` Cyrill Gorcunov via Tarantool-patches 2021-04-11 15:43 ` Vladislav Shpilevoy via Tarantool-patches 2021-04-11 21:56 ` Cyrill Gorcunov via Tarantool-patches 2021-04-11 22:36 ` Cyrill Gorcunov via Tarantool-patches 2021-04-12 22:08 ` Vladislav Shpilevoy via Tarantool-patches 2021-04-13 7:10 ` Cyrill Gorcunov via Tarantool-patches 2021-04-13 21:53 ` [Tarantool-patches] [PATCH v21 0/6] box: implement box.lib Lua module Vladislav Shpilevoy via Tarantool-patches 2021-04-14 8:07 ` Kirill Yukhin via Tarantool-patches
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=YHTLBU3HnhkI1DaJ@grain \ --to=tarantool-patches@dev.tarantool.org \ --cc=gorcunov@gmail.com \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH v21 5/6] box: implement box.lib module' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox