fix cde warn

Signed-off-by: liqiao49 <liqiao49@huawei.com>
This commit is contained in:
liqiao49
2023-07-31 20:42:47 +08:00
parent f764ef7213
commit 34541fdb6e
5 changed files with 13 additions and 18 deletions
+3 -3
View File
@@ -449,7 +449,7 @@ int32_t InputHub::OpenInputDeviceLocked(const std::string& devicePath)
std::unique_lock<std::mutex> my_lock(operationMutex_);
DHLOGI("Opening device: %s", devicePath.c_str());
int fd = OpenInputDeviceFdByPath(devicePath);
if (fd == -1) {
if (fd == UN_INIT_FD_VALUE) {
DHLOGE("The fd open failed, devicePath %s.", devicePath.c_str());
return ERR_DH_INPUT_HUB_OPEN_DEVICEPATH_FAIL;
}
@@ -476,7 +476,7 @@ int32_t InputHub::OpenInputDeviceLocked(const std::string& devicePath)
int32_t InputHub::QueryInputDeviceInfo(int fd, InputDevice& identifier)
{
char buffer[256] = {0};
char buffer[INPUT_EVENT_BUFFER_SIZE] = {0};
// Get device name.
if (ioctl(fd, EVIOCGNAME(sizeof(buffer) - 1), &buffer) < 1) {
DHLOGE(
@@ -1279,7 +1279,7 @@ void InputHub::Device::Close()
{
if (fd >= 0) {
::close(fd);
fd = -1;
fd = UN_INIT_FD_VALUE;
}
}
@@ -33,7 +33,6 @@ public:
static DistributedInputInject &GetInstance();
int32_t RegisterDistributedHardware(const std::string& devId, const std::string& dhId,
const std::string& parameters);
int32_t UnregisterDistributedHardware(const std::string& devId, const std::string& dhId);
int32_t RegisterDistributedEvent(RawEvent* buffer, size_t bufferSize);
int32_t StructTransJson(const InputDevice& pBuf, std::string& strDescriptor);
@@ -45,22 +44,18 @@ public:
const uint32_t sourcePhyWidth, const uint32_t sourcePhyHeight);
int32_t RemoveVirtualTouchScreenNode(const std::string& dhId);
int32_t GetVirtualTouchScreenFd();
int32_t RegisterInputNodeListener(sptr<InputNodeListener> listener);
int32_t UnregisterInputNodeListener(sptr<InputNodeListener> listener);
int32_t GetDhIdsByInputType(const std::string &devId, const uint32_t &inputTypes, std::vector<std::string> &dhIds);
void NotifyNodeMgrScanVirNode(const std::string &dhId);
void InputDeviceEventInject(const std::shared_ptr<RawEvent> &rawEvent);
void SyncNodeOfflineInfo(const std::string &srcDevId, const std::string &sinkDevId, const std::string &sinkNodeId);
void SyncNodeOnlineInfo(const std::string &srcDevId, const std::string &sinkDevId, const std::string &sinkNodeId,
const std::string &sinkNodeDesc);
void SyncNodeOfflineInfo(const std::string &srcDevId, const std::string &sinkDevId, const std::string &sinkNodeId);
void GetVirtualKeyboardPathsByDhIds(const std::vector<std::string> &dhIds,
std::vector<std::string> &shareDhidsPaths, std::vector<std::string> &shareDhIds);
void NotifyNodeMgrScanVirNode(const std::string &dhId);
private:
DistributedInputInject();
~DistributedInputInject();
@@ -193,7 +193,7 @@ void DistributedInputNodeManager::NotifyNodeMgrScanVirNode(const std::string &dh
bool DistributedInputNodeManager::IsVirtualDev(int fd)
{
char buffer[256] = {0};
char buffer[INPUT_EVENT_BUFFER_SIZE] = {0};
std::string deviceName;
if (ioctl(fd, EVIOCGNAME(sizeof(buffer) - 1), &buffer) < 1) {
DHLOGE("Could not get device name for %s.", ConvertErrNo().c_str());
@@ -212,7 +212,7 @@ bool DistributedInputNodeManager::IsVirtualDev(int fd)
bool DistributedInputNodeManager::GetDevDhIdByFd(int fd, std::string& dhId, std::string& physicalPath)
{
char buffer[256] = {0};
char buffer[INPUT_EVENT_BUFFER_SIZE] = {0};
if (ioctl(fd, EVIOCGPHYS(sizeof(buffer) - 1), &buffer) < 1) {
DHLOGE("Could not get device physicalPath for %s.", ConvertErrNo().c_str());
return false;
@@ -251,7 +251,7 @@ void DistributedInputNodeManager::OpenInputDevice(const std::string& devicePath,
std::string curDhId;
std::string physicalPath;
int fd = OpenInputDeviceFdByPath(devicePath);
if (fd == -1) {
if (fd == UN_INIT_FD_VALUE) {
DHLOGE("The fd open failed, devicePath %s.", devicePath.c_str());
return;
}
+4 -4
View File
@@ -22,10 +22,10 @@
#include <unistd.h>
#include <vector>
#include "constants_dinput.h"
#include "dinput_errcode.h"
#include "dinput_log.h"
#include "dinput_utils_tool.h"
#include "constants_dinput.h"
#include "distributed_input_collector.h"
#include "distributed_input_inject.h"
#include "distributed_input_sink_transport.h"
@@ -143,10 +143,10 @@ void DInputState::SpecEventInject(const int32_t &sessionId, std::vector<std::str
std::vector<std::string> keyboardNodeDhIds;
DistributedInputCollector::GetInstance().GetShareKeyboardPathsByDhIds(dhids, keyboardNodePaths, keyboardNodeDhIds);
DistributedInputInject::GetInstance().GetVirtualKeyboardPathsByDhIds(dhids, keyboardNodePaths, keyboardNodeDhIds);
ssize_t len = keyboardNodePaths.size();
for (ssize_t i = 0; i < len; ++i) {
size_t len = keyboardNodePaths.size();
for (size_t i = 0; i < len; ++i) {
std::vector<uint32_t> keyboardPressedKeys;
int fd = -1;
int fd = UN_INIT_FD_VALUE;
CheckKeyboardState(keyboardNodeDhIds[i], keyboardNodePaths[i], keyboardPressedKeys, fd);
for (auto &code : keyboardPressedKeys) {
struct input_event event = {
+1 -1
View File
@@ -300,7 +300,7 @@ void CloseFd(int& fd)
return;
}
close(fd);
fd = -1;
fd = UN_INIT_FD_VALUE;
}
int BitIsSet(const unsigned long *array, int bit)