Skip to content

Commit

Permalink
fix lint warnings in msd.cpp (Xilinx#2524)
Browse files Browse the repository at this point in the history
  • Loading branch information
xuhz authored and maxzhen committed Dec 5, 2019
1 parent 9396525 commit 897b368
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/runtime_src/core/pcie/tools/cloud-daemon/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,9 @@ int handleMsg(const pcieFunc& dev, queue_msg &msg)
pass = (*msg.cb)(dev, swmsg, swmsgProcessed);
}

if (pass == FOR_LOCAL && sendMsg(dev, msg.localFd, swmsgProcessed.get()))
if (pass == FOR_LOCAL && msg.localFd > 0 && sendMsg(dev, msg.localFd, swmsgProcessed.get()))
return 0;
if (pass == FOR_REMOTE && sendMsg(dev, msg.remoteFd, swmsgProcessed.get()))
if (pass == FOR_REMOTE && msg.remoteFd > 0 && sendMsg(dev, msg.remoteFd, swmsgProcessed.get()))
return 0;
// Error occured
return -EINVAL;
Expand Down
12 changes: 7 additions & 5 deletions src/runtime_src/core/pcie/tools/cloud-daemon/msd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,6 @@ void Msd::msd_thread(size_t index, std::string host)
int sockfd = -1, mpdfd = -1, mbxfd = -1;
int retfd[2];
int ret;
struct queue_msg msg = {0};
const int interval = 2;

pcieFunc dev(index, false);
Expand Down Expand Up @@ -356,15 +355,17 @@ void Msd::msd_thread(size_t index, std::string host)
continue;
}

msg.localFd = mbxfd;
msg.remoteFd = mpdfd;

// Process msg.
for (int i = 0; i < 2; i++) {
struct queue_msg msg = {0};
if (retfd[i] == mbxfd) {
msg.localFd = mbxfd;
msg.remoteFd = -1;
msg.type = LOCAL_MSG;
msg.data = std::move(getLocalMsg(dev, mbxfd));
} else if (retfd[i] == mpdfd) {
msg.localFd = -1;
msg.remoteFd = mpdfd;
msg.type = REMOTE_MSG;
msg.data = std::move(getRemoteMsg(dev, mpdfd));
msg.cb = Msd::remoteMsgHandler;
Expand All @@ -374,7 +375,8 @@ void Msd::msd_thread(size_t index, std::string host)

ret = handleMsg(dev, msg);
if (ret) { // Socket connection was lost, retry
close(mpdfd);
if (mpdfd >= 0)
close(mpdfd);
mpdfd = -1;
continue;
}
Expand Down

0 comments on commit 897b368

Please sign in to comment.