OSDN Git Service

Fix warnings and set Werror flag to not let them happen again.
authorTomasz Wasilczyk <twasilczyk@google.com>
Fri, 7 Apr 2017 22:53:44 +0000 (15:53 -0700)
committerTomasz Wasilczyk <twasilczyk@google.com>
Fri, 7 Apr 2017 22:53:44 +0000 (15:53 -0700)
Test: it builds.
Bug: b/37159108
Change-Id: I898f5de0f8e992404977d4958b8dd44af4aea9fe

13 files changed:
jni/Android.mk
jni/filters/filters.h
jni/filters/fx.c
jni/filters/geometry.c
jni/filters/redEyeMath.c
jni/filters/saturated.c
jni/filters/vibrance.c
jni/jni_egl_fence.cpp
jni_jpegstream/Android.mk
jni_jpegstream/src/jerr_hook.cpp
jni_jpegstream/src/jpeg_hook.cpp
jni_jpegstream/src/jpeg_reader.cpp
jni_jpegstream/src/jpegstream.cpp

index 857fca2..6e0552a 100644 (file)
@@ -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
 
index 6856a26..e203963 100644 (file)
@@ -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)
index c3c9cbd..4d4cda1 100644 (file)
@@ -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;
index b01e5e0..8537549 100644 (file)
@@ -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);
index 9a16d60..7bc558c 100644 (file)
@@ -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);
index 1bc0cc5..f5cf767 100644 (file)
@@ -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;
index cb5c536..feef7bc 100644 (file)
@@ -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;
index cf15e2f..0f696fc 100644 (file)
@@ -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();
 
index b13d4fb..cac2a7b 100644 (file)
@@ -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
index f8f864f..c8491cc 100644 (file)
@@ -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<ErrManager*>(cinfo->err);
     char buf[JMSG_LENGTH_MAX];
     (*cinfo->err->format_message) (cinfo, buf);
     buf[JMSG_LENGTH_MAX - 1] = '\0';  // Force null terminator
index cca54e4..db04c18 100644 (file)
@@ -121,7 +121,7 @@ void Mgr_skip_input_data_fcn(j_decompress_ptr cinfo, long num_bytes) {
         return;
     }
     SourceManager *src = reinterpret_cast<SourceManager*>(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
 }
 
index 4726b64..9662152 100644 (file)
@@ -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;
index 3b9a683..afff64c 100644 (file)
@@ -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<void**>(&env), JNI_VERSION_1_6) != JNI_OK) {
         LOGE("Error: GetEnv failed in JNI_OnLoad");