From a836402ee66cc1d723fa752ff5cff9930c1249c6 Mon Sep 17 00:00:00 2001 From: Tomasz Wasilczyk Date: Fri, 7 Apr 2017 15:53:44 -0700 Subject: [PATCH] Fix warnings and set Werror flag to not let them happen again. Test: it builds. Bug: b/37159108 Change-Id: I898f5de0f8e992404977d4958b8dd44af4aea9fe --- jni/Android.mk | 2 ++ jni/filters/filters.h | 2 +- jni/filters/fx.c | 4 ++-- jni/filters/geometry.c | 22 ++++++++++------------ jni/filters/redEyeMath.c | 11 +++++------ jni/filters/saturated.c | 1 - jni/filters/vibrance.c | 1 - jni/jni_egl_fence.cpp | 6 +++--- jni_jpegstream/Android.mk | 1 + jni_jpegstream/src/jerr_hook.cpp | 1 - jni_jpegstream/src/jpeg_hook.cpp | 4 ++-- jni_jpegstream/src/jpeg_reader.cpp | 2 -- jni_jpegstream/src/jpegstream.cpp | 2 +- 13 files changed, 27 insertions(+), 32 deletions(-) diff --git a/jni/Android.mk b/jni/Android.mk index 857fca243..6e0552a67 100644 --- a/jni/Android.mk +++ b/jni/Android.mk @@ -3,6 +3,7 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_CFLAGS += -DEGL_EGLEXT_PROTOTYPES -Wno-unused-parameter +LOCAL_CFLAGS += -Wall -Wextra -Werror LOCAL_SRC_FILES := jni_egl_fence.cpp @@ -45,6 +46,7 @@ LOCAL_SRC_FILES := filters/gradient.c \ filters/kmeans.cc LOCAL_CFLAGS += -ffast-math -O3 -funroll-loops -Wno-unused-parameter +LOCAL_CFLAGS += -Wall -Wextra -Werror LOCAL_LDLIBS := -llog -ljnigraphics LOCAL_ARM_MODE := arm diff --git a/jni/filters/filters.h b/jni/filters/filters.h index 6856a2616..e20396384 100644 --- a/jni/filters/filters.h +++ b/jni/filters/filters.h @@ -35,7 +35,7 @@ typedef unsigned int Color; #define LOG(msg...) __android_log_print(ANDROID_LOG_VERBOSE, "NativeFilters", msg) -#define JNIFUNCF(cls, name, vars...) Java_com_android_gallery3d_filtershow_filters_ ## cls ## _ ## name(JNIEnv* env, jobject obj, vars) +#define JNIFUNCF(cls, name, vars...) Java_com_android_gallery3d_filtershow_filters_ ## cls ## _ ## name(JNIEnv* env, jobject obj_unused __unused, vars) #define RED i #define GREEN (i+1) diff --git a/jni/filters/fx.c b/jni/filters/fx.c index c3c9cbdc6..4d4cda123 100644 --- a/jni/filters/fx.c +++ b/jni/filters/fx.c @@ -29,8 +29,8 @@ __inline__ int interp(unsigned char *src, int p , int *off ,float dr,float dg, return (int)frbg ; } -void JNIFUNCF(ImageFilterFx, nativeApplyFilter, jobject bitmap, jint width, jint height, - jobject lutbitmap, jint lutwidth, jint lutheight, +void JNIFUNCF(ImageFilterFx, nativeApplyFilter, jobject bitmap, jint width __unused, + jint height __unused, jobject lutbitmap, jint lutwidth, jint lutheight, jint start, jint end) { char* destination = 0; diff --git a/jni/filters/geometry.c b/jni/filters/geometry.c index b01e5e05f..8537549d0 100644 --- a/jni/filters/geometry.c +++ b/jni/filters/geometry.c @@ -19,7 +19,8 @@ #include "filters.h" -static __inline__ void flipVertical(char * source, int srcWidth, int srcHeight, char * destination, int dstWidth, int dstHeight){ +static __inline__ void flipVertical(char * source, int srcWidth, int srcHeight, char * destination, + int dstWidth __unused, int dstHeight __unused) { //Vertical size_t cpy_bytes = sizeof(char) * 4; int width = cpy_bytes * srcWidth; @@ -33,7 +34,8 @@ static __inline__ void flipVertical(char * source, int srcWidth, int srcHeight, } } -static __inline__ void flipHorizontal(char * source, int srcWidth, int srcHeight, char * destination, int dstWidth, int dstHeight){ +static __inline__ void flipHorizontal(char * source, int srcWidth, int srcHeight, + char * destination, int dstWidth __unused, int dstHeight __unused) { //Horizontal size_t cpy_bytes = sizeof(char) * 4; int width = cpy_bytes * srcWidth; @@ -72,11 +74,11 @@ static __inline__ void flip_fun(int flip, char * source, int srcWidth, int srcHe } //90 CCW (opposite of what's used in UI?) -static __inline__ void rotate90(char * source, int srcWidth, int srcHeight, char * destination, int dstWidth, int dstHeight){ +static __inline__ void rotate90(char * source, int srcWidth, int srcHeight, char * destination, + int dstWidth __unused, int dstHeight __unused) { size_t cpy_bytes = sizeof(char) * 4; int width = cpy_bytes * srcWidth; int length = srcHeight; - int total = length * width; for (size_t j = 0; j < length * cpy_bytes; j+= cpy_bytes){ for (int i = 0; i < width; i+=cpy_bytes){ int column_disp = (width - cpy_bytes - i) * length; @@ -120,7 +122,6 @@ static __inline__ void crop(char * source, int srcWidth, int srcHeight, char * d if ((srcWidth > dstWidth + offsetWidth) || (srcHeight > dstHeight + offsetHeight)){ return; } - int i = 0; int j = 0; for (j = offsetHeight; j < offsetHeight + dstHeight; j++){ memcpy(destination + (j - offsetHeight) * new_row_width, source + j * row_width + offsetWidth * cpy_bytes, cpy_bytes * dstWidth ); @@ -143,7 +144,6 @@ void JNIFUNCF(ImageFilterGeometry, nativeApplyFilterFlip, jobject src, jint srcW void JNIFUNCF(ImageFilterGeometry, nativeApplyFilterRotate, jobject src, jint srcWidth, jint srcHeight, jobject dst, jint dstWidth, jint dstHeight, jint rotate) { char* destination = 0; char* source = 0; - int len = dstWidth * dstHeight * 4; AndroidBitmap_lockPixels(env, src, (void**) &source); AndroidBitmap_lockPixels(env, dst, (void**) &destination); rotate_fun(rotate, source, srcWidth, srcHeight, destination, dstWidth, dstHeight); @@ -154,7 +154,6 @@ void JNIFUNCF(ImageFilterGeometry, nativeApplyFilterRotate, jobject src, jint sr void JNIFUNCF(ImageFilterGeometry, nativeApplyFilterCrop, jobject src, jint srcWidth, jint srcHeight, jobject dst, jint dstWidth, jint dstHeight, jint offsetWidth, jint offsetHeight) { char* destination = 0; char* source = 0; - int len = dstWidth * dstHeight * 4; AndroidBitmap_lockPixels(env, src, (void**) &source); AndroidBitmap_lockPixels(env, dst, (void**) &destination); crop(source, srcWidth, srcHeight, destination, dstWidth, dstHeight, offsetWidth, offsetHeight); @@ -162,7 +161,9 @@ void JNIFUNCF(ImageFilterGeometry, nativeApplyFilterCrop, jobject src, jint srcW AndroidBitmap_unlockPixels(env, src); } -void JNIFUNCF(ImageFilterGeometry, nativeApplyFilterStraighten, jobject src, jint srcWidth, jint srcHeight, jobject dst, jint dstWidth, jint dstHeight, jfloat straightenAngle) { +void JNIFUNCF(ImageFilterGeometry, nativeApplyFilterStraighten, jobject src, jint srcWidth __unused, + jint srcHeight __unused, jobject dst, jint dstWidth, jint dstHeight, + jfloat straightenAngle __unused) { char* destination = 0; char* source = 0; int len = dstWidth * dstHeight * 4; @@ -171,11 +172,8 @@ void JNIFUNCF(ImageFilterGeometry, nativeApplyFilterStraighten, jobject src, jin // TODO: implement straighten int i = 0; for (; i < len; i += 4) { - int r = source[RED]; - int g = source[GREEN]; - int b = source[BLUE]; destination[RED] = 128; - destination[GREEN] = g; + destination[GREEN] = source[GREEN]; destination[BLUE] = 128; } AndroidBitmap_unlockPixels(env, dst); diff --git a/jni/filters/redEyeMath.c b/jni/filters/redEyeMath.c index 9a16d6004..7bc558c78 100644 --- a/jni/filters/redEyeMath.c +++ b/jni/filters/redEyeMath.c @@ -32,8 +32,8 @@ int isRed(unsigned char *src, int p) { return ((r * 100 / (max + 2) > 160) & (max < 80)); } -void findPossible(unsigned char *src, unsigned char *mask, int iw, int ih, - short *rect) { +void findPossible(unsigned char *src, unsigned char *mask, int iw, + int ih __unused, short *rect) { int recX = rect[0], recY = rect[1], recW = rect[2], recH = rect[3]; int y, x; @@ -53,7 +53,7 @@ void findPossible(unsigned char *src, unsigned char *mask, int iw, int ih, } } -void findReds(unsigned char *src, unsigned char *mask, int iw, int ih, +void findReds(unsigned char *src, unsigned char *mask, int iw, int ih __unused, short *rect) { int recX = rect[0], recY = rect[1], recW = rect[2], recH = rect[3]; int y, x; @@ -70,8 +70,8 @@ void findReds(unsigned char *src, unsigned char *mask, int iw, int ih, } } -void dialateMaskIfRed(unsigned char *src, int iw, int ih, unsigned char *mask, - unsigned char *out, short *rect) { +void dialateMaskIfRed(unsigned char *src, int iw, int ih __unused, + unsigned char *mask, unsigned char *out, short *rect) { int recX = rect[0], recY = rect[1], recW = rect[2], recH = rect[3]; int y, x; @@ -113,7 +113,6 @@ void filterRedEye(unsigned char *src, unsigned char *dest, int iw, int ih, short int recX = rect[0], recY = rect[1], recW = rect[2], recH = rect[3]; unsigned char *mask1 = (unsigned char *) malloc(recW * recH); unsigned char *mask2 = (unsigned char *)malloc(recW*recH); - int QUE_LEN = 100; int y, x, i; rect[0] = MAX(rect[0],0); diff --git a/jni/filters/saturated.c b/jni/filters/saturated.c index 1bc0cc56b..f5cf7677a 100644 --- a/jni/filters/saturated.c +++ b/jni/filters/saturated.c @@ -36,7 +36,6 @@ void JNIFUNCF(ImageFilterSaturated, nativeApplyFilter, jobject bitmap, jint widt int r = destination[RED]; int g = destination[GREEN]; int b = destination[BLUE]; - int t = (r + g) / 2; R = r; G = g; B = b; diff --git a/jni/filters/vibrance.c b/jni/filters/vibrance.c index cb5c536e5..feef7bc97 100644 --- a/jni/filters/vibrance.c +++ b/jni/filters/vibrance.c @@ -45,7 +45,6 @@ void JNIFUNCF(ImageFilterVibrance, nativeApplyFilter, jobject bitmap, jint width Rt = Rf * MS; Gt = Gf * MS; Bt = Bf * MS; - int t = (r + g) / 2; R = r; G = g; B = b; diff --git a/jni/jni_egl_fence.cpp b/jni/jni_egl_fence.cpp index cf15e2f5d..0f696fc1e 100644 --- a/jni/jni_egl_fence.cpp +++ b/jni/jni_egl_fence.cpp @@ -38,7 +38,7 @@ static bool egl_khr_fence_sync_supported = false; bool IsEglKHRFenceSyncSupported() { if (!initialized) { EGLDisplay display = eglGetCurrentDisplay(); - const char* eglExtensions = eglQueryString(eglGetCurrentDisplay(), EGL_EXTENSIONS); + const char* eglExtensions = eglQueryString(display, EGL_EXTENSIONS); if (eglExtensions && strstr(eglExtensions, "EGL_KHR_fence_sync")) { FuncEglCreateSyncKHR = (TypeEglCreateSyncKHR) eglGetProcAddress("eglCreateSyncKHR"); FuncEglClientWaitSyncKHR = (TypeEglClientWaitSyncKHR) eglGetProcAddress("eglClientWaitSyncKHR"); @@ -54,8 +54,8 @@ bool IsEglKHRFenceSyncSupported() { } void -Java_com_android_gallery3d_photoeditor_FilterStack_nativeEglSetFenceAndWait(JNIEnv* env, - jobject thiz) { +Java_com_android_gallery3d_photoeditor_FilterStack_nativeEglSetFenceAndWait( + JNIEnv* env __unused, jobject thiz __unused) { if (!IsEglKHRFenceSyncSupported()) return; EGLDisplay display = eglGetCurrentDisplay(); diff --git a/jni_jpegstream/Android.mk b/jni_jpegstream/Android.mk index b13d4fb35..cac2a7b72 100644 --- a/jni_jpegstream/Android.mk +++ b/jni_jpegstream/Android.mk @@ -17,6 +17,7 @@ LOCAL_SDK_VERSION := 17 LOCAL_ARM_MODE := arm LOCAL_CFLAGS += -ffast-math -O3 -funroll-loops +LOCAL_CFLAGS += -Wall -Wextra -Werror LOCAL_LDLIBS := -llog LOCAL_CPP_EXTENSION := .cpp diff --git a/jni_jpegstream/src/jerr_hook.cpp b/jni_jpegstream/src/jerr_hook.cpp index f8f864f78..c8491ccbd 100644 --- a/jni_jpegstream/src/jerr_hook.cpp +++ b/jni_jpegstream/src/jerr_hook.cpp @@ -34,7 +34,6 @@ void ErrExit(j_common_ptr cinfo) { * to logcat's error log. */ void ErrOutput(j_common_ptr cinfo) { - ErrManager* mgr = reinterpret_cast(cinfo->err); char buf[JMSG_LENGTH_MAX]; (*cinfo->err->format_message) (cinfo, buf); buf[JMSG_LENGTH_MAX - 1] = '\0'; // Force null terminator diff --git a/jni_jpegstream/src/jpeg_hook.cpp b/jni_jpegstream/src/jpeg_hook.cpp index cca54e405..db04c18e1 100644 --- a/jni_jpegstream/src/jpeg_hook.cpp +++ b/jni_jpegstream/src/jpeg_hook.cpp @@ -121,7 +121,7 @@ void Mgr_skip_input_data_fcn(j_decompress_ptr cinfo, long num_bytes) { return; } SourceManager *src = reinterpret_cast(cinfo->src); - if (src->mgr.bytes_in_buffer >= num_bytes) { + if (src->mgr.bytes_in_buffer >= (size_t)num_bytes) { src->mgr.bytes_in_buffer -= num_bytes; src->mgr.next_input_byte += num_bytes; } else { @@ -149,7 +149,7 @@ void Mgr_skip_input_data_fcn(j_decompress_ptr cinfo, long num_bytes) { } } -void Mgr_term_source_fcn(j_decompress_ptr cinfo) { +void Mgr_term_source_fcn(j_decompress_ptr cinfo __unused) { //noop } diff --git a/jni_jpegstream/src/jpeg_reader.cpp b/jni_jpegstream/src/jpeg_reader.cpp index 4726b6426..9662152da 100644 --- a/jni_jpegstream/src/jpeg_reader.cpp +++ b/jni_jpegstream/src/jpeg_reader.cpp @@ -215,7 +215,6 @@ void JpegReader::formatPixels(uint8_t* buf, int32_t len) { // Do endianness and alpha for output format if (mFormat == Jpeg_Config::FORMAT_RGBA) { // Set alphas to 255 - uint8_t* end = buf + len - 1; for (int i = len - 1; i >= 0; i -= 4) { buf[i] = 255; buf[i - 1] = *--iter; @@ -224,7 +223,6 @@ void JpegReader::formatPixels(uint8_t* buf, int32_t len) { } } else if (mFormat == Jpeg_Config::FORMAT_ABGR) { // Reverse endianness and set alphas to 255 - uint8_t* end = buf + len - 1; int r, g, b; for (int i = len - 1; i >= 0; i -= 4) { b = *--iter; diff --git a/jni_jpegstream/src/jpegstream.cpp b/jni_jpegstream/src/jpegstream.cpp index 3b9a6830b..afff64ce1 100644 --- a/jni_jpegstream/src/jpegstream.cpp +++ b/jni_jpegstream/src/jpegstream.cpp @@ -323,7 +323,7 @@ static int registerNativeMethods(JNIEnv* env, const char* className, return JNI_TRUE; } -jint JNI_OnLoad(JavaVM* vm, void* reserved) { +jint JNI_OnLoad(JavaVM* vm, void* reserved __unused) { JNIEnv* env; if (vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_6) != JNI_OK) { LOGE("Error: GetEnv failed in JNI_OnLoad"); -- 2.11.0