VA_X.dll file version 10.9.2237.0 built 2017.10.03
DevEnv.exe version 14.0.25420.1 Professional
msenv.dll version 14.0.25431.1
Comctl32.dll version 6.10.7601.18837
Windows 7 6.1 Build 7601 Service Pack 1 (remote)
4 processors (x86-64, WOW64)
Language info: 1252, 0x409
Inspection problem says "Check emptiness with empty() instead of size()
Given the following code:
int Prep(
sqlite3* db,
std::string querry,
sqlite3_stmt* statement)
{
const char* errorString = nullptr;
if (sqlite3_prepare_v2(db, querry.c_str(), querry.size(), &statement, &errorString) != SQLITE_OK)
{
return true;
}
return false;
}
Applying auto-fix results in the following:
int Prep(
sqlite3* db,
std::string querry,
sqlite3_stmt* statement)
{
const char* errorString = nullptr;
if (!querry.empty())
{
return true;
}
return false;
}
The entire database interaction call is gone, not to mention the function never actually was checking for emptiness at all, leaving that job to the caller or sqlite3_prepare_v2
Note: To compile this example, it may be necessary to download sqlite from https://sqlite.org/download.html