public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
* [infiniband-diags] [PATCH] [1/3] remove unnecessary casting in libibnetdiscover
@ 2009-11-17 18:16 Al Chu
       [not found] ` <1258481774.1335.95.camel-X2zTWyBD0EhliZ7u+bvwcg@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Al Chu @ 2009-11-17 18:16 UTC (permalink / raw)
  To: sashak-smomgflXvOZWk0Htik3J/w; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 308 bytes --]

Hey Sasha,

I noticed a bunch of unnecessary casting.  The typing is done correctly
throughout the code, so I assume the casting was done due to legacy
reasons.

Al

-- 
Albert Chu
chu11-i2BcT+NCU+M@public.gmane.org
Computer Scientist
High Performance Systems Division
Lawrence Livermore National Laboratory

[-- Attachment #2: 0001-remove-unnecessary-casting-in-libibnetdiscover.patch --]
[-- Type: text/plain, Size: 3616 bytes --]

From: Albert Chu <chu11-i2BcT+NCU+M@public.gmane.org>
Date: Mon, 16 Nov 2009 17:14:34 -0800
Subject: [PATCH] remove unnecessary casting in libibnetdiscover


Signed-off-by: Albert Chu <chu11-i2BcT+NCU+M@public.gmane.org>
---
 infiniband-diags/libibnetdisc/src/chassis.c |   28 ++++++++++----------------
 1 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/infiniband-diags/libibnetdisc/src/chassis.c b/infiniband-diags/libibnetdisc/src/chassis.c
index 3bd0108..a8b6767 100644
--- a/infiniband-diags/libibnetdisc/src/chassis.c
+++ b/infiniband-diags/libibnetdisc/src/chassis.c
@@ -346,30 +346,28 @@ char anafa_spine4_slot_2_slb[25] = {
 
 /*	reference                     { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 }; */
 
-static int get_sfb_slot(ibnd_node_t * node, ibnd_port_t * lineport)
+static int get_sfb_slot(ibnd_node_t * n, ibnd_port_t * lineport)
 {
-	ibnd_node_t *n = (ibnd_node_t *) node;
-
 	n->ch_slot = SPINE_CS;
-	if (is_spine_9096(node)) {
+	if (is_spine_9096(n)) {
 		n->ch_type = ISR9096_CT;
 		n->ch_slotnum = spine4_slot_2_slb[lineport->portnum];
 		n->ch_anafanum = anafa_spine4_slot_2_slb[lineport->portnum];
-	} else if (is_spine_9288(node)) {
+	} else if (is_spine_9288(n)) {
 		n->ch_type = ISR9288_CT;
 		n->ch_slotnum = spine12_slot_2_slb[lineport->portnum];
 		n->ch_anafanum = anafa_spine12_slot_2_slb[lineport->portnum];
-	} else if (is_spine_2012(node)) {
+	} else if (is_spine_2012(n)) {
 		n->ch_type = ISR2012_CT;
 		n->ch_slotnum = spine12_slot_2_slb[lineport->portnum];
 		n->ch_anafanum = anafa_spine12_slot_2_slb[lineport->portnum];
-	} else if (is_spine_2004(node)) {
+	} else if (is_spine_2004(n)) {
 		n->ch_type = ISR2004_CT;
 		n->ch_slotnum = spine4_slot_2_slb[lineport->portnum];
 		n->ch_anafanum = anafa_spine4_slot_2_slb[lineport->portnum];
 	} else {
 		IBND_ERROR("Unexpected node found: guid 0x%016" PRIx64,
-			   node->guid);
+			   n->guid);
 		return -1;
 	}
 	return 0;
@@ -653,7 +651,7 @@ static int build_chassis(ibnd_node_t * node, ibnd_chassis_t * chassis)
 	ibnd_port_t *port = 0;
 
 	/* we get here with node = chassis_spine */
-	if (insert_spine((ibnd_node_t *) node, chassis))
+	if (insert_spine(node, chassis))
 		return -1;
 
 	/* loop: pass on all ports of node */
@@ -874,8 +872,7 @@ int group_nodes(ibnd_fabric_t * fabric, ibnd_scan_t *scan)
 			if (mad_get_field64(node->info, 0,
 					    IB_NODE_SYSTEM_GUID_F)) {
 				chassis =
-				    find_chassisguid(fabric,
-						     (ibnd_node_t *) node);
+				    find_chassisguid(fabric, node);
 				if (chassis)
 					chassis->nodecount++;
 				else {
@@ -883,8 +880,7 @@ int group_nodes(ibnd_fabric_t * fabric, ibnd_scan_t *scan)
 					if (add_chassis(scan))
 						goto cleanup;
 					scan->current_chassis->chassisguid =
-					    get_chassisguid((ibnd_node_t *)
-							    node);
+					    get_chassisguid(node);
 					scan->current_chassis->nodecount = 1;
 				}
 			}
@@ -902,8 +898,7 @@ int group_nodes(ibnd_fabric_t * fabric, ibnd_scan_t *scan)
 			if (mad_get_field64(node->info, 0,
 					    IB_NODE_SYSTEM_GUID_F)) {
 				chassis =
-				    find_chassisguid(fabric,
-						     (ibnd_node_t *) node);
+				    find_chassisguid(fabric, node);
 				if (chassis && chassis->nodecount > 1) {
 					if (!chassis->chassisnum)
 						chassis->chassisnum =
@@ -911,8 +906,7 @@ int group_nodes(ibnd_fabric_t * fabric, ibnd_scan_t *scan)
 					if (!node->ch_found) {
 						node->ch_found = 1;
 						add_node_to_chassis(chassis,
-								    (ibnd_node_t
-								     *) node);
+								    node);
 					}
 				}
 			}
-- 
1.5.4.5


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [infiniband-diags] [PATCH] [1/3] remove unnecessary casting in libibnetdiscover
       [not found] ` <1258481774.1335.95.camel-X2zTWyBD0EhliZ7u+bvwcg@public.gmane.org>
@ 2009-11-26 17:02   ` Sasha Khapyorsky
  0 siblings, 0 replies; 2+ messages in thread
From: Sasha Khapyorsky @ 2009-11-26 17:02 UTC (permalink / raw)
  To: Al Chu; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA

On 10:16 Tue 17 Nov     , Al Chu wrote:
> Hey Sasha,
> 
> I noticed a bunch of unnecessary casting.  The typing is done correctly
> throughout the code, so I assume the casting was done due to legacy
> reasons.
> 
> Al
> 
> -- 
> Albert Chu
> chu11-i2BcT+NCU+M@public.gmane.org
> Computer Scientist
> High Performance Systems Division
> Lawrence Livermore National Laboratory

> From: Albert Chu <chu11-i2BcT+NCU+M@public.gmane.org>
> Date: Mon, 16 Nov 2009 17:14:34 -0800
> Subject: [PATCH] remove unnecessary casting in libibnetdiscover
> 
> 
> Signed-off-by: Albert Chu <chu11-i2BcT+NCU+M@public.gmane.org>

Applied. Thanks.

Sasha
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-11-26 17:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-17 18:16 [infiniband-diags] [PATCH] [1/3] remove unnecessary casting in libibnetdiscover Al Chu
     [not found] ` <1258481774.1335.95.camel-X2zTWyBD0EhliZ7u+bvwcg@public.gmane.org>
2009-11-26 17:02   ` Sasha Khapyorsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox