mirror of
https://gitee.com/openharmony/developtools_hdc
synced 2024-11-24 07:31:06 +00:00
feat:cleancodeg告警清理
Signed-off-by: m30058418 <maliang87@huawei.com>
This commit is contained in:
parent
d570f1f518
commit
6d95450fa0
@ -95,7 +95,7 @@ int HdcBridge::WriteClient(int fd, SerializedBuffer buf)
|
||||
{
|
||||
uint8_t* ptr = reinterpret_cast<uint8_t *>(buf.ptr);
|
||||
size_t size = static_cast<size_t>(buf.size);
|
||||
int cnt = size;
|
||||
int cnt = static_cast<int>(size);
|
||||
constexpr int intrmax = 1000;
|
||||
int intrcnt = 0;
|
||||
while (cnt > 0) {
|
||||
@ -116,7 +116,7 @@ int HdcBridge::WriteClient(int fd, SerializedBuffer buf)
|
||||
ptr += rc;
|
||||
cnt -= rc;
|
||||
}
|
||||
return cnt == 0 ? size : cnt;
|
||||
return cnt == 0 ? static_cast<int>(size) : cnt;
|
||||
}
|
||||
|
||||
void HdcBridge::Stop()
|
||||
|
@ -45,8 +45,8 @@ public:
|
||||
void Stop();
|
||||
|
||||
private:
|
||||
int bridgeListenPort;
|
||||
int bridgeFd;
|
||||
int bridgeListenPort = 0;
|
||||
int bridgeFd = 0;
|
||||
};
|
||||
}
|
||||
#endif
|
@ -31,7 +31,7 @@ public:
|
||||
this->func = func;
|
||||
}
|
||||
virtual ~CTimer() {}
|
||||
void Start(unsigned int msec, bool immediatelyRun = false);
|
||||
void Start(unsigned int imsec, bool immediatelyRun = false);
|
||||
void Stop();
|
||||
void SetExit(bool exit);
|
||||
private:
|
||||
|
@ -127,7 +127,7 @@ public:
|
||||
static void UsbWorkThread(void *arg); // 3rd thread
|
||||
static void WatchUsbNodeChange(void *arg);
|
||||
static void LIBUSB_CALL USBBulkCallback(struct libusb_transfer *transfer);
|
||||
void CancelUsbIo(HUSB hUsb);
|
||||
void CancelUsbIo(HUSB hUSB);
|
||||
PersistBuffer ReadUsbIO(HUSB hUsb, int exceptedSize);
|
||||
int WriteUsbIO(HUSB hUsb, SerializedBuffer buf);
|
||||
HUSB GetUsbDevice(std::string connectKey);
|
||||
|
@ -30,7 +30,7 @@ extern "C" int SendMsg(int socketFd, int fd, char* data, int size)
|
||||
constexpr int cmsgNullptrError = -5;
|
||||
struct iovec iov;
|
||||
iov.iov_base = data;
|
||||
iov.iov_len = size;
|
||||
iov.iov_len = static_cast<size_t>(size);
|
||||
struct msghdr msg;
|
||||
msg.msg_name = nullptr;
|
||||
msg.msg_namelen = 0;
|
||||
|
@ -235,19 +235,25 @@ extern "C" uint8_t ParseTransferPayload(RustStruct::TransferPayload &value, Seri
|
||||
|
||||
extern "C" uint8_t ParsePayloadHead(RustStruct::PayloadHead &value, SerializedBuffer buf)
|
||||
{
|
||||
(void)memcpy_s(&value, buf.size, reinterpret_cast<struct PayloadHead *>(buf.ptr), buf.size);
|
||||
if(memcpy_s(&value, buf.size, reinterpret_cast<struct PayloadHead *>(buf.ptr), buf.size) != EOK) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
extern "C" uint8_t ParseUsbHead(RustStruct::USBHead &value, SerializedBuffer buf)
|
||||
{
|
||||
(void)memcpy_s(&value, sizeof(RustStruct::USBHead), reinterpret_cast<struct USBHead *>(buf.ptr), buf.size);
|
||||
if(memcpy_s(&value, sizeof(RustStruct::USBHead), reinterpret_cast<struct USBHead *>(buf.ptr), buf.size) != EOK) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
extern "C" uint8_t ParseUartHead(RustStruct::UartHead &value, SerializedBuffer buf)
|
||||
{
|
||||
(void)memcpy_s(&value, sizeof(RustStruct::UartHead), reinterpret_cast<struct UartHead *>(buf.ptr), buf.size);
|
||||
if(memcpy_s(&value, sizeof(RustStruct::UartHead), reinterpret_cast<struct UartHead *>(buf.ptr), buf.size) != EOK) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -96,24 +96,24 @@ bool EnumSerialPort(bool &portChange)
|
||||
#else
|
||||
DIR *dir = opendir("/dev");
|
||||
dirent *p = nullptr;
|
||||
while (dir != nullptr && ((p = readdir(dir)) != nullptr)) {
|
||||
if (dir != nullptr) {
|
||||
while ((p = readdir(dir)) != nullptr) {
|
||||
#ifdef HOST_LINUX
|
||||
if (p->d_name[0] != '.' && string(p->d_name).find("tty") != std::string::npos) {
|
||||
if (p->d_name[0] != '.' && string(p->d_name).find("tty") != std::string::npos) {
|
||||
#else
|
||||
if (p->d_name[0] != '.' && string(p->d_name).find("serial") != std::string::npos) {
|
||||
if (p->d_name[0] != '.' && string(p->d_name).find("serial") != std::string::npos) {
|
||||
#endif
|
||||
string port = "/dev/" + string(p->d_name);
|
||||
if (port.find("/dev/ttyUSB") == 0 || port.find("/dev/ttySerial") == 0 || port.find("/dev/cu.") == 0) {
|
||||
newPortInfo.push_back(port);
|
||||
auto it = std::find(serialPortInfo.begin(), serialPortInfo.end(), port);
|
||||
if (it == serialPortInfo.end()) {
|
||||
portChange = true;
|
||||
WRITE_LOG(LOG_INFO, "new port:%s", port.c_str());
|
||||
string port = "/dev/" + string(p->d_name);
|
||||
if (port.find("/dev/ttyUSB") == 0 || port.find("/dev/ttySerial") == 0 || port.find("/dev/cu.") == 0) {
|
||||
newPortInfo.push_back(port);
|
||||
auto it = std::find(serialPortInfo.begin(), serialPortInfo.end(), port);
|
||||
if (it == serialPortInfo.end()) {
|
||||
portChange = true;
|
||||
WRITE_LOG(LOG_INFO, "new port:%s", port.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (dir != nullptr) {
|
||||
closedir(dir);
|
||||
}
|
||||
#endif
|
||||
@ -355,6 +355,9 @@ int OpenSerialPort(std::string portName) {
|
||||
// cannot open with O_CLOEXEC, must fcntl
|
||||
fcntl(uartHandle, F_SETFD, FD_CLOEXEC);
|
||||
int flag = fcntl(uartHandle, F_GETFL);
|
||||
if (flag < 0) {
|
||||
return -1;
|
||||
}
|
||||
flag &= ~O_NONBLOCK;
|
||||
fcntl(uartHandle, F_SETFL, flag);
|
||||
|
||||
|
@ -130,7 +130,7 @@ extern "C" {
|
||||
return ERR_BUF_OVERFLOW;
|
||||
}
|
||||
|
||||
int fd = open(bufPath, O_RDWR | O_CREAT, 0666);
|
||||
int fd = open(bufPath, O_RDWR | O_CREAT, 0644); // 0644:-rw-r--r--
|
||||
if (fd < 0) {
|
||||
return ERR_FILE_OPEN;
|
||||
}
|
||||
|
@ -75,13 +75,19 @@ static int GetUserPermit(void)
|
||||
}
|
||||
if (!con->GetShowDialogResult()) {
|
||||
AUTH_LOGE("show dialog failed");
|
||||
delete con;
|
||||
con = nullptr;
|
||||
return USER_PERMIT_ERR_SHOW_DIALOG_FAIL;
|
||||
}
|
||||
if (!WaitDialogResult()) {
|
||||
AUTH_LOGE("wait ability result failed");
|
||||
delete con;
|
||||
con = nullptr;
|
||||
return USER_PERMIT_ERR_WAIT_DIALOG_FAIL;
|
||||
}
|
||||
|
||||
delete con;
|
||||
con = nullptr;
|
||||
return USER_PERMIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -213,8 +213,8 @@ void HdcHostUSB::ReviewUsbNodeLater(string &nodeKey)
|
||||
|
||||
void HdcHostUSB::WatchUsbNodeChange(uv_timer_t *handle)
|
||||
{
|
||||
HdcHostUSB *thisClass = (HdcHostUSB *)handle->data;
|
||||
HdcServer *ptrConnect = (HdcServer *)thisClass->clsMainBase;
|
||||
HdcHostUSB *thisClass = static_cast<HdcHostUSB *>(handle->data);
|
||||
HdcServer *ptrConnect = static_cast<HdcServer *>(thisClass->clsMainBase);
|
||||
libusb_device **devs = nullptr;
|
||||
libusb_device *dev = nullptr;
|
||||
// kick zombie
|
||||
|
Loading…
Reference in New Issue
Block a user