From 46d8444631b4b1253a76bfcc78a29d26014d022f Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Tue, 18 Nov 2014 16:07:51 -0800 Subject: Fix clang warnings in core/jni. There are a few bugs in here too (mostly people expecting + to concatenate C strings) :( Change-Id: I0a243c05c4ea8b56e84896f37814d0fbea4c39d5 --- core/jni/android/graphics/Bitmap.cpp | 5 ++++- core/jni/android/graphics/BitmapFactory.cpp | 10 ++-------- core/jni/android/graphics/GraphicsJNI.h | 3 +-- core/jni/android/graphics/NinePatchImpl.cpp | 2 +- core/jni/android/graphics/pdf/PdfEditor.cpp | 8 ++++---- core/jni/android/graphics/pdf/PdfRenderer.cpp | 4 ++-- core/jni/android/opengl/util.cpp | 12 ++++++------ 7 files changed, 20 insertions(+), 24 deletions(-) (limited to 'core/jni/android') diff --git a/core/jni/android/graphics/Bitmap.cpp b/core/jni/android/graphics/Bitmap.cpp index 70cf9a8..9c455df 100755 --- a/core/jni/android/graphics/Bitmap.cpp +++ b/core/jni/android/graphics/Bitmap.cpp @@ -43,8 +43,11 @@ static void FromColor_D32(void* dst, const SkColor src[], int width, static void FromColor_D32_Raw(void* dst, const SkColor src[], int width, int, int) { + // Needed to thwart the unreachable code detection from clang. + static const bool sk_color_ne_zero = SK_COLOR_MATCHES_PMCOLOR_BYTE_ORDER; + // SkColor's ordering may be different from SkPMColor - if (SK_COLOR_MATCHES_PMCOLOR_BYTE_ORDER) { + if (sk_color_ne_zero) { memcpy(dst, src, width * sizeof(SkColor)); return; } diff --git a/core/jni/android/graphics/BitmapFactory.cpp b/core/jni/android/graphics/BitmapFactory.cpp index e0abc24..1255c4f 100644 --- a/core/jni/android/graphics/BitmapFactory.cpp +++ b/core/jni/android/graphics/BitmapFactory.cpp @@ -49,12 +49,6 @@ jmethodID gInsetStruct_constructorMethodID; using namespace android; -static inline int32_t validOrNeg1(bool isValid, int32_t value) { -// return isValid ? value : -1; - SkASSERT((int)isValid == 0 || (int)isValid == 1); - return ((int32_t)isValid - 1) | value; -} - jstring getMimeTypeString(JNIEnv* env, SkImageDecoder::Format format) { static const struct { SkImageDecoder::Format fFormat; @@ -185,8 +179,8 @@ public: const size_t size = sk_64_asS32(size64); if (size > mSize) { - ALOGW("bitmap marked for reuse (%d bytes) can't fit new bitmap (%d bytes)", - mSize, size); + ALOGW("bitmap marked for reuse (%u bytes) can't fit new bitmap " + "(%zu bytes)", mSize, size); return false; } diff --git a/core/jni/android/graphics/GraphicsJNI.h b/core/jni/android/graphics/GraphicsJNI.h index e2b31cb..8ef56cf 100644 --- a/core/jni/android/graphics/GraphicsJNI.h +++ b/core/jni/android/graphics/GraphicsJNI.h @@ -19,7 +19,7 @@ class SkCanvas; namespace android { class Paint; -class TypefaceImpl; +struct TypefaceImpl; } class GraphicsJNI { @@ -205,7 +205,6 @@ public: private: JavaVM* fVM; - bool fAllocateInJavaHeap; jbyteArray fStorageObj; int fAllocCount; }; diff --git a/core/jni/android/graphics/NinePatchImpl.cpp b/core/jni/android/graphics/NinePatchImpl.cpp index c162c48..39a9554 100644 --- a/core/jni/android/graphics/NinePatchImpl.cpp +++ b/core/jni/android/graphics/NinePatchImpl.cpp @@ -120,7 +120,7 @@ void NinePatch_Draw(SkCanvas* canvas, const SkRect& bounds, const int32_t* yDivs = chunk.getYDivs(); // if our SkCanvas were back by GL we should enable this and draw this as // a mesh, which will be faster in most cases. - if (false) { + if ((false)) { SkNinePatch::DrawMesh(canvas, bounds, bitmap, xDivs, chunk.numXDivs, yDivs, chunk.numYDivs, diff --git a/core/jni/android/graphics/pdf/PdfEditor.cpp b/core/jni/android/graphics/pdf/PdfEditor.cpp index 66d1722..6ac9f77 100644 --- a/core/jni/android/graphics/pdf/PdfEditor.cpp +++ b/core/jni/android/graphics/pdf/PdfEditor.cpp @@ -72,8 +72,8 @@ static jlong nativeOpen(JNIEnv* env, jclass thiz, jint fd, jlong size) { if (!document) { const long error = FPDF_GetLastError(); - jniThrowException(env, "java/io/IOException", - "cannot create document. Error:" + error); + jniThrowExceptionFmt(env, "java/io/IOException", + "cannot create document. Error: %ld", error); destroyLibraryIfNeeded(); return -1; } @@ -138,8 +138,8 @@ static void nativeWrite(JNIEnv* env, jclass thiz, jlong documentPtr, jint fd) { writer.WriteBlock = &writeBlock; const bool success = FPDF_SaveAsCopy(document, &writer, FPDF_NO_INCREMENTAL); if (!success) { - jniThrowException(env, "java/io/IOException", - "cannot write to fd. Error:" + errno); + jniThrowExceptionFmt(env, "java/io/IOException", + "cannot write to fd. Error: %d", errno); destroyLibraryIfNeeded(); } } diff --git a/core/jni/android/graphics/pdf/PdfRenderer.cpp b/core/jni/android/graphics/pdf/PdfRenderer.cpp index b68aa38..e1e36dd 100644 --- a/core/jni/android/graphics/pdf/PdfRenderer.cpp +++ b/core/jni/android/graphics/pdf/PdfRenderer.cpp @@ -86,8 +86,8 @@ static jlong nativeCreate(JNIEnv* env, jclass thiz, jint fd, jlong size) { if (!document) { const long error = FPDF_GetLastError(); - jniThrowException(env, "java/io/IOException", - "cannot create document. Error:" + error); + jniThrowExceptionFmt(env, "java/io/IOException", + "cannot create document. Error: %ld", error); destroyLibraryIfNeeded(); return -1; } diff --git a/core/jni/android/opengl/util.cpp b/core/jni/android/opengl/util.cpp index e0ca951..f60a154 100644 --- a/core/jni/android/opengl/util.cpp +++ b/core/jni/android/opengl/util.cpp @@ -471,13 +471,13 @@ static void multiplyMM(float* r, const float* lhs, const float* rhs) { for (int i=0 ; i<4 ; i++) { - register const float rhs_i0 = rhs[ I(i,0) ]; - register float ri0 = lhs[ I(0,0) ] * rhs_i0; - register float ri1 = lhs[ I(0,1) ] * rhs_i0; - register float ri2 = lhs[ I(0,2) ] * rhs_i0; - register float ri3 = lhs[ I(0,3) ] * rhs_i0; + const float rhs_i0 = rhs[ I(i,0) ]; + float ri0 = lhs[ I(0,0) ] * rhs_i0; + float ri1 = lhs[ I(0,1) ] * rhs_i0; + float ri2 = lhs[ I(0,2) ] * rhs_i0; + float ri3 = lhs[ I(0,3) ] * rhs_i0; for (int j=1 ; j<4 ; j++) { - register const float rhs_ij = rhs[ I(i,j) ]; + const float rhs_ij = rhs[ I(i,j) ]; ri0 += lhs[ I(j,0) ] * rhs_ij; ri1 += lhs[ I(j,1) ] * rhs_ij; ri2 += lhs[ I(j,2) ] * rhs_ij; -- cgit v1.1