aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYohei Yukawa <yukawa@google.com>2018-07-25 17:11:00 -0700
committerYohei Yukawa <yukawa@google.com>2018-07-25 17:11:00 -0700
commit3d74fc73a8b4b0bd6709c07ff95eea7f59e19856 (patch)
treec373ceb47083d5f3b642884a14031bb125c057bd
parent41f89ae88ce5221dd2f64abe86304eaa869bf412 (diff)
downloadlatinime-3d74fc73a8b4b0bd6709c07ff95eea7f59e19856.tar.gz
latinime-3d74fc73a8b4b0bd6709c07ff95eea7f59e19856.tar.xz
latinime-3d74fc73a8b4b0bd6709c07ff95eea7f59e19856.zip
Fix lint warnings in LatinIME JNI code
This CL addresses compiler warnings when building libjni_latinime.so with NDK from Android Studio. There should be no behavior change. Bug: 110741422 Bug: 110757803 Test: tapas LatinIME LatinIMETests arm64 userdebug && make -j Change-Id: Icc711dd46511a167b1fd90028552def5b2f9941f
-rw-r--r--native/jni/Android.mk2
-rw-r--r--native/jni/src/defines.h4
2 files changed, 4 insertions, 2 deletions
diff --git a/native/jni/Android.mk b/native/jni/Android.mk
index 893a60dde..b9fc414f8 100644
--- a/native/jni/Android.mk
+++ b/native/jni/Android.mk
@@ -29,7 +29,7 @@ LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(LATIN_IME_SRC_DIR)
LOCAL_CFLAGS += -Werror -Wall -Wextra -Weffc++ -Wformat=2 -Wcast-qual -Wcast-align \
-Wwrite-strings -Wfloat-equal -Wpointer-arith -Winit-self -Wredundant-decls \
- -Woverloaded-virtual -Wsign-promo -Wno-system-headers
+ -Woverloaded-virtual -Wsign-promo -Wno-system-headers -Wno-format-nonliteral
# To suppress compiler warnings for unused variables/functions used for debug features etc.
LOCAL_CFLAGS += -Wno-unused-parameter -Wno-unused-function
diff --git a/native/jni/src/defines.h b/native/jni/src/defines.h
index 10b930e4f..1531b6cbe 100644
--- a/native/jni/src/defines.h
+++ b/native/jni/src/defines.h
@@ -17,6 +17,8 @@
#ifndef LATINIME_DEFINES_H
#define LATINIME_DEFINES_H
+#include <cstdint>
+
#ifdef __GNUC__
#define AK_FORCE_INLINE __attribute__((always_inline)) __inline__
#else // __GNUC__
@@ -51,7 +53,7 @@ AK_FORCE_INLINE static int intArrayToCharArray(const int *const source, const in
int si = 0;
int di = 0;
while (si < sourceSize && di < destLimit && 0 != source[si]) {
- const int codePoint = source[si++];
+ const uint32_t codePoint = static_cast<uint32_t>(source[si++]);
if (codePoint < 0x7F) { // One byte
dest[di++] = codePoint;
} else if (codePoint < 0x7FF) { // Two bytes