Camera: Clean up warnings and set -Werror
- Also fix error logging template inconsistency
- Also add a few error handling cases into camera2 NDK
to deal with previously-ignored error codes
Bug: 27149500
Change-Id: I8f1f4c72252dd48d652f24b595b642199f20c327
diff --git a/camera/Android.mk b/camera/Android.mk
index b0df7c4..1a3382f 100644
--- a/camera/Android.mk
+++ b/camera/Android.mk
@@ -73,6 +73,8 @@
system/media/camera/include \
frameworks/av/include/camera
+LOCAL_CFLAGS += -Werror -Wall -Wextra
+
LOCAL_MODULE:= libcamera_client
include $(BUILD_SHARED_LIBRARY)
diff --git a/camera/CameraBase.cpp b/camera/CameraBase.cpp
index 9aa0b4e..15d7715 100644
--- a/camera/CameraBase.cpp
+++ b/camera/CameraBase.cpp
@@ -118,7 +118,6 @@
ALOGV("%s: connect", __FUNCTION__);
sp<TCam> c = new TCam(cameraId);
sp<TCamCallbacks> cl = c;
- status_t status = NO_ERROR;
const sp<::android::hardware::ICameraService>& cs = getCameraService();
binder::Status ret;
diff --git a/camera/CameraParameters2.cpp b/camera/CameraParameters2.cpp
index 378afeb..c29233c 100644
--- a/camera/CameraParameters2.cpp
+++ b/camera/CameraParameters2.cpp
@@ -351,7 +351,7 @@
void CameraParameters2::dump() const
{
- ALOGD("dump: mMap.size = %d", mMap.size());
+ ALOGD("dump: mMap.size = %zu", mMap.size());
for (size_t i = 0; i < mMap.size(); i++) {
String8 k, v;
k = mMap.keyAt(i);
diff --git a/camera/VendorTagDescriptor.cpp b/camera/VendorTagDescriptor.cpp
index de69a5b..5538da9 100644
--- a/camera/VendorTagDescriptor.cpp
+++ b/camera/VendorTagDescriptor.cpp
@@ -59,7 +59,7 @@
VendorTagDescriptor::VendorTagDescriptor() :
mTagCount(0),
- mVendorOps({nullptr}) {
+ mVendorOps() {
}
VendorTagDescriptor::VendorTagDescriptor(const VendorTagDescriptor& src) {
diff --git a/camera/camera2/OutputConfiguration.cpp b/camera/camera2/OutputConfiguration.cpp
index 2c2c90b..3247d0d 100644
--- a/camera/camera2/OutputConfiguration.cpp
+++ b/camera/camera2/OutputConfiguration.cpp
@@ -80,8 +80,8 @@
mRotation = rotation;
mSurfaceSetID = setID;
- ALOGV("%s: OutputConfiguration: bp = %p, name = %s", __FUNCTION__,
- mGbp.get(), String8(surfaceShim.name).string());
+ ALOGV("%s: OutputConfiguration: bp = %p, name = %s, rotation = %d, setId = %d", __FUNCTION__,
+ mGbp.get(), String8(surfaceShim.name).string(), mRotation, mSurfaceSetID);
return err;
}
diff --git a/camera/cameraserver/Android.mk b/camera/cameraserver/Android.mk
index 0207505..7e36c5e 100644
--- a/camera/cameraserver/Android.mk
+++ b/camera/cameraserver/Android.mk
@@ -29,6 +29,8 @@
LOCAL_MODULE:= cameraserver
LOCAL_32_BIT_ONLY := true
+LOCAL_CFLAGS += -Wall -Wextra -Werror -Wno-unused-parameter
+
LOCAL_INIT_RC := cameraserver.rc
include $(BUILD_EXECUTABLE)
diff --git a/camera/ndk/Android.mk b/camera/ndk/Android.mk
index e43bb2c..ebd473d 100644
--- a/camera/ndk/Android.mk
+++ b/camera/ndk/Android.mk
@@ -38,6 +38,7 @@
frameworks/av/include/ndk
LOCAL_CFLAGS += -fvisibility=hidden -D EXPORT='__attribute__ ((visibility ("default")))'
+LOCAL_CFLAGS += -Wall -Wextra -Werror
LOCAL_SHARED_LIBRARIES := \
libbinder \
diff --git a/camera/ndk/impl/ACameraDevice.cpp b/camera/ndk/impl/ACameraDevice.cpp
index 1ab6af8..880befe 100644
--- a/camera/ndk/impl/ACameraDevice.cpp
+++ b/camera/ndk/impl/ACameraDevice.cpp
@@ -64,10 +64,15 @@
// Setup looper thread to perfrom device callbacks to app
mCbLooper = new ALooper;
mCbLooper->setName("C2N-dev-looper");
- status_t ret = mCbLooper->start(
+ status_t err = mCbLooper->start(
/*runOnCallingThread*/false,
/*canCallJava*/ true,
PRIORITY_DEFAULT);
+ if (err != OK) {
+ ALOGE("%s: Unable to start camera device callback looper: %s (%d)",
+ __FUNCTION__, strerror(-err), err);
+ setCameraDeviceErrorLocked(ACAMERA_ERROR_CAMERA_DEVICE);
+ }
mHandler = new CallbackHandler();
mCbLooper->registerHandler(mHandler);
@@ -162,8 +167,6 @@
ACameraCaptureSession* newSession = new ACameraCaptureSession(
mNextSessionId++, outputs, callbacks, this);
- bool configureSucceeded = (ret == ACAMERA_OK);
-
// set new session as current session
newSession->incStrong((void *) ACameraDevice_createCaptureSession);
mCurrentSession = newSession;
@@ -419,7 +422,7 @@
}
int value;
int err = (*anw->query)(anw, NATIVE_WINDOW_CONCRETE_TYPE, &value);
- if (value != NATIVE_WINDOW_SURFACE) {
+ if (err != OK || value != NATIVE_WINDOW_SURFACE) {
ALOGE("Error: ANativeWindow is not backed by Surface!");
return ACAMERA_ERROR_INVALID_PARAMETER;
}
@@ -437,7 +440,7 @@
}
int value;
int err = (*anw->query)(anw, NATIVE_WINDOW_CONCRETE_TYPE, &value);
- if (value != NATIVE_WINDOW_SURFACE) {
+ if (err != OK || value != NATIVE_WINDOW_SURFACE) {
ALOGE("Error: ANativeWindow is not backed by Surface!");
return ACAMERA_ERROR_INVALID_PARAMETER;
}
@@ -453,7 +456,6 @@
outputs = &emptyOutput;
}
- bool success = false;
camera_status_t ret = checkCameraClosedOrErrorLocked();
if (ret != ACAMERA_OK) {
return ret;
@@ -1126,7 +1128,6 @@
}
int sequenceId = resultExtras.requestId;
- int64_t frameNumber = resultExtras.frameNumber;
int32_t burstId = resultExtras.burstId;
auto it = dev->mSequenceCallbackMap.find(sequenceId);
diff --git a/camera/ndk/impl/ACameraManager.cpp b/camera/ndk/impl/ACameraManager.cpp
index 6fa0864..24d5282 100644
--- a/camera/ndk/impl/ACameraManager.cpp
+++ b/camera/ndk/impl/ACameraManager.cpp
@@ -94,10 +94,16 @@
if (mCbLooper == nullptr) {
mCbLooper = new ALooper;
mCbLooper->setName("C2N-mgr-looper");
- status_t ret = mCbLooper->start(
+ status_t err = mCbLooper->start(
/*runOnCallingThread*/false,
/*canCallJava*/ true,
PRIORITY_DEFAULT);
+ if (err != OK) {
+ ALOGE("%s: Unable to start camera service listener looper: %s (%d)",
+ __FUNCTION__, strerror(-err), err);
+ mCbLooper.clear();
+ return nullptr;
+ }
if (mHandler == nullptr) {
mHandler = new CallbackHandler();
}
diff --git a/camera/tests/Android.mk b/camera/tests/Android.mk
index cde26dd..8019999 100644
--- a/camera/tests/Android.mk
+++ b/camera/tests/Android.mk
@@ -36,7 +36,7 @@
system/media/camera/tests \
frameworks/av/services/camera/libcameraservice \
-LOCAL_CFLAGS += -Wall -Wextra
+LOCAL_CFLAGS += -Wall -Wextra -Werror
LOCAL_MODULE:= camera_client_test
LOCAL_MODULE_TAGS := tests
diff --git a/services/camera/libcameraservice/Android.mk b/services/camera/libcameraservice/Android.mk
index bb3a685..c011613 100644
--- a/services/camera/libcameraservice/Android.mk
+++ b/services/camera/libcameraservice/Android.mk
@@ -76,7 +76,7 @@
LOCAL_EXPORT_C_INCLUDE_DIRS := \
frameworks/av/services/camera/libcameraservice
-LOCAL_CFLAGS += -Wall -Wextra
+LOCAL_CFLAGS += -Wall -Wextra -Werror
LOCAL_MODULE:= libcameraservice
diff --git a/services/camera/libcameraservice/api1/client2/JpegCompressor.h b/services/camera/libcameraservice/api1/client2/JpegCompressor.h
index 945b1de..df5da54 100644
--- a/services/camera/libcameraservice/api1/client2/JpegCompressor.h
+++ b/services/camera/libcameraservice/api1/client2/JpegCompressor.h
@@ -71,7 +71,6 @@
Vector<CpuConsumer::LockedBuffer*> mBuffers;
CpuConsumer::LockedBuffer *mJpegBuffer;
CpuConsumer::LockedBuffer *mAuxBuffer;
- bool mFoundJpeg, mFoundAux;
jpeg_compress_struct mCInfo;
diff --git a/services/camera/libcameraservice/api2/CameraDeviceClient.cpp b/services/camera/libcameraservice/api2/CameraDeviceClient.cpp
index 6f9bc7c..307b412 100644
--- a/services/camera/libcameraservice/api2/CameraDeviceClient.cpp
+++ b/services/camera/libcameraservice/api2/CameraDeviceClient.cpp
@@ -30,16 +30,13 @@
// Convenience methods for constructing binder::Status objects for error returns
-#define STRINGIZE_IMPL(x) #x
-#define STRINGIZE(x) STRINGIZE_IMPL(x)
-
#define STATUS_ERROR(errorCode, errorString) \
binder::Status::fromServiceSpecificError(errorCode, \
- String8(STRINGIZE(__FUNCTION__) ":" STRINGIZE(__LINE__) ":" # errorString))
+ String8::format("%s:%d: %s", __FUNCTION__, __LINE__, errorString))
#define STATUS_ERROR_FMT(errorCode, errorString, ...) \
binder::Status::fromServiceSpecificError(errorCode, \
- String8::format(STRINGIZE(__FUNCTION__) ":" STRINGIZE(__LINE__) ":" # errorString, \
+ String8::format("%s:%d: " errorString, __FUNCTION__, __LINE__, \
__VA_ARGS__))
namespace android {
diff --git a/services/camera/libcameraservice/device3/Camera3Device.cpp b/services/camera/libcameraservice/device3/Camera3Device.cpp
index 0de956b..ee84ff0 100644
--- a/services/camera/libcameraservice/device3/Camera3Device.cpp
+++ b/services/camera/libcameraservice/device3/Camera3Device.cpp
@@ -463,7 +463,7 @@
mDeviceInfo.find(ANDROID_SENSOR_OPAQUE_RAW_SIZE);
size_t count = rawOpaqueSizes.count;
if (count == 0 || (count % PER_CONFIGURATION_SIZE)) {
- ALOGE("%s: Camera %d: bad opaque RAW size static metadata length(%d)!",
+ ALOGE("%s: Camera %d: bad opaque RAW size static metadata length(%zu)!",
__FUNCTION__, mId, count);
return BAD_VALUE;
}
diff --git a/services/camera/libcameraservice/device3/Camera3DummyStream.cpp b/services/camera/libcameraservice/device3/Camera3DummyStream.cpp
index fe04eb1..5bf76bd 100644
--- a/services/camera/libcameraservice/device3/Camera3DummyStream.cpp
+++ b/services/camera/libcameraservice/device3/Camera3DummyStream.cpp
@@ -36,26 +36,26 @@
}
-status_t Camera3DummyStream::getBufferLocked(camera3_stream_buffer *buffer) {
+status_t Camera3DummyStream::getBufferLocked(camera3_stream_buffer *) {
ATRACE_CALL();
ALOGE("%s: Stream %d: Dummy stream cannot produce buffers!", __FUNCTION__, mId);
return INVALID_OPERATION;
}
status_t Camera3DummyStream::returnBufferLocked(
- const camera3_stream_buffer &buffer,
- nsecs_t timestamp) {
+ const camera3_stream_buffer &,
+ nsecs_t) {
ATRACE_CALL();
ALOGE("%s: Stream %d: Dummy stream cannot return buffers!", __FUNCTION__, mId);
return INVALID_OPERATION;
}
status_t Camera3DummyStream::returnBufferCheckedLocked(
- const camera3_stream_buffer &buffer,
- nsecs_t timestamp,
- bool output,
+ const camera3_stream_buffer &,
+ nsecs_t,
+ bool,
/*out*/
- sp<Fence> *releaseFenceOut) {
+ sp<Fence>*) {
ATRACE_CALL();
ALOGE("%s: Stream %d: Dummy stream cannot return buffers!", __FUNCTION__, mId);
return INVALID_OPERATION;
@@ -70,7 +70,7 @@
Camera3IOStreamBase::dump(fd, args);
}
-status_t Camera3DummyStream::setTransform(int transform) {
+status_t Camera3DummyStream::setTransform(int) {
ATRACE_CALL();
// Do nothing
return OK;
diff --git a/services/camera/libcameraservice/device3/Camera3Stream.cpp b/services/camera/libcameraservice/device3/Camera3Stream.cpp
index ed3ab97..50f7a91 100644
--- a/services/camera/libcameraservice/device3/Camera3Stream.cpp
+++ b/services/camera/libcameraservice/device3/Camera3Stream.cpp
@@ -55,9 +55,9 @@
mMaxSize(maxSize),
mState(STATE_CONSTRUCTED),
mStatusId(StatusTracker::NO_STATUS_ID),
- oldUsage(0),
- oldMaxBuffers(0),
mStreamUnpreparable(false),
+ mOldUsage(0),
+ mOldMaxBuffers(0),
mPrepared(false),
mPreparedBufferIdx(0),
mLastMaxCount(Camera3StreamInterface::ALLOCATE_PIPELINE_MAX) {
@@ -118,7 +118,7 @@
case STATE_IN_CONFIG:
case STATE_IN_RECONFIG:
// Can start config again with no trouble; but don't redo
- // oldUsage/oldMaxBuffers
+ // mOldUsage/mOldMaxBuffers
return this;
case STATE_CONFIGURED:
if (hasOutstandingBuffersLocked()) {
@@ -132,8 +132,8 @@
return NULL;
}
- oldUsage = camera3_stream::usage;
- oldMaxBuffers = camera3_stream::max_buffers;
+ mOldUsage = camera3_stream::usage;
+ mOldMaxBuffers = camera3_stream::max_buffers;
res = getEndpointUsage(&(camera3_stream::usage));
if (res != OK) {
@@ -196,8 +196,8 @@
// Check if the stream configuration is unchanged, and skip reallocation if
// so. As documented in hardware/camera3.h:configure_streams().
if (mState == STATE_IN_RECONFIG &&
- oldUsage == camera3_stream::usage &&
- oldMaxBuffers == camera3_stream::max_buffers) {
+ mOldUsage == camera3_stream::usage &&
+ mOldMaxBuffers == camera3_stream::max_buffers) {
mState = STATE_CONFIGURED;
return OK;
}
@@ -250,8 +250,8 @@
return INVALID_OPERATION;
}
- camera3_stream::usage = oldUsage;
- camera3_stream::max_buffers = oldMaxBuffers;
+ camera3_stream::usage = mOldUsage;
+ camera3_stream::max_buffers = mOldMaxBuffers;
mState = (mState == STATE_IN_RECONFIG) ? STATE_CONFIGURED : STATE_CONSTRUCTED;
return OK;
@@ -268,7 +268,6 @@
ATRACE_CALL();
Mutex::Autolock l(mLock);
- status_t res = OK;
if (maxCount < 0) {
ALOGE("%s: Stream %d: Can't prepare stream if max buffer count (%d) is < 0",
@@ -340,7 +339,7 @@
// Get next buffer - this may allocate, and take a while for large buffers
res = getBufferLocked( &mPreparedBuffers.editItemAt(mPreparedBufferIdx) );
if (res != OK) {
- ALOGE("%s: Stream %d: Unable to allocate buffer %d during preparation",
+ ALOGE("%s: Stream %d: Unable to allocate buffer %zu during preparation",
__FUNCTION__, mId, mPreparedBufferIdx);
return NO_INIT;
}
@@ -719,7 +718,7 @@
ALOGE("%s: This type of stream does not support input", __FUNCTION__);
return INVALID_OPERATION;
}
-status_t Camera3Stream::getInputBufferProducerLocked(sp<IGraphicBufferProducer> *producer) {
+status_t Camera3Stream::getInputBufferProducerLocked(sp<IGraphicBufferProducer>*) {
ALOGE("%s: This type of stream does not support input", __FUNCTION__);
return INVALID_OPERATION;
}
diff --git a/services/camera/libcameraservice/device3/Camera3Stream.h b/services/camera/libcameraservice/device3/Camera3Stream.h
index fe51ab5..c932e253 100644
--- a/services/camera/libcameraservice/device3/Camera3Stream.h
+++ b/services/camera/libcameraservice/device3/Camera3Stream.h
@@ -442,8 +442,8 @@
bool mStreamUnpreparable;
private:
- uint32_t oldUsage;
- uint32_t oldMaxBuffers;
+ uint32_t mOldUsage;
+ uint32_t mOldMaxBuffers;
Condition mOutputBufferReturnedSignal;
Condition mInputBufferReturnedSignal;
static const nsecs_t kWaitForBufferDuration = 3000000000LL; // 3000 ms
@@ -468,7 +468,7 @@
size_t mPreparedBufferIdx;
// Number of buffers allocated on last prepare call.
- int mLastMaxCount;
+ size_t mLastMaxCount;
}; // class Camera3Stream
diff --git a/services/camera/libcameraservice/gui/RingBufferConsumer.cpp b/services/camera/libcameraservice/gui/RingBufferConsumer.cpp
index 65816e0..3d54460 100644
--- a/services/camera/libcameraservice/gui/RingBufferConsumer.cpp
+++ b/services/camera/libcameraservice/gui/RingBufferConsumer.cpp
@@ -256,9 +256,7 @@
BI_LOGV("Buffer timestamp %" PRId64 ", frame %" PRIu64 " evicted",
item.mTimestamp, item.mFrameNumber);
- size_t currentSize = mBufferItemList.size();
mBufferItemList.erase(accIt);
- assert(mBufferItemList.size() == currentSize - 1);
} else {
BI_LOGW("All buffers pinned, could not find any to release");
return NO_BUFFER_AVAILABLE;
diff --git a/services/camera/libcameraservice/utils/CameraTraces.h b/services/camera/libcameraservice/utils/CameraTraces.h
index d10dbc9..13ca16d 100644
--- a/services/camera/libcameraservice/utils/CameraTraces.h
+++ b/services/camera/libcameraservice/utils/CameraTraces.h
@@ -24,7 +24,7 @@
namespace android {
namespace camera3 {
-class CameraTracesImpl;
+struct CameraTracesImpl;
// Collect a list of the process's stack traces
class CameraTraces {