int ret = EncodeBase64(output, outputSize, reinterpret_cast<const unsigned char *>(sslContext.secretKey.c_str()), sslContext.secretKey.size());
if (ret < 0) {
return ret;
- } else if (output == nullptr || outputSize <= 0) {
+ } else if (output == nullptr) {
+ return -EINVAL;
+ } else if (outputSize <= 0) {
+ free(output);
return -EINVAL;
}
} else {
ret = command->Recv(cmdId, _data);
if (ret < 0) {
ErrPrint("Failed to receive");
- } else if (cmdId < 0 || data == nullptr) {
+ } else if (cmdId < 0 || _data == nullptr) {
ErrPrint("Invalid cmdId or cmdData");
ret = -EINVAL;
} else {
NsdEventLoop::~NsdEventLoop()
{
- quit();
+ try {
+ quit();
+ } catch (NsdLoopException &e) {
+ ErrPrintCode(e.returnValue, "quit() Fail");
+ }
close(epoll_fd);
}
if (events[i].data.fd == looprun_fd) {
isLoopRun = false;
break;
- } else {
- auto result = callbackMap.find(events[i].data.fd);
- if (result == callbackMap.end()) {
- ErrPrint("Invalid fd(%d), not found", events[i].data.fd);
- }
+ }
+
+ auto result = callbackMap.find(events[i].data.fd);
+ if (result != callbackMap.end()) {
result->second();
+ } else {
+ ErrPrint("Invalid fd(%d), not found", events[i].data.fd);
}
+
}
}
}
if (ret != kDNSServiceErr_NoError) {
ErrPrint("TXTRecordSetValue() Fail(%d)", ret);
TXTRecordDeallocate(&txtRecord);
+ delete cbData;
return -1;
}
}
REGTYPE, DOMAIN_LOCAL, NULL, htons(info.port),
TXTRecordGetLength(&txtRecord),
TXTRecordGetBytesPtr(&txtRecord), register_reply, cbData);
+ TXTRecordDeallocate(&txtRecord);
if (err != kDNSServiceErr_NoError || svc == nullptr) {
ErrPrint("DNSServiceRegister() Fail(%d)", err);
+ delete cbData;
return -1;
}
eventLoop.run();
} catch (NsdLoopException &e) {
unregisterService();
+ delete cbData;
return e.returnValue;
}
void NsdManager::process_result(DNSServiceRef sdRef)
{
- DNSServiceProcessResult(sdRef);
+ int ret = DNSServiceProcessResult(sdRef);
+ if (ret != kDNSServiceErr_NoError) {
+ ErrPrint("DNSServiceProcessResult() Fail(%d)", ret);
+ }
}
inline NsdManager::NsdDiscoverData::NsdDiscoverData(NsdManager *obj, CallbackWithInfo cb)
Peer::GrpcClient::Gst::Thread::CommandHandlerExit,
},
}
+ , threadId(0)
{
}
}
Peer::GrpcClient::Gst::Source::Source(void)
- : pipeline(nullptr)
+ : gstClient(nullptr)
+ , pipeline(nullptr)
, element(nullptr)
, bus(nullptr)
{
#include "beyond/plugin/peer_nn_plugin.h"
Peer::GrpcServer::GrpcServer(void)
- : server(nullptr)
+ : threadId(0)
+ , server(nullptr)
, peer(nullptr)
, nextPeerId(0)
{
Peer::GrpcServer::Gst::Thread::CommandHandlerExit,
},
}
+ , threadId(0)
+ , nonce(0)
{
}
_exit(0);
break;
case 'm':
- model = strdup(optarg);
+ model = optarg ? strdup(optarg) : nullptr;
break;
case 's':
if (sscanf(optarg, "%d", &input_size) != 1) {
input_idx++;
break;
case 't':
- if (nullptr == input) {
+ if (input == nullptr) {
fprintf(stderr, "Invalid input(NULL)");
break;
}
+ if (optarg == nullptr) {
+ fprintf(stderr, "Invalid argument(NULL)");
+ break;
+ }
if (strcmp(optarg, "int8") == 0) {
input[input_idx].type = BEYOND_TENSOR_TYPE_INT8;
} else if (strcmp(optarg, "int16") == 0) {
void ResourceInfoCollector::impl::collectResourceInfo(beyond_peer_info *info)
{
if (info->free_memory <= 0) {
- struct sysinfo _info;
+ struct sysinfo _info = {0};
if (sysinfo(&_info) < 0) {
ErrPrintCode(errno, "sysinfo");
} else {