From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id E71582566F for ; Mon, 9 Apr 2018 16:21:29 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ytq86KF66ary for ; Mon, 9 Apr 2018 16:21:29 -0400 (EDT) Received: from smtp58.i.mail.ru (smtp58.i.mail.ru [217.69.128.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 2A7B0252F9 for ; Mon, 9 Apr 2018 16:21:28 -0400 (EDT) Date: Mon, 9 Apr 2018 23:21:24 +0300 From: Konstantin Osipov Subject: [tarantool-patches] Re: [PATCH] Fix static buffer align Message-ID: <20180409202124.GA4527@atlas> References: <20180409065540.22360-1-avkhatskevich@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180409065540.22360-1-avkhatskevich@tarantool.org> Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: tarantool-patches@freelists.org Cc: v.shpilevoy@tarantool.org * AKhatskevich [18/04/09 10:35]: This is OK to push. > Branch: https://github.com/tarantool/tarantool/tree/kh/align_static_buf > > The length of the TT_STATIC_BUFS was 1025 bytes which lead to unaligned > allocation. > The addresses was allocated like this: > - 0 0x7ffdd80aaa20 > - 1 0x7ffdd80aae21 > - 2 0x7ffdd80ab222 > - 3 0x7ffdd80ab623 > > It may affect the performance and looks wired. > --- > src/trivia/util.h | 2 +- > src/tt_uuid.c | 2 +- > src/tt_uuid.h | 3 ++- > 3 files changed, 4 insertions(+), 3 deletions(-) > > diff --git a/src/trivia/util.h b/src/trivia/util.h > index 38beff395..8f2075664 100644 > --- a/src/trivia/util.h > +++ b/src/trivia/util.h > @@ -489,7 +489,7 @@ static inline char * > tt_static_buf(void) > { > enum { TT_STATIC_BUFS = 4 }; > - static __thread char bufs[TT_STATIC_BUFS][TT_STATIC_BUF_LEN + 1]; > + static __thread char bufs[TT_STATIC_BUFS][TT_STATIC_BUF_LEN]; > static __thread int bufno = TT_STATIC_BUFS - 1; > > bufno = (bufno + 1) % TT_STATIC_BUFS; > diff --git a/src/tt_uuid.c b/src/tt_uuid.c > index f621ba711..530aa31a1 100644 > --- a/src/tt_uuid.c > +++ b/src/tt_uuid.c > @@ -86,7 +86,7 @@ tt_uuid_is_equal(const struct tt_uuid *lhs, const struct tt_uuid *rhs); > char * > tt_uuid_str(const struct tt_uuid *uu) > { > - assert(TT_STATIC_BUF_LEN >= UUID_STR_LEN); > + assert(TT_STATIC_BUF_LEN > UUID_STR_LEN); > char *buf = tt_static_buf(); > tt_uuid_to_string(uu, buf); > return buf; > diff --git a/src/tt_uuid.h b/src/tt_uuid.h > index 818914b83..00d6de662 100644 > --- a/src/tt_uuid.h > +++ b/src/tt_uuid.h > @@ -124,7 +124,8 @@ tt_uuid_compare(const struct tt_uuid *a, const struct tt_uuid *b) > inline void > tt_uuid_to_string(const struct tt_uuid *uu, char *out) > { > - sprintf(out, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", > + snprintf(out, UUID_STR_LEN + 1, > + "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", > uu->time_low, uu->time_mid, uu->time_hi_and_version, > uu->clock_seq_hi_and_reserved, uu->clock_seq_low, uu->node[0], > uu->node[1], uu->node[2], uu->node[3], uu->node[4], uu->node[5]); > -- > 2.14.1 > > -- Konstantin Osipov, Moscow, Russia, +7 903 626 22 32 http://tarantool.io - www.twitter.com/kostja_osipov