From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp60.i.mail.ru (smtp60.i.mail.ru [217.69.128.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 4EC5E469710 for ; Thu, 21 May 2020 17:37:19 +0300 (MSK) From: "Timur Safin" References: <172feb69ec2caea2aa63a24de8b76a4dba13bebb.1589583614.git.v.shpilevoy@tarantool.org> <52af1bb7-b125-7490-3882-ce74698789d2@tarantool.org> In-Reply-To: Date: Thu, 21 May 2020 17:37:17 +0300 Message-ID: <402001d62f7d$54311a90$fc934fb0$@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Language: ru Subject: Re: [Tarantool-patches] [PATCH 2/2] uuid: fix unaligned memory access List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: 'Vladislav Shpilevoy' , 'Aleksandr Lyapunov' , tarantool-patches@dev.tarantool.org, gorcunov@gmail.com LGTM : -----Original Message----- : From: Vladislav Shpilevoy : Sent: Wednesday, May 20, 2020 12:25 AM : To: Aleksandr Lyapunov ; tarantool- : patches@dev.tarantool.org; tsafin@tarantool.org; gorcunov@gmail.com : Subject: Re: [PATCH 2/2] uuid: fix unaligned memory access : : ==================== : diff --git a/src/lib/uuid/tt_uuid.h b/src/lib/uuid/tt_uuid.h : index d62991c65..70c3b98b1 100644 : --- a/src/lib/uuid/tt_uuid.h : +++ b/src/lib/uuid/tt_uuid.h : @@ -149,19 +149,6 @@ tt_uuid_bswap(struct tt_uuid *uu) : uu->time_hi_and_version = bswap_u16(uu->time_hi_and_version); : } : : -/** : - * \brief Test that uuid is nil : - * \param uu UUID : - * \retval true if all members of \a uu 0 : - * \retval false otherwise : - */ : -inline bool : -tt_uuid_is_nil(const struct tt_uuid *uu) : -{ : - const uint32_t *p = (const uint32_t *) uu; : - return p[0] == 0 && p[1] == 0 && p[2] == 0 && p[3] == 0; : -} : - : /** : * \brief Test that \a lhs equal \a rhs : * \param lhs UUID : @@ -172,14 +159,23 @@ tt_uuid_is_nil(const struct tt_uuid *uu) : inline bool : tt_uuid_is_equal(const struct tt_uuid *lhs, const struct tt_uuid *rhs) : { : - const uint32_t *lp = (const uint32_t *) lhs; : - const uint32_t *rp = (const uint32_t *) rhs; : - return lp[0] == rp[0] && lp[1] == rp[1] && lp[2] == rp[2] && : - lp[3] == rp[3]; : + return memcmp(lhs, rhs, sizeof(*lhs)) == 0; : } : : extern const struct tt_uuid uuid_nil; : : +/** : + * \brief Test that uuid is nil. : + * \param uu UUID. : + * \retval true If all members of \a uu 0. : + * \retval false Otherwise. : + */ : +inline bool : +tt_uuid_is_nil(const struct tt_uuid *uu) : +{ : + return tt_uuid_is_equal(uu, &uuid_nil); : +} : + : char * : tt_uuid_str(const struct tt_uuid *uu); :