Skip to content

Commit

Permalink
Merge pull request #37 from solidoss/coverity
Browse files Browse the repository at this point in the history
Coverity fixes
  • Loading branch information
vipalade authored Oct 24, 2024
2 parents 6638471 + 20aaa4a commit 7f5d523
Show file tree
Hide file tree
Showing 96 changed files with 602 additions and 313 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
#-----------------------------------------------------------------
# The project
#-----------------------------------------------------------------
project (SolidFrame VERSION 12.0)
project (SolidFrame VERSION 12.1)

message("SolidFrame version: ${PROJECT_VERSION} - ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")
#-----------------------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# SolidFrame Releases

## Version 12.1
* Coverity fixes

## Version 12.0
* utility: support pthread_spin_lock when available
* utility: ThreadPool improvements and fixes
Expand Down
8 changes: 4 additions & 4 deletions examples/frame/aio_echo/example_echo_auto_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,16 @@ struct Statistics {

namespace {
struct Params {
uint32_t connection_count;
uint32_t repeat_count;
uint32_t connection_count = 1;
uint32_t repeat_count = 1;
string connect_addr_str;
string connect_port_str;

vector<string> dbg_modules;
string dbg_addr;
string dbg_port;
bool dbg_console;
bool dbg_buffered;
bool dbg_console = true;
bool dbg_buffered = true;
};

mutex mtx;
Expand Down
12 changes: 6 additions & 6 deletions examples/frame/aio_echo/example_echo_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ typedef frame::Scheduler<frame::aio::Reactor<Event<32>>> AioSchedulerT;
//------------------------------------------------------------------

struct Params {
int listener_port;
int talker_port;
int connect_port;
int listener_port = -1;
int talker_port = -1;
int connect_port = -1;
vector<string> dbg_modules;
string dbg_addr;
string dbg_port;
bool dbg_console;
bool dbg_buffered;
bool log;
bool dbg_console = true;
bool dbg_buffered = true;
bool log = true;
};

namespace {
Expand Down
6 changes: 3 additions & 3 deletions examples/frame/aio_echo/example_secure_echo_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ struct Params {
vector<string> dbg_modules;
string dbg_addr;
string dbg_port;
bool dbg_console;
bool dbg_buffered;
bool log;
bool dbg_console = true;
bool dbg_buffered = true;
bool log = true;
};

using ConnectStT = std::pair<std::string&, std::string&>;
Expand Down
8 changes: 4 additions & 4 deletions examples/frame/aio_echo/example_secure_echo_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ typedef frame::aio::openssl::Context SecureContextT;
//------------------------------------------------------------------

struct Params {
int listener_port;
int listener_port = 2000;
vector<string> dbg_modules;
string dbg_addr;
string dbg_port;
bool dbg_console;
bool dbg_buffered;
bool log;
bool dbg_console = true;
bool dbg_buffered = true;
bool log = true;
};

namespace {
Expand Down
8 changes: 4 additions & 4 deletions examples/frame/file_server/example_file_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ enum Events {
//------------------------------------------------------------------

struct Params {
int start_port;
int start_port = -1;
vector<string> dbg_modules;
string dbg_addr;
string dbg_port;
bool dbg_console;
bool dbg_buffered;
bool log;
bool dbg_console = true;
bool dbg_buffered = true;
bool log = true;
};

namespace {
Expand Down
14 changes: 7 additions & 7 deletions examples/frame/mprpc_echo/example_mprpc_echo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ struct Params {
vector<string> dbg_modules;
string dbg_addr;
string dbg_port;
bool dbg_console;
bool dbg_buffered;
bool dbg_console = true;
bool dbg_buffered = true;

std::string baseport;
bool log;
bool log = true;
StringVectorT connectstringvec;
bool secure;
bool secure = true;

bool prepare(frame::mprpc::Configuration& _rcfg, string& _err);
};
Expand Down Expand Up @@ -99,15 +99,15 @@ struct FirstMessage : frame::mprpc::Message {
FirstMessage(std::string const& _str)
: str(_str)
{
solid_log(generic_logger, Info, "CREATE ---------------- " << (void*)this);
solid_log(generic_logger, Info, "CREATE ---------------- " << this);
}
FirstMessage()
{
solid_log(generic_logger, Info, "CREATE ---------------- " << (void*)this);
solid_log(generic_logger, Info, "CREATE ---------------- " << this);
}
~FirstMessage()
{
solid_log(generic_logger, Info, "DELETE ---------------- " << (void*)this);
solid_log(generic_logger, Info, "DELETE ---------------- " << this);
}

SOLID_REFLECT_V1(_rr, _rthis, _rctx)
Expand Down
10 changes: 5 additions & 5 deletions examples/frame/relay_server/example_relay_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@ enum Events {
namespace {

struct Params {
int listener_port;
int talker_port;
int listener_port = -1;
int talker_port = -1;
string connect_addr_str;
string connect_port_str;

vector<string> dbg_modules;
string dbg_addr;
string dbg_port;
bool dbg_console;
bool dbg_buffered;
bool log;
bool dbg_console = true;
bool dbg_buffered = true;
bool log = true;
};

Params params;
Expand Down
8 changes: 4 additions & 4 deletions examples/frame/relay_server/example_relay_server_bi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ using BufferPairT = pair<const char*, size_t>;
namespace {

struct Params {
int listener_port;
int listener_port = -1;
string connect_addr_str;
string connect_port_str;

vector<string> dbg_modules;
string dbg_addr;
string dbg_port;
bool dbg_console;
bool dbg_buffered;
bool log;
bool dbg_console = true;
bool dbg_buffered = true;
bool log = true;
};

Params params;
Expand Down
8 changes: 4 additions & 4 deletions examples/frame/relay_server/example_relay_server_bi_cp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ using BufferPairT = pair<const char*, size_t>;
namespace {

struct Params {
int listener_port;
int listener_port = -1;
string connect_addr_str;
string connect_port_str;

vector<string> dbg_modules;
string dbg_addr;
string dbg_port;
bool dbg_console;
bool dbg_buffered;
bool log;
bool dbg_console = true;
bool dbg_buffered = true;
bool log = true;
};

Params params;
Expand Down
8 changes: 4 additions & 4 deletions examples/frame/relay_server/example_relay_server_bi_ex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ using AioSchedulerT = frame::Scheduler<frame::aio::Reactor<Event<32>>>;
namespace {

struct Params {
int listener_port;
int listener_port = -1;
string connect_addr_str;
string connect_port_str;

vector<string> dbg_modules;
string dbg_addr;
string dbg_port;
bool dbg_console;
bool dbg_buffered;
bool log;
bool dbg_console = true;
bool dbg_buffered = true;
bool log = true;
};

Params params;
Expand Down
8 changes: 4 additions & 4 deletions examples/frame/relay_server/example_relay_server_bi_sh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ using BufferPairT = pair<const char*, size_t>;
namespace {

struct Params {
int listener_port;
int listener_port = -1;
string connect_addr_str;
string connect_port_str;

vector<string> dbg_modules;
string dbg_addr;
string dbg_port;
bool dbg_console;
bool dbg_buffered;
bool log;
bool dbg_console = true;
bool dbg_buffered = true;
bool log = true;
};

Params params;
Expand Down
2 changes: 1 addition & 1 deletion solid/frame/aio/aiocompletion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class CompletionHandler : public ForwardCompletionHandler {
return pprev != nullptr;
}
bool activate(Actor const& _ract);
void deactivate();
void deactivate(const bool _check = true);
void unregister();

protected:
Expand Down
2 changes: 1 addition & 1 deletion solid/frame/aio/aiodatagram.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ class Datagram : public CompletionHandler {
~Datagram()
{
// MUST call here and not in the ~CompletionHandler
this->deactivate();
this->deactivate(false);
}

bool hasPendingRecv() const
Expand Down
2 changes: 1 addition & 1 deletion solid/frame/aio/aiolistener.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Listener : public CompletionHandler {
~Listener()
{
// MUST call here and not in the ~CompletionHandler
this->deactivate();
this->deactivate(false);
}

SocketDevice reset(ReactorContext& _rctx, SocketDevice&& _rnewdev = std::move(dummy_socket_device()));
Expand Down
4 changes: 2 additions & 2 deletions solid/frame/aio/aioresolver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ struct DirectResolveCbk : DirectResolve {
int _type,
int _proto)
: DirectResolve(_host, _srvc, _flags, _family, _type, _proto)
, cbk(_cbk)
, cbk(std::move(_cbk))
{
}

Expand Down Expand Up @@ -144,7 +144,7 @@ class Resolver {
int _type = -1,
int _proto = -1)
{
push_fnc_(DirectResolveCbk<Cbk>(_cbk, _host, _srvc, _flags, _family, _type, _proto));
push_fnc_(DirectResolveCbk<Cbk>(std::move(_cbk), _host, _srvc, _flags, _family, _type, _proto));
}

template <class Cbk>
Expand Down
2 changes: 1 addition & 1 deletion solid/frame/aio/aiostream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ class Stream : public CompletionHandler {
~Stream()
{
// MUST call here and not in the ~CompletionHandler
this->deactivate();
this->deactivate(false);
}

bool hasPendingRecv() const
Expand Down
2 changes: 1 addition & 1 deletion solid/frame/aio/aiotimer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class SteadyTimer : public CompletionHandler {
~SteadyTimer()
{
// MUST call here and not in the ~CompletionHandler
this->deactivate();
this->deactivate(false);
}

const NanoTime& expiry() const
Expand Down
2 changes: 1 addition & 1 deletion solid/frame/aio/openssl/src/aiosecuresocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ ReactorEventE Socket::filterReactorEvents(
// solid_log(logger, Info, "EventRecvSend "<<want_read_on_send<<' '<<want_read_on_recv<<' '<<want_write_on_send<<' '<<want_write_on_recv);
if (want_read_on_send && (want_read_on_recv || want_write_on_recv)) {
return ReactorEventE::SendRecv;
} else if ((want_write_on_send || want_write_on_send) && (want_write_on_recv || want_read_on_recv)) {
} else if ((want_write_on_send || want_read_on_send) && (want_write_on_recv || want_read_on_recv)) {
return _evt;
} else if (want_write_on_send || want_read_on_send) {
return ReactorEventE::Send;
Expand Down
6 changes: 3 additions & 3 deletions solid/frame/aio/src/aiocompletion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,16 @@ void CompletionHandler::unregister()
}
}

void CompletionHandler::deactivate()
void CompletionHandler::deactivate(const bool _check)
{
impl::Reactor* preactor = nullptr;
if (isActive() && (preactor = impl::Reactor::safeSpecific()) != nullptr) {
// the actor has entered the reactor
preactor->unregisterCompletionHandler(*this);
idxreactor = InvalidIndex();
}
if (isActive()) {
solid_throw_log(generic_logger, "FATAL: CompletionHandler deleted/deactivated outside actor's reactor!");
if (_check) {
solid_check_log(!isActive(), generic_logger, "FATAL: CompletionHandler deleted/deactivated outside actor's reactor!");
}
}

Expand Down
Loading

0 comments on commit 7f5d523

Please sign in to comment.