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 09AD868713; Mon, 1 Feb 2021 01:13:22 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 09AD868713 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1612131202; bh=V2xbMVwSVQDqC4l+KcHF3+3hGj6fBmYdMv+yMjZ0MMc=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=DViAjAFN0+gryuReXXJiM0BA0ECJKIkokF1emG1AHiKQxsKLLGnJoR/zoaLqZlJ4G gfyfBzt8F06kDlRdLUgimPCKqma7pFnxIsi7GRk5GhB/O/IDmyPblV1uAuReZuX4uJ 4CdWlYqDZaE79fe5X+XeRFPuGRntD46OxHRQjZSM= Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) (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 6C8D368713 for ; Mon, 1 Feb 2021 01:13:20 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 6C8D368713 Received: by mail-lf1-f41.google.com with SMTP id v24so20153307lfr.7 for ; Sun, 31 Jan 2021 14:13:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=WAihNxA/EXPpvxPq63REY8kxMXMEq4TlvRKL7bXbXQs=; b=NKLVo6HzmER+oZSSbgy1LLTPYR1wkvTkDudmZBL487bE0/QAyl8ePok0BjZ2z6CzVO SmxQFRwGDZ/hJF0lxQ260Xyr/+mHnU266lYaYcq5iG12m+q7Ed03ydHjYtFcnFGmYhP+ adBGk5CWt6/+LqFxzZrYzpUyG3U0Nf+TMzD8yNBRecDVNLs7L7un1HqYFxdhr62fp0/y Gjxjd2H6EqIYDGqCxBUnqKaCJUGJIV6aeKoS1w2MP0Lth7LLI2srFK7sqwgaCaR4gmvm vogj4hH6neWMHhn8xIKf20ZfeUVXSAoStqocu5y5d90M4SRxzHp9xocVn5G35Xi07IOR jw5Q== X-Gm-Message-State: AOAM530/7iM1N3bvlX3Kv/6a6ddP7Rj1F2OBnctiYT8lcUtlbaxL96Pw gW2CDWUHKW9xp6Ug4dgin1cOQ3mbIE8JUA== X-Google-Smtp-Source: ABdhPJykkPh4IodHj9YoyBy6OqlKb6goExG9L5RkLjhsxlSLKEv0OPZyQn8dMEZwBG5htRwlHWXKsQ== X-Received: by 2002:a19:4c02:: with SMTP id z2mr6833679lfa.590.1612131199360; Sun, 31 Jan 2021 14:13:19 -0800 (PST) Received: from grain.localdomain ([5.18.103.226]) by smtp.gmail.com with ESMTPSA id j20sm2762334lfu.94.2021.01.31.14.13.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Jan 2021 14:13:17 -0800 (PST) Received: by grain.localdomain (Postfix, from userid 1000) id 2C463560113; Mon, 1 Feb 2021 01:13:17 +0300 (MSK) Date: Mon, 1 Feb 2021 01:13:17 +0300 To: Vladislav Shpilevoy Message-ID: <20210131221317.GB2172@grain> References: <20210122132700.272816-1-gorcunov@gmail.com> <20210122132700.272816-6-gorcunov@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.14.6 (2020-07-11) Subject: Re: [Tarantool-patches] [PATCH 5/6] txn: stop using txn_has_flag 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: tml Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" On Sat, Jan 30, 2021 at 08:17:59PM +0100, Vladislav Shpilevoy wrote: > > --- a/src/box/txn.c > > +++ b/src/box/txn.c > > @@ -526,7 +526,7 @@ txn_free_or_wakeup(struct txn *txn) > > void > > txn_complete_fail(struct txn *txn) > > { > > - assert(!txn_has_flag(txn, TXN_IS_DONE)); > > + assert(!(txn->flags & TXN_IS_DONE)); > > Please, use explicit != 0. We don't apply '!' operator to > non-boolean values. The same in other places. This I can even > find in the code style guide: > > https://github.com/tarantool/tarantool/wiki/Code-review-procedure#code-style I remember this. And used this style initially. But with this rule applied code becomes a way more ugly. For example - if (!txn_has_flag(txn, TXN_CAN_YIELD)) + if ((txn->flags & TXN_CAN_YIELD) == 0) In first place a person notes the "logical not" operator immediately, and this sounds more natural than excessive five symbols at the tail of the 'if' statement. Another example - assert(!txn_has_flag(txn, TXN_IS_DONE)); - assert(!txn_has_flag(txn, TXN_WAIT_SYNC)); + assert(!(txn->flags & (TXN_IS_DONE | TXN_WAIT_SYNC))); Which should be changed to either assert((txn->flags & (TXN_IS_DONE | TXN_WAIT_SYNC)) == 0); or back to pair assert((txn->flags & TXN_IS_DONE) == 0); assert((txn->flags & TXN_WAIT_SYNC) == 0); which is a way more worse than it was with txn_has_flag() helper, at least for me. The initial rationale for this series was (as far as I remember) to setup several flags at once, so I think you could consider implementing txn_set_flags() helper which would do the trick instead. Thus lets drop this series, it doesn't make anything better without using neg operator.