[Spice-devel] [spice-xpi] generator: Fix parsing of UUIDs

Christophe Fergeau cfergeau at redhat.com
Wed Aug 20 07:06:58 PDT 2014


coverity is reporting dead code in that test: if len is >= 36, then the
next part of the condition will always be false: (len == 8 || len == 13
|| len == 18 || len == 23)

This code is checking that the UUID does not have alphanumeric characters where
a '-' is expected, so the adjusted condition should be correct.
---
 generator/scanner.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/generator/scanner.cpp b/generator/scanner.cpp
index f475e73..7eaa4ee 100644
--- a/generator/scanner.cpp
+++ b/generator/scanner.cpp
@@ -186,8 +186,8 @@ Token Scanner::getNextToken()
                 return Token(param.size() != 36 ? Token::T_LEX_ERROR : Token::T_UUIDVAL, param);
             }
             const int len = param.size();
-            if (c != '-' && len >= 36 &&
-               (len == 8 || len == 13 || len == 18 || len == 23))
+            if (c != '-' &&
+               (len > 36 || len == 8 || len == 13 || len == 18 || len == 23))
             {
                 return Token(Token::T_LEX_ERROR);
             }
-- 
1.9.3



More information about the Spice-devel mailing list