[VPU] Coverity fixes (#9214)

Some coverity fixes
This commit is contained in:
Aleksandr Korolev
2021-12-21 12:58:05 +03:00
committed by GitHub
parent ec858fcffd
commit 4b0a2c9127
9 changed files with 27 additions and 20 deletions

View File

@@ -173,7 +173,7 @@ class HWConvolutionTiler final {
public:
HWConvolutionTiler() = delete;
HWConvolutionTiler(const HWConvolutionTiler&) = default;
HWConvolutionTiler(ConvolutionOptions convolutionOptions, const Direction& direction, std::size_t maxTilingOptions);
HWConvolutionTiler(const ConvolutionOptions& convolutionOptions, const Direction& direction, std::size_t maxTilingOptions);
bool isTilingPossible() const {

View File

@@ -83,7 +83,7 @@ public:
HWPoolingTiler() = delete;
HWPoolingTiler(const HWPoolingTiler&) = default;
HWPoolingTiler(ConvolutionOptions convolutionOptions, const Direction& direction, std::size_t maxTilingOptions);
HWPoolingTiler(const ConvolutionOptions& convolutionOptions, const Direction& direction, std::size_t maxTilingOptions);
bool isTilingPossible() const {
return _tilingPossible;

View File

@@ -257,7 +257,7 @@ public:
}
};
HWConvolutionTiler::HWConvolutionTiler(ConvolutionOptions convolutionOptions, const Direction& direction,
HWConvolutionTiler::HWConvolutionTiler(const ConvolutionOptions& convolutionOptions, const Direction& direction,
std::size_t maxTilingOptions) :
_convolutionOptions(std::move(convolutionOptions)),
_searcher(_convolutionOptions, direction, maxTilingOptions) {

View File

@@ -247,7 +247,7 @@ private:
};
HWPoolingTiler::HWPoolingTiler(ConvolutionOptions convolutionOptions, const Direction& direction,
HWPoolingTiler::HWPoolingTiler(const ConvolutionOptions& convolutionOptions, const Direction& direction,
std::size_t maxTilingOptions) :
_convolutionOptions(std::move(convolutionOptions)),
_searcher(_convolutionOptions, direction, maxTilingOptions) {

View File

@@ -977,7 +977,7 @@ static int dispatcherClean(xLinkSchedulerState_t* curr)
XLINK_RET_ERR_IF(pthread_mutex_lock(&clean_mutex), 1);
if (curr->schedulerId == -1) {
mvLog(MVLOG_WARN,"Scheduler has already been reset or cleaned");
if(pthread_mutex_unlock(&clean_mutex) != 0) {
if (pthread_mutex_unlock(&clean_mutex) != 0) {
mvLog(MVLOG_ERROR, "Failed to unlock clean_mutex");
}
@@ -996,7 +996,13 @@ static int dispatcherClean(xLinkSchedulerState_t* curr)
XLINK_RET_ERR_IF(pthread_mutex_lock(&(curr->queueMutex)) != 0, 1);
postAndMarkEventServed(event);
XLINK_RET_ERR_IF(pthread_mutex_unlock(&(curr->queueMutex)) != 0, 1);
if (pthread_mutex_unlock(&(curr->queueMutex)) != 0) {
if (pthread_mutex_unlock(&clean_mutex) != 0) {
mvLog(MVLOG_ERROR, "Failed to unlock clean_mutex after failing to unlock curr->queueMutex");
}
mvLog(MVLOG_ERROR, "Failed to unlock curr->queueMutex");
return 1;
}
event = dispatcherGetNextEvent(curr);
}

View File

@@ -44,7 +44,7 @@ static int handleIncomingEvent(xLinkEvent_t* event);
//adds a new event with parameters and returns event id
int dispatcherEventSend(xLinkEvent_t *event)
{
mvLog(MVLOG_DEBUG, "Send event: %s, size %lu, streamId %lu.\n",
mvLog(MVLOG_DEBUG, "Send event: %s, size %u, streamId %u.\n",
TypeToStr(event->header.type), event->header.size, event->header.streamId);
int rc = XLinkPlatformWrite(&event->deviceHandle,
@@ -124,17 +124,17 @@ int dispatcherLocalEventGetResponse(xLinkEvent_t* event, xLinkEvent_t* response)
XLINK_EVENT_ACKNOWLEDGE(event);
event->header.flags.bitField.localServe = 0;
if(!isStreamSpaceEnoughFor(stream, event->header.size)){
if (!isStreamSpaceEnoughFor(stream, event->header.size)) {
mvLog(MVLOG_DEBUG,"local NACK RTS. stream '%s' is full (event %d)\n", stream->name, event->header.id);
event->header.flags.bitField.block = 1;
event->header.flags.bitField.localServe = 1;
// TODO: easy to implement non-blocking read here, just return nack
mvLog(MVLOG_WARN, "Blocked event would cause dispatching thread to wait on semaphore infinitely\n");
}else{
} else {
event->header.flags.bitField.block = 0;
stream->remoteFillLevel += event->header.size;
stream->remoteFillPacketLevel++;
mvLog(MVLOG_DEBUG,"S%lu: Got local write of %lu , remote fill level %lu out of %lu %lu\n",
mvLog(MVLOG_DEBUG,"S%u: Got local write of %u , remote fill level %u out of %u %u\n",
event->header.streamId, event->header.size, stream->remoteFillLevel, stream->writeSize, stream->readSize);
}
releaseStream(stream);
@@ -295,7 +295,7 @@ int dispatcherRemoteEventGetResponse(xLinkEvent_t* event, xLinkEvent_t* response
stream->remoteFillLevel -= event->header.size;
stream->remoteFillPacketLevel--;
mvLog(MVLOG_DEBUG,"S%lu: Got remote release of %lu, remote fill level %lu out of %lu %lu\n",
mvLog(MVLOG_DEBUG,"S%u: Got remote release of %u, remote fill level %u out of %u %u\n",
event->header.streamId, event->header.size, stream->remoteFillLevel, stream->writeSize, stream->readSize);
releaseStream(stream);
@@ -321,7 +321,7 @@ int dispatcherRemoteEventGetResponse(xLinkEvent_t* event, xLinkEvent_t* response
stream->remoteFillLevel -= event->header.size;
stream->remoteFillPacketLevel--;
mvLog(MVLOG_DEBUG,"S%lu: Got remote release of %lu, remote fill level %lu out of %lu %lu\n",
mvLog(MVLOG_DEBUG,"S%u: Got remote release of %u, remote fill level %u out of %u %u\n",
event->header.streamId, event->header.size, stream->remoteFillLevel, stream->writeSize, stream->readSize);
releaseStream(stream);
@@ -537,7 +537,7 @@ int isStreamSpaceEnoughFor(streamDesc_t* stream, uint32_t size)
{
if(stream->remoteFillPacketLevel >= XLINK_MAX_PACKETS_PER_STREAM ||
stream->remoteFillLevel + size > stream->writeSize){
mvLog(MVLOG_DEBUG, "S%lu: Not enough space in stream '%s' for %lu: PKT %lu, FILL %lu SIZE %lu\n",
mvLog(MVLOG_DEBUG, "S%u: Not enough space in stream '%s' for %u: PKT %u, FILL %u SIZE %u\n",
stream->id, stream->name, size, stream->remoteFillPacketLevel, stream->remoteFillLevel, stream->writeSize);
return 0;
}
@@ -568,7 +568,7 @@ int releasePacketFromStream(streamDesc_t* stream, uint32_t* releasedSize)
}
stream->localFillLevel -= currPack->length;
mvLog(MVLOG_DEBUG, "S%lu: Got release of %lu , current local fill level is %lu out of %lu %lu\n",
mvLog(MVLOG_DEBUG, "S%u: Got release of %u , current local fill level is %u out of %u %u\n",
stream->id, currPack->length, stream->localFillLevel, stream->readSize, stream->writeSize);
XLinkPlatformDeallocateData(currPack->data,
@@ -606,7 +606,7 @@ int releaseSpecificPacketFromStream(streamDesc_t* stream, uint32_t* releasedSize
stream->localFillLevel -= currPack->length;
mvLog(MVLOG_DEBUG, "S%lu: Got release of %lu , current local fill level is %lu out of %lu %lu\n",
mvLog(MVLOG_DEBUG, "S%u: Got release of %u , current local fill level is %u out of %u %u\n",
stream->id, currPack->length, stream->localFillLevel, stream->readSize, stream->writeSize);
XLinkPlatformDeallocateData(currPack->data,
ALIGN_UP_INT32((int32_t) currPack->length, __CACHE_LINE_SIZE), __CACHE_LINE_SIZE);
@@ -665,7 +665,7 @@ int handleIncomingEvent(xLinkEvent_t* event) {
ASSERT_XLINK(stream);
stream->localFillLevel += event->header.size;
mvLog(MVLOG_DEBUG,"S%lu: Got write of %lu, current local fill level is %lu out of %lu %lu\n",
mvLog(MVLOG_DEBUG,"S%u: Got write of %u, current local fill level is %u out of %u %u\n",
event->header.streamId, event->header.size, stream->localFillLevel, stream->readSize, stream->writeSize);
void* buffer = XLinkPlatformAllocateData(ALIGN_UP(event->header.size, __CACHE_LINE_SIZE), __CACHE_LINE_SIZE);

View File

@@ -37,7 +37,7 @@ static streamId_t getNextStreamUniqueId(xLinkDesc_t *link);
streamId_t XLinkAddOrUpdateStream(void *fd, const char *name,
uint32_t writeSize, uint32_t readSize, streamId_t forcedId)
{
mvLog(MVLOG_DEBUG, "name: %s, writeSize: %lu, readSize: %lu, forcedId: %lu\n",
mvLog(MVLOG_DEBUG, "name: %s, writeSize: %u, readSize: %u, forcedId: %u\n",
name, writeSize, readSize, forcedId);
streamId_t retStreamId = INVALID_STREAM_ID;
@@ -50,7 +50,7 @@ streamId_t XLinkAddOrUpdateStream(void *fd, const char *name,
int streamAlreadyExists = (writeSize > stream->writeSize && stream->writeSize != 0)
|| (readSize > stream->readSize && stream->readSize != 0);
XLINK_OUT_WITH_LOG_IF(streamAlreadyExists,
mvLog(MVLOG_ERROR, "Stream with name:%s already exists: id=%lu\n", name, stream->id));
mvLog(MVLOG_ERROR, "Stream with name:%s already exists: id=%u\n", name, stream->id));
} else {
streamId_t nextStreamId = forcedId == INVALID_STREAM_ID ?
getNextStreamUniqueId(link) : forcedId;

View File

@@ -17,7 +17,7 @@
XLinkError_t XLinkStreamInitialize(
streamDesc_t* stream, streamId_t id, const char* name) {
mvLog(MVLOG_DEBUG, "name: %s, id: %lu\n", name, id);
mvLog(MVLOG_DEBUG, "name: %s, id: %u\n", name, id);
ASSERT_XLINK(stream);
memset(stream, 0, sizeof(*stream));

View File

@@ -1483,8 +1483,9 @@ static void printfOverXLinkOpen(struct _devicePrivate_t *d) {
int portNum = 7788;
int connfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (connfd != 0) {
if (connfd == -1) {
fprintf(stderr,"ERROR in socket function, return value is : %d\n", connfd);
close(connfd);
return;
}
bzero((char *) &serv_addr, sizeof(serv_addr));