From patchwork Tue Sep 7 15:07:13 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yevgeny Kliteynik X-Patchwork-Id: 161171 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o87F7QHP001237 for ; Tue, 7 Sep 2010 15:07:27 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755556Ab0IGPH0 (ORCPT ); Tue, 7 Sep 2010 11:07:26 -0400 Received: from mail.mellanox.co.il ([194.90.237.43]:60399 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751830Ab0IGPH0 (ORCPT ); Tue, 7 Sep 2010 11:07:26 -0400 Received: from Internal Mail-Server by MTLPINE2 (envelope-from kliteyn@mellanox.co.il) with SMTP; 7 Sep 2010 18:06:44 +0300 Received: from [10.4.1.29] (10.4.1.29) by mtlmail01.mtl.com (10.0.8.12) with Microsoft SMTP Server id 8.2.254.0; Tue, 7 Sep 2010 18:07:22 +0300 Message-ID: <4C865521.4080600@mellanox.co.il> Date: Tue, 7 Sep 2010 18:07:13 +0300 From: Yevgeny Kliteynik Reply-To: kliteyn@dev.mellanox.co.il User-Agent: Thunderbird 1.5.0.5 (X11/20060719) MIME-Version: 1.0 To: Sasha Khapyorsky , Linux RDMA Subject: [PATCH] osmtest/osmt_slvl_vl_arb.c: handling fopen() failure Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Tue, 07 Sep 2010 15:07:27 +0000 (UTC) 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; }