mirror of
https://github.com/openharmony/drivers_peripheral.git
synced 2026-08-25 02:23:31 -04:00
camera codemars warning clear
Signed-off-by: bigA2021 <yanyin1@huawei.com>
This commit is contained in:
@@ -304,8 +304,9 @@ int HosFileFormat::V4L2OpenDevice(const std::string& deviceName)
|
||||
|
||||
int rc = 0;
|
||||
char* devName = nullptr;
|
||||
char absPath[PATH_MAX] = {0};
|
||||
|
||||
devName = realpath(deviceName.c_str(), nullptr);
|
||||
devName = realpath(deviceName.c_str(), absPath);
|
||||
if (devName == nullptr) {
|
||||
CAMERA_LOGE("V4L2OpenDevice realpath error\n");
|
||||
return RCERRORFD;
|
||||
|
||||
@@ -34,8 +34,9 @@ void HosV4L2UVC::V4L2UvcSearchCapability(const std::string devName, const std::s
|
||||
|
||||
if (inOut) {
|
||||
char *name = nullptr;
|
||||
char absPath[PATH_MAX] = {0};
|
||||
|
||||
name = realpath(v4l2Device.c_str(), nullptr);
|
||||
name = realpath(v4l2Device.c_str(), absPath);
|
||||
if (name == nullptr) {
|
||||
CAMERA_LOGE("UVC:V4L2UvcMatchDev realpath error\n");
|
||||
return;
|
||||
@@ -116,8 +117,9 @@ RetCode HosV4L2UVC::V4L2UvcGetCap(const std::string v4l2Device, struct v4l2_capa
|
||||
{
|
||||
int fd, rc;
|
||||
char *devName = nullptr;
|
||||
char absPath[PATH_MAX] = {0};
|
||||
|
||||
devName = realpath(v4l2Device.c_str(), nullptr);
|
||||
devName = realpath(v4l2Device.c_str(), absPath);
|
||||
if (devName == nullptr) {
|
||||
CAMERA_LOGE("UVC:V4L2UvcGetCap realpath error v4l2Device == %{public}s\n", v4l2Device.c_str());
|
||||
return RC_ERROR;
|
||||
|
||||
@@ -47,8 +47,13 @@ uint64_t GetCurrentLocalTimeStampOFL()
|
||||
|
||||
int32_t SaveToFile(const char* type, const void* buffer, int32_t size)
|
||||
{
|
||||
int ret;
|
||||
char path[PATH_MAX] = {0};
|
||||
sprintf_s(path, PATH_MAX, "/mnt/%s_%lld.yuv", type, GetCurrentLocalTimeStampOFL());
|
||||
ret = sprintf_s(path, PATH_MAX, "/mnt/%s_%lld.yuv", type, GetCurrentLocalTimeStampOFL());
|
||||
if (ret < 0) {
|
||||
std::cout << "sprintf_s failed, errno = " << strerror(errno) << std::endl;
|
||||
return -1;
|
||||
}
|
||||
int imgFd = open(path, O_RDWR | O_CREAT, 00766);
|
||||
if (imgFd == -1) {
|
||||
std::cout << "open file failed, errno = " << strerror(errno) << std::endl;
|
||||
|
||||
@@ -31,8 +31,13 @@ uint64_t TestDisplay::GetCurrentLocalTimeStamp()
|
||||
|
||||
int32_t TestDisplay::SaveYUV(char* type, unsigned char* buffer, int32_t size)
|
||||
{
|
||||
int ret;
|
||||
char path[PATH_MAX] = {0};
|
||||
sprintf_s(path, sizeof(path) / sizeof(path[0]), "/mnt/yuv/%s_%lld.yuv", type, GetCurrentLocalTimeStamp());
|
||||
ret = sprintf_s(path, sizeof(path) / sizeof(path[0]), "/mnt/yuv/%s_%lld.yuv", type, GetCurrentLocalTimeStamp());
|
||||
if (ret < 0) {
|
||||
CAMERA_LOGE("%s, sprintf_s failed, errno = %s.", __FUNCTION__, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
CAMERA_LOGI("%s, save yuv to file %s", __FUNCTION__, path);
|
||||
system("mkdir -p /mnt/yuv");
|
||||
int imgFd = open(path, O_RDWR | O_CREAT, 00766); // 00766: file permissions
|
||||
|
||||
@@ -96,6 +96,9 @@ CamRetCode CameraDevice::EnableResult(const std::vector<MetaType>& results)
|
||||
}
|
||||
|
||||
int count = results.size();
|
||||
if (count <= 0) {
|
||||
return DEVICE_ERROR;
|
||||
}
|
||||
MetaTypeCIF* meta = new MetaTypeCIF[count];
|
||||
if (meta == nullptr) {
|
||||
return INSUFFICIENT_RESOURCES;
|
||||
@@ -114,6 +117,9 @@ CamRetCode CameraDevice::DisableResult(const std::vector<MetaType>& results)
|
||||
}
|
||||
|
||||
int count = results.size();
|
||||
if (count <= 0) {
|
||||
return DEVICE_ERROR;
|
||||
}
|
||||
MetaTypeCIF* meta = new MetaTypeCIF[count];
|
||||
if (meta == nullptr) {
|
||||
return INSUFFICIENT_RESOURCES;
|
||||
|
||||
@@ -47,6 +47,9 @@ CamRetCode OfflineStreamOperator::ReleaseStreams(const std::vector<int>& streamI
|
||||
}
|
||||
|
||||
int count = streamIds.size();
|
||||
if (count <= 0) {
|
||||
return DEVICE_ERROR;
|
||||
}
|
||||
int* ids = new int[count];
|
||||
if (ids == nullptr) {
|
||||
return INSUFFICIENT_RESOURCES;
|
||||
|
||||
@@ -73,6 +73,9 @@ CamRetCode StreamOperator::CreateStreams(const std::vector<std::shared_ptr<Strea
|
||||
}
|
||||
|
||||
int count = streamInfos.size();
|
||||
if (count <= 0) {
|
||||
return DEVICE_ERROR;
|
||||
}
|
||||
StreamInfoCIF* sis = new StreamInfoCIF[count];
|
||||
if (sis == nullptr) {
|
||||
return INSUFFICIENT_RESOURCES;
|
||||
@@ -113,6 +116,9 @@ CamRetCode StreamOperator::ReleaseStreams(const std::vector<int>& streamIds)
|
||||
}
|
||||
|
||||
int count = streamIds.size();
|
||||
if (count <= 0) {
|
||||
return DEVICE_ERROR;
|
||||
}
|
||||
int* ids = new int[count];
|
||||
if (ids == nullptr) {
|
||||
return INSUFFICIENT_RESOURCES;
|
||||
@@ -217,6 +223,9 @@ CamRetCode StreamOperator::Capture(int captureId, const std::shared_ptr<CaptureI
|
||||
}
|
||||
|
||||
int count = pInfo->streamIds_.size();
|
||||
if (count <= 0) {
|
||||
return DEVICE_ERROR;
|
||||
}
|
||||
int* ids = new int[count];
|
||||
if (ids == nullptr) {
|
||||
return INSUFFICIENT_RESOURCES;
|
||||
@@ -261,6 +270,9 @@ CamRetCode StreamOperator::ChangeToOfflineStream(const std::vector<int>& streamI
|
||||
cb.OnFrameShutter = StreamCBOnFrameShutter;
|
||||
|
||||
int count = streamIds.size();
|
||||
if (count <= 0) {
|
||||
return DEVICE_ERROR;
|
||||
}
|
||||
int* ids = new int[count];
|
||||
if (ids == nullptr) {
|
||||
return INSUFFICIENT_RESOURCES;
|
||||
|
||||
Reference in New Issue
Block a user