netlink: Don't use int as bool in netlink_update_socket_mc()
Subsystems (2)
PATCH 1/1 netlink: Don't use int as bool in netlink_update_socket_mc()
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.
--- net/netlink/af_netlink.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
net/netlink/af_netlink.c +4 -3
@@ -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 *
Signature · 1 line
2.40.0.1.gaa8946217a0b
Quoted 16 lines · Andy Shevchenko
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 <[email protected]>--- net/netlink/af_netlink.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)net/netlink/af_netlink.c +0
-0@@ -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,
net/netlink/af_netlink.c EXPORT_SYMBOL(netlink_set_err); · line 1632
Quoted 10 lines
net/netlink/af_netlink.c +3
-2unsigned 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
Quoted 6 lines · Simon Horman
Quoted 4 lines · Andy Shevchenko
net/netlink/af_netlink.c +2
-1-int old, new = !!is_new, subscriptions; +int subscriptions; +bool old;
Quoted 6 lines
net/netlink/af_netlink.c EXPORT_SYMBOL(netlink_set_err); · line 1632
Quoted 2 lines
net/netlink/af_netlink.c +0
-0old =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.
Quoted 2 lines
In any case, net-next is closed.
Please consider reposting once it re-opens, after 10th July.
Sure.
Thank you for the review!
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 12 lines · Andy Shevchenko
Quoted 11 lines · Simon Horman
net/netlink/af_netlink.c EXPORT_SYMBOL(netlink_set_err); · line 1632
Quoted 6 lines · Andy Shevchenko
net/netlink/af_netlink.c +2
-1-int old, new = !!is_new, subscriptions; +int subscriptions; +bool old; old =test_bit (group -1 , nlk->groups); subscriptions = nlk->subscriptions - old + new;Hi Andy,
Quoted 5 lines
Quoted 1 line
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.
Quoted 13 lines
Quoted 2 lines
In any case, net-next is closed.
Please consider reposting once it re-opens, after 10th July.Sure.
Thank you for the review!
Signature · 2 lines
With Best Regards, Andy Shevchenko