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

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

parent 36ff980c
......@@ -15,7 +15,7 @@ using namespace std;
using namespace UniSetTypes;
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),
addr(addr),
// prev(ModbusRTU::erNoError),
......
......@@ -15,7 +15,7 @@ using namespace std;
using namespace UniSetTypes;
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),
addr(myaddr),
// prev(ModbusRTU::erNoError),
......
......@@ -676,7 +676,7 @@ int main( int argc, char **argv )
catch( ModbusRTU::mbException& ex )
{
if( ex.err != ModbusRTU::erTimeOut )
throw ex;
throw;
cout << "timeout..." << endl;
}
......
......@@ -507,7 +507,7 @@ int main( int argc, char **argv )
catch( ModbusRTU::mbException& ex )
{
if( ex.err != ModbusRTU::erTimeOut )
throw ex;
throw;
cout << "timeout..." << endl;
}
......
......@@ -256,7 +256,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
catch( Exception&amp; ex )
{
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(getdata): " &lt;&lt; ex &lt;&lt; endl;
throw ex;
throw;
}
</xsl:template>
......@@ -306,7 +306,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
catch( Exception&amp; ex )
{
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
throw ex;
throw;
}
</xsl:template>
......@@ -336,7 +336,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
catch( Exception&amp; ex )
{
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
throw ex;
throw;
}
</xsl:template>
......
......@@ -204,7 +204,7 @@ long <xsl:value-of select="$CLASSNAME"/>_SK::getValue( UniSetTypes::ObjectId _si
catch(Exception&amp; ex)
{
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(getState): " &lt;&lt; ex &lt;&lt; endl;
throw ex;
throw;
}
return 0;
......@@ -294,7 +294,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
catch( UniSetTypes::Exception&amp; ex )
{
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(getdata): " &lt;&lt; ex &lt;&lt; endl;
throw ex;
throw;
}
}
</xsl:template>
......@@ -326,7 +326,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
catch( UniSetTypes::Exception&amp; ex )
{
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
throw ex;
throw;
}
}
</xsl:template>
......@@ -359,7 +359,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
catch( UniSetTypes::Exception&amp; ex )
{
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
throw ex;
throw;
}
}
</xsl:template>
......
......@@ -235,9 +235,9 @@
xmlNode* 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 */
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 */
bool activated;
......@@ -553,7 +553,7 @@ end_private(false)
}
// -----------------------------------------------------------------------------
// ( 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() )
return s1;
......@@ -872,7 +872,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::testMode( bool _state )
<xsl:template name="COMMON-CC-ALONE-FUNCS">
// -----------------------------------------------------------------------------
// ( 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() )
return s1;
......
......@@ -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))
{
......@@ -65,7 +65,7 @@ bool DBInterface::close()
return true;
}
// -----------------------------------------------------------------------------------------
bool DBInterface::insert(const string q)
bool DBInterface::insert( const string& q )
{
if( !mysql )
return false;
......@@ -80,7 +80,7 @@ bool DBInterface::insert(const string q)
return true;
}
// -----------------------------------------------------------------------------------------
bool DBInterface::query(const string q)
bool DBInterface::query( const string& q )
{
if( !mysql )
return false;
......@@ -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 )
return 0;
......@@ -233,7 +233,7 @@ bool DBInterface::isConnection()
return ping(); //!mysql;
}
// -----------------------------------------------------------------------------------------
string DBInterface::addslashes(const string& str)
string DBInterface::addslashes( const string& str )
{
ostringstream tmp;
for( unsigned int i=0; i<str.size(); i++ )
......
......@@ -39,16 +39,16 @@ class DBInterface
// bool createDB(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,
const std::string dbname);
bool connect( const std::string& host, const std::string& user, const std::string& pswd,
const std::string& dbname);
bool close();
bool query(const std::string q);
bool query(const std::string& q);
const std::string lastQuery();
bool insert(const std::string q);
bool insert(const std::string& q);
std::string addslashes(const std::string& str);
......
......@@ -44,6 +44,7 @@ DBServer_MySQL::DBServer_MySQL(ObjectId id):
ReconnectTime(180000),
connect_ok(false),
activate(true),
qbufSize(200),
lastRemove(false)
{
if( getId() == DefaultObjectId )
......@@ -61,6 +62,7 @@ DBServer_MySQL::DBServer_MySQL():
ReconnectTime(180000),
connect_ok(false),
activate(true),
qbufSize(200),
lastRemove(false)
{
// init();
......
......@@ -44,8 +44,7 @@ opCheckPause(50)
SQLiteInterface::~SQLiteInterface()
{
close();
if( db )
delete db;
delete db;
}
// -----------------------------------------------------------------------------------------
......@@ -54,7 +53,7 @@ bool SQLiteInterface::ping()
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 по умолчанию, создаёт файл при открытии, то проверим "сами"
// if( !create && !UniSetTypes::file_exist(dbfile) )
......@@ -97,7 +96,7 @@ void SQLiteInterface::setOperationTimeout( timeout_t msec )
sqlite3_busy_timeout(db,opTimeout);
}
// -----------------------------------------------------------------------------------------
bool SQLiteInterface::insert( const string q )
bool SQLiteInterface::insert( const string& q )
{
if( !db )
return false;
......@@ -134,7 +133,7 @@ bool SQLiteInterface::checkResult( int rc )
return true;
}
// -----------------------------------------------------------------------------------------
SQLiteResult SQLiteInterface::query( const string q )
SQLiteResult SQLiteInterface::query( const string& q )
{
if( !db )
return SQLiteResult();
......
......@@ -94,10 +94,10 @@
class LProcessor
{
public:
LProcessor( const std::string name="" );
LProcessor( const std::string& name="" );
virtual ~LProcessor();
virtual void execute( const string lfile );
virtual void execute( const string& lfile );
protected:
......
......@@ -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() )
return dtUnknown;
......
......@@ -559,7 +559,7 @@ void RTUStorage::print()
cout << this;
}
// -----------------------------------------------------------------------------
RTUStorage::RTUJack RTUStorage::s2j( const std::string jack )
RTUStorage::RTUJack RTUStorage::s2j( const std::string& jack )
{
if( jack == "J1" || jack == "j1" )
return nJ1;
......
......@@ -38,7 +38,7 @@ class RTUStorage
nX5 // DI (8)
};
static RTUJack s2j( const std::string jack );
static RTUJack s2j( const std::string& jack );
static std::string j2s( RTUJack j );
long getInt( RTUJack jack, unsigned short channel, UniversalIO::IOTypes t );
......
......@@ -88,7 +88,7 @@ int main( int argc, char **argv )
ModbusRTU::ModbusAddr end = 255;
int tout = 20;
DebugStream dlog;
string tofile("");
//string tofile("");
int use485 = 0;
ComPort::StopBits sbits = ComPort::OneBit;
ComPort::Parity parity = ComPort::NoParity;
......
......@@ -53,6 +53,7 @@ class MBSlave:
IOProperty():
mbreg(0),
amode(amRW),
vtype(VTypes::vtUnknown),
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