Fixing Coverity issues

Note: This doesn't address Google Code style guidelines issues.
Review URL: https://webrtc-codereview.appspot.com/391011

git-svn-id: http://webrtc.googlecode.com/svn/trunk@1707 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
mallinath@webrtc.org
2012-02-16 18:18:21 +00:00
parent 3ab6dda5cb
commit 12984f0d02
6 changed files with 61 additions and 74 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@@ -61,7 +61,7 @@ class VideoCaptureModule: public RefCountedModule {
// Returns the deviceCapabilityNumber on success.
virtual WebRtc_Word32 GetBestMatchedCapability(
const WebRtc_UWord8*deviceUniqueIdUTF8,
const VideoCaptureCapability requested,
const VideoCaptureCapability& requested,
VideoCaptureCapability& resulting) = 0;
// Display OS /capture device specific settings dialog

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@@ -10,7 +10,6 @@
#include "device_info_linux.h"
#include <sys/stat.h>
#include <errno.h>
#include <unistd.h>
#include <sys/ioctl.h>
@@ -68,17 +67,13 @@ WebRtc_UWord32 DeviceInfoLinux::NumberOfDevices()
/* detect /dev/video [0-63]VideoCaptureModule entries */
for (int n = 0; n < 64; n++)
{
struct stat s;
sprintf(device, "/dev/video%d", n);
if (stat(device, &s) == 0) //check validity of path
{
if ((fd = open(device, O_RDONLY)) != -1)
{
close(fd);
count++;
}
}
}
return count;
}
@@ -101,10 +96,7 @@ WebRtc_Word32 DeviceInfoLinux::GetDeviceName(
bool found = false;
for (int n = 0; n < 64; n++)
{
struct stat s;
sprintf(device, "/dev/video%d", n);
if (stat(device, &s) == 0) // Check validity of path
{
if ((fd = open(device, O_RDONLY)) != -1)
{
if (count == deviceNumber) {
@@ -117,7 +109,6 @@ WebRtc_Word32 DeviceInfoLinux::GetDeviceName(
}
}
}
}
if (!found)
return -1;
@@ -187,14 +178,13 @@ WebRtc_Word32 DeviceInfoLinux::CreateCapabilityMap(
"CreateCapabilityMap called for device %s", deviceUniqueIdUTF8);
/* detect /dev/video [0-63] entries */
for (int n = 0; n < 64; n++)
for (int n = 0; n < 64; ++n)
{
struct stat s;
sprintf(device, "/dev/video%d", n);
if (stat(device, &s) == 0) //check validity of path
{
if ((fd = open(device, O_RDONLY)) > 0)
{
fd = open(device, O_RDONLY);
if (fd == -1)
continue;
// query device capabilities
struct v4l2_capability cap;
if (ioctl(fd, VIDIOC_QUERYCAP, &cap) == 0)
@@ -221,8 +211,6 @@ WebRtc_Word32 DeviceInfoLinux::CreateCapabilityMap(
}
close(fd); // close since this is not the matching device
}
}
}
if (!found)
{

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@@ -50,7 +50,8 @@ VideoCaptureModuleV4L2::VideoCaptureModuleV4L2(const WebRtc_Word32 id)
: VideoCaptureImpl(id), _captureThread(NULL),
_captureCritSect(CriticalSectionWrapper::CreateCriticalSection()),
_deviceId(-1), _currentWidth(-1), _currentHeight(-1),
_currentFrameRate(-1), _captureStarted(false), _captureVideoType(kVideoI420)
_currentFrameRate(-1), _captureStarted(false),
_captureVideoType(kVideoI420), pool(NULL)
{
}
@@ -71,11 +72,8 @@ WebRtc_Word32 VideoCaptureModuleV4L2::Init(const WebRtc_UWord8* deviceUniqueIdUT
int n;
for (n = 0; n < 64; n++)
{
struct stat s;
sprintf(device, "/dev/video%d", n);
if (stat(device, &s) == 0) //check validity of path
{
if ((fd = open(device, O_RDONLY)) > 0)
if ((fd = open(device, O_RDONLY)) != -1)
{
// query device capabilities
struct v4l2_capability cap;
@@ -96,7 +94,6 @@ WebRtc_Word32 VideoCaptureModuleV4L2::Init(const WebRtc_UWord8* deviceUniqueIdUT
close(fd); // close since this is not the matching device
}
}
}
if (!found)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCapture, _id, "no matching device found");

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@@ -149,7 +149,7 @@ WebRtc_Word32 DeviceInfoImpl::GetCapability(const WebRtc_UWord8* deviceUniqueIdU
WebRtc_Word32 DeviceInfoImpl::GetBestMatchedCapability(
const WebRtc_UWord8*deviceUniqueIdUTF8,
const VideoCaptureCapability requested,
const VideoCaptureCapability& requested,
VideoCaptureCapability& resulting)
{

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@@ -32,7 +32,7 @@ public:
VideoCaptureCapability& capability);
virtual WebRtc_Word32 GetBestMatchedCapability(const WebRtc_UWord8*deviceUniqueIdUTF8,
const VideoCaptureCapability requested,
const VideoCaptureCapability& requested,
VideoCaptureCapability& resulting);
virtual WebRtc_Word32 GetOrientation(const WebRtc_UWord8* deviceUniqueIdUTF8,
VideoCaptureRotation& orientation);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@@ -136,7 +136,9 @@ VideoCaptureImpl::VideoCaptureImpl(const WebRtc_Word32 id)
_lastProcessTime(TickTime::Now()),
_lastFrameRateCallbackTime(TickTime::Now()), _frameRateCallBack(false),
_noPictureAlarmCallBack(false), _captureAlarm(Cleared), _setCaptureDelay(0),
_dataCallBack(NULL), _captureCallBack(NULL), _startImageFrameIntervall(0),
_dataCallBack(NULL), _captureCallBack(NULL),
_startImage(), _startImageFrameIntervall(0),
_lastSentStartImageTime(TickTime::Now()),
_lastProcessFrameCount(TickTime::Now()), _rotateFrame(kRotateNone),
last_capture_time_(TickTime::MillisecondTimestamp())