Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3320723pxb; Mon, 18 Oct 2021 12:42:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVAxPOtNpjs+RbWs/pqLxfxVBRKzhOX84JRVs4tMRcRrLWCNzezlBq85in1km9NJ3txC3o X-Received: by 2002:a63:6a05:: with SMTP id f5mr25371384pgc.97.1634586132613; Mon, 18 Oct 2021 12:42:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634586132; cv=none; d=google.com; s=arc-20160816; b=pygaorWsbUCwhe8tBLrgQqRrsOPnIvJEqYPnIWopcWgW3fErXQ27+d80Q0t9gnKBUr CQTqgAGCWCtz5uPO5f1vcL6KAI69NbIhPkYfn4khEd3BkUBRbvOyBbUa61D7RGsdTcrP vD91AP4biI9ez1fTgBy6iugyu/Iunw95INhc/t3jutcEvpTe/SL6Os0tjS3+jxN5mdVU A+TcsxlJFjFaBVhu22JUB1pF09/VM2ZL53B+okCvtHiGadeb8r4u12JFK0ay4xNdCrDd PX+xcYS8+CEh+sBRDMbMEaD4giZ8C09V4On6l5M5cnNjzUG5baPBd3D3FFkdve/4hXmE k7dQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=rYHsusTbkwFk7JVuDdYhrxYd3Oez/UvdkWTXcYHAjQg=; b=N3euW67UCFiApJ+Jae+VXTbN/wN6CFscdCOXau23rlIe4ZD7hZ/Zo8mvtn1TZm0qr+ dUEFkRrR+vTbMsI8uvVl3Ss45RMfaCZpjHUadyQ9BUIGTUjT2AUGepPB+qM41NOCf1mS cQTDutPE8EZnKg0hj3LWmPH3DhV/vYAMOLv5rmDQRzEBw95iR5hWjiPRaJSssCkVzX0X hO9a3Lya76dCK5n665y/xq75Hdt1ygAGKNtKLaKu3xxSMSbBKy09Rq2oAgE/AIFRT25G 3DKcqn58WpfXW1U9BESEYUmpC5d6kAHsNKv7DKxyPEaIqGEDUBq6aXZ7n7VAUKfxKWA+ AWiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=puzIN8gg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r23si21859457pls.210.2021.10.18.12.41.58; Mon, 18 Oct 2021 12:42:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=puzIN8gg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233337AbhJRTnQ (ORCPT + 99 others); Mon, 18 Oct 2021 15:43:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233182AbhJRTnQ (ORCPT ); Mon, 18 Oct 2021 15:43:16 -0400 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F18AC061745 for ; Mon, 18 Oct 2021 12:41:04 -0700 (PDT) Received: by mail-lf1-x12c.google.com with SMTP id n8so2111022lfk.6 for ; Mon, 18 Oct 2021 12:41:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=rYHsusTbkwFk7JVuDdYhrxYd3Oez/UvdkWTXcYHAjQg=; b=puzIN8gggSDMtRiBbPLKaFTvqQy7PZ8lkaBt48DLOPtDNScgLO0caCDFtegsdUQKjh Zc/9C9T+HcnA0SgWMfyVRL5Ow0do6yh926ZWvkvrHFCiJIURdHJtffZVyrlXtKUVxPEL CFb9eFu99VyaFY/bIua4CuBGKaeQJd9DYeCQ9wzlGimgK1EBifwsZ4CshgBhoOAqjOme WyfGuhjDxSnqdzwsVnrYBnFFxr2SP2/Ywj2aWK9DfxgAcTsIbf6faxSP4UQxnwkMqo0N 95L5ciwCdpwEX0pPghtf7pHBFRZu12Yw7rmn+RDW6wvQrGNPlTd/rQsHYm5aSXcFWhWr tvbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=rYHsusTbkwFk7JVuDdYhrxYd3Oez/UvdkWTXcYHAjQg=; b=aZaBa56Qi4OOXZWOdoVK5cq6/MhruXmHHN+iYuUNoBaqAcfC07+dtfE51itLvG0vEu XbEZ3s+rVx+WkuzFwhLbGpZT9rIQHZSeGZjwn0KTcd+l58S+LXM0FgV6a2uy3NpYuAtB vtVEQzpCdQ11P10I5FixKiGAo+LzJDSv4j3QBT/qNHZl+qE4Q5MN7Q7ax5zDoNUHOrFo Wiu4iIS5pOKJTvDHp/hICKUp9Uoc8gvSi9N5cUPSt/cazAZXSnDO1Cyb/H0h8BlolacZ XgqjBNXLjLxXez3de+AWMwjOxa2QPaEBMfcCmOJcKYwoTb7QImtU1nlB+qJaA5Q9UXUo TCnw== X-Gm-Message-State: AOAM5335NeUOIkooTSougW5wOjq4L8IEL235ydDCAH73QQm9+0MtXk1L 8xhYTPnCoH1gWuvN6cDCGaVUXFWHxU15mraoHf+tiA== X-Received: by 2002:a05:6512:398f:: with SMTP id j15mr1512665lfu.523.1634586062336; Mon, 18 Oct 2021 12:41:02 -0700 (PDT) MIME-Version: 1.0 References: <20211018193101.2340261-1-nathan@kernel.org> In-Reply-To: From: Nick Desaulniers Date: Mon, 18 Oct 2021 12:40:51 -0700 Message-ID: Subject: Re: [PATCH] nfp: bpf: Fix bitwise vs. logical OR warning To: Nathan Chancellor Cc: Simon Horman , Jakub Kicinski , "David S. Miller" , oss-drivers@corigine.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, llvm@lists.linux.dev Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 18, 2021 at 12:39 PM Nick Desaulniers wrote: > > On Mon, Oct 18, 2021 at 12:31 PM Nathan Chancellor wrote: > > > > A new warning in clang points out two places in this driver where > > boolean expressions are being used with a bitwise OR instead of a > > logical one: > > > > drivers/net/ethernet/netronome/nfp/nfp_asm.c:199:20: error: use of bitwise '|' with boolean operands [-Werror,-Wbitwise-instead-of-logical] > > reg->src_lmextn = swreg_lmextn(lreg) | swreg_lmextn(rreg); > > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > || > > drivers/net/ethernet/netronome/nfp/nfp_asm.c:199:20: note: cast one or both operands to int to silence this warning > > drivers/net/ethernet/netronome/nfp/nfp_asm.c:280:20: error: use of bitwise '|' with boolean operands [-Werror,-Wbitwise-instead-of-logical] > > reg->src_lmextn = swreg_lmextn(lreg) | swreg_lmextn(rreg); > > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > || > > drivers/net/ethernet/netronome/nfp/nfp_asm.c:280:20: note: cast one or both operands to int to silence this warning > > 2 errors generated. > > > > The motivation for the warning is that logical operations short circuit > > while bitwise operations do not. In this case, it does not seem like > > short circuiting is harmful so implement the suggested fix of changing > > to a logical operation to fix the warning. > > I agree. Thanks for the patch. > Reviewed-by: Nick Desaulniers Perhaps: Fixes: 995e101ffa71 ("nfp: bpf: encode extended LM pointer operands") > > > > > Link: https://github.com/ClangBuiltLinux/linux/issues/1479 > > Reported-by: Nick Desaulniers > > Signed-off-by: Nathan Chancellor > > --- > > drivers/net/ethernet/netronome/nfp/nfp_asm.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/net/ethernet/netronome/nfp/nfp_asm.c b/drivers/net/ethernet/netronome/nfp/nfp_asm.c > > index 2643ea5948f4..154399c5453f 100644 > > --- a/drivers/net/ethernet/netronome/nfp/nfp_asm.c > > +++ b/drivers/net/ethernet/netronome/nfp/nfp_asm.c > > @@ -196,7 +196,7 @@ int swreg_to_unrestricted(swreg dst, swreg lreg, swreg rreg, > > } > > > > reg->dst_lmextn = swreg_lmextn(dst); > > - reg->src_lmextn = swreg_lmextn(lreg) | swreg_lmextn(rreg); > > + reg->src_lmextn = swreg_lmextn(lreg) || swreg_lmextn(rreg); > > > > return 0; > > } > > @@ -277,7 +277,7 @@ int swreg_to_restricted(swreg dst, swreg lreg, swreg rreg, > > } > > > > reg->dst_lmextn = swreg_lmextn(dst); > > - reg->src_lmextn = swreg_lmextn(lreg) | swreg_lmextn(rreg); > > + reg->src_lmextn = swreg_lmextn(lreg) || swreg_lmextn(rreg); > > > > return 0; > > } > > > > base-commit: 041c61488236a5a84789083e3d9f0a51139b6edf > > -- > > 2.33.1.637.gf443b226ca > > > > > > > -- > Thanks, > ~Nick Desaulniers -- Thanks, ~Nick Desaulniers