Merge "Silence clang static analyzer warnings"

This commit is contained in:
Yang Ni
2016-04-01 16:26:17 +00:00
committed by Gerrit Code Review

View File

@@ -421,31 +421,43 @@ nClosureCreate(JNIEnv *_env, jobject _this, jlong con, jlong kernelID,
goto exit; goto exit;
} }
fieldIDs = (RsScriptFieldID*)alloca(sizeof(RsScriptFieldID) * numValues); if (numValues > 0) {
if (fieldIDs == nullptr) { fieldIDs = (RsScriptFieldID*)alloca(sizeof(RsScriptFieldID) * numValues);
goto exit; if (fieldIDs == nullptr) {
goto exit;
}
} else {
// numValues == 0
// alloca(0) implementation is platform-dependent.
fieldIDs = nullptr;
} }
for (size_t i = 0; i < numValues; i++) { for (size_t i = 0; i < numValues; i++) {
fieldIDs[i] = (RsScriptFieldID)jFieldIDs[i]; fieldIDs[i] = (RsScriptFieldID)jFieldIDs[i];
} }
depClosures = (RsClosure*)alloca(sizeof(RsClosure) * numDependencies); if (numDependencies > 0) {
if (depClosures == nullptr) { depClosures = (RsClosure*)alloca(sizeof(RsClosure) * numDependencies);
goto exit; if (depClosures == nullptr) {
} goto exit;
}
for (size_t i = 0; i < numDependencies; i++) { for (size_t i = 0; i < numDependencies; i++) {
depClosures[i] = (RsClosure)jDepClosures[i]; depClosures[i] = (RsClosure)jDepClosures[i];
} }
depFieldIDs = (RsScriptFieldID*)alloca(sizeof(RsScriptFieldID) * numDependencies); depFieldIDs = (RsScriptFieldID*)alloca(sizeof(RsScriptFieldID) * numDependencies);
if (depFieldIDs == nullptr) { if (depFieldIDs == nullptr) {
goto exit; goto exit;
} }
for (size_t i = 0; i < numDependencies; i++) { for (size_t i = 0; i < numDependencies; i++) {
depFieldIDs[i] = (RsClosure)jDepFieldIDs[i]; depFieldIDs[i] = (RsClosure)jDepFieldIDs[i];
}
} else {
// alloca(0) implementation is platform-dependent.
depClosures = nullptr;
depFieldIDs = nullptr;
} }
ret = (jlong)(uintptr_t)rsClosureCreate( ret = (jlong)(uintptr_t)rsClosureCreate(
@@ -853,7 +865,7 @@ nContextCreateGL(JNIEnv *_env, jobject _this, jlong dev, jint ver, jint sdkVer,
jint samplesMin, jint samplesPref, jfloat samplesQ, jint samplesMin, jint samplesPref, jfloat samplesQ,
jint dpi) jint dpi)
{ {
RsSurfaceConfig sc; RsSurfaceConfig sc = {};
sc.alphaMin = alphaMin; sc.alphaMin = alphaMin;
sc.alphaPref = alphaPref; sc.alphaPref = alphaPref;
sc.colorMin = colorMin; sc.colorMin = colorMin;
@@ -1403,8 +1415,8 @@ nAllocationElementData(JNIEnv *_env, jobject _this, jlong con, jlong alloc,
jint xoff, jint yoff, jint zoff, jint xoff, jint yoff, jint zoff,
jint lod, jint compIdx, jbyteArray data, jint sizeBytes) jint lod, jint compIdx, jbyteArray data, jint sizeBytes)
{ {
jint len = _env->GetArrayLength(data);
if (kLogApi) { if (kLogApi) {
jint len = _env->GetArrayLength(data);
ALOGD("nAllocationElementData, con(%p), alloc(%p), xoff(%i), yoff(%i), zoff(%i), comp(%i), len(%i), " ALOGD("nAllocationElementData, con(%p), alloc(%p), xoff(%i), yoff(%i), zoff(%i), comp(%i), len(%i), "
"sizeBytes(%i)", (RsContext)con, (RsAllocation)alloc, xoff, yoff, zoff, compIdx, len, "sizeBytes(%i)", (RsContext)con, (RsAllocation)alloc, xoff, yoff, zoff, compIdx, len,
sizeBytes); sizeBytes);
@@ -1545,8 +1557,8 @@ nAllocationElementRead(JNIEnv *_env, jobject _this, jlong con, jlong alloc,
jint xoff, jint yoff, jint zoff, jint xoff, jint yoff, jint zoff,
jint lod, jint compIdx, jbyteArray data, jint sizeBytes) jint lod, jint compIdx, jbyteArray data, jint sizeBytes)
{ {
jint len = _env->GetArrayLength(data);
if (kLogApi) { if (kLogApi) {
jint len = _env->GetArrayLength(data);
ALOGD("nAllocationElementRead, con(%p), alloc(%p), xoff(%i), yoff(%i), zoff(%i), comp(%i), len(%i), " ALOGD("nAllocationElementRead, con(%p), alloc(%p), xoff(%i), yoff(%i), zoff(%i), comp(%i), len(%i), "
"sizeBytes(%i)", (RsContext)con, (RsAllocation)alloc, xoff, yoff, zoff, compIdx, len, "sizeBytes(%i)", (RsContext)con, (RsAllocation)alloc, xoff, yoff, zoff, compIdx, len,
sizeBytes); sizeBytes);