Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Technical Support
 VA Code Inspection problem.
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Breany
New Member

8 Posts

Posted - Oct 28 2017 :  6:17:16 PM  Show Profile  Reply with Quote
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

accord
Whole Tomato Software

United Kingdom
3277 Posts

Posted - Oct 29 2017 :  10:45:48 AM  Show Profile  Reply with Quote
I was able to reproduce the problem and I have put in a bug report for this:

case=112036

Thank you for the feedback!
Go to Top of Page

sean
Whole Tomato Software

USA
2817 Posts

Posted - Feb 21 2018 :  5:50:53 PM  Show Profile  Reply with Quote
case=112036 is fixed in build 2258
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2019 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000