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 <[email protected]>
---
 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 [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to