Blame SOURCES/0002-infiniband-diags-drop-unnecessary-nodedesc-local-cop.patch

be1f7d
From d5723a0f69577fd3022024ca17c27e273a29695b Mon Sep 17 00:00:00 2001
be1f7d
From: Michal Schmidt <mschmidt@redhat.com>
be1f7d
Date: Wed, 1 Feb 2023 22:41:16 +0100
be1f7d
Subject: [PATCH 2/3] infiniband-diags: drop unnecessary nodedesc local copies
be1f7d
be1f7d
Now that remap_node_name() never rewrites nodedesc in-place, some
be1f7d
copying can be avoided.
be1f7d
be1f7d
Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
be1f7d
---
be1f7d
 infiniband-diags/dump_fts.c | 14 +++-----------
be1f7d
 1 file changed, 3 insertions(+), 11 deletions(-)
be1f7d
be1f7d
diff --git a/infiniband-diags/dump_fts.c b/infiniband-diags/dump_fts.c
be1f7d
index ce6bfb9ecc33..acef9efe692d 100644
be1f7d
--- a/infiniband-diags/dump_fts.c
be1f7d
+++ b/infiniband-diags/dump_fts.c
be1f7d
@@ -109,7 +109,6 @@ static void dump_multicast_tables(ibnd_node_t *node, unsigned startl,
be1f7d
 				  unsigned endl, struct ibmad_port *mad_port)
be1f7d
 {
be1f7d
 	ib_portid_t *portid = &node->path_portid;
be1f7d
-	char nd[IB_SMP_DATA_SIZE + 1] = { 0 };
be1f7d
 	char str[512];
be1f7d
 	char *s;
be1f7d
 	uint64_t nodeguid;
be1f7d
@@ -119,7 +118,6 @@ static void dump_multicast_tables(ibnd_node_t *node, unsigned startl,
be1f7d
 	char *mapnd = NULL;
be1f7d
 	int n = 0;
be1f7d
 
be1f7d
-	memcpy(nd, node->nodedesc, strlen(node->nodedesc));
be1f7d
 	nports = node->numports;
be1f7d
 	nodeguid = node->guid;
be1f7d
 
be1f7d
@@ -149,7 +147,7 @@ static void dump_multicast_tables(ibnd_node_t *node, unsigned startl,
be1f7d
 		endl = IB_MAX_MCAST_LID;
be1f7d
 	}
be1f7d
 
be1f7d
-	mapnd = remap_node_name(node_name_map, nodeguid, nd);
be1f7d
+	mapnd = remap_node_name(node_name_map, nodeguid, node->nodedesc);
be1f7d
 
be1f7d
 	printf("Multicast mlids [0x%x-0x%x] of switch %s guid 0x%016" PRIx64
be1f7d
 	       " (%s):\n", startl, endl, portid2str(portid), nodeguid,
be1f7d
@@ -224,8 +222,6 @@ static int dump_lid(char *str, int str_len, int lid, int valid,
be1f7d
 		    ibnd_fabric_t *fabric, int *last_port_lid,
be1f7d
 		    int *base_port_lid, uint64_t *portguid)
be1f7d
 {
be1f7d
-	char nd[IB_SMP_DATA_SIZE + 1] = { 0 };
be1f7d
-
be1f7d
 	ibnd_port_t *port = NULL;
be1f7d
 
be1f7d
 	char ntype[50], sguid[30];
be1f7d
@@ -276,14 +272,12 @@ static int dump_lid(char *str, int str_len, int lid, int valid,
be1f7d
 	baselid = port->base_lid;
be1f7d
 	lmc = port->lmc;
be1f7d
 
be1f7d
-	memcpy(nd, port->node->nodedesc, strlen(port->node->nodedesc));
be1f7d
-
be1f7d
 	if (lmc > 0) {
be1f7d
 		*base_port_lid = baselid;
be1f7d
 		*last_port_lid = baselid + (1 << lmc) - 1;
be1f7d
 	}
be1f7d
 
be1f7d
-	mapnd = remap_node_name(node_name_map, nodeguid, nd);
be1f7d
+	mapnd = remap_node_name(node_name_map, nodeguid, port->node->nodedesc);
be1f7d
  
be1f7d
 	rc = snprintf(str, str_len, ": (%s portguid %s: '%s')",
be1f7d
 		      mad_dump_val(IB_NODE_TYPE_F, ntype, sizeof ntype,
be1f7d
@@ -302,7 +296,6 @@ static void dump_unicast_tables(ibnd_node_t *node, int startl, int endl,
be1f7d
 {
be1f7d
 	ib_portid_t * portid = &node->path_portid;
be1f7d
 	char lft[IB_SMP_DATA_SIZE] = { 0 };
be1f7d
-	char nd[IB_SMP_DATA_SIZE + 1] = { 0 };
be1f7d
 	char str[200];
be1f7d
 	uint64_t nodeguid;
be1f7d
 	int block, i, e, top;
be1f7d
@@ -315,7 +308,6 @@ static void dump_unicast_tables(ibnd_node_t *node, int startl, int endl,
be1f7d
 	mad_decode_field(node->switchinfo, IB_SW_LINEAR_FDB_TOP_F, &top);
be1f7d
 	nodeguid = node->guid;
be1f7d
 	nports = node->numports;
be1f7d
-	memcpy(nd, node->nodedesc, strlen(node->nodedesc));
be1f7d
 
be1f7d
 	if (!endl || endl > top)
be1f7d
 		endl = top;
be1f7d
@@ -326,7 +318,7 @@ static void dump_unicast_tables(ibnd_node_t *node, int startl, int endl,
be1f7d
 		endl = IB_MAX_UCAST_LID;
be1f7d
 	}
be1f7d
 
be1f7d
-	mapnd = remap_node_name(node_name_map, nodeguid, nd);
be1f7d
+	mapnd = remap_node_name(node_name_map, nodeguid, node->nodedesc);
be1f7d
 
be1f7d
 	printf("Unicast lids [0x%x-0x%x] of switch %s guid 0x%016" PRIx64
be1f7d
 	       " (%s):\n", startl, endl, portid2str(portid), nodeguid,
be1f7d
-- 
be1f7d
2.39.1
be1f7d