From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-f194.google.com (mail-lj1-f194.google.com [209.85.208.194]) (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 8FCE4469719 for ; Sat, 14 Mar 2020 19:34:35 +0300 (MSK) Received: by mail-lj1-f194.google.com with SMTP id w1so13987848ljh.5 for ; Sat, 14 Mar 2020 09:34:35 -0700 (PDT) Date: Sat, 14 Mar 2020 19:34:32 +0300 From: Cyrill Gorcunov Message-ID: <20200314163432.GW27301@uranus> References: <3d2907a0285c640ea09eec86c8922e43c5844953.1584198310.git.v.shpilevoy@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3d2907a0285c640ea09eec86c8922e43c5844953.1584198310.git.v.shpilevoy@tarantool.org> Subject: Re: [Tarantool-patches] [PATCH 1/1] fiber: extend max fiber name length to 255 List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Vladislav Shpilevoy Cc: tarantool-patches@dev.tarantool.org On Sat, Mar 14, 2020 at 04:16:35PM +0100, Vladislav Shpilevoy wrote: > Users keep complaining about too short fiber name. New limit is > 255, should be enough for any sane name. > > Closes #4394 > > fiber_set_name(struct fiber *fiber, const char *name) > { > - assert(name != NULL); > - snprintf(fiber->name, sizeof(fiber->name), "%s", name); > + size_t len = MIN(strlen(name), FIBER_NAME_MAX); > + char *new_name = realloc(fiber->name, len + 1); I don't like it completely. The fiber cache has been made not just to eliminate new memory allocation but also to reduce memory fragmentation and now we give a user a hand to shuffle memory in easy path :( If 32 bytes is really not enough lest make it 64 (or 128) and allocate together with fiber cache. > + if (new_name == NULL) > + panic("fiber_set_name() can't fail"); > + fiber->name = new_name; > + memcpy(new_name, name, len); > + new_name[len] = 0;