Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 VA Code Inspection problem.

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
Breany Posted - Oct 28 2017 : 6:17:16 PM
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
2   L A T E S T    R E P L I E S    (Newest First)
sean Posted - Feb 21 2018 : 5:50:53 PM
case=112036 is fixed in build 2258
accord Posted - Oct 29 2017 : 10:45:48 AM
I was able to reproduce the problem and I have put in a bug report for this:

case=112036

Thank you for the feedback!

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000