Commit 3fb92dd5 authored by Pavel Vainerman's avatar Pavel Vainerman

Очередная группа исправлений по результатам прогона cppcheck.

parent 36ff980c
...@@ -15,7 +15,7 @@ using namespace std; ...@@ -15,7 +15,7 @@ using namespace std;
using namespace UniSetTypes; using namespace UniSetTypes;
using namespace ModbusRTU; using namespace ModbusRTU;
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
MBSlave::MBSlave( ModbusRTU::ModbusAddr addr, const std::string dev, const std::string speed, bool use485 ): MBSlave::MBSlave( ModbusRTU::ModbusAddr addr, const std::string& dev, const std::string& speed, bool use485 ):
rscomm(NULL), rscomm(NULL),
addr(addr), addr(addr),
// prev(ModbusRTU::erNoError), // prev(ModbusRTU::erNoError),
......
...@@ -15,7 +15,7 @@ using namespace std; ...@@ -15,7 +15,7 @@ using namespace std;
using namespace UniSetTypes; using namespace UniSetTypes;
using namespace ModbusRTU; using namespace ModbusRTU;
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
MBTCPServer::MBTCPServer( ModbusAddr myaddr, const string inetaddr, int port, bool verb ): MBTCPServer::MBTCPServer( ModbusAddr myaddr, const string& inetaddr, int port, bool verb ):
sslot(NULL), sslot(NULL),
addr(myaddr), addr(myaddr),
// prev(ModbusRTU::erNoError), // prev(ModbusRTU::erNoError),
......
...@@ -676,7 +676,7 @@ int main( int argc, char **argv ) ...@@ -676,7 +676,7 @@ int main( int argc, char **argv )
catch( ModbusRTU::mbException& ex ) catch( ModbusRTU::mbException& ex )
{ {
if( ex.err != ModbusRTU::erTimeOut ) if( ex.err != ModbusRTU::erTimeOut )
throw ex; throw;
cout << "timeout..." << endl; cout << "timeout..." << endl;
} }
......
...@@ -507,7 +507,7 @@ int main( int argc, char **argv ) ...@@ -507,7 +507,7 @@ int main( int argc, char **argv )
catch( ModbusRTU::mbException& ex ) catch( ModbusRTU::mbException& ex )
{ {
if( ex.err != ModbusRTU::erTimeOut ) if( ex.err != ModbusRTU::erTimeOut )
throw ex; throw;
cout << "timeout..." << endl; cout << "timeout..." << endl;
} }
......
...@@ -256,7 +256,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code ...@@ -256,7 +256,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
catch( Exception&amp; ex ) catch( Exception&amp; ex )
{ {
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(getdata): " &lt;&lt; ex &lt;&lt; endl; unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(getdata): " &lt;&lt; ex &lt;&lt; endl;
throw ex; throw;
} }
</xsl:template> </xsl:template>
...@@ -306,7 +306,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code ...@@ -306,7 +306,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
catch( Exception&amp; ex ) catch( Exception&amp; ex )
{ {
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl; unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
throw ex; throw;
} }
</xsl:template> </xsl:template>
...@@ -336,7 +336,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code ...@@ -336,7 +336,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
catch( Exception&amp; ex ) catch( Exception&amp; ex )
{ {
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl; unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
throw ex; throw;
} }
</xsl:template> </xsl:template>
......
...@@ -204,7 +204,7 @@ long <xsl:value-of select="$CLASSNAME"/>_SK::getValue( UniSetTypes::ObjectId _si ...@@ -204,7 +204,7 @@ long <xsl:value-of select="$CLASSNAME"/>_SK::getValue( UniSetTypes::ObjectId _si
catch(Exception&amp; ex) catch(Exception&amp; ex)
{ {
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(getState): " &lt;&lt; ex &lt;&lt; endl; unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(getState): " &lt;&lt; ex &lt;&lt; endl;
throw ex; throw;
} }
return 0; return 0;
...@@ -294,7 +294,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code ...@@ -294,7 +294,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
catch( UniSetTypes::Exception&amp; ex ) catch( UniSetTypes::Exception&amp; ex )
{ {
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(getdata): " &lt;&lt; ex &lt;&lt; endl; unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(getdata): " &lt;&lt; ex &lt;&lt; endl;
throw ex; throw;
} }
} }
</xsl:template> </xsl:template>
...@@ -326,7 +326,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code ...@@ -326,7 +326,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
catch( UniSetTypes::Exception&amp; ex ) catch( UniSetTypes::Exception&amp; ex )
{ {
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl; unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
throw ex; throw;
} }
} }
</xsl:template> </xsl:template>
...@@ -359,7 +359,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code ...@@ -359,7 +359,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
catch( UniSetTypes::Exception&amp; ex ) catch( UniSetTypes::Exception&amp; ex )
{ {
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl; unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
throw ex; throw;
} }
} }
</xsl:template> </xsl:template>
......
...@@ -235,9 +235,9 @@ ...@@ -235,9 +235,9 @@
xmlNode* confnode; xmlNode* confnode;
/*! получить числовое свойство из конф. файла по привязанной confnode */ /*! получить числовое свойство из конф. файла по привязанной confnode */
int getIntProp(const std::string& name) { return UniSetTypes::conf->getIntProp(confnode, name); } int getIntProp(const std::string&amp; name) { return UniSetTypes::conf->getIntProp(confnode, name); }
/*! получить текстовое свойство из конф. файла по привязанной confnode */ /*! получить текстовое свойство из конф. файла по привязанной confnode */
inline const std::string getProp(const std::string name) { return UniSetTypes::conf->getProp(confnode, name); } inline const std::string getProp(const std::string&amp; name) { return UniSetTypes::conf->getProp(confnode, name); }
int smReadyTimeout; /*!&lt; время ожидания готовности SM */ int smReadyTimeout; /*!&lt; время ожидания готовности SM */
bool activated; bool activated;
...@@ -553,7 +553,7 @@ end_private(false) ...@@ -553,7 +553,7 @@ end_private(false)
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// ( val, confval, default val ) // ( val, confval, default val )
static const std::string init3_str(const std::string& s1, const std::string& s2, const std::string& s3 ) static const std::string init3_str( const std::string&amp; s1, const std::string&amp; s2, const std::string&amp; s3 )
{ {
if( !s1.empty() ) if( !s1.empty() )
return s1; return s1;
...@@ -872,7 +872,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::testMode( bool _state ) ...@@ -872,7 +872,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::testMode( bool _state )
<xsl:template name="COMMON-CC-ALONE-FUNCS"> <xsl:template name="COMMON-CC-ALONE-FUNCS">
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// ( val, confval, default val ) // ( val, confval, default val )
static const std::string init3_str(const std::string& s1, const std::string& s2, const std::string& s3 ) static const std::string init3_str( const std::string&amp; s1, const std::string&amp; s2, const std::string&amp; s3 )
{ {
if( !s1.empty() ) if( !s1.empty() )
return s1; return s1;
......
...@@ -45,7 +45,7 @@ DBInterface::~DBInterface() ...@@ -45,7 +45,7 @@ DBInterface::~DBInterface()
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
bool DBInterface::connect( const string host, const string user, const string pswd, const string dbname) bool DBInterface::connect( const string& host, const string& user, const string& pswd, const string& dbname)
{ {
if (!mysql_real_connect(mysql,host.c_str(), user.c_str(),pswd.c_str(),dbname.c_str(),0,NULL,0)) if (!mysql_real_connect(mysql,host.c_str(), user.c_str(),pswd.c_str(),dbname.c_str(),0,NULL,0))
{ {
...@@ -65,7 +65,7 @@ bool DBInterface::close() ...@@ -65,7 +65,7 @@ bool DBInterface::close()
return true; return true;
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
bool DBInterface::insert(const string q) bool DBInterface::insert( const string& q )
{ {
if( !mysql ) if( !mysql )
return false; return false;
...@@ -80,7 +80,7 @@ bool DBInterface::insert(const string q) ...@@ -80,7 +80,7 @@ bool DBInterface::insert(const string q)
return true; return true;
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
bool DBInterface::query(const string q) bool DBInterface::query( const string& q )
{ {
if( !mysql ) if( !mysql )
return false; return false;
...@@ -189,7 +189,7 @@ bool DBInterface::dropDB(const string dbname) ...@@ -189,7 +189,7 @@ bool DBInterface::dropDB(const string dbname)
} }
*/ */
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
MYSQL_RES* DBInterface::listFields(const string table, const string wild ) MYSQL_RES* DBInterface::listFields( const string& table, const string& wild )
{ {
if( !mysql || !result ) if( !mysql || !result )
return 0; return 0;
...@@ -233,7 +233,7 @@ bool DBInterface::isConnection() ...@@ -233,7 +233,7 @@ bool DBInterface::isConnection()
return ping(); //!mysql; return ping(); //!mysql;
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
string DBInterface::addslashes(const string& str) string DBInterface::addslashes( const string& str )
{ {
ostringstream tmp; ostringstream tmp;
for( unsigned int i=0; i<str.size(); i++ ) for( unsigned int i=0; i<str.size(); i++ )
......
...@@ -39,16 +39,16 @@ class DBInterface ...@@ -39,16 +39,16 @@ class DBInterface
// bool createDB(const std::string dbname); // bool createDB(const std::string dbname);
// bool dropDB(const std::string dbname); // bool dropDB(const std::string dbname);
MYSQL_RES * listFields(const std::string table, const std::string wild ); MYSQL_RES * listFields(const std::string& table, const std::string& wild );
bool connect( const std::string host, const std::string user, const std::string pswd, bool connect( const std::string& host, const std::string& user, const std::string& pswd,
const std::string dbname); const std::string& dbname);
bool close(); bool close();
bool query(const std::string q); bool query(const std::string& q);
const std::string lastQuery(); const std::string lastQuery();
bool insert(const std::string q); bool insert(const std::string& q);
std::string addslashes(const std::string& str); std::string addslashes(const std::string& str);
......
...@@ -44,6 +44,7 @@ DBServer_MySQL::DBServer_MySQL(ObjectId id): ...@@ -44,6 +44,7 @@ DBServer_MySQL::DBServer_MySQL(ObjectId id):
ReconnectTime(180000), ReconnectTime(180000),
connect_ok(false), connect_ok(false),
activate(true), activate(true),
qbufSize(200),
lastRemove(false) lastRemove(false)
{ {
if( getId() == DefaultObjectId ) if( getId() == DefaultObjectId )
...@@ -61,6 +62,7 @@ DBServer_MySQL::DBServer_MySQL(): ...@@ -61,6 +62,7 @@ DBServer_MySQL::DBServer_MySQL():
ReconnectTime(180000), ReconnectTime(180000),
connect_ok(false), connect_ok(false),
activate(true), activate(true),
qbufSize(200),
lastRemove(false) lastRemove(false)
{ {
// init(); // init();
......
...@@ -44,8 +44,7 @@ opCheckPause(50) ...@@ -44,8 +44,7 @@ opCheckPause(50)
SQLiteInterface::~SQLiteInterface() SQLiteInterface::~SQLiteInterface()
{ {
close(); close();
if( db ) delete db;
delete db;
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
...@@ -54,7 +53,7 @@ bool SQLiteInterface::ping() ...@@ -54,7 +53,7 @@ bool SQLiteInterface::ping()
return db && ( sqlite3_db_status(db,0,NULL,NULL,0) == SQLITE_OK ); return db && ( sqlite3_db_status(db,0,NULL,NULL,0) == SQLITE_OK );
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
bool SQLiteInterface::connect( const string dbfile, bool create ) bool SQLiteInterface::connect( const string& dbfile, bool create )
{ {
// т.к. sqlite3 по умолчанию, создаёт файл при открытии, то проверим "сами" // т.к. sqlite3 по умолчанию, создаёт файл при открытии, то проверим "сами"
// if( !create && !UniSetTypes::file_exist(dbfile) ) // if( !create && !UniSetTypes::file_exist(dbfile) )
...@@ -97,7 +96,7 @@ void SQLiteInterface::setOperationTimeout( timeout_t msec ) ...@@ -97,7 +96,7 @@ void SQLiteInterface::setOperationTimeout( timeout_t msec )
sqlite3_busy_timeout(db,opTimeout); sqlite3_busy_timeout(db,opTimeout);
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
bool SQLiteInterface::insert( const string q ) bool SQLiteInterface::insert( const string& q )
{ {
if( !db ) if( !db )
return false; return false;
...@@ -134,7 +133,7 @@ bool SQLiteInterface::checkResult( int rc ) ...@@ -134,7 +133,7 @@ bool SQLiteInterface::checkResult( int rc )
return true; return true;
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
SQLiteResult SQLiteInterface::query( const string q ) SQLiteResult SQLiteInterface::query( const string& q )
{ {
if( !db ) if( !db )
return SQLiteResult(); return SQLiteResult();
......
...@@ -94,10 +94,10 @@ ...@@ -94,10 +94,10 @@
class LProcessor class LProcessor
{ {
public: public:
LProcessor( const std::string name="" ); LProcessor( const std::string& name="" );
virtual ~LProcessor(); virtual ~LProcessor();
virtual void execute( const string lfile ); virtual void execute( const string& lfile );
protected: protected:
......
...@@ -277,7 +277,7 @@ bool MBExchange::readItem( UniXML& xml, UniXML_iterator& it, xmlNode* sec ) ...@@ -277,7 +277,7 @@ bool MBExchange::readItem( UniXML& xml, UniXML_iterator& it, xmlNode* sec )
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
MBExchange::DeviceType MBExchange::getDeviceType( const std::string dtype ) MBExchange::DeviceType MBExchange::getDeviceType( const std::string& dtype )
{ {
if( dtype.empty() ) if( dtype.empty() )
return dtUnknown; return dtUnknown;
......
...@@ -559,7 +559,7 @@ void RTUStorage::print() ...@@ -559,7 +559,7 @@ void RTUStorage::print()
cout << this; cout << this;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
RTUStorage::RTUJack RTUStorage::s2j( const std::string jack ) RTUStorage::RTUJack RTUStorage::s2j( const std::string& jack )
{ {
if( jack == "J1" || jack == "j1" ) if( jack == "J1" || jack == "j1" )
return nJ1; return nJ1;
......
...@@ -38,7 +38,7 @@ class RTUStorage ...@@ -38,7 +38,7 @@ class RTUStorage
nX5 // DI (8) nX5 // DI (8)
}; };
static RTUJack s2j( const std::string jack ); static RTUJack s2j( const std::string& jack );
static std::string j2s( RTUJack j ); static std::string j2s( RTUJack j );
long getInt( RTUJack jack, unsigned short channel, UniversalIO::IOTypes t ); long getInt( RTUJack jack, unsigned short channel, UniversalIO::IOTypes t );
......
...@@ -88,7 +88,7 @@ int main( int argc, char **argv ) ...@@ -88,7 +88,7 @@ int main( int argc, char **argv )
ModbusRTU::ModbusAddr end = 255; ModbusRTU::ModbusAddr end = 255;
int tout = 20; int tout = 20;
DebugStream dlog; DebugStream dlog;
string tofile(""); //string tofile("");
int use485 = 0; int use485 = 0;
ComPort::StopBits sbits = ComPort::OneBit; ComPort::StopBits sbits = ComPort::OneBit;
ComPort::Parity parity = ComPort::NoParity; ComPort::Parity parity = ComPort::NoParity;
......
...@@ -53,6 +53,7 @@ class MBSlave: ...@@ -53,6 +53,7 @@ class MBSlave:
IOProperty(): IOProperty():
mbreg(0), mbreg(0),
amode(amRW),
vtype(VTypes::vtUnknown), vtype(VTypes::vtUnknown),
wnum(0) wnum(0)
{} {}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment