From 89b83b2d165c83b666f8607258958edb99bd15be Mon Sep 17 00:00:00 2001 From: Dmitry-Me Date: Wed, 8 Nov 2017 15:06:51 +0300 Subject: [PATCH] Fix FN for unsigned ptrdiff_t passed as %Ix into scanf --- lib/checkio.cpp | 3 +-- test/testio.cpp | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/checkio.cpp b/lib/checkio.cpp index da3eb0b0b..2206c4741 100644 --- a/lib/checkio.cpp +++ b/lib/checkio.cpp @@ -763,8 +763,7 @@ void CheckIO::checkFormatString(const Token * const tok, } else if (specifier.find("I32") != std::string::npos) { if (argInfo.typeToken->str() != "int" || argInfo.typeToken->isLong()) invalidScanfArgTypeError_int(tok, numFormat, specifier, &argInfo, true); - } else if (!typesMatch(argInfo.typeToken->originalName(), "ptrdiff_t") && - !typesMatch(argInfo.typeToken->originalName(), "size_t")) + } else if (!typesMatch(argInfo.typeToken->originalName(), "size_t")) invalidScanfArgTypeError_int(tok, numFormat, specifier, &argInfo, true); break; case 'j': diff --git a/test/testio.cpp b/test/testio.cpp index c06e479a4..e32a88eb9 100644 --- a/test/testio.cpp +++ b/test/testio.cpp @@ -1576,7 +1576,7 @@ private: TEST_SCANF_NOWARN("%Ix", "size_t", "size_t"); TEST_SCANF_WARN_AKA("%Ix", "size_t", "ssize_t", "signed long", "signed long long"); TEST_SCANF_WARN_AKA("%Ix", "size_t", "ptrdiff_t", "signed long", "signed long long"); - // TODO TEST_SCANF_WARN_AKA("%Ix", "size_t", "unsigned ptrdiff_t", "unsigned long", "unsigned long long"); + TEST_SCANF_WARN_AKA("%Ix", "size_t", "unsigned ptrdiff_t", "unsigned long", "unsigned long long"); TEST_SCANF_WARN_AKA("%Ix", "size_t", "intmax_t", "signed long", "signed long long"); TEST_SCANF_WARN_AKA("%Ix", "size_t", "uintmax_t", "unsigned long", "unsigned long long"); TEST_SCANF_NOWARN("%Ix", "size_t", "std::size_t");