diff mbox series

[v1,1/1] netlink: Don't use int as bool in netlink_update_socket_mc()

Message ID 20230629133131.83284-1-andriy.shevchenko@linux.intel.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [v1,1/1] netlink: Don't use int as bool in netlink_update_socket_mc() | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 13 this patch: 13
netdev/cc_maintainers warning 1 maintainers not CCed: kuniyu@amazon.com
netdev/build_clang fail Errors and warnings before: 61 this patch: 53
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 13 this patch: 13
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 20 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

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

Andy Shevchenko June 29, 2023, 6:55 p.m. UTC | #1
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!
diff mbox series

Patch

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 *