[Open-FCoE] [PATCH] fcoeadm: fix find_hba_index().

Joe Eykholt jeykholt at cisco.com
Sat Jan 17 01:49:19 UTC 2009


fcoeadm: fix find_hba_index().

Was always acting as if the first HBA matched all serial numbers.
This was due to missing curly-brackets.
Also, reserve the last byte of the string for an EOL, just in case.

Signed-off-by: Joe Eykholt <jeykholt at cisco.com>
---
 usr/tools/fcoeadm/fcoeadm_display.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)


diff --git a/usr/tools/fcoeadm/fcoeadm_display.c b/usr/tools/fcoeadm/fcoeadm_display.c
index 7373733..2f4c400 100644
--- a/usr/tools/fcoeadm/fcoeadm_display.c
+++ b/usr/tools/fcoeadm/fcoeadm_display.c
@@ -1130,7 +1130,7 @@ find_hba_index(char *serial_number, int *hba_index)
 {
 	int i, j;
 
-	j = sizeof(hba_name_table[0].SerialNumber);
+	j = sizeof(hba_name_table[0].SerialNumber) - 1;
 	for (i = 0; i < MAX_HBA_COUNT; i++) {
 		if (hba_name_table[i].index == -1) {
 			/* not found */
@@ -1141,9 +1141,11 @@ find_hba_index(char *serial_number, int *hba_index)
 			*hba_index = i;
 			return 1;    /* print hba info */
 		}
-		if (!strncmp(serial_number, hba_name_table[i].SerialNumber, j))
+		if (!strncmp(serial_number,
+		    hba_name_table[i].SerialNumber, j)) {
 			*hba_index = hba_name_table[i].index;
 			return 0;    /* do not print hba info */
+		}
 	}
 	/* table full */
 	return -1;





More information about the devel mailing list