From patchwork Thu Jan 16 16:18:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 3499441 X-Patchwork-Delegate: hal@mellanox.com Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 288A29F32F for ; Thu, 16 Jan 2014 16:19:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0DF0720165 for ; Thu, 16 Jan 2014 16:19:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E843520163 for ; Thu, 16 Jan 2014 16:18:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752085AbaAPQS4 (ORCPT ); Thu, 16 Jan 2014 11:18:56 -0500 Received: from mail-wi0-f178.google.com ([209.85.212.178]:59739 "EHLO mail-wi0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752721AbaAPQS4 (ORCPT ); Thu, 16 Jan 2014 11:18:56 -0500 Received: by mail-wi0-f178.google.com with SMTP id cc10so3905141wib.5 for ; Thu, 16 Jan 2014 08:18:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:content-type:content-transfer-encoding; bh=uMq8fIhjkksYUlhycfjautyyMvf6YG9jjWsXcnpoTxg=; b=aaE9GY9rbXTRVrZxIhZcAbw0hoAl78uB7oDkmPX+I5I3w2PAody6qgKm5ecy+pl8JI kdxaAYfg4NQgHamJG7J9VzpbuBaOC2/oVADeFSIuff1zw68G2pGDvH/oX4TFiS3/QiPt 7yjqcfO9wcISYyNINbGkxWQYlwoN79p9Sk4/elVQZVFiIkSVXooD1n5NYi9uentq8paK JAsdGtJ8YFYghQsyCfrS12/ZlihsvqJjMkxZfgutsYZeokj1j/XCRy9EZRUu/7R67we2 zRYi1cvpbApEPQTukppa6UFKBFX64V5kz2hdQy+6FOKVYgU8SZwtI6nmIORRh6PCHBGD QIUw== X-Gm-Message-State: ALoCoQn9Ki0GTyofU7JHX4nyusloE6qpJxl1evO5u74knoqyk+4Z5gxniXggFI7b8FMDROIo6YdI X-Received: by 10.194.92.7 with SMTP id ci7mr3227000wjb.58.1389889134711; Thu, 16 Jan 2014 08:18:54 -0800 (PST) Received: from [192.168.1.102] (c-98-229-118-119.hsd1.ma.comcast.net. [98.229.118.119]) by mx.google.com with ESMTPSA id pl7sm6655453wjc.16.2014.01.16.08.18.53 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 16 Jan 2014 08:18:54 -0800 (PST) Message-ID: <52D8066A.3070109@dev.mellanox.co.il> Date: Thu, 16 Jan 2014 11:18:50 -0500 From: Hal Rosenstock User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 MIME-Version: 1.0 To: "linux-rdma (linux-rdma@vger.kernel.org)" CC: Bernd Schubert , Vladimir Koushnir Subject: [PATCH opensm] osm_prtn_config.c: Some changes to osm_prtn_config_parse_file Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From 48c9f436d6c85d32d2748ba4c2756e2736bc5e7e Mon Sep 17 00:00:00 2001 From: Hal Rosenstock Date: Thu, 16 Jan 2014 18:15:02 +0200 Subject: [PATCH] osm_prtn_config.c: Some changes to osm_prtn_config_parse_file in terms of deciding when partition file is valid or not and hence when to fallback to default partition configuration. Improvements to commit 5a97c782a4b4f968c2d964c371decec5083f8499 Try default partition config if parsing partitions.conf fails Specific changes are: break out of global while on a parsing failure change is_parse_success to int from boolean and reverse logic setting this also, detect whether there is at least one valid partition parsed Signed-off-by: Hal Rosenstock --- opensm/osm_prtn_config.c | 22 +++++++++++----------- 1 files changed, 11 insertions(+), 11 deletions(-) diff --git a/opensm/osm_prtn_config.c b/opensm/osm_prtn_config.c index 9bad7a7..100282a 100644 --- a/opensm/osm_prtn_config.c +++ b/opensm/osm_prtn_config.c @@ -697,7 +697,7 @@ done: } /** - * @return -1 on error, 0 on success + * @return 1 on error, 0 on success */ int osm_prtn_config_parse_file(osm_log_t * p_log, osm_subn_t * p_subn, const char *file_name) @@ -706,7 +706,7 @@ int osm_prtn_config_parse_file(osm_log_t * p_log, osm_subn_t * p_subn, struct part_conf *conf = NULL; FILE *file; int lineno; - boolean_t is_parse_success; + int is_parse_success; file = fopen(file_name, "r"); if (!file) { @@ -718,7 +718,7 @@ int osm_prtn_config_parse_file(osm_log_t * p_log, osm_subn_t * p_subn, lineno = 0; - is_parse_success = FALSE; + is_parse_success = 0; while (fgets(line, sizeof(line) - 1, file) != NULL) { char *q, *p = line; @@ -730,8 +730,6 @@ int osm_prtn_config_parse_file(osm_log_t * p_log, osm_subn_t * p_subn, q = strchr(p, '#'); if (q) *q = '\0'; - else - is_parse_success = TRUE; do { int len; @@ -749,7 +747,7 @@ int osm_prtn_config_parse_file(osm_log_t * p_log, osm_subn_t * p_subn, "PARSE ERROR: line %d: " "internal: cannot create config\n", lineno); - is_parse_success = FALSE; + is_parse_success = -1; break; } @@ -759,10 +757,12 @@ int osm_prtn_config_parse_file(osm_log_t * p_log, osm_subn_t * p_subn, len = parse_part_conf(conf, p, lineno); if (len < 0) { - is_parse_success = FALSE; + is_parse_success = -1; break; } + is_parse_success = 1; + p += len; if (q) { @@ -770,12 +770,12 @@ int osm_prtn_config_parse_file(osm_log_t * p_log, osm_subn_t * p_subn, conf = NULL; } } while (q); + + if (is_parse_success == -1) + break; } fclose(file); - if (is_parse_success) - return 0; - else - return -1; + return (is_parse_success == 1) ? 0 : 1; }