summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Wasilczyk <twasilczyk@google.com>2017-04-07 15:53:44 -0700
committerMichael Bestas <mkbestas@lineageos.org>2020-05-27 00:06:14 +0300
commitc2614ab9a32a4ec0a1dc2700981b2a806d5c8469 (patch)
tree9454a373aa7b134da5cee9555aa3c2122605d6ad
parentff433d3966f6ccb5924489d0d92d49095ee95dca (diff)
downloadandroid_packages_apps_Gallery2-c2614ab9a32a4ec0a1dc2700981b2a806d5c8469.tar.gz
android_packages_apps_Gallery2-c2614ab9a32a4ec0a1dc2700981b2a806d5c8469.tar.bz2
android_packages_apps_Gallery2-c2614ab9a32a4ec0a1dc2700981b2a806d5c8469.zip
Fix warnings and set Werror flag to not let them happen again.
Test: it builds. Bug: b/37159108 Change-Id: I898f5de0f8e992404977d4958b8dd44af4aea9fe
-rw-r--r--jni/Android.mk6
-rw-r--r--jni/filters/filters.h2
-rw-r--r--jni/filters/fx.c4
-rw-r--r--jni/filters/geometry.c22
-rw-r--r--jni/filters/redEyeMath.c11
-rw-r--r--jni/filters/saturated.c1
-rw-r--r--jni/filters/vibrance.c1
-rw-r--r--jni/jni_egl_fence.cpp6
-rw-r--r--jni_jpegstream/Android.mk1
-rw-r--r--jni_jpegstream/src/jerr_hook.cpp1
-rw-r--r--jni_jpegstream/src/jpeg_hook.cpp4
-rw-r--r--jni_jpegstream/src/jpeg_reader.cpp2
-rw-r--r--jni_jpegstream/src/jpegstream.cpp2
13 files changed, 29 insertions, 34 deletions
diff --git a/jni/Android.mk b/jni/Android.mk
index 0c4018d67..6517d9b1a 100644
--- a/jni/Android.mk
+++ b/jni/Android.mk
@@ -2,7 +2,8 @@ LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
-LOCAL_CFLAGS += -DEGL_EGLEXT_PROTOTYPES -Wno-unused-parameter
+LOCAL_CFLAGS += -DEGL_EGLEXT_PROTOTYPES
+LOCAL_CFLAGS += -Wall -Wextra -Werror
LOCAL_SRC_FILES := jni_egl_fence.cpp
@@ -47,7 +48,8 @@ LOCAL_SRC_FILES := filters/gradient.c \
filters/tinyplanet.cc \
filters/kmeans.cc
-LOCAL_CFLAGS += -ffast-math -O3 -funroll-loops -Wno-unused-parameter
+LOCAL_CFLAGS += -ffast-math -O3 -funroll-loops
+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 31660549b..356d0af32 100644
--- a/jni_jpegstream/Android.mk
+++ b/jni_jpegstream/Android.mk
@@ -18,6 +18,7 @@ LOCAL_ARM_MODE := arm
LOCAL_PRODUCT_MODULE := true
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<ErrManager*>(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<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
}
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<void**>(&env), JNI_VERSION_1_6) != JNI_OK) {
LOGE("Error: GetEnv failed in JNI_OnLoad");