From 966d078dcc8e95583734c18600782e658f1afaea Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Fri, 15 Jan 2016 09:29:29 +0100 Subject: [PATCH] CheckIO: Fix FN when using '%x' as format specifier for a 'signed int' variable --- lib/checkio.cpp | 2 +- test/testio.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/checkio.cpp b/lib/checkio.cpp index 05efdf4e8..b61af0dc8 100644 --- a/lib/checkio.cpp +++ b/lib/checkio.cpp @@ -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") || diff --git a/test/testio.cpp b/test/testio.cpp index 08d2509fe..6de795af4 100644 --- a/test/testio.cpp +++ b/test/testio.cpp @@ -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");