From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C05BFC10DCE for ; Sat, 14 Mar 2020 01:06:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 790BF206FA for ; Sat, 14 Mar 2020 01:06:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727715AbgCNBGL (ORCPT ); Fri, 13 Mar 2020 21:06:11 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:51266 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726853AbgCNBGL (ORCPT ); Fri, 13 Mar 2020 21:06:11 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jCvFf-00B8aM-T5; Sat, 14 Mar 2020 01:06:08 +0000 Date: Sat, 14 Mar 2020 01:06:07 +0000 From: Al Viro To: Linus Torvalds Cc: linux-fsdevel , Linux Kernel Mailing List Subject: Re: [RFC][PATCH v4 15/69] new step_into() flag: WALK_NOFOLLOW Message-ID: <20200314010607.GR23230@ZenIV.linux.org.uk> References: <20200313235303.GP23230@ZenIV.linux.org.uk> <20200313235357.2646756-1-viro@ZenIV.linux.org.uk> <20200313235357.2646756-15-viro@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 13, 2020 at 05:32:32PM -0700, Linus Torvalds wrote: > I mentioned this last time (perhaps for a different sequence): > > On Fri, Mar 13, 2020 at 4:54 PM Al Viro wrote: > > > > if (likely(!d_is_symlink(path->dentry)) || > > - !(flags & WALK_FOLLOW || nd->flags & LOOKUP_FOLLOW)) { > > + !(flags & WALK_FOLLOW || nd->flags & LOOKUP_FOLLOW) || > > + flags & WALK_NOFOLLOW) { > > Yes, I know that bitwise operations have higher precedence than the > logical ones. And I know & (and &&) have higher precedence than | (and > ||). > > But I have to _think_ about it every time I see code like this. > > I'd really prefer to see > > if ((a & BIT) || (b & ANOTHER_BIT)) > > over the "equivalent" and shorter > > if (a & BIT || b & ANOTHER_BIT) > > Please make it explicit. It wasn't before either, but it _could_ be. Not a problem (actually, I'd done that several commits later when I was rewriting the expression anyway). Folded the following into it now: diff --git a/fs/namei.c b/fs/namei.c index e47b376cf442..79f06be7f5d4 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -1839,8 +1839,8 @@ static inline int step_into(struct nameidata *nd, struct path *path, int flags, struct inode *inode, unsigned seq) { if (likely(!d_is_symlink(path->dentry)) || - !(flags & WALK_FOLLOW || nd->flags & LOOKUP_FOLLOW) || - flags & WALK_NOFOLLOW) { + !((flags & WALK_FOLLOW) || (nd->flags & LOOKUP_FOLLOW)) || + (flags & WALK_NOFOLLOW)) { /* not a symlink or should not follow */ path_to_nameidata(path, nd); nd->inode = inode;