Commit 2de094bf authored by Pavel Vainerman's avatar Pavel Vainerman

Исправления предупреждений по результатам статического анализа в clion

parent 59bf1d78
......@@ -97,7 +97,6 @@ DB: Сделать регулируемый буфер на INSERT-ы БД, чт
-----
- ведение статистики по типам сообщений в каждом объекте (и в SM). Чтобы увидеть где происходит потеря пакетов (если происходит).
(т.е. идея в том, что сколько "успешно" послала SM столько должно придти и быть обработано (разные счётчики) в объекте)
- NoSQL база (в памяти) как буфер (держит интенсивную запись) перед "не спешной" записью в реляционную (MySQL,Postgre и т.п.)
......@@ -106,10 +105,6 @@ DB: Сделать регулируемый буфер на INSERT-ы БД, чт
lock-free: mentomic
Но тогда стоит вводить и namespace uniset
=================
version 3
=========
- подумать нужен ли нам где-то ZeroMQ (zerorpc) (вместо omniORB?)
......@@ -128,5 +123,3 @@ UResolver (или ObjectRepository) позволяющего манипулир
- Перепроектировать OIndex и Configure.. Инициализироват для Configure(объектом OIndex)
- подумать возможно стоит переходить на lockfree-библиотеку libcds..(актуально для многопроцессорных систем)
- Ввести namespace uniset:: ust:: uns:: ?
......@@ -505,6 +505,9 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
%exclude %_pkgconfigdir/libUniSet2.pc
# history of current unpublished changes
# add tests for REST API (with RPC)
# python: refactoring UInterface (add UInterfaceModbus and UInterfaceUniSet)
# refactoring TCPCheck (use future)
%changelog
* Fri Dec 16 2016 Pavel Vainerman <pv@altlinux.ru> 2.6-alt9
......
......@@ -106,7 +106,7 @@ namespace uniset
// net
size_t getCountOfNet() const noexcept;
size_t getRepeatTimeout() const noexcept;
timeout_t getRepeatTimeout() const noexcept;
size_t getRepeatCount() const noexcept;
uniset::ObjectId getSensorID( const std::string& name ) const noexcept;
......
......@@ -72,7 +72,7 @@ namespace uniset
static int as_int( const DBResult::COL::iterator& it );
static double as_double(const DBResult::COL::iterator& it );
static std::string as_string( const DBResult::COL::iterator& it );
static int num_cols( const DBResult::iterator& it );
static size_t num_cols( const DBResult::iterator& it );
// ----------------------------------------------------------------------------
protected:
......
......@@ -127,7 +127,6 @@ namespace uniset
protected:
PassiveTimer t1; // таймер "1"
PassiveTimer t0; // таймер "0"
PassiveTimer tCorr; // корректирующий таймер
bool ostate = { false };
bool isOn = { false };
timeout_t t1_msec = { 0 };
......
......@@ -13,8 +13,7 @@ namespace uniset
{
public:
// dup and accept...raw socket
USocket( int sock );
USocket();
virtual ~USocket();
// set keepalive params
......
......@@ -20,17 +20,17 @@ namespace uniset
// Buffer class - allow for output buffering such that it can be written out into async pieces
struct Buffer
{
Buffer( const unsigned char* bytes, ssize_t nbytes );
Buffer( const unsigned char* bytes, size_t nbytes );
Buffer( const std::string& s );
virtual ~Buffer();
unsigned char* dpos() noexcept;
ssize_t nbytes() noexcept;
size_t nbytes() noexcept;
unsigned char* data = { 0 };
ssize_t len;
ssize_t pos;
size_t len;
size_t pos;
};
}
// -------------------------------------------------------------------------
......
......@@ -37,7 +37,7 @@ namespace uniset
UTCPStream();
virtual ~UTCPStream();
void create( const std::string& hname, int port, timeout_t tout_msec = 1000 );
void create( const std::string& hname, uint16_t port, timeout_t tout_msec = 1000 );
bool isConnected() noexcept;
......
......@@ -38,9 +38,10 @@
#include "IOController_i.hh"
#include "Mutex.h"
#include "UniXML.h"
#include "PassiveTimer.h" // for typedef timeout_t
// -----------------------------------------------------------------------------------------
/*! Задержка в миллисекундах */
inline void msleep( unsigned int m )
inline void msleep( uniset::timeout_t m )
{
std::this_thread::sleep_for(std::chrono::milliseconds(m));
}
......@@ -80,7 +81,6 @@ namespace uniset
typedef std::list<std::string> ListObjectName; /*!< Список объектов типа ObjectName */
typedef ObjectId SysId;
typedef CORBA::Object_ptr ObjectPtr; /*!< Ссылка на объект регистрируемый в ObjectRepository */
typedef CORBA::Object_var ObjectVar; /*!< Ссылка на объект регистрируемый в ObjectRepository */
......@@ -114,7 +114,7 @@ namespace uniset
void add( ObjectId id );
void del( ObjectId id );
inline int size() const noexcept
inline size_t size() const noexcept
{
return lst.size();
}
......@@ -304,7 +304,7 @@ namespace uniset
{
while( begin != end)
{
if( p(*begin) ) &destBegin++ = *begin;
if( p(*begin) ) &(destBegin++) = *begin;
++begin;
}
......
......@@ -15,10 +15,8 @@
*/
// -----------------------------------------------------------------------------
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <future>
#include <thread>
#include <chrono>
#include "UniSetTypes.h"
#include "TCPCheck.h"
......
......@@ -15,8 +15,7 @@ namespace uniset
catch(...) {}
}
// -------------------------------------------------------------------------
USocket::USocket( int sock )
// Socket(sock)
USocket::USocket()
{
init();
}
......
......@@ -27,19 +27,19 @@ namespace uniset
return ok;
}
// -------------------------------------------------------------------------
UTCPCore::Buffer::Buffer(const unsigned char* bytes, ssize_t nbytes)
UTCPCore::Buffer::Buffer( const unsigned char* bytes, size_t nbytes )
{
pos = 0;
len = nbytes;
if( len <= 0 ) // ??!!
if( len == 0 ) // ??!!
return;
data = new unsigned char[nbytes];
std::memcpy(data, bytes, nbytes);
}
// -------------------------------------------------------------------------
UTCPCore::Buffer::Buffer(const string& s)
UTCPCore::Buffer::Buffer( const string& s )
{
pos = 0;
len = s.length();
......@@ -61,7 +61,7 @@ namespace uniset
return data + pos;
}
// -------------------------------------------------------------------------
ssize_t UTCPCore::Buffer::nbytes() noexcept
size_t UTCPCore::Buffer::nbytes() noexcept
{
return len - pos;
}
......
......@@ -107,7 +107,7 @@ namespace uniset
return tm.totalMicroseconds();
}
// -------------------------------------------------------------------------
void UTCPStream::create( const std::string& hname, int port, timeout_t tout_msec )
void UTCPStream::create( const std::string& hname, uint16_t port, timeout_t tout_msec )
{
Poco::Net::SocketAddress saddr(hname, port);
connect(saddr, UniSetTimer::millisecToPoco(tout_msec));
......
......@@ -331,14 +331,14 @@ namespace uniset
// -----------------------------------------------------------------------------
std::string LogServer::help_print( const std::string& prefix )
{
ostringstream h;
std::ostringstream h;
h << "--" << prefix << "-cmd-timeout msec - Timeout for wait command. Default: 2000 msec." << endl;
return h.str();
}
// -----------------------------------------------------------------------------
string LogServer::getShortInfo()
{
ostringstream inf;
std::ostringstream inf;
inf << "LogServer: " << myname
<< " ["
......
......@@ -981,7 +981,7 @@ void UniSetActivator::normalexit()
ulogsys << g_act->getName() << "(default exit): ..begin..." << endl << flush;
if( g_term == false )
if( !g_term )
{
// прежде чем вызывать notify_one(), мы должны освободить mutex!
{
......@@ -1021,7 +1021,7 @@ void UniSetActivator::normalterminate()
ulogsys << g_act->getName() << "(default terminate): ..begin..." << endl << flush;
if( g_term == false )
if( !g_term )
{
// прежде чем вызывать notify_one(), мы должны освободить mutex!
{
......
......@@ -203,7 +203,7 @@ bool UniSetManager::removeObject( const std::shared_ptr<UniSetObject>& obj )
try
{
if(obj)
if( obj )
obj->deactivate();
}
catch( const uniset::Exception& ex )
......@@ -225,7 +225,6 @@ bool UniSetManager::removeObject( const std::shared_ptr<UniSetObject>& obj )
<< " line: " << fe.line()
<< " mesg: " << fe.errmsg() << endl;
}
catch(...) {}
olist.erase(li);
......
......@@ -202,7 +202,7 @@ bool uniset::file_exist( const std::string& filename )
#endif
bool result = false;
if( file )
if( file.is_open() )
result = true;
file.close();
......
......@@ -811,7 +811,7 @@ void IOController::USensorInfo::checkDepend( std::shared_ptr<USensorInfo>& d_it,
uniset_rwmutex_wrlock lock(val_lock);
bool prev = blocked;
uniset_rwmutex_rlock dlock(d_it->val_lock);
blocked = ( d_it->value == d_value ) ? false : true;
blocked = ( d_it->value != d_value );
changed = ( prev != blocked );
sup_id = d_it->supplier;
}
......
......@@ -932,7 +932,7 @@ void IONotifyController::checkThreshold( std::shared_ptr<IOController::USensorIn
// если состояние не normal, значит порог сработал,
// не важно какой.. нижний или верхний (зависит от inverse)
sm.threshold = ( state != IONotifyController_i::NormalThreshold ) ? true : false;
sm.threshold = ( state != IONotifyController_i::NormalThreshold );
// запоминаем время изменения состояния
it->tv_sec = tm.tv_sec;
......
......@@ -63,8 +63,6 @@ void NCRestorer::addlist( IONotifyController* ic, std::shared_ptr<IOController::
ucrit << ic->getName() << "(askDumper::addlist): НЕИЗВЕСТНЫЙ ТИП ДАТЧИКА! -> "
<< uniset_conf()->oind->getNameById(inf->si.id) << endl;
return;
break;
}
}
}
......
......@@ -391,7 +391,7 @@ void NCRestorer_XML::read_thresholds( const std::shared_ptr<UniXML>& xml, xmlNod
IONotifyController::ThresholdExtList tlst;
for( ; tit; tit.goNext() )
for( ; tit.getCurrent(); tit++ )
{
IONotifyController::ThresholdInfoExt ti(0, 0, 0, false);
......@@ -471,7 +471,7 @@ bool NCRestorer_XML::getConsumerList( const std::shared_ptr<UniXML>& xml, xmlNod
{
UniXML::iterator it(node);
for(; it; it.goNext())
for(; it.getCurrent(); it++ )
{
if( !check_consumer_item(it) )
continue;
......
......@@ -9,7 +9,7 @@ namespace uniset
std::string user = "";
std::string pswd = "";
std::string dbname = "";
unsigned int port = 0;
uint port = 0;
for(;;)
{
......@@ -42,7 +42,7 @@ namespace uniset
prev = pos + 1;
pos = param.find_first_of(":", prev);
port = atoi( param.substr(prev, pos - prev).c_str() );
port = (uint)std::atoi( param.substr(prev, pos - prev).c_str() );
break;
}
......@@ -94,7 +94,7 @@ namespace uniset
return ((*it)[col]);
}
// ----------------------------------------------------------------------------
int DBResult::num_cols( const DBResult::iterator& it )
size_t DBResult::num_cols( const DBResult::iterator& it )
{
return it->size();
}
......
......@@ -90,7 +90,7 @@ void DBServer::processingMessage( const uniset::VoidMessage* msg )
switch(msg->type)
{
case Message::Confirm:
confirmInfo( reinterpret_cast<const ConfirmMessage*>(msg) );
confirmInfo( reinterpret_cast<const uniset::ConfirmMessage*>(msg) );
break;
default:
......
......@@ -19,7 +19,6 @@
*/
// -----------------------------------------------------------------------------
#include <cstdio>
#include <unistd.h>
#include "PassiveTimer.h"
// -----------------------------------------------------------------------------
namespace uniset
......
......@@ -1332,7 +1332,7 @@ namespace uniset
return countOfNet;
}
// -------------------------------------------------------------------------
size_t Configuration::getRepeatTimeout() const noexcept
timeout_t Configuration::getRepeatTimeout() const noexcept
{
return repeatTimeout;
}
......
......@@ -181,12 +181,12 @@ string UniXML::getProp(const xmlNode* node, const string& name) noexcept
{
// формально при конструировании строки может быть exception
const string t( (const char*)text );
xmlFree( (xmlChar*) text );
xmlFree( text );
return t;
}
catch(...) {}
xmlFree( (xmlChar*) text );
xmlFree( text );
return "";
}
// -----------------------------------------------------------------------------
......@@ -282,7 +282,7 @@ xmlNode* UniXML::copyNode(xmlNode* node, int recursive)
return 0;
}
// -----------------------------------------------------------------------------
bool UniXML::save(const string& filename, int level)
bool UniXML::save( const string& filename, int level )
{
string fn(filename);
......@@ -450,7 +450,7 @@ bool UniXML_iterator::canPrev() const noexcept
// -------------------------------------------------------------------------
bool UniXML_iterator::canNext() const noexcept
{
if (!curNode || !curNode->next )
if( !curNode || !curNode->next )
return false;
return true;
......
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