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

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