diff mbox

osmtest/osmt_slvl_vl_arb.c: handling fopen() failure

Message ID 4C865521.4080600@mellanox.co.il (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Yevgeny Kliteynik Sept. 7, 2010, 3:07 p.m. UTC
None
diff mbox

Patch

diff --git a/opensm/osmtest/osmt_slvl_vl_arb.c b/opensm/osmtest/osmt_slvl_vl_arb.c
index d3919fb..d4a08ff 100644
--- a/opensm/osmtest/osmt_slvl_vl_arb.c
+++ b/opensm/osmtest/osmt_slvl_vl_arb.c
@@ -489,6 +489,12 @@  osmt_run_slvl_and_vlarb_records_flow(IN osmtest_t * const p_osmt)
 	OSM_LOG_ENTER(&p_osmt->log);

 	fh = fopen("qos.txt", "w");
+	if (!fh) {
+		OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0474: "
+			"Failed to open file qos.txt for writing\n");
+		status = IB_ERROR;
+		goto Exit;
+	}

 	/* go over all ports in the subnet */
 	status = osmt_query_all_ports_vl_arb(p_osmt, fh);
@@ -520,7 +526,8 @@  osmt_run_slvl_and_vlarb_records_flow(IN osmtest_t * const p_osmt)
 	}

 Exit:
-	fclose(fh);
+	if (fh)
+		fclose(fh);
 	OSM_LOG_EXIT(&p_osmt->log);
 	return status;
 }