From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sasha Khapyorsky Subject: [PATCH] opensm/osm_qos_parser_y.y: fix endless loop Date: Sat, 3 Oct 2009 03:15:59 +0200 Message-ID: <20091003011559.GE17846@me> References: <20091001192536.GY17846@me> <20091003003357.GD17846@me> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <20091003003357.GD17846@me> Sender: linux-rdma-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: linux-rdma Cc: Dale Purdy , Hal Rosenstock List-Id: linux-rdma@vger.kernel.org Fix endless loop introduced by signed --> unsigned conversion (was done for compilation warning fix). Reimplement __parser_strip_white() in slightly shorter variant without explicit index. Signed-off-by: Sasha Khapyorsky --- opensm/opensm/osm_qos_parser_y.y | 25 +++++++++++-------------- 1 files changed, 11 insertions(+), 14 deletions(-) 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; } /*************************************************** -- 1.6.5.rc1 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html