From patchwork Sat Oct 3 01:15:59 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Khapyorsky X-Patchwork-Id: 51488 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 n931EDYr024411 for ; Sat, 3 Oct 2009 01:14:13 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756453AbZJCBOH (ORCPT ); Fri, 2 Oct 2009 21:14:07 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756490AbZJCBOH (ORCPT ); Fri, 2 Oct 2009 21:14:07 -0400 Received: from mail-ew0-f211.google.com ([209.85.219.211]:42839 "EHLO mail-ew0-f211.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756453AbZJCBOG (ORCPT ); Fri, 2 Oct 2009 21:14:06 -0400 Received: by ewy7 with SMTP id 7so1541731ewy.17 for ; Fri, 02 Oct 2009 18:14:09 -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:references:mime-version:content-type :content-disposition:in-reply-to:user-agent; bh=I18ZG/f3uBKM12LONmpfOQ9aJnK+bxFlQdXyhz9q46A=; b=qNnfNR5q9temc7JpCCQftNT0pom3PkE8m2212mFn+79guPI9DnXE9wUWX1TQYWFqzc uhJOQ6iI+Dzay1zez011lY+/GrzWjweBvNx7oq/LXrEtGEZsGIPScLR3l1W6lDJXNbmU 6MHjULO0iT4BU6+RA9pOHw220ZN/QAEnVf0CQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=PiKmfqyRgyMdQn0bDaE5hRh4Rpp0/sswRt2uE9JDjR2AuK254CaX6YTtR2oi66SVWL SYWVMDSB/efhZxy5G2EYA/EPdL3hjXUbZTH0H7ZzX/l6mpOo6gwWTDkFjP5HhHtZ5U6H fEqB3zPiVG6M5T6rTO0kjN8V0lvSyRVg1wNSs= Received: by 10.211.147.12 with SMTP id z12mr3873372ebn.37.1254532449119; Fri, 02 Oct 2009 18:14:09 -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 10sm552565eyz.10.2009.10.02.18.14.08 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 02 Oct 2009 18:14:08 -0700 (PDT) Received: by me.localdomain (Postfix, from userid 1000) id 74157429E0; Sat, 3 Oct 2009 03:15:59 +0200 (IST) Date: Sat, 3 Oct 2009 03:15:59 +0200 From: Sasha Khapyorsky To: linux-rdma Cc: Dale Purdy , Hal Rosenstock Subject: [PATCH] opensm/osm_qos_parser_y.y: fix endless loop Message-ID: <20091003011559.GE17846@me> References: <20091001192536.GY17846@me> <20091003003357.GD17846@me> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20091003003357.GD17846@me> 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_qos_parser_y.y b/opensm/opensm/osm_qos_parser_y.y index 7a2ce13..95e420e 100644 --- a/opensm/opensm/osm_qos_parser_y.y +++ b/opensm/opensm/osm_qos_parser_y.y @@ -2394,20 +2394,17 @@ static void yyerror(const char *format, ...) static char * __parser_strip_white(char * str) { - unsigned int i; - for (i = (strlen(str)-1); i >= 0; i--) - { - if (isspace(str[i])) - str[i] = '\0'; - else - break; - } - for (i = 0; i < strlen(str); i++) - { - if (!isspace(str[i])) - break; - } - return &(str[i]); + char *p; + + while (isspace(*str)) + str++; + if (!*str) + return str; + p = str + strlen(str) - 1; + while (isspace(*p)) + *p-- = '\0'; + + return str; } /***************************************************