From patchwork Mon Jan 7 19:50:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 1942341 X-Patchwork-Delegate: alexne@voltaire.com Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id AC8533FE37 for ; Mon, 7 Jan 2013 19:50:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753373Ab3AGTuH (ORCPT ); Mon, 7 Jan 2013 14:50:07 -0500 Received: from mail-oa0-f46.google.com ([209.85.219.46]:45949 "EHLO mail-oa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751536Ab3AGTuG (ORCPT ); Mon, 7 Jan 2013 14:50:06 -0500 Received: by mail-oa0-f46.google.com with SMTP id h16so18354814oag.19 for ; Mon, 07 Jan 2013 11:50:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:cc :subject:content-type:content-transfer-encoding:x-gm-message-state; bh=/VUULzWcnxF4rxmNnzVF39mY5G3nbG95aXvKW1uFjTM=; b=GFawWhDQ6DDp1hFdl7G2/yQVFIIfIeEdyDHLMxnE1/fgc77puyqL+HoKa8Pb90KmKR lOkncxgPA/Sxo+S4w41CiQZpCMP5yVI54dSM//4h1vwnG1VML3zE3fgPzyQvidbnVS2w 5P8XQ/hkuNq6voANB5onH5IeWec85u9r/zuIWWNZaehLqXS+3UfBolHyAgSUudmAi69E QIXK+ytVN4wTyMHxgJ7Ga7TwSbh5lxq9bIx+yvox90BA+JhRJFdXwuUlGcbTn2HUevGC /mZ0LXN2GZK4cEgTgjRfuZafUFHB3Q2TndoWoVb/GRIWmAHXmbJ5m/p4PwjsLF3OVLV7 aiaA== X-Received: by 10.60.19.133 with SMTP id f5mr35225412oee.105.1357588205033; Mon, 07 Jan 2013 11:50:05 -0800 (PST) Received: from [192.168.1.102] (c-71-234-225-85.hsd1.ct.comcast.net. [71.234.225.85]) by mx.google.com with ESMTPS id y10sm33979770oeg.12.2013.01.07.11.50.02 (version=SSLv3 cipher=OTHER); Mon, 07 Jan 2013 11:50:03 -0800 (PST) Message-ID: <50EB26FF.5080507@dev.mellanox.co.il> Date: Mon, 07 Jan 2013 14:50:23 -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: Alex Netes CC: "linux-rdma (linux-rdma@vger.kernel.org)" , Jim Schutt Subject: [PATCH 1/3] opensm/osm_torus.c: Consolidate some parsing with parse_unsigned X-Gm-Message-State: ALoCoQlevSZKfSiv2bngGHqOBBmXXDYtMKY4HBdyz7C9U0oyMTMieaVqC8gmfkf634Pi/wOaUAHH Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Signed-off-by: Jim Schutt Signed-off-by: Hal Rosenstock --- -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/opensm/osm_torus.c b/opensm/osm_torus.c index 1d847b3..ff83edb 100644 --- a/opensm/osm_torus.c +++ b/opensm/osm_torus.c @@ -853,14 +853,14 @@ out: } static -bool parse_port(unsigned *pnum, const char *parse_sep) +bool parse_unsigned(unsigned *result, const char *parse_sep) { char *val, *nextchar; val = strtok(NULL, parse_sep); if (!val) return false; - *pnum = strtoul(val, &nextchar, 0); + *result = strtoul(val, &nextchar, 0); return true; } @@ -870,7 +870,7 @@ bool parse_port_order(struct torus *t, unsigned port_order[], const char *parse_ unsigned i, j, k, n; for (i = 0; i < ARRAY_SIZE(port_order); i++) { - if (!parse_port(&(port_order[i]), parse_sep)) + if (!parse_unsigned(&(port_order[i]), parse_sep)) break; for (j = 0; j < i; j++) { @@ -898,18 +898,6 @@ bool parse_port_order(struct torus *t, unsigned port_order[], const char *parse_ } static -bool parse_pg_max_ports(struct torus *t, const char *parse_sep) -{ - char *val, *nextchar; - - val = strtok(NULL, parse_sep); - if (!val) - return false; - t->portgrp_sz = strtoul(val, &nextchar, 0); - return true; -} - -static bool parse_guid(struct torus *t, guid_t *guid, const char *parse_sep) { char *val; @@ -1094,7 +1082,7 @@ next_line: kw_success = grow_seed_array(t, 1); t->seed_cnt++; } else if (strcmp("portgroup_max_ports", keyword) == 0) { - kw_success = parse_pg_max_ports(t, parse_sep); + kw_success = parse_unsigned(&t->portgrp_sz, parse_sep); } else if (strcmp("xp_link", keyword) == 0) { if (!t->seed_cnt) t->seed_cnt++;