lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 18 Aug 2022 18:49:07 +0300
From:   Vladimir Oltean <vladimir.oltean@....com>
To:     netdev@...r.kernel.org
Cc:     Andrew Lunn <andrew@...n.ch>,
        Vivien Didelot <vivien.didelot@...il.com>,
        Florian Fainelli <f.fainelli@...il.com>,
        Vladimir Oltean <olteanv@...il.com>,
        "David S. Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>,
        "Rafael J. Wysocki" <rafael@...nel.org>,
        Kevin Hilman <khilman@...nel.org>,
        Ulf Hansson <ulf.hansson@...aro.org>,
        Len Brown <len.brown@...el.com>, Pavel Machek <pavel@....cz>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Subject: [RFC PATCH net-next 06/10] net: dsa: convert switch.c functions to return void if they can

We try to convert the non-robust cross-chip notifiers (dsa_tree_notify
and derivatives) to return void, and we'll suppress errors inside
dsa_tree_notify() itself.

It makes little sense to force all dsa_switch_event() handlers to return
int especially since they're going to be called from a function that
returns void to its own callers, so stop that and convert functions in
switch.c to return void where possible.

Signed-off-by: Vladimir Oltean <vladimir.oltean@....com>
---
 net/dsa/switch.c | 23 +++++++++--------------
 1 file changed, 9 insertions(+), 14 deletions(-)

diff --git a/net/dsa/switch.c b/net/dsa/switch.c
index 4dfd68cf61c5..e3a91f38c5db 100644
--- a/net/dsa/switch.c
+++ b/net/dsa/switch.c
@@ -104,8 +104,8 @@ static int dsa_switch_bridge_join(struct dsa_switch *ds,
 	return 0;
 }
 
-static int dsa_switch_bridge_leave(struct dsa_switch *ds,
-				   struct dsa_notifier_bridge_info *info)
+static void dsa_switch_bridge_leave(struct dsa_switch *ds,
+				    struct dsa_notifier_bridge_info *info)
 {
 	if (info->dp->ds == ds && ds->ops->port_bridge_leave)
 		ds->ops->port_bridge_leave(ds, info->dp->index, info->bridge);
@@ -115,8 +115,6 @@ static int dsa_switch_bridge_leave(struct dsa_switch *ds,
 						info->dp->ds->index,
 						info->dp->index,
 						info->bridge);
-
-	return 0;
 }
 
 /* Matches for all upstream-facing ports (the CPU port and all upstream-facing
@@ -871,7 +869,7 @@ dsa_switch_connect_tag_proto(struct dsa_switch *ds,
 	return 0;
 }
 
-static int
+static void
 dsa_switch_disconnect_tag_proto(struct dsa_switch *ds,
 				struct dsa_notifier_tag_proto_info *info)
 {
@@ -884,26 +882,23 @@ dsa_switch_disconnect_tag_proto(struct dsa_switch *ds,
 	/* No need to notify the switch, since it shouldn't have any
 	 * resources to tear down
 	 */
-	return 0;
 }
 
-static int
+static void
 dsa_switch_master_state_change(struct dsa_switch *ds,
 			       struct dsa_notifier_master_state_info *info)
 {
 	if (!ds->ops->master_state_change)
-		return 0;
+		return;
 
 	ds->ops->master_state_change(ds, info->master, info->operational);
-
-	return 0;
 }
 
 static int dsa_switch_event(struct notifier_block *nb,
 			    unsigned long event, void *info)
 {
 	struct dsa_switch *ds = container_of(nb, struct dsa_switch, nb);
-	int err;
+	int err = 0;
 
 	switch (event) {
 	case DSA_NOTIFIER_AGEING_TIME:
@@ -913,7 +908,7 @@ static int dsa_switch_event(struct notifier_block *nb,
 		err = dsa_switch_bridge_join(ds, info);
 		break;
 	case DSA_NOTIFIER_BRIDGE_LEAVE:
-		err = dsa_switch_bridge_leave(ds, info);
+		dsa_switch_bridge_leave(ds, info);
 		break;
 	case DSA_NOTIFIER_FDB_ADD:
 		err = dsa_switch_fdb_add(ds, info);
@@ -976,7 +971,7 @@ static int dsa_switch_event(struct notifier_block *nb,
 		err = dsa_switch_connect_tag_proto(ds, info);
 		break;
 	case DSA_NOTIFIER_TAG_PROTO_DISCONNECT:
-		err = dsa_switch_disconnect_tag_proto(ds, info);
+		dsa_switch_disconnect_tag_proto(ds, info);
 		break;
 	case DSA_NOTIFIER_TAG_8021Q_VLAN_ADD:
 		err = dsa_switch_tag_8021q_vlan_add(ds, info);
@@ -985,7 +980,7 @@ static int dsa_switch_event(struct notifier_block *nb,
 		err = dsa_switch_tag_8021q_vlan_del(ds, info);
 		break;
 	case DSA_NOTIFIER_MASTER_STATE_CHANGE:
-		err = dsa_switch_master_state_change(ds, info);
+		dsa_switch_master_state_change(ds, info);
 		break;
 	default:
 		err = -EOPNOTSUPP;
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ