CheckIO: Fix FN when using '%x' as format specifier for a 'signed int' variable

This commit is contained in:
Robert Reif 2016-01-15 09:29:29 +01:00 committed by Daniel Marjamäki
parent 161412dc31
commit 966d078dcc
2 changed files with 3 additions and 3 deletions

View File

@ -770,7 +770,7 @@ void CheckIO::checkFormatString(const Token * const tok,
invalidScanfArgTypeError_int(tok, numFormat, specifier, &argInfo, true);
break;
default:
if (argInfo.typeToken->str() != "int")
if (argInfo.typeToken->str() != "int" || !argInfo.typeToken->isUnsigned())
invalidScanfArgTypeError_int(tok, numFormat, specifier, &argInfo, true);
else if (typesMatch(argInfo.typeToken->originalName(), "size_t") ||
typesMatch(argInfo.typeToken->originalName(), "ptrdiff_t") ||

View File

@ -1186,8 +1186,8 @@ private:
TEST_SCANF("%x", "unsigned int", "short");
TEST_SCANF("%x", "unsigned int", "signed short");
TEST_SCANF("%x", "unsigned int", "unsigned short");
// TEST_SCANF("%x", "unsigned int", "int");
// TODO TEST_SCANF("%x", "unsigned int", "signed int");
TEST_SCANF("%x", "unsigned int", "int");
TEST_SCANF("%x", "unsigned int", "signed int");
TEST_SCANF("%x", "unsigned int", "long");
TEST_SCANF("%x", "unsigned int", "signed long");
TEST_SCANF("%x", "unsigned int", "unsigned long");