Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2058055pxb; Sun, 17 Oct 2021 04:55:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNdNix9tJil8rJTFG+/0WgM5on5sZOiVpM0eX8ylP+xBnChrS+QDlsraDVK4yxLtQQG6SW X-Received: by 2002:a17:90b:4ac9:: with SMTP id mh9mr26709039pjb.173.1634471740012; Sun, 17 Oct 2021 04:55:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634471740; cv=none; d=google.com; s=arc-20160816; b=1LoqkjyOgdx8yZK2OszwybNIs4VhelZ4+HAvzmsWqX3OZT2PvHQz0vndpwodx7ZKi9 vGQAEdZm+UKKFEB4jKmThOtcNpKeEQ4frxZw4Y+JwBDLzO+6k8km9OgOIJZDlST3d3XE LQBcTrm74I7sDjzK7b64YoCnM9+bOWvg5F86W7PMVC983A5FwJslPAYL7894CLS/w08d A2bR7EufbewErZaNKOmvZkezmmYTzCe09OZl2iD4Ka3xP80PC3z4wTfUTqWpJVgY2HDh yqf66jh8B7v6cZy5e+Q8bGFEaAnVcNK9topYZNGZOlu7TcqvqjKrTFhLfWWV4SxEoEa0 XA+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=+hTIRKOP7jf3cdouHBIBpFNNRjb2jdkmRLPvZvvMc+U=; b=yMQBmub4UCz/sdJUYaKMf2EScWuMMWJq69dmDt7mmWXlOvVifpmAWO/PyBOgvSX8IM piCQ/nBopOE9jqJy+u5XriSaDzw7EHiyQInBdiQgqfgMH4MUbtmlVtPZnVZTVD+nLQ+4 lamSxpGei97mOuDCdbun8lkaxiVIYd96MwTHLDTu/mhuHWe2IQlpJ1qzx+w9XofivLUy Sy6JVdna280f+hwkNQYzDRVmB6iFLIMelmmHCXoRXNHHYsrJZkuUAR0+/sWfeWFn6X/o yKA5vW9GYsWOxrj0TaPOs+Rtg76afIv9tJvpf2Y8TvxHQEbiOUEBRoWkDdLiXxWcRLVE YHVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="BD8Jd/d9"; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s2si16916460plk.12.2021.10.17.04.55.27; Sun, 17 Oct 2021 04:55:40 -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=@kernel.org header.s=k20201202 header.b="BD8Jd/d9"; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242087AbhJORPR (ORCPT + 99 others); Fri, 15 Oct 2021 13:15:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:42952 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242068AbhJORPQ (ORCPT ); Fri, 15 Oct 2021 13:15:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 188F4610E8; Fri, 15 Oct 2021 17:13:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634317990; bh=VRvCgVl+c//XzNBQ2V8OIkV7ggBQcxC5gMCr8ztLdFg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=BD8Jd/d9u6v7/jMJ5e5lFdrL4ElC2BTL/Uwx3emFlTdYpFT6ufTCCcmSiNBkg+iuL uk4bFKHBY+DufTQ7kh5RgPEhLAbzn+jl3TnLFtIHkAu938jjvVXstGbuE0vp4djR/b Ce6l7O0B3bcpHD3hle1Q/ZKd6mhYnHkl1A1JwBcZiLFKhuLzF8FSAJyovS3gzi2Smp VoeqrbHXVq+L7uW5lWIyyzJuo/LIPPgX2ID700bqeOgoS5fq1cb4hIsKlYo1m2v3Fn t5TscUJ1KLnlv7CssbVOZ3QDRzLqVskQ/3DMBWvfpL1yxjvjVKgQ8TpI+t/p5o5lbZ P22JEfqV6kWjg== Date: Fri, 15 Oct 2021 10:13:05 -0700 From: Nathan Chancellor To: Dan Carpenter Cc: Greg Kroah-Hartman , Nick Desaulniers , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: Re: [PATCH] staging: wlan-ng: Avoid bitwise vs logical OR warning in hfa384x_usb_throttlefn() Message-ID: References: <20211014215703.3705371-1-nathan@kernel.org> <20211015094344.GQ8429@kadam> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211015094344.GQ8429@kadam> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 15, 2021 at 12:43:44PM +0300, Dan Carpenter wrote: > On Thu, Oct 14, 2021 at 02:57:03PM -0700, Nathan Chancellor wrote: > > A new warning in clang points out a place in this file where a bitwise > > OR is being used with boolean expressions: > > > > In file included from drivers/staging/wlan-ng/prism2usb.c:2: > > drivers/staging/wlan-ng/hfa384x_usb.c:3787:7: warning: use of bitwise '|' with boolean operands [-Wbitwise-instead-of-logical] > > ((test_and_clear_bit(THROTTLE_RX, &hw->usb_flags) && > > ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > drivers/staging/wlan-ng/hfa384x_usb.c:3787:7: note: cast one or both operands to int to silence this warning > > 1 warning generated. > > Both sides of this bitwise OR are bool, so | and || are equivalent > logically. Clang should not warn about it. I do not disagree. The original motivation for the warning was code like if (a() & b()) where a '&&' was intended to short circuit the call to b() if a() was false but then it expanded to encompass bitwise OR as well. The clang developers felt that warning on bitwise OR was worthwhile because most of the time, '||' was intended. Feel free to comment on the Phabricator thread if you feel strongly, there are not too many instances of this warning and I think the '&' vs '&&' aspect of the warning is useful. https://reviews.llvm.org/D108003 Cheers, Nathan