[ofa-general] [PATCH] infiniband-diags/mcm_rereg_test.c: Handle error when guid file not found

Hal Rosenstock hrosenstock at xsigo.com
Thu Jun 5 12:51:49 PDT 2008


infiniband-diags/mcm_rereg_test.c: Handle error when guid file not found

ERR: cannot open port_guids.list: No such file or directory

Signed-off-by: Hal Rosenstock <hal at xsigo.com>

diff --git a/infiniband-diags/src/mcm_rereg_test.c b/infiniband-diags/src/mcm_rereg_test.c
index 4f3ccc1..2bdf9dc 100644
--- a/infiniband-diags/src/mcm_rereg_test.c
+++ b/infiniband-diags/src/mcm_rereg_test.c
@@ -397,6 +397,11 @@ static int rereg_and_test_port(char *guid_file, int port, int agent, ib_portid_t
 	}
 
 	f = fopen(guid_file, "r");
+	if (!f) {
+		err("cannot open %s: %s\n", guid_file, strerror(errno));
+		return -1;
+	}
+
 	while (fgets(line, sizeof(line), f)) {
 		guid = strtoull(line, NULL, 0);
 		guid = htonll(guid);





More information about the general mailing list