Message ID | 20230629133131.83284-1-andriy.shevchenko@linux.intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9642553vqr; Thu, 29 Jun 2023 06:35:24 -0700 (PDT) X-Google-Smtp-Source: APBJJlHYK6GYP+J8JWFhKRRiuE/xa9R/hRAYaKqP1S+YzoKDMVe5NNB19rGuqSK8MOKyQI+UFwrV X-Received: by 2002:a17:90a:f014:b0:263:484c:f173 with SMTP id bt20-20020a17090af01400b00263484cf173mr4630487pjb.2.1688045724293; Thu, 29 Jun 2023 06:35:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688045724; cv=none; d=google.com; s=arc-20160816; b=OO7uyvzNX15rZAqkXITzhPM/izFOxrsI7U138TPFX1bkj7E3VixClXeGV2kL/n7/bD /4/+CcyGMs05+5TdnzC2wOy2N4LbnTtQv4HF1ZtHQFyJhgzbOfu2FkUgLOyNP/zmU8X6 LPvkbYKNxRYMlJdR0BIioZ19mei7yxZI4t/LvLsMThI0SjOG12X6R18epBEfzkIuXfFi tArL7lWXANCvakbLZIN9VWGfUcXU7NEVn1+4ls+PapYx2LA8xoydOO0ppWvIdFszaN9z h6xwo5jIxetYKpKBEHB3O1IhHFWKWKD8TjQTu+I/UPFal2ZvN8AeJtuwzZzoZNH2vlHm Dr4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=MY/CBzqggpCL3GLBZUvesQ4Y89d8biWTznxFEXZiS0A=; fh=VBs/5jiHsdY+iY+aPoKp7jwua1fV1L9ZgLrBklhlDuM=; b=FFIiVjo+/qhJNAhlHpUr+nbTDGrdRgvnLmpQSTsELAVpc0exb4GPfVAt+DCjiDUpv1 E6b77F5ytDR9zsnkBvLYuVf/+Z5+jTMmmO1Pf9Zrip0eAk5+aGjmPPD+tMuSX18cu4ef oOJX+qkkRQWM7j5N4TjD27Ea6vVfetdR6ly8y1rhxjdnMb3OQX1E/xqlIHoeIxQSoBKy cXHRTJoXas/kFFW6Lk9TbTSIHZmTN/dovufc4fgsdj6pCNiJuiPz465rvpFoAXOb0jjh zwGOww82fkfcQt6EBRz9QE+7JxpW0KPv/JBGgyBQt2q6/dCpXbWcepqS0z+RM6Mmhgmv ew8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=E3qVfdDh; 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=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 72-20020a17090a09ce00b002634e08d484si1724381pjo.56.2023.06.29.06.35.10; Thu, 29 Jun 2023 06:35:24 -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=@intel.com header.s=Intel header.b=E3qVfdDh; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231290AbjF2Nbh (ORCPT <rfc822;ivan.orlov0322@gmail.com> + 99 others); Thu, 29 Jun 2023 09:31:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229873AbjF2Nbf (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 29 Jun 2023 09:31:35 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF9BD10FB; Thu, 29 Jun 2023 06:31:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688045493; x=1719581493; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=y020DshgdnrNO1wXKnK2PXOgAt0ifI+bDGqZ24iFWSk=; b=E3qVfdDhs+0IZazqwkV56cvA0vpswJZkHxZUtVXfDLDTqZ42JA5ERdR0 RbhHNCbc/96KD1WW6z38kc04B6fF51XiJTYLtGaN2hXX1llNqO0j3J906 y+eUQYZQgSonykdb/ka+KkRqHShcGwdfbwcfBpcFDD425vBOFUbhuUjWs hZcix+22LjaqGeTqjO8oyMyQkM+MmnyMyA9nfkD+vO1HbTfXRJLPKeUa1 63FuJdy+cEy97tX7wZYhTRgGktbQigJ6T+tCy96ownP9vCoo41ZNRY0uD 7BflRYBtu84NsByNwBBlTpjDSqI2FF0TwUMAwLIeTNpTrvX5oXnQr+/14 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10756"; a="341688262" X-IronPort-AV: E=Sophos;i="6.01,168,1684825200"; d="scan'208";a="341688262" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jun 2023 06:31:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10756"; a="782686737" X-IronPort-AV: E=Sophos;i="6.01,168,1684825200"; d="scan'208";a="782686737" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga008.fm.intel.com with ESMTP; 29 Jun 2023 06:31:31 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id DE55A358; Thu, 29 Jun 2023 16:31:32 +0300 (EEST) From: Andy Shevchenko <andriy.shevchenko@linux.intel.com> To: Jakub Kicinski <kuba@kernel.org>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Paolo Abeni <pabeni@redhat.com>, Andy Shevchenko <andriy.shevchenko@linux.intel.com> Subject: [PATCH v1 1/1] netlink: Don't use int as bool in netlink_update_socket_mc() Date: Thu, 29 Jun 2023 16:31:31 +0300 Message-Id: <20230629133131.83284-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_PASS, SPF_NONE,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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770044233670124876?= X-GMAIL-MSGID: =?utf-8?q?1770044233670124876?= |
Series |
[v1,1/1] netlink: Don't use int as bool in netlink_update_socket_mc()
|
|
Commit Message
Andy Shevchenko
June 29, 2023, 1:31 p.m. UTC
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 <andriy.shevchenko@linux.intel.com>
---
net/netlink/af_netlink.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
Comments
On Thu, Jun 29, 2023 at 04:31:31PM +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 <andriy.shevchenko@linux.intel.com> > --- > 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 9c9df143a2ec..81e4b802f3f9 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; Hi Andy, Doing arithmetic with boolean values doesn't seem right to me. In any case, net-next is closed. Please consider reposting once it re-opens, after 10th July. -- pw-bot: deferred
On Thu, Jun 29, 2023 at 05:11:23PM +0200, Simon Horman wrote: > On Thu, Jun 29, 2023 at 04:31:31PM +0300, Andy Shevchenko wrote: > > - int old, new = !!is_new, subscriptions; > > + int subscriptions; > > + bool old; > > > > old = test_bit(group - 1, nlk->groups); > > subscriptions = nlk->subscriptions - old + new; > > Hi Andy, > > Doing arithmetic with boolean values doesn't seem right to me. In any case it does not change the status quo, the same still applies to the existing code (that's implied in the commit message). And obfuscating it for the sake of purity seems wrong to me. Hence this patch. > In any case, net-next is closed. > Please consider reposting once it re-opens, after 10th July. Sure. Thank you for the review!
On Thu, Jun 29, 2023 at 09:55:50PM +0300, Andy Shevchenko wrote: > On Thu, Jun 29, 2023 at 05:11:23PM +0200, Simon Horman wrote: > > On Thu, Jun 29, 2023 at 04:31:31PM +0300, Andy Shevchenko wrote: > > > > - int old, new = !!is_new, subscriptions; > > > + int subscriptions; > > > + bool old; > > > > > > old = test_bit(group - 1, nlk->groups); > > > subscriptions = nlk->subscriptions - old + new; > > > > Hi Andy, > > > > Doing arithmetic with boolean values doesn't seem right to me. > > In any case it does not change the status quo, the same still applies to > the existing code (that's implied in the commit message). And obfuscating > it for the sake of purity seems wrong to me. Hence this patch. Yes, sure. That is true. > > In any case, net-next is closed. > > Please consider reposting once it re-opens, after 10th July. > > Sure. > > Thank you for the review! > > -- > With Best Regards, > Andy Shevchenko > > >
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index 9c9df143a2ec..81e4b802f3f9 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; @@ -2149,7 +2150,7 @@ void __netlink_clear_multicast_users(struct sock *ksk, unsigned int group) struct netlink_table *tbl = &nl_table[ksk->sk_protocol]; sk_for_each_bound(sk, &tbl->mc_list) - netlink_update_socket_mc(nlk_sk(sk), group, 0); + netlink_update_socket_mc(nlk_sk(sk), group, false); } struct nlmsghdr *