From patchwork Thu Oct 1 17:04:43 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Khapyorsky X-Patchwork-Id: 50987 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n91H2usj006923 for ; Thu, 1 Oct 2009 17:02:56 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755704AbZJARCv (ORCPT ); Thu, 1 Oct 2009 13:02:51 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755716AbZJARCv (ORCPT ); Thu, 1 Oct 2009 13:02:51 -0400 Received: from mail-ew0-f211.google.com ([209.85.219.211]:42876 "EHLO mail-ew0-f211.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755704AbZJARCu (ORCPT ); Thu, 1 Oct 2009 13:02:50 -0400 Received: by ewy7 with SMTP id 7so396969ewy.17 for ; Thu, 01 Oct 2009 10:02:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:received:date:from:to :cc:subject:message-id:mime-version:content-type:content-disposition :user-agent; bh=f3y16jtv2RY1ktv8Hwgy+LpIOL5b4im5dp7kruH6YIs=; b=bUk4C6IwY5Dzu8DqYAGINq3X25eNuDOgG5WGPY7jssJ8zzvrpMFv2/o5EwVrfx7w7x Lxz7HlCIjLfncthESN/e5hk7rPAUqbwttI612klaCy0O/8vb/EkTWHfBP9zUlAAeWwxA tQwjuFaPFt0y8xYGeXv740rifGOkIcq4n72YA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; b=QPxEUWHMucSxgScgaJEZ1IEHXiC8dRN/VB3iCaO5O3Ys0rBgGMTtct7761OWbyscWK xX0xEarco6YkcZA1Wma4nOskMIaVpEZt1B/QVNFZy80DLF0x/n8qXkJmtQ8XHZL1UgCe VytJUyaz7w+aWxEJ066FnoHXlsiUXff6hDpSk= Received: by 10.211.128.9 with SMTP id f9mr1493699ebn.93.1254416574041; Thu, 01 Oct 2009 10:02:54 -0700 (PDT) Received: from me.localdomain (85.64.35.106.dynamic.barak-online.net [85.64.35.106]) by mx.google.com with ESMTPS id 7sm17406eyb.4.2009.10.01.10.02.53 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 01 Oct 2009 10:02:53 -0700 (PDT) Received: by me.localdomain (Postfix, from userid 1000) id 62E92429E0; Thu, 1 Oct 2009 19:04:43 +0200 (IST) Date: Thu, 1 Oct 2009 19:04:43 +0200 From: Sasha Khapyorsky To: linux-rdma Cc: Hal Rosenstock Subject: [PATCH] opensm/osm_mesh.c: simplify compare_switches() function Message-ID: <20091001170443.GS17846@me> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org diff --git a/opensm/opensm/osm_mesh.c b/opensm/opensm/osm_mesh.c index e5c53d9..76191d9 100644 --- a/opensm/opensm/osm_mesh.c +++ b/opensm/opensm/osm_mesh.c @@ -1370,21 +1370,17 @@ static int reorder_links(lash_t *p_lash, mesh_t *mesh) */ static int compare_switches(const void *p1, const void *p2) { - int i, j, d; const comp_t *cp1 = p1, *cp2 = p2; const sort_ctx_t *ctx = &cp1->ctx; switch_t *s1 = ctx->p_lash->switches[cp1->index]; switch_t *s2 = ctx->p_lash->switches[cp2->index]; + int i, j; + int ret; for (i = 0; i < ctx->mesh->dimension; i++) { j = ctx->mesh->dim_order[i]; - d = s1->node->coord[j] - s2->node->coord[j]; - - if (d > 0) - return 1; - - if (d < 0) - return -1; + if ((ret = s1->node->coord[j] - s2->node->coord[j])); + return ret; } return 0;