Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp36782903rwd; Tue, 11 Jul 2023 05:48:41 -0700 (PDT) X-Google-Smtp-Source: APBJJlGf4D1mpI5SG+ZC2xnBK9bopyTSSr1U84m3OZsG8InzhsTb59iQaX8XdYPe+mn4GW6RjwGZ X-Received: by 2002:a50:eac5:0:b0:51d:f3b2:87b8 with SMTP id u5-20020a50eac5000000b0051df3b287b8mr17418890edp.0.1689079721414; Tue, 11 Jul 2023 05:48:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689079721; cv=none; d=google.com; s=arc-20160816; b=Hwggqq+W8WBCry5KJB2jV2QMaIX3Z8AHFzTfMCGPPfS2ekQr+s1YYR6iTGs/zx1Jnv y6Si5uXLwPVxPepUW6+OcvxF0SICCLyuOM6OaZiYwcnvhVhbWjCDXA5EC2Bpn7EhES8V 7PDqGeJhTTQw3oi9QFMgjJAOPKSlg5AqbBg7QhF7yfzlEthI5PGB71eRoMPNgp/RkxgC aYmruYanXVhQurnNc0BzoUCGwg+2Osig27llgdov2/QObmUyJ1TzMqgKJesjQ0/c48eg CTGdFmcfFwynHo73CEZILNkBHauxo7f2Zo+/GHFXbTYxPa/NTtr2NMLj5oStxGbC/PvS LsvA== 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=Q+7XBiHWV/aK/oAzZaOdQVk1xxInF4zeWn8ey5e6pIs=; fh=hXtGuEA05zkIvTZUgMtgz55njjZkjQgo/o+FAeiE56I=; b=PCwrLROtKRL4Lr99AD0VYBWtl1KFrTWIMwftCThOfOA6XhNZAaix4EcWSoy2GSYfpI f53JFc1Y55Hhoi+bZKO+R8C6K9ufqjK8iln4UP5DgERtdq5I4BQE5GbILwttsSNeGxlX VTtN+3pD/yqQo0o5gMI4djADGV8E7inQSvj0tg3mX9MXu+86eCG0L8090QLTdSUzvgQg Z2imOGCXhutHfawH7H2CIWTLXotZGGAn2mtKJYzWBA9bdE+jsbB+evQPgpXn6JkMqGwT 5fRPOJl8TXpinzz6F+GEsJ5nulyhsTHt83UIIDxsrMOm5V8PXlaUqjoPzj/Cc2v85/SU gLwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=l0woitDj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g6-20020a056402180600b0051e2ccf8121si1920440edy.631.2023.07.11.05.48.17; Tue, 11 Jul 2023 05:48:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=l0woitDj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S232401AbjGKMXJ (ORCPT + 99 others); Tue, 11 Jul 2023 08:23:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232516AbjGKMWs (ORCPT ); Tue, 11 Jul 2023 08:22:48 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 940341717 for ; Tue, 11 Jul 2023 05:21:18 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5FC4F614BA for ; Tue, 11 Jul 2023 12:20:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 00EF4C433C7; Tue, 11 Jul 2023 12:20:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689078016; bh=ESrFukL6Avmq96Qu5Z0oVFoi45CucnlANyNQFqVS/EI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=l0woitDjv2729w2lKE8MkSDWhI9pE3s5StDUzTavbZivo5Oyc5vZwwAUIfxPu3Juz 0P7vfULY6rAu7A4YI/aCthk+ruMFZURj9z0a6HJQ/81tSA46wsiaiddONLZKKmaCR4 9+2b84FyJcP3VMxTaU8qVaKGPyBX/Kn4GwLZBuRzMDuUXQGbO115qE1M/AYZLGmajz WcUPq7qEzXmtGmHPsm37f3u0KgU8MJQ8W7Xdsv1Q/bqdXHPxh1Cz9DhsIqhx6BDxtX 4PdxfsZ8kqPQmS/eJo2eYK6I4wNmbVq3ai2TcCpauITpYOutNeAobWuJoB+VyS/nHJ hrjIJPdP7q2cg== Date: Tue, 11 Jul 2023 15:20:12 +0300 From: Leon Romanovsky To: Andy Shevchenko Cc: Paolo Abeni , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "David S. Miller" , Eric Dumazet Subject: Re: [PATCH net-next][resend v1 1/1] netlink: Don't use int as bool in netlink_update_socket_mc() Message-ID: <20230711122012.GR41919@unreal> References: <20230710100624.87836-1-andriy.shevchenko@linux.intel.com> <20230711063348.GB41919@unreal> <2a2d55f167a06782eb9dfa6988ec96c2eedb7fba.camel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 11, 2023 at 01:54:18PM +0300, Andy Shevchenko wrote: > On Tue, Jul 11, 2023 at 12:21:12PM +0200, Paolo Abeni wrote: > > On Tue, 2023-07-11 at 09:33 +0300, Leon Romanovsky wrote: > > > On Mon, Jul 10, 2023 at 01:06:24PM +0300, Andy Shevchenko wrote: > > > > The bit operations take boolean parameter and return also boolean > > > > (in test_bit()-like cases). Don't threat booleans as integers when > > > > it's not needed. > > > > > > > > Signed-off-by: Andy Shevchenko > > > > --- > > > > net/netlink/af_netlink.c | 7 ++++--- > > > > 1 file changed, 4 insertions(+), 3 deletions(-) > > > > > > > > diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c > > > > index 383631873748..d81e7a43944c 100644 > > > > --- a/net/netlink/af_netlink.c > > > > +++ b/net/netlink/af_netlink.c > > > > @@ -1623,9 +1623,10 @@ EXPORT_SYMBOL(netlink_set_err); > > > > /* must be called with netlink table grabbed */ > > > > static void netlink_update_socket_mc(struct netlink_sock *nlk, > > > > unsigned int group, > > > > - int is_new) > > > > + bool new) > > > > { > > > > - int old, new = !!is_new, subscriptions; > > > > + int subscriptions; > > > > + bool old; > > > > > > > > old = test_bit(group - 1, nlk->groups); > > > > subscriptions = nlk->subscriptions - old + new; > > > > > > So what is the outcome of "int - bool + bool" in the line above? > > The same as with int - int [0 .. 1] + int [0 .. 1]. No, it is not. bool is defined as _Bool C99 type, so strictly speaking you are mixing types int - _Bool + _Bool. Thanks > > Note, the code _already_ uses boolean as integers. > > > FTR, I agree with Leon, the old code is more readable to me/I don't see > > a practical gain with this change. > > This change does not change the status quo. The code uses booleans as integers > already (in the callers). > > As I mentioned earlier, the purity of the code (converting booleans to integers > beforehand) adds unneeded churn and with this change code becomes cleaner at > least for the (existing) callers. > > -- > With Best Regards, > Andy Shevchenko > >