diff options
92 files changed, 867 insertions, 675 deletions
diff --git a/cmds/app_process/Android.mk b/cmds/app_process/Android.mk index 397a7d1649e9..dd5e0ea51bb1 100644 --- a/cmds/app_process/Android.mk +++ b/cmds/app_process/Android.mk @@ -3,17 +3,17 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_SRC_FILES:= \ - app_main.cpp + app_main.cpp LOCAL_LDFLAGS := -Wl,--version-script,art/sigchainlib/version-script.txt -Wl,--export-dynamic LOCAL_SHARED_LIBRARIES := \ - libdl \ - libcutils \ - libutils \ - liblog \ - libbinder \ - libandroid_runtime + libdl \ + libcutils \ + libutils \ + liblog \ + libbinder \ + libandroid_runtime LOCAL_WHOLE_STATIC_LIBRARIES := libsigchain @@ -21,6 +21,9 @@ LOCAL_MODULE:= app_process LOCAL_MULTILIB := both LOCAL_MODULE_STEM_32 := app_process32 LOCAL_MODULE_STEM_64 := app_process64 + +LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code + include $(BUILD_EXECUTABLE) # Create a symlink from app_process to app_process32 or 64 @@ -34,14 +37,14 @@ ifeq ($(TARGET_ARCH),arm) include $(CLEAR_VARS) LOCAL_SRC_FILES:= \ - app_main.cpp + app_main.cpp LOCAL_SHARED_LIBRARIES := \ - libcutils \ - libutils \ - liblog \ - libbinder \ - libandroid_runtime + libcutils \ + libutils \ + liblog \ + libbinder \ + libandroid_runtime LOCAL_WHOLE_STATIC_LIBRARIES := libsigchain @@ -54,6 +57,8 @@ LOCAL_MODULE_PATH := $(TARGET_OUT_EXECUTABLES)/asan LOCAL_MODULE_STEM := app_process LOCAL_ADDRESS_SANITIZER := true +LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code + include $(BUILD_EXECUTABLE) endif # ifeq($(TARGET_ARCH),arm) diff --git a/cmds/app_process/app_main.cpp b/cmds/app_process/app_main.cpp index 1bb28c38ceef..fbdbb255f174 100644 --- a/cmds/app_process/app_main.cpp +++ b/cmds/app_process/app_main.cpp @@ -24,7 +24,7 @@ namespace android { -void app_usage() +static void app_usage() { fprintf(stderr, "Usage: app_process [java-options] cmd-dir start-class-name [options]\n"); diff --git a/cmds/backup/Android.mk b/cmds/backup/Android.mk index 42e513345d9c..8e1508c9efe8 100644 --- a/cmds/backup/Android.mk +++ b/cmds/backup/Android.mk @@ -12,4 +12,6 @@ LOCAL_MODULE:= btool LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) LOCAL_MODULE_TAGS := optional +LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code + include $(BUILD_EXECUTABLE) diff --git a/cmds/backup/backup.cpp b/cmds/backup/backup.cpp index ea1888beea2a..8d9b528ae6a9 100644 --- a/cmds/backup/backup.cpp +++ b/cmds/backup/backup.cpp @@ -25,8 +25,7 @@ using namespace android; #include <unistd.h> -int -usage(int argc, const char** argv) +static int usage(int /* argc */, const char** argv) { const char* p = argv[0]; @@ -44,15 +43,13 @@ usage(int argc, const char** argv) return 1; } -int -perform_full_backup() +static int perform_full_backup() { printf("this would have written all of your data to stdout\n"); return 0; } -int -perform_list(const char* filename) +static int perform_list(const char* filename) { int err; int fd; @@ -78,7 +75,7 @@ perform_list(const char* filename) size_t dataSize; err = reader.ReadEntityHeader(&key, &dataSize); if (err == 0) { - printf(" entity: %s (%d bytes)\n", key.string(), dataSize); + printf(" entity: %s (%zu bytes)\n", key.string(), dataSize); } else { printf(" Error reading entity header\n"); } @@ -95,14 +92,13 @@ perform_list(const char* filename) return 0; } -int perform_print(const char* entityname, const char* filename) +static int perform_print(const char* entityname, const char* filename) { printf("perform_print(%s, %s);", entityname, filename); return 0; } -int -main(int argc, const char** argv) +int main(int argc, const char** argv) { if (argc <= 1) { return perform_full_backup(); diff --git a/cmds/bootanimation/Android.mk b/cmds/bootanimation/Android.mk index d6ecbe31f5e8..2ee586f2c3ca 100644 --- a/cmds/bootanimation/Android.mk +++ b/cmds/bootanimation/Android.mk @@ -2,22 +2,24 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_SRC_FILES:= \ - bootanimation_main.cpp \ - AudioPlayer.cpp \ - BootAnimation.cpp + bootanimation_main.cpp \ + AudioPlayer.cpp \ + BootAnimation.cpp LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES +LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code + LOCAL_C_INCLUDES += external/tinyalsa/include LOCAL_SHARED_LIBRARIES := \ - libcutils \ - liblog \ - libandroidfw \ - libutils \ - libbinder \ + libcutils \ + liblog \ + libandroidfw \ + libutils \ + libbinder \ libui \ - libskia \ + libskia \ libEGL \ libGLESv1_CM \ libgui \ diff --git a/cmds/bootanimation/AudioPlayer.cpp b/cmds/bootanimation/AudioPlayer.cpp index 471b77f227de..459190f9198f 100644 --- a/cmds/bootanimation/AudioPlayer.cpp +++ b/cmds/bootanimation/AudioPlayer.cpp @@ -207,7 +207,6 @@ bool AudioPlayer::threadLoop() struct pcm *pcm = NULL; bool moreChunks = true; const struct chunk_fmt* chunkFmt = NULL; - void* buffer = NULL; int bufferSize; const uint8_t* wavData; size_t wavLength; diff --git a/cmds/bootanimation/BootAnimation.cpp b/cmds/bootanimation/BootAnimation.cpp index 167014e7c7a2..1d4de22e4049 100644 --- a/cmds/bootanimation/BootAnimation.cpp +++ b/cmds/bootanimation/BootAnimation.cpp @@ -42,9 +42,13 @@ #include <gui/Surface.h> #include <gui/SurfaceComposerClient.h> +// TODO: Fix Skia. +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" #include <SkBitmap.h> #include <SkStream.h> #include <SkImageDecoder.h> +#pragma GCC diagnostic pop #include <GLES/gl.h> #include <GLES/glext.h> @@ -105,7 +109,7 @@ void BootAnimation::binderDied(const wp<IBinder>&) status_t BootAnimation::initTexture(Texture* texture, AssetManager& assets, const char* name) { Asset* asset = assets.open(name, Asset::ACCESS_BUFFER); - if (!asset) + if (asset == NULL) return NO_INIT; SkBitmap bitmap; SkImageDecoder::DecodeMemory(asset->getBuffer(false), asset->getLength(), @@ -164,7 +168,7 @@ status_t BootAnimation::initTexture(const Animation::Frame& frame) SkBitmap bitmap; SkMemoryStream stream(frame.map->getDataPtr(), frame.map->getDataLength()); SkImageDecoder* codec = SkImageDecoder::Factory(&stream); - if (codec) { + if (codec != NULL) { codec->setDitherImage(false); codec->decode(&stream, &bitmap, kN32_SkColorType, @@ -252,7 +256,7 @@ status_t BootAnimation::readyToRun() { EGL_DEPTH_SIZE, 0, EGL_NONE }; - EGLint w, h, dummy; + EGLint w, h; EGLint numConfigs; EGLConfig config; EGLSurface surface; @@ -470,7 +474,7 @@ bool BootAnimation::movie() // Parse the description file for (;;) { const char* endl = strstr(s, "\n"); - if (!endl) break; + if (endl == NULL) break; String8 line(s, endl - s); const char* l = line.string(); int fps, width, height, count, pause; @@ -572,7 +576,6 @@ bool BootAnimation::movie() const int xc = (mWidth - animation.width) / 2; const int yc = ((mHeight - animation.height) / 2); - nsecs_t lastFrame = systemTime(); nsecs_t frameDuration = s2ns(1) / animation.fps; Region clearReg(Rect(mWidth, mHeight)); @@ -620,9 +623,9 @@ bool BootAnimation::movie() Region::const_iterator tail(clearReg.end()); glEnable(GL_SCISSOR_TEST); while (head != tail) { - const Rect& r(*head++); - glScissor(r.left, mHeight - r.bottom, - r.width(), r.height()); + const Rect& r2(*head++); + glScissor(r2.left, mHeight - r2.bottom, + r2.width(), r2.height()); glClear(GL_COLOR_BUFFER_BIT); } glDisable(GL_SCISSOR_TEST); diff --git a/cmds/bootanimation/bootanimation_main.cpp b/cmds/bootanimation/bootanimation_main.cpp index 417e138b7041..6550d22f2763 100644 --- a/cmds/bootanimation/bootanimation_main.cpp +++ b/cmds/bootanimation/bootanimation_main.cpp @@ -36,7 +36,7 @@ using namespace android; // --------------------------------------------------------------------------- -int main(int argc, char** argv) +int main() { #if defined(HAVE_PTHREADS) setpriority(PRIO_PROCESS, 0, ANDROID_PRIORITY_DISPLAY); diff --git a/cmds/idmap/Android.mk b/cmds/idmap/Android.mk index ffa83f2ba428..50ccb07a3826 100644 --- a/cmds/idmap/Android.mk +++ b/cmds/idmap/Android.mk @@ -25,4 +25,6 @@ LOCAL_C_INCLUDES := external/zlib LOCAL_MODULE_TAGS := optional +LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code + include $(BUILD_EXECUTABLE) diff --git a/cmds/idmap/create.cpp b/cmds/idmap/create.cpp index 593a1973669a..7a501a4ee497 100644 --- a/cmds/idmap/create.cpp +++ b/cmds/idmap/create.cpp @@ -22,7 +22,7 @@ namespace { if (entry == NULL) { return -1; } - if (!zip->getEntryInfo(entry, NULL, NULL, NULL, NULL, NULL, (long*)crc)) { + if (!zip->getEntryInfo(entry, NULL, NULL, NULL, NULL, NULL, reinterpret_cast<long*>(crc))) { return -1; } zip->releaseEntry(entry); @@ -66,7 +66,7 @@ fail: fprintf(stderr, "error: write: %s\n", strerror(errno)); return -1; } - bytesLeft -= w; + bytesLeft -= static_cast<size_t>(w); } return 0; } @@ -78,13 +78,13 @@ fail: if (fstat(idmap_fd, &st) == -1) { return true; } - if (st.st_size < N) { + if (st.st_size < static_cast<off_t>(N)) { // file is empty or corrupt return true; } char buf[N]; - ssize_t bytesLeft = N; + size_t bytesLeft = N; if (lseek(idmap_fd, SEEK_SET, 0) < 0) { return true; } @@ -93,7 +93,7 @@ fail: if (r < 0) { return true; } - bytesLeft -= r; + bytesLeft -= static_cast<size_t>(r); if (bytesLeft == 0) { break; } diff --git a/cmds/idmap/inspect.cpp b/cmds/idmap/inspect.cpp index b9ac8a59de02..f6afc8594309 100644 --- a/cmds/idmap/inspect.cpp +++ b/cmds/idmap/inspect.cpp @@ -152,13 +152,13 @@ namespace { printe("failed to get resource name id=0x%08x\n", res_id); return UNKNOWN_ERROR; } - if (package) { + if (package != NULL) { *package = String8(String16(data.package, data.packageLen)); } - if (type) { + if (type != NULL) { *type = String8(String16(data.type, data.typeLen)); } - if (name) { + if (name != NULL) { *name = String8(String16(data.name, data.nameLen)); } return NO_ERROR; diff --git a/cmds/idmap/scan.cpp b/cmds/idmap/scan.cpp index 1153f38a9c02..4f19a74ad9ba 100644 --- a/cmds/idmap/scan.cpp +++ b/cmds/idmap/scan.cpp @@ -64,30 +64,6 @@ namespace { return String8(tmp); } - int mkdir_p(const String8& path, uid_t uid, gid_t gid) - { - static const mode_t mode = - S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IXOTH; - struct stat st; - - if (stat(path.string(), &st) == 0) { - return 0; - } - if (mkdir_p(path.getPathDir(), uid, gid) < 0) { - return -1; - } - if (mkdir(path.string(), 0755) != 0) { - return -1; - } - if (chown(path.string(), uid, gid) == -1) { - return -1; - } - if (chmod(path.string(), mode) == -1) { - return -1; - } - return 0; - } - int parse_overlay_tag(const ResXMLTree& parser, const char *target_package_name) { const size_t N = parser.getAttributeCount(); @@ -98,7 +74,7 @@ namespace { String16 key(parser.getAttributeName(i, &len)); if (key == String16("targetPackage")) { const uint16_t *p = parser.getAttributeStringValue(i, &len); - if (p) { + if (p != NULL) { target = String16(p, len); } } else if (key == String16("priority")) { @@ -164,7 +140,7 @@ namespace { return -1; } FileMap *dataMap = zip->createEntryFileMap(entry); - if (!dataMap) { + if (dataMap == NULL) { ALOGW("%s: failed to create FileMap\n", __FUNCTION__); return -1; } diff --git a/cmds/interrupter/Android.mk b/cmds/interrupter/Android.mk index e324627517ec..97a96bfc8e25 100644 --- a/cmds/interrupter/Android.mk +++ b/cmds/interrupter/Android.mk @@ -7,6 +7,7 @@ LOCAL_SRC_FILES := \ LOCAL_MODULE := interrupter LOCAL_MODULE_TAGS := eng tests LOCAL_LDFLAGS := -ldl +LOCAL_CFLAGS := -Wall -Werror -Wunused -Wunreachable-code include $(BUILD_SHARED_LIBRARY) @@ -17,5 +18,6 @@ LOCAL_SRC_FILES := \ LOCAL_MODULE := interrupter LOCAL_MODULE_TAGS := eng tests LOCAL_LDFLAGS := -ldl +LOCAL_CFLAGS := -Wall -Werror -Wunused -Wunreachable-code -include $(BUILD_HOST_SHARED_LIBRARY)
\ No newline at end of file +include $(BUILD_HOST_SHARED_LIBRARY) diff --git a/cmds/screencap/Android.mk b/cmds/screencap/Android.mk index 5c11b7546f84..b0dc42250fae 100644 --- a/cmds/screencap/Android.mk +++ b/cmds/screencap/Android.mk @@ -2,13 +2,13 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_SRC_FILES:= \ - screencap.cpp + screencap.cpp LOCAL_SHARED_LIBRARIES := \ - libcutils \ - libutils \ - libbinder \ - libskia \ + libcutils \ + libutils \ + libbinder \ + libskia \ libui \ libgui @@ -16,4 +16,6 @@ LOCAL_MODULE:= screencap LOCAL_MODULE_TAGS := optional +LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code + include $(BUILD_EXECUTABLE) diff --git a/cmds/screencap/screencap.cpp b/cmds/screencap/screencap.cpp index 1ddbecb08819..b0aee7b08d8c 100644 --- a/cmds/screencap/screencap.cpp +++ b/cmds/screencap/screencap.cpp @@ -32,10 +32,14 @@ #include <ui/PixelFormat.h> +// TODO: Fix Skia. +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" #include <SkImageEncoder.h> #include <SkBitmap.h> #include <SkData.h> #include <SkStream.h> +#pragma GCC diagnostic pop using namespace android; @@ -129,7 +133,7 @@ int main(int argc, char** argv) argv += optind; int fd = -1; - const char* fn; + const char* fn = NULL; if (argc == 0) { fd = dup(STDOUT_FILENO); } else if (argc == 1) { @@ -153,7 +157,7 @@ int main(int argc, char** argv) void const* mapbase = MAP_FAILED; ssize_t mapsize = -1; - void const* base = 0; + void const* base = NULL; uint32_t w, s, h, f; size_t size = 0; @@ -190,7 +194,7 @@ int main(int argc, char** argv) } } - if (base) { + if (base != NULL) { if (png) { const SkImageInfo info = SkImageInfo::Make(w, h, flinger2skia(f), kPremul_SkAlphaType); @@ -202,7 +206,9 @@ int main(int argc, char** argv) SkData* streamData = stream.copyToData(); write(fd, streamData->data(), streamData->size()); streamData->unref(); - notifyMediaScanner(fn); + if (fn != NULL) { + notifyMediaScanner(fn); + } } else { write(fd, &w, 4); write(fd, &h, 4); diff --git a/core/jni/android/graphics/BitmapFactory.cpp b/core/jni/android/graphics/BitmapFactory.cpp index 8ea28eca476b..e0abc24c42c5 100644 --- a/core/jni/android/graphics/BitmapFactory.cpp +++ b/core/jni/android/graphics/BitmapFactory.cpp @@ -478,7 +478,7 @@ static jobject nativeDecodeFileDescriptor(JNIEnv* env, jobject clazz, jobject fi NPE_CHECK_RETURN_ZERO(env, fileDescriptor); - jint descriptor = jniGetFDFromFileDescriptor(env, fileDescriptor); + int descriptor = jniGetFDFromFileDescriptor(env, fileDescriptor); struct stat fdStat; if (fstat(descriptor, &fdStat) == -1) { @@ -486,16 +486,27 @@ static jobject nativeDecodeFileDescriptor(JNIEnv* env, jobject clazz, jobject fi return nullObjectReturn("fstat return -1"); } - // Restore the descriptor's offset on exiting this function. + // Restore the descriptor's offset on exiting this function. Even though + // we dup the descriptor, both the original and dup refer to the same open + // file description and changes to the file offset in one impact the other. AutoFDSeek autoRestore(descriptor); - FILE* file = fdopen(descriptor, "r"); + // Duplicate the descriptor here to prevent leaking memory. A leak occurs + // if we only close the file descriptor and not the file object it is used to + // create. If we don't explicitly clean up the file (which in turn closes the + // descriptor) the buffers allocated internally by fseek will be leaked. + int dupDescriptor = dup(descriptor); + + FILE* file = fdopen(dupDescriptor, "r"); if (file == NULL) { + // cleanup the duplicated descriptor since it will not be closed when the + // file is cleaned up (fclose). + close(dupDescriptor); return nullObjectReturn("Could not open file"); } SkAutoTUnref<SkFILEStream> fileStream(new SkFILEStream(file, - SkFILEStream::kCallerRetains_Ownership)); + SkFILEStream::kCallerPasses_Ownership)); // Use a buffered stream. Although an SkFILEStream can be rewound, this // ensures that SkImageDecoder::Factory never rewinds beyond the diff --git a/core/jni/android/graphics/GraphicsJNI.h b/core/jni/android/graphics/GraphicsJNI.h index dcc97e546979..e2b31cb27538 100644 --- a/core/jni/android/graphics/GraphicsJNI.h +++ b/core/jni/android/graphics/GraphicsJNI.h @@ -1,6 +1,8 @@ #ifndef GraphicsJNI_DEFINED #define GraphicsJNI_DEFINED +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" #include "SkBitmap.h" #include "SkDevice.h" #include "SkPixelRef.h" @@ -8,6 +10,8 @@ #include "SkPoint.h" #include "SkRect.h" #include "SkImageDecoder.h" +#pragma GCC diagnostic pop + #include <jni.h> class SkBitmapRegionDecoder; diff --git a/core/jni/android_util_AssetManager.cpp b/core/jni/android_util_AssetManager.cpp index 4859ee6fb796..e104948543b0 100644 --- a/core/jni/android_util_AssetManager.cpp +++ b/core/jni/android_util_AssetManager.cpp @@ -2084,7 +2084,7 @@ static JNINativeMethod gAssetManagerMethods[] = { { "getAssetAllocations", "()Ljava/lang/String;", (void*) android_content_AssetManager_getAssetAllocations }, { "getGlobalAssetManagerCount", "()I", - (void*) android_content_AssetManager_getGlobalAssetCount }, + (void*) android_content_AssetManager_getGlobalAssetManagerCount }, }; int register_android_content_AssetManager(JNIEnv* env) diff --git a/core/jni/android_util_FileObserver.cpp b/core/jni/android_util_FileObserver.cpp index 0327d8c491d9..b906cfdf0662 100644 --- a/core/jni/android_util_FileObserver.cpp +++ b/core/jni/android_util_FileObserver.cpp @@ -29,7 +29,7 @@ #include <sys/ioctl.h> #include <errno.h> -#ifdef HAVE_INOTIFY +#if defined(__linux__) #include <sys/inotify.h> #endif @@ -39,29 +39,25 @@ static jmethodID method_onEvent; static jint android_os_fileobserver_init(JNIEnv* env, jobject object) { -#ifdef HAVE_INOTIFY - - return (jint)inotify_init(); - -#else // HAVE_INOTIFY - +#if defined(__linux__) + return (jint)inotify_init(); +#else return -1; - -#endif // HAVE_INOTIFY +#endif } static void android_os_fileobserver_observe(JNIEnv* env, jobject object, jint fd) { -#ifdef HAVE_INOTIFY - +#if defined(__linux__) + char event_buf[512]; struct inotify_event* event; - + while (1) { int event_pos = 0; int num_bytes = read(fd, event_buf, sizeof(event_buf)); - + if (num_bytes < (int)sizeof(*event)) { if (errno == EINTR) @@ -70,14 +66,14 @@ static void android_os_fileobserver_observe(JNIEnv* env, jobject object, jint fd ALOGE("***** ERROR! android_os_fileobserver_observe() got a short event!"); return; } - + while (num_bytes >= (int)sizeof(*event)) { int event_size; event = (struct inotify_event *)(event_buf + event_pos); jstring path = NULL; - + if (event->len > 0) { path = env->NewStringUTF(event->name); @@ -98,37 +94,37 @@ static void android_os_fileobserver_observe(JNIEnv* env, jobject object, jint fd event_pos += event_size; } } - -#endif // HAVE_INOTIFY + +#endif } static jint android_os_fileobserver_startWatching(JNIEnv* env, jobject object, jint fd, jstring pathString, jint mask) { int res = -1; - -#ifdef HAVE_INOTIFY - + +#if defined(__linux__) + if (fd >= 0) { const char* path = env->GetStringUTFChars(pathString, NULL); - + res = inotify_add_watch(fd, path, mask); - + env->ReleaseStringUTFChars(pathString, path); } -#endif // HAVE_INOTIFY - +#endif + return res; } static void android_os_fileobserver_stopWatching(JNIEnv* env, jobject object, jint fd, jint wfd) { -#ifdef HAVE_INOTIFY +#if defined(__linux__) inotify_rm_watch((int)fd, (uint32_t)wfd); -#endif // HAVE_INOTIFY +#endif } static JNINativeMethod sMethods[] = { @@ -137,7 +133,7 @@ static JNINativeMethod sMethods[] = { { "observe", "(I)V", (void*)android_os_fileobserver_observe }, { "startWatching", "(ILjava/lang/String;I)I", (void*)android_os_fileobserver_startWatching }, { "stopWatching", "(II)V", (void*)android_os_fileobserver_stopWatching } - + }; int register_android_os_FileObserver(JNIEnv* env) diff --git a/core/jni/android_util_Process.cpp b/core/jni/android_util_Process.cpp index 65061900ffbb..2b0960fc24d4 100644 --- a/core/jni/android_util_Process.cpp +++ b/core/jni/android_util_Process.cpp @@ -287,7 +287,8 @@ static void android_os_Process_setCanSelfBackground(JNIEnv* env, jobject clazz, void android_os_Process_setThreadScheduler(JNIEnv* env, jclass clazz, jint tid, jint policy, jint pri) { -#ifdef HAVE_SCHED_SETSCHEDULER +// linux has sched_setscheduler(), others don't. +#if defined(__linux__) struct sched_param param; param.sched_priority = pri; int rc = sched_setscheduler(tid, policy, ¶m); diff --git a/drm/jni/Android.mk b/drm/jni/Android.mk index 474b9b299f86..08c7b953b813 100644 --- a/drm/jni/Android.mk +++ b/drm/jni/Android.mk @@ -39,8 +39,8 @@ LOCAL_C_INCLUDES += \ $(TOP)/frameworks/av/include \ $(TOP)/libcore/include - - LOCAL_MODULE_TAGS := optional +LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code + include $(BUILD_SHARED_LIBRARY) diff --git a/drm/jni/android_drm_DrmManagerClient.cpp b/drm/jni/android_drm_DrmManagerClient.cpp index d321baf68b46..52597e10609a 100644 --- a/drm/jni/android_drm_DrmManagerClient.cpp +++ b/drm/jni/android_drm_DrmManagerClient.cpp @@ -381,7 +381,8 @@ static jobjectArray android_drm_DrmManagerClient_getAllSupportInfo( } static void android_drm_DrmManagerClient_installDrmEngine( - JNIEnv* env, jobject thiz, jint uniqueId, jstring engineFilePath) { + JNIEnv* /* env */, jobject /* thiz */, jint /* uniqueId */, + jstring /* engineFilePath */) { ALOGV("installDrmEngine - Enter"); //getDrmManagerClient(env, thiz) // ->installDrmEngine(uniqueId, Utility::getStringValue(env, engineFilePath)); @@ -776,7 +777,7 @@ static int registerNativeMethods(JNIEnv* env) { return result; } -jint JNI_OnLoad(JavaVM* vm, void* reserved) { +jint JNI_OnLoad(JavaVM* vm, void* /* reserved */) { JNIEnv* env = NULL; jint result = -1; diff --git a/include/androidfw/ResourceTypes.h b/include/androidfw/ResourceTypes.h index ce30d8164668..a44975b37eb2 100644 --- a/include/androidfw/ResourceTypes.h +++ b/include/androidfw/ResourceTypes.h @@ -236,8 +236,8 @@ enum { #define Res_MAKEINTERNAL(entry) (0x01000000 | (entry&0xFFFF)) #define Res_MAKEARRAY(entry) (0x02000000 | (entry&0xFFFF)) -#define Res_MAXPACKAGE 255 -#define Res_MAXTYPE 255 +static const size_t Res_MAXPACKAGE = 255; +static const size_t Res_MAXTYPE = 255; /** * Representation of a value in a resource, supplying type @@ -1773,9 +1773,7 @@ public: const char* targetPath, const char* overlayPath, void** outData, size_t* outSize) const; - enum { - IDMAP_HEADER_SIZE_BYTES = 4 * sizeof(uint32_t) + 2 * 256, - }; + static const size_t IDMAP_HEADER_SIZE_BYTES = 4 * sizeof(uint32_t) + 2 * 256; // Retrieve idmap meta-data. // diff --git a/libs/androidfw/Android.mk b/libs/androidfw/Android.mk index 376b101a178d..9c0a7479f218 100644 --- a/libs/androidfw/Android.mk +++ b/libs/androidfw/Android.mk @@ -52,8 +52,10 @@ LOCAL_MODULE_TAGS := optional LOCAL_CFLAGS += -DSTATIC_ANDROIDFW_FOR_TOOLS +LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code + LOCAL_C_INCLUDES := \ - external/zlib + external/zlib LOCAL_STATIC_LIBRARIES := liblog libziparchive-host libutils @@ -69,11 +71,11 @@ LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk LOCAL_SRC_FILES:= $(deviceSources) LOCAL_SHARED_LIBRARIES := \ - libbinder \ - liblog \ - libcutils \ - libutils \ - libz + libbinder \ + liblog \ + libcutils \ + libutils \ + libz LOCAL_STATIC_LIBRARIES := libziparchive @@ -85,6 +87,8 @@ LOCAL_MODULE:= libandroidfw LOCAL_MODULE_TAGS := optional +LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code + include $(BUILD_SHARED_LIBRARY) diff --git a/libs/androidfw/Asset.cpp b/libs/androidfw/Asset.cpp index 589211fa60b8..4b3382e4fc5d 100644 --- a/libs/androidfw/Asset.cpp +++ b/libs/androidfw/Asset.cpp @@ -45,6 +45,8 @@ using namespace android; # define O_BINARY 0 #endif +static const bool kIsDebug = false; + static Mutex gAssetLock; static int32_t gCount = 0; static Asset* gHead = NULL; @@ -89,7 +91,9 @@ Asset::Asset(void) gTail->mNext = this; gTail = this; } - //ALOGI("Creating Asset %p #%d\n", this, gCount); + if (kIsDebug) { + ALOGI("Creating Asset %p #%d\n", this, gCount); + } } Asset::~Asset(void) @@ -109,7 +113,9 @@ Asset::~Asset(void) mPrev->mNext = mNext; } mNext = mPrev = NULL; - //ALOGI("Destroying Asset in %p #%d\n", this, gCount); + if (kIsDebug) { + ALOGI("Destroying Asset in %p #%d\n", this, gCount); + } } /* diff --git a/libs/androidfw/AssetManager.cpp b/libs/androidfw/AssetManager.cpp index de6a33cf15e7..e5c5b108921f 100644 --- a/libs/androidfw/AssetManager.cpp +++ b/libs/androidfw/AssetManager.cpp @@ -64,6 +64,8 @@ using namespace android; +static const bool kIsDebug = false; + /* * Names for default app, locale, and vendor. We might want to change * these to be an actual locale, e.g. always use en-US as the default. @@ -152,15 +154,19 @@ AssetManager::AssetManager(CacheMode cacheMode) mResources(NULL), mConfig(new ResTable_config), mCacheMode(cacheMode), mCacheValid(false) { - int count = android_atomic_inc(&gCount)+1; - //ALOGI("Creating AssetManager %p #%d\n", this, count); + int count = android_atomic_inc(&gCount) + 1; + if (kIsDebug) { + ALOGI("Creating AssetManager %p #%d\n", this, count); + } memset(mConfig, 0, sizeof(ResTable_config)); } AssetManager::~AssetManager(void) { int count = android_atomic_dec(&gCount); - //ALOGI("Destroying AssetManager in %p #%d\n", this, count); + if (kIsDebug) { + ALOGI("Destroying AssetManager in %p #%d\n", this, count); + } delete mConfig; delete mResources; @@ -1864,7 +1870,9 @@ AssetManager::SharedZip::SharedZip(const String8& path, time_t modWhen) : mPath(path), mZipFile(NULL), mModWhen(modWhen), mResourceTableAsset(NULL), mResourceTable(NULL) { - //ALOGI("Creating SharedZip %p %s\n", this, (const char*)mPath); + if (kIsDebug) { + ALOGI("Creating SharedZip %p %s\n", this, (const char*)mPath); + } ALOGV("+++ opening zip '%s'\n", mPath.string()); mZipFile = ZipFileRO::open(mPath.string()); if (mZipFile == NULL) { @@ -1958,7 +1966,9 @@ bool AssetManager::SharedZip::getOverlay(size_t idx, asset_path* out) const AssetManager::SharedZip::~SharedZip() { - //ALOGI("Destroying SharedZip %p %s\n", this, (const char*)mPath); + if (kIsDebug) { + ALOGI("Destroying SharedZip %p %s\n", this, (const char*)mPath); + } if (mResourceTable != NULL) { delete mResourceTable; } diff --git a/libs/androidfw/BackupData.cpp b/libs/androidfw/BackupData.cpp index d16d54983973..ba4a4ff4fe63 100644 --- a/libs/androidfw/BackupData.cpp +++ b/libs/androidfw/BackupData.cpp @@ -27,7 +27,7 @@ namespace android { -static const bool DEBUG = false; +static const bool kIsDebug = false; /* * File Format (v1): @@ -45,12 +45,6 @@ static const bool DEBUG = false; const static int ROUND_UP[4] = { 0, 3, 2, 1 }; static inline size_t -round_up(size_t n) -{ - return n + ROUND_UP[n % 4]; -} - -static inline size_t padding_extra(size_t n) { return ROUND_UP[n % 4]; @@ -62,7 +56,7 @@ BackupDataWriter::BackupDataWriter(int fd) m_entityCount(0) { m_pos = (ssize_t) lseek(fd, 0, SEEK_CUR); - if (DEBUG) ALOGI("BackupDataWriter(%d) @ %ld", fd, (long)m_pos); + if (kIsDebug) ALOGI("BackupDataWriter(%d) @ %ld", fd, (long)m_pos); } BackupDataWriter::~BackupDataWriter() @@ -79,7 +73,7 @@ BackupDataWriter::write_padding_for(int n) paddingSize = padding_extra(n); if (paddingSize > 0) { uint32_t padding = 0xbcbcbcbc; - if (DEBUG) ALOGI("writing %zd padding bytes for %d", paddingSize, n); + if (kIsDebug) ALOGI("writing %zd padding bytes for %d", paddingSize, n); amt = write(m_fd, &padding, paddingSize); if (amt != paddingSize) { m_status = errno; @@ -112,7 +106,7 @@ BackupDataWriter::WriteEntityHeader(const String8& key, size_t dataSize) } else { k = key; } - if (DEBUG) { + if (kIsDebug) { ALOGD("Writing header: prefix='%s' key='%s' dataSize=%zu", m_keyPrefix.string(), key.string(), dataSize); } @@ -126,7 +120,7 @@ BackupDataWriter::WriteEntityHeader(const String8& key, size_t dataSize) header.keyLen = tolel(keyLen); header.dataSize = tolel(dataSize); - if (DEBUG) ALOGI("writing entity header, %zu bytes", sizeof(entity_header_v1)); + if (kIsDebug) ALOGI("writing entity header, %zu bytes", sizeof(entity_header_v1)); amt = write(m_fd, &header, sizeof(entity_header_v1)); if (amt != sizeof(entity_header_v1)) { m_status = errno; @@ -134,7 +128,7 @@ BackupDataWriter::WriteEntityHeader(const String8& key, size_t dataSize) } m_pos += amt; - if (DEBUG) ALOGI("writing entity header key, %zd bytes", keyLen+1); + if (kIsDebug) ALOGI("writing entity header key, %zd bytes", keyLen+1); amt = write(m_fd, k.string(), keyLen+1); if (amt != keyLen+1) { m_status = errno; @@ -152,10 +146,10 @@ BackupDataWriter::WriteEntityHeader(const String8& key, size_t dataSize) status_t BackupDataWriter::WriteEntityData(const void* data, size_t size) { - if (DEBUG) ALOGD("Writing data: size=%lu", (unsigned long) size); + if (kIsDebug) ALOGD("Writing data: size=%lu", (unsigned long) size); if (m_status != NO_ERROR) { - if (DEBUG) { + if (kIsDebug) { ALOGD("Not writing data - stream in error state %d (%s)", m_status, strerror(m_status)); } return m_status; @@ -167,7 +161,7 @@ BackupDataWriter::WriteEntityData(const void* data, size_t size) ssize_t amt = write(m_fd, data, size); if (amt != (ssize_t)size) { m_status = errno; - if (DEBUG) ALOGD("write returned error %d (%s)", m_status, strerror(m_status)); + if (kIsDebug) ALOGD("write returned error %d (%s)", m_status, strerror(m_status)); return m_status; } m_pos += amt; @@ -189,7 +183,7 @@ BackupDataReader::BackupDataReader(int fd) { memset(&m_header, 0, sizeof(m_header)); m_pos = (ssize_t) lseek(fd, 0, SEEK_CUR); - if (DEBUG) ALOGI("BackupDataReader(%d) @ %ld", fd, (long)m_pos); + if (kIsDebug) ALOGI("BackupDataReader(%d) @ %ld", fd, (long)m_pos); } BackupDataReader::~BackupDataReader() @@ -342,15 +336,19 @@ BackupDataReader::ReadEntityData(void* data, size_t size) return -1; } int remaining = m_dataEndPos - m_pos; - //ALOGD("ReadEntityData size=%d m_pos=0x%x m_dataEndPos=0x%x remaining=%d\n", - // size, m_pos, m_dataEndPos, remaining); + if (kIsDebug) { + ALOGD("ReadEntityData size=%zu m_pos=0x%zx m_dataEndPos=0x%zx remaining=%d\n", + size, m_pos, m_dataEndPos, remaining); + } if (remaining <= 0) { return 0; } if (((int)size) > remaining) { size = remaining; } - //ALOGD(" reading %d bytes", size); + if (kIsDebug) { + ALOGD(" reading %zu bytes", size); + } int amt = read(m_fd, data, size); if (amt < 0) { m_status = errno; diff --git a/libs/androidfw/BackupHelpers.cpp b/libs/androidfw/BackupHelpers.cpp index 52dce9f7f5c5..3f82830c4fa1 100644 --- a/libs/androidfw/BackupHelpers.cpp +++ b/libs/androidfw/BackupHelpers.cpp @@ -68,14 +68,11 @@ struct file_metadata_v1 { const static int CURRENT_METADATA_VERSION = 1; -#if 1 -#define LOGP(f, x...) -#else +static const bool kIsDebug = false; #if TEST_BACKUP_HELPERS -#define LOGP(f, x...) printf(f "\n", x) +#define LOGP(f, x...) if (kIsDebug) printf(f "\n", x) #else -#define LOGP(x...) ALOGD(x) -#endif +#define LOGP(x...) if (kIsDebug) ALOGD(x) #endif const static int ROUND_UP[4] = { 0, 3, 2, 1 }; @@ -205,13 +202,6 @@ write_snapshot_file(int fd, const KeyedVector<String8,FileRec>& snapshot) } static int -write_delete_file(BackupDataWriter* dataStream, const String8& key) -{ - LOGP("write_delete_file %s\n", key.string()); - return dataStream->WriteEntityHeader(key, -1); -} - -static int write_update_file(BackupDataWriter* dataStream, int fd, int mode, const String8& key, char const* realFilename) { @@ -225,8 +215,6 @@ write_update_file(BackupDataWriter* dataStream, int fd, int mode, const String8& file_metadata_v1 metadata; char* buf = (char*)malloc(bufsize); - int crc = crc32(0L, Z_NULL, 0); - fileSize = lseek(fd, 0, SEEK_END); lseek(fd, 0, SEEK_SET); @@ -442,18 +430,6 @@ back_up_files(int oldSnapshotFD, BackupDataWriter* dataStream, int newSnapshotFD return 0; } -// Utility function, equivalent to stpcpy(): perform a strcpy, but instead of -// returning the initial dest, return a pointer to the trailing NUL. -static char* strcpy_ptr(char* dest, const char* str) { - if (dest && str) { - while ((*dest = *str) != 0) { - dest++; - str++; - } - } - return dest; -} - static void calc_tar_checksum(char* buf) { // [ 148 : 8 ] checksum -- to be calculated with this field as space chars memset(buf + 148, ' ', 8); @@ -579,7 +555,7 @@ int write_tarfile(const String8& packageName, const String8& domain, snprintf(buf + 124, 12, "%011llo", (isdir) ? 0LL : s.st_size); // [ 136 : 12 ] last mod time as a UTC time_t - snprintf(buf + 136, 12, "%0lo", s.st_mtime); + snprintf(buf + 136, 12, "%0lo", (unsigned long)s.st_mtime); // [ 156 : 1 ] link/file type uint8_t type; @@ -635,7 +611,6 @@ int write_tarfile(const String8& packageName, const String8& domain, // construct the pax extended header data block memset(paxData, 0, BUFSIZE - (paxData - buf)); - int len; // size header -- calc len in digits by actually rendering the number // to a string - brute force but simple @@ -1200,7 +1175,6 @@ test_read_header_and_entity(BackupDataReader& reader, const char* str) size_t bufSize = strlen(str)+1; char* buf = (char*)malloc(bufSize); String8 string; - int cookie = 0x11111111; size_t actualSize; bool done; int type; @@ -1333,23 +1307,12 @@ get_mod_time(const char* filename, struct timeval times[2]) fprintf(stderr, "stat '%s' failed: %s\n", filename, strerror(errno)); return errno; } - times[0].tv_sec = st.st_atime; - times[1].tv_sec = st.st_mtime; - // If st_atime is a macro then struct stat64 uses struct timespec - // to store the access and modif time values and typically - // st_*time_nsec is not defined. In glibc, this is controlled by - // __USE_MISC. -#ifdef __USE_MISC -#if !defined(st_atime) || defined(st_atime_nsec) -#error "Check if this __USE_MISC conditional is still needed." -#endif + times[0].tv_sec = st.st_atim.tv_sec; times[0].tv_usec = st.st_atim.tv_nsec / 1000; + + times[1].tv_sec = st.st_mtim.tv_sec; times[1].tv_usec = st.st_mtim.tv_nsec / 1000; -#else - times[0].tv_usec = st.st_atime_nsec / 1000; - times[1].tv_usec = st.st_mtime_nsec / 1000; -#endif return 0; } @@ -1490,7 +1453,6 @@ int backup_helper_test_null_base() { int err; - int oldSnapshotFD; int dataStreamFD; int newSnapshotFD; @@ -1539,7 +1501,6 @@ int backup_helper_test_missing_file() { int err; - int oldSnapshotFD; int dataStreamFD; int newSnapshotFD; diff --git a/libs/androidfw/ObbFile.cpp b/libs/androidfw/ObbFile.cpp index ec59f0666c02..195fa9ac00d3 100644 --- a/libs/androidfw/ObbFile.cpp +++ b/libs/androidfw/ObbFile.cpp @@ -122,7 +122,7 @@ bool ObbFile::parseObbFile(int fd) if (fileLength < 0) { ALOGW("error seeking in ObbFile: %s\n", strerror(errno)); } else { - ALOGW("file is only %lld (less than %d minimum)\n", fileLength, kFooterMinSize); + ALOGW("file is only %lld (less than %d minimum)\n", (long long int)fileLength, kFooterMinSize); } return false; } @@ -150,8 +150,8 @@ bool ObbFile::parseObbFile(int fd) footerSize = get4LE((unsigned char*)footer); if (footerSize > (size_t)fileLength - kFooterTagSize || footerSize > kMaxBufSize) { - ALOGW("claimed footer size is too large (0x%08zx; file size is 0x%08llx)\n", - footerSize, fileLength); + ALOGW("claimed footer size is too large (0x%08zx; file size is 0x%08lld)\n", + footerSize, (long long int)fileLength); return false; } @@ -164,7 +164,7 @@ bool ObbFile::parseObbFile(int fd) off64_t fileOffset = fileLength - footerSize - kFooterTagSize; if (lseek64(fd, fileOffset, SEEK_SET) != fileOffset) { - ALOGW("seek %lld failed: %s\n", fileOffset, strerror(errno)); + ALOGW("seek %lld failed: %s\n", (long long int)fileOffset, strerror(errno)); return false; } diff --git a/libs/androidfw/ResourceTypes.cpp b/libs/androidfw/ResourceTypes.cpp index 825071a61924..679a75fdc5d9 100644 --- a/libs/androidfw/ResourceTypes.cpp +++ b/libs/androidfw/ResourceTypes.cpp @@ -27,6 +27,10 @@ #include <utils/String16.h> #include <utils/String8.h> +#ifdef HAVE_ANDROID_OS +#include <binder/TextOutput.h> +#endif + #include <stdlib.h> #include <string.h> #include <memory.h> @@ -38,15 +42,6 @@ #define INT32_MAX ((int32_t)(2147483647)) #endif -#define STRING_POOL_NOISY(x) //x -#define XML_NOISY(x) //x -#define TABLE_NOISY(x) //x -#define TABLE_GETENTRY(x) //x -#define TABLE_SUPER_NOISY(x) //x -#define LOAD_TABLE_NOISY(x) //x -#define TABLE_THEME(x) //x -#define LIB_NOISY(x) //x - namespace android { #ifdef HAVE_WINSOCK @@ -72,6 +67,19 @@ namespace android { #define APP_PACKAGE_ID 0x7f #define SYS_PACKAGE_ID 0x01 +static const bool kDebugStringPoolNoisy = false; +static const bool kDebugXMLNoisy = false; +static const bool kDebugTableNoisy = false; +static const bool kDebugTableGetEntry = false; +static const bool kDebugTableSuperNoisy = false; +static const bool kDebugLoadTableNoisy = false; +static const bool kDebugLoadTableSuperNoisy = false; +static const bool kDebugTableTheme = false; +static const bool kDebugResXMLTree = false; +static const bool kDebugLibNoisy = false; + +// TODO: This code uses 0xFFFFFFFF converted to bag_set* as a sentinel value. This is bad practice. + // Standard C isspace() is only required to look at the low byte of its input, so // produces incorrect results for UTF-16 characters. For safety's sake, assume that // any high-byte UTF-16 code point is not whitespace. @@ -719,12 +727,14 @@ const char16_t* ResStringPool::stringAt(size_t idx, size_t* u16len) const if (mCache == NULL) { #ifndef HAVE_ANDROID_OS - STRING_POOL_NOISY(ALOGI("CREATING STRING CACHE OF %d bytes", - mHeader->stringCount*sizeof(char16_t**))); + if (kDebugStringPoolNoisy) { + ALOGI("CREATING STRING CACHE OF %zu bytes", + mHeader->stringCount*sizeof(char16_t**)); + } #else // We do not want to be in this case when actually running Android. - ALOGW("CREATING STRING CACHE OF %d bytes", - mHeader->stringCount*sizeof(char16_t**)); + ALOGW("CREATING STRING CACHE OF %zu bytes", + static_cast<size_t>(mHeader->stringCount*sizeof(char16_t**))); #endif mCache = (char16_t**)calloc(mHeader->stringCount, sizeof(char16_t**)); if (mCache == NULL) { @@ -753,7 +763,9 @@ const char16_t* ResStringPool::stringAt(size_t idx, size_t* u16len) const return NULL; } - STRING_POOL_NOISY(ALOGI("Caching UTF8 string: %s", u8str)); + if (kDebugStringPoolNoisy) { + ALOGI("Caching UTF8 string: %s", u8str); + } utf8_to_utf16(u8str, u8len, u16str); mCache[idx] = u16str; return u16str; @@ -843,7 +855,9 @@ ssize_t ResStringPool::indexOfString(const char16_t* str, size_t strLen) const size_t len; if ((mHeader->flags&ResStringPool_header::UTF8_FLAG) != 0) { - STRING_POOL_NOISY(ALOGI("indexOfString UTF-8: %s", String8(str, strLen).string())); + if (kDebugStringPoolNoisy) { + ALOGI("indexOfString UTF-8: %s", String8(str, strLen).string()); + } // The string pool contains UTF 8 strings; we don't want to cause // temporary UTF-16 strings to be created as we search. @@ -869,10 +883,14 @@ ssize_t ResStringPool::indexOfString(const char16_t* str, size_t strLen) const } else { c = -1; } - STRING_POOL_NOISY(ALOGI("Looking at %s, cmp=%d, l/mid/h=%d/%d/%d\n", - (const char*)s, c, (int)l, (int)mid, (int)h)); + if (kDebugStringPoolNoisy) { + ALOGI("Looking at %s, cmp=%d, l/mid/h=%d/%d/%d\n", + (const char*)s, c, (int)l, (int)mid, (int)h); + } if (c == 0) { - STRING_POOL_NOISY(ALOGI("MATCH!")); + if (kDebugStringPoolNoisy) { + ALOGI("MATCH!"); + } free(convBuffer); return mid; } else if (c < 0) { @@ -891,18 +909,22 @@ ssize_t ResStringPool::indexOfString(const char16_t* str, size_t strLen) const const size_t str8Len = str8.size(); for (int i=mHeader->stringCount-1; i>=0; i--) { const char* s = string8At(i, &len); - STRING_POOL_NOISY(ALOGI("Looking at %s, i=%d\n", - String8(s).string(), - i)); + if (kDebugStringPoolNoisy) { + ALOGI("Looking at %s, i=%d\n", String8(s).string(), i); + } if (s && str8Len == len && memcmp(s, str8.string(), str8Len) == 0) { - STRING_POOL_NOISY(ALOGI("MATCH!")); + if (kDebugStringPoolNoisy) { + ALOGI("MATCH!"); + } return i; } } } } else { - STRING_POOL_NOISY(ALOGI("indexOfString UTF-16: %s", String8(str, strLen).string())); + if (kDebugStringPoolNoisy) { + ALOGI("indexOfString UTF-16: %s", String8(str, strLen).string()); + } if (mHeader->flags&ResStringPool_header::SORTED_FLAG) { // Do a binary search for the string... @@ -914,11 +936,14 @@ ssize_t ResStringPool::indexOfString(const char16_t* str, size_t strLen) const mid = l + (h - l)/2; const char16_t* s = stringAt(mid, &len); int c = s ? strzcmp16(s, len, str, strLen) : -1; - STRING_POOL_NOISY(ALOGI("Looking at %s, cmp=%d, l/mid/h=%d/%d/%d\n", - String8(s).string(), - c, (int)l, (int)mid, (int)h)); + if (kDebugStringPoolNoisy) { + ALOGI("Looking at %s, cmp=%d, l/mid/h=%d/%d/%d\n", + String8(s).string(), c, (int)l, (int)mid, (int)h); + } if (c == 0) { - STRING_POOL_NOISY(ALOGI("MATCH!")); + if (kDebugStringPoolNoisy) { + ALOGI("MATCH!"); + } return mid; } else if (c < 0) { l = mid + 1; @@ -933,11 +958,13 @@ ssize_t ResStringPool::indexOfString(const char16_t* str, size_t strLen) const // block, start searching at the back. for (int i=mHeader->stringCount-1; i>=0; i--) { const char16_t* s = stringAt(i, &len); - STRING_POOL_NOISY(ALOGI("Looking at %s, i=%d\n", - String8(s).string(), - i)); + if (kDebugStringPoolNoisy) { + ALOGI("Looking at %s, i=%d\n", String8(s).string(), i); + } if (s && strLen == len && strzcmp16(s, len, str, strLen) == 0) { - STRING_POOL_NOISY(ALOGI("MATCH!")); + if (kDebugStringPoolNoisy) { + ALOGI("MATCH!"); + } return i; } } @@ -1138,7 +1165,9 @@ const char16_t* ResXMLParser::getAttributeNamespace(size_t idx, size_t* outLen) { int32_t id = getAttributeNamespaceID(idx); //printf("attribute namespace=%d idx=%d event=%p\n", id, idx, mEventCode); - //XML_NOISY(printf("getAttributeNamespace 0x%x=0x%x\n", idx, id)); + if (kDebugXMLNoisy) { + printf("getAttributeNamespace 0x%zx=0x%x\n", idx, id); + } return id >= 0 ? mTree.mStrings.stringAt(id, outLen) : NULL; } @@ -1146,7 +1175,9 @@ const char* ResXMLParser::getAttributeNamespace8(size_t idx, size_t* outLen) con { int32_t id = getAttributeNamespaceID(idx); //printf("attribute namespace=%d idx=%d event=%p\n", id, idx, mEventCode); - //XML_NOISY(printf("getAttributeNamespace 0x%x=0x%x\n", idx, id)); + if (kDebugXMLNoisy) { + printf("getAttributeNamespace 0x%zx=0x%x\n", idx, id); + } return id >= 0 ? mTree.mStrings.string8At(id, outLen) : NULL; } @@ -1169,7 +1200,9 @@ const char16_t* ResXMLParser::getAttributeName(size_t idx, size_t* outLen) const { int32_t id = getAttributeNameID(idx); //printf("attribute name=%d idx=%d event=%p\n", id, idx, mEventCode); - //XML_NOISY(printf("getAttributeName 0x%x=0x%x\n", idx, id)); + if (kDebugXMLNoisy) { + printf("getAttributeName 0x%zx=0x%x\n", idx, id); + } return id >= 0 ? mTree.mStrings.stringAt(id, outLen) : NULL; } @@ -1177,7 +1210,9 @@ const char* ResXMLParser::getAttributeName8(size_t idx, size_t* outLen) const { int32_t id = getAttributeNameID(idx); //printf("attribute name=%d idx=%d event=%p\n", id, idx, mEventCode); - //XML_NOISY(printf("getAttributeName 0x%x=0x%x\n", idx, id)); + if (kDebugXMLNoisy) { + printf("getAttributeName 0x%zx=0x%x\n", idx, id); + } return id >= 0 ? mTree.mStrings.string8At(id, outLen) : NULL; } @@ -1208,7 +1243,9 @@ int32_t ResXMLParser::getAttributeValueStringID(size_t idx) const const char16_t* ResXMLParser::getAttributeStringValue(size_t idx, size_t* outLen) const { int32_t id = getAttributeValueStringID(idx); - //XML_NOISY(printf("getAttributeValue 0x%x=0x%x\n", idx, id)); + if (kDebugXMLNoisy) { + printf("getAttributeValue 0x%zx=0x%x\n", idx, id); + } return id >= 0 ? mTree.mStrings.stringAt(id, outLen) : NULL; } @@ -1299,54 +1336,69 @@ ssize_t ResXMLParser::indexOfAttribute(const char16_t* ns, size_t nsLen, ns8 = String8(ns, nsLen); } attr8 = String8(attr, attrLen); - STRING_POOL_NOISY(ALOGI("indexOfAttribute UTF8 %s (%d) / %s (%d)", ns8.string(), nsLen, - attr8.string(), attrLen)); + if (kDebugStringPoolNoisy) { + ALOGI("indexOfAttribute UTF8 %s (%zu) / %s (%zu)", ns8.string(), nsLen, + attr8.string(), attrLen); + } for (size_t i=0; i<N; i++) { size_t curNsLen = 0, curAttrLen = 0; const char* curNs = getAttributeNamespace8(i, &curNsLen); const char* curAttr = getAttributeName8(i, &curAttrLen); - STRING_POOL_NOISY(ALOGI(" curNs=%s (%d), curAttr=%s (%d)", curNs, curNsLen, - curAttr, curAttrLen)); + if (kDebugStringPoolNoisy) { + ALOGI(" curNs=%s (%zu), curAttr=%s (%zu)", curNs, curNsLen, curAttr, curAttrLen); + } if (curAttr != NULL && curNsLen == nsLen && curAttrLen == attrLen && memcmp(attr8.string(), curAttr, attrLen) == 0) { if (ns == NULL) { if (curNs == NULL) { - STRING_POOL_NOISY(ALOGI(" FOUND!")); + if (kDebugStringPoolNoisy) { + ALOGI(" FOUND!"); + } return i; } } else if (curNs != NULL) { //printf(" --> ns=%s, curNs=%s\n", // String8(ns).string(), String8(curNs).string()); if (memcmp(ns8.string(), curNs, nsLen) == 0) { - STRING_POOL_NOISY(ALOGI(" FOUND!")); + if (kDebugStringPoolNoisy) { + ALOGI(" FOUND!"); + } return i; } } } } } else { - STRING_POOL_NOISY(ALOGI("indexOfAttribute UTF16 %s (%d) / %s (%d)", - String8(ns, nsLen).string(), nsLen, - String8(attr, attrLen).string(), attrLen)); + if (kDebugStringPoolNoisy) { + ALOGI("indexOfAttribute UTF16 %s (%zu) / %s (%zu)", + String8(ns, nsLen).string(), nsLen, + String8(attr, attrLen).string(), attrLen); + } for (size_t i=0; i<N; i++) { size_t curNsLen = 0, curAttrLen = 0; const char16_t* curNs = getAttributeNamespace(i, &curNsLen); const char16_t* curAttr = getAttributeName(i, &curAttrLen); - STRING_POOL_NOISY(ALOGI(" curNs=%s (%d), curAttr=%s (%d)", - String8(curNs, curNsLen).string(), curNsLen, - String8(curAttr, curAttrLen).string(), curAttrLen)); + if (kDebugStringPoolNoisy) { + ALOGI(" curNs=%s (%zu), curAttr=%s (%zu)", + String8(curNs, curNsLen).string(), curNsLen, + String8(curAttr, curAttrLen).string(), curAttrLen); + } if (curAttr != NULL && curNsLen == nsLen && curAttrLen == attrLen && (memcmp(attr, curAttr, attrLen*sizeof(char16_t)) == 0)) { if (ns == NULL) { if (curNs == NULL) { - STRING_POOL_NOISY(ALOGI(" FOUND!")); + if (kDebugStringPoolNoisy) { + ALOGI(" FOUND!"); + } return i; } } else if (curNs != NULL) { //printf(" --> ns=%s, curNs=%s\n", // String8(ns).string(), String8(curNs).string()); if (memcmp(ns, curNs, nsLen*sizeof(char16_t)) == 0) { - STRING_POOL_NOISY(ALOGI(" FOUND!")); + if (kDebugStringPoolNoisy) { + ALOGI(" FOUND!"); + } return i; } } @@ -1394,7 +1446,9 @@ ResXMLParser::event_code_t ResXMLParser::nextNode() do { const ResXMLTree_node* next = (const ResXMLTree_node*) (((const uint8_t*)mCurNode) + dtohl(mCurNode->header.size)); - //ALOGW("Next node: prev=%p, next=%p\n", mCurNode, next); + if (kDebugXMLNoisy) { + ALOGI("Next node: prev=%p, next=%p\n", mCurNode, next); + } if (((const uint8_t*)next) >= mTree.mDataEnd) { mCurNode = NULL; @@ -1471,7 +1525,9 @@ ResXMLTree::ResXMLTree(const DynamicRefTable* dynamicRefTable) , mDynamicRefTable(dynamicRefTable) , mError(NO_INIT), mOwnedData(NULL) { - //ALOGI("Creating ResXMLTree %p #%d\n", this, android_atomic_inc(&gCount)+1); + if (kDebugResXMLTree) { + ALOGI("Creating ResXMLTree %p #%d\n", this, android_atomic_inc(&gCount)+1); + } restart(); } @@ -1480,13 +1536,17 @@ ResXMLTree::ResXMLTree() , mDynamicRefTable(NULL) , mError(NO_INIT), mOwnedData(NULL) { - //ALOGI("Creating ResXMLTree %p #%d\n", this, android_atomic_inc(&gCount)+1); + if (kDebugResXMLTree) { + ALOGI("Creating ResXMLTree %p #%d\n", this, android_atomic_inc(&gCount)+1); + } restart(); } ResXMLTree::~ResXMLTree() { - //ALOGI("Destroying ResXMLTree in %p #%d\n", this, android_atomic_dec(&gCount)-1); + if (kDebugResXMLTree) { + ALOGI("Destroying ResXMLTree in %p #%d\n", this, android_atomic_dec(&gCount)-1); + } uninit(); } @@ -1539,8 +1599,10 @@ status_t ResXMLTree::setTo(const void* data, size_t size, bool copyData) } const uint16_t type = dtohs(chunk->type); const size_t size = dtohl(chunk->size); - XML_NOISY(printf("Scanning @ %p: type=0x%x, size=0x%x\n", - (void*)(((uint32_t)chunk)-((uint32_t)mHeader)), type, size)); + if (kDebugXMLNoisy) { + printf("Scanning @ %p: type=0x%x, size=0x%zx\n", + (void*)(((uintptr_t)chunk)-((uintptr_t)mHeader)), type, size); + } if (type == RES_STRING_POOL_TYPE) { mStrings.setTo(chunk, size); } else if (type == RES_XML_RESOURCE_MAP_TYPE) { @@ -1563,7 +1625,9 @@ status_t ResXMLTree::setTo(const void* data, size_t size, bool copyData) mRootCode = mEventCode; break; } else { - XML_NOISY(printf("Skipping unknown chunk!\n")); + if (kDebugXMLNoisy) { + printf("Skipping unknown chunk!\n"); + } } lastChunk = chunk; chunk = (const ResChunk_header*) @@ -2147,9 +2211,11 @@ bool ResTable_config::isBetterThan(const ResTable_config& o, myDelta += requested->screenHeightDp - screenHeightDp; otherDelta += requested->screenHeightDp - o.screenHeightDp; } - //ALOGI("Comparing this %dx%d to other %dx%d in %dx%d: myDelta=%d otherDelta=%d", - // screenWidthDp, screenHeightDp, o.screenWidthDp, o.screenHeightDp, - // requested->screenWidthDp, requested->screenHeightDp, myDelta, otherDelta); + if (kDebugTableSuperNoisy) { + ALOGI("Comparing this %dx%d to other %dx%d in %dx%d: myDelta=%d otherDelta=%d", + screenWidthDp, screenHeightDp, o.screenWidthDp, o.screenHeightDp, + requested->screenWidthDp, requested->screenHeightDp, myDelta, otherDelta); + } if (myDelta != otherDelta) { return myDelta < otherDelta; } @@ -2404,11 +2470,17 @@ bool ResTable_config::match(const ResTable_config& settings) const { } if (screenSizeDp != 0) { if (screenWidthDp != 0 && screenWidthDp > settings.screenWidthDp) { - //ALOGI("Filtering out width %d in requested %d", screenWidthDp, settings.screenWidthDp); + if (kDebugTableSuperNoisy) { + ALOGI("Filtering out width %d in requested %d", screenWidthDp, + settings.screenWidthDp); + } return false; } if (screenHeightDp != 0 && screenHeightDp > settings.screenHeightDp) { - //ALOGI("Filtering out height %d in requested %d", screenHeightDp, settings.screenHeightDp); + if (kDebugTableSuperNoisy) { + ALOGI("Filtering out height %d in requested %d", screenHeightDp, + settings.screenHeightDp); + } return false; } } @@ -2428,9 +2500,13 @@ bool ResTable_config::match(const ResTable_config& settings) const { // For compatibility, we count a request for KEYSHIDDEN_NO as also // matching the more recent KEYSHIDDEN_SOFT. Basically // KEYSHIDDEN_NO means there is some kind of keyboard available. - //ALOGI("Matching keysHidden: have=%d, config=%d\n", keysHidden, setKeysHidden); + if (kDebugTableSuperNoisy) { + ALOGI("Matching keysHidden: have=%d, config=%d\n", keysHidden, setKeysHidden); + } if (keysHidden != KEYSHIDDEN_NO || setKeysHidden != KEYSHIDDEN_SOFT) { - //ALOGI("No match!"); + if (kDebugTableSuperNoisy) { + ALOGI("No match!"); + } return false; } } @@ -2935,17 +3011,25 @@ struct ResTable::PackageGroup void clearBagCache() { if (bags) { - TABLE_NOISY(printf("bags=%p\n", bags)); + if (kDebugTableNoisy) { + printf("bags=%p\n", bags); + } for (size_t i = 0; i < bags->size(); i++) { - TABLE_NOISY(printf("type=%d\n", i)); + if (kDebugTableNoisy) { + printf("type=%zu\n", i); + } const TypeList& typeList = types[i]; if (!typeList.isEmpty()) { bag_set** typeBags = bags->get(i); - TABLE_NOISY(printf("typeBags=%p\n", typeBags)); + if (kDebugTableNoisy) { + printf("typeBags=%p\n", typeBags); + } if (typeBags) { const size_t N = typeList[0]->entryCount; - TABLE_NOISY(printf("type->entryCount=%x\n", N)); - for (size_t j=0; j<N; j++) { + if (kDebugTableNoisy) { + printf("type->entryCount=%zu\n", N); + } + for (size_t j = 0; j < N; j++) { if (typeBags[j] && typeBags[j] != (bag_set*)0xFFFFFFFF) free(typeBags[j]); } @@ -3053,7 +3137,9 @@ status_t ResTable::Theme::applyStyle(uint32_t resID, bool force) uint32_t bagTypeSpecFlags = 0; mTable.lock(); const ssize_t N = mTable.getBagLocked(resID, &bag, &bagTypeSpecFlags); - TABLE_NOISY(ALOGV("Applying style 0x%08x to theme %p, count=%d", resID, this, N)); + if (kDebugTableNoisy) { + ALOGV("Applying style 0x%08x to theme %p, count=%zu", resID, this, N); + } if (N < 0) { mTable.unlock(); return N; @@ -3084,7 +3170,6 @@ status_t ResTable::Theme::applyStyle(uint32_t resID, bool force) curPackageIndex = pidx; curPI = mPackages[pidx]; if (curPI == NULL) { - PackageGroup* const grp = mTable.mPackageGroups[pidx]; curPI = (package_info*)malloc(sizeof(package_info)); memset(curPI, 0, sizeof(*curPI)); mPackages[pidx] = curPI; @@ -3116,9 +3201,11 @@ status_t ResTable::Theme::applyStyle(uint32_t resID, bool force) continue; } theme_entry* curEntry = curEntries + e; - TABLE_NOISY(ALOGV("Attr 0x%08x: type=0x%x, data=0x%08x; curType=0x%x", - attrRes, bag->map.value.dataType, bag->map.value.data, - curEntry->value.dataType)); + if (kDebugTableNoisy) { + ALOGV("Attr 0x%08x: type=0x%x, data=0x%08x; curType=0x%x", + attrRes, bag->map.value.dataType, bag->map.value.data, + curEntry->value.dataType); + } if (force || curEntry->value.dataType == Res_value::TYPE_NULL) { curEntry->stringBlock = bag->stringBlock; curEntry->typeSpecFlags |= bagTypeSpecFlags; @@ -3130,17 +3217,21 @@ status_t ResTable::Theme::applyStyle(uint32_t resID, bool force) mTable.unlock(); - //ALOGI("Applying style 0x%08x (force=%d) theme %p...\n", resID, force, this); - //dumpToLog(); + if (kDebugTableTheme) { + ALOGI("Applying style 0x%08x (force=%d) theme %p...\n", resID, force, this); + dumpToLog(); + } return NO_ERROR; } status_t ResTable::Theme::setTo(const Theme& other) { - //ALOGI("Setting theme %p from theme %p...\n", this, &other); - //dumpToLog(); - //other.dumpToLog(); + if (kDebugTableTheme) { + ALOGI("Setting theme %p from theme %p...\n", this, &other); + dumpToLog(); + other.dumpToLog(); + } if (&mTable == &other.mTable) { for (size_t i=0; i<Res_MAXPACKAGE; i++) { @@ -3169,8 +3260,10 @@ status_t ResTable::Theme::setTo(const Theme& other) } } - //ALOGI("Final theme:"); - //dumpToLog(); + if (kDebugTableTheme) { + ALOGI("Final theme:"); + dumpToLog(); + } return NO_ERROR; } @@ -3187,23 +3280,33 @@ ssize_t ResTable::Theme::getAttribute(uint32_t resID, Res_value* outValue, const uint32_t t = Res_GETTYPE(resID); const uint32_t e = Res_GETENTRY(resID); - TABLE_THEME(ALOGI("Looking up attr 0x%08x in theme %p", resID, this)); + if (kDebugTableTheme) { + ALOGI("Looking up attr 0x%08x in theme %p", resID, this); + } if (p >= 0) { const package_info* const pi = mPackages[p]; - TABLE_THEME(ALOGI("Found package: %p", pi)); + if (kDebugTableTheme) { + ALOGI("Found package: %p", pi); + } if (pi != NULL) { - TABLE_THEME(ALOGI("Desired type index is %ld in avail %d", t, Res_MAXTYPE + 1)); + if (kDebugTableTheme) { + ALOGI("Desired type index is %zd in avail %zu", t, Res_MAXTYPE + 1); + } if (t <= Res_MAXTYPE) { const type_info& ti = pi->types[t]; - TABLE_THEME(ALOGI("Desired entry index is %ld in avail %d", e, ti.numEntries)); + if (kDebugTableTheme) { + ALOGI("Desired entry index is %u in avail %zu", e, ti.numEntries); + } if (e < ti.numEntries) { const theme_entry& te = ti.entries[e]; if (outTypeSpecFlags != NULL) { *outTypeSpecFlags |= te.typeSpecFlags; } - TABLE_THEME(ALOGI("Theme value: type=0x%x, data=0x%08x", - te.value.dataType, te.value.data)); + if (kDebugTableTheme) { + ALOGI("Theme value: type=0x%x, data=0x%08x", + te.value.dataType, te.value.data); + } const uint8_t type = te.value.dataType; if (type == Res_value::TYPE_ATTRIBUTE) { if (cnt > 0) { @@ -3237,8 +3340,10 @@ ssize_t ResTable::Theme::resolveAttributeReference(Res_value* inOutValue, if (inOutValue->dataType == Res_value::TYPE_ATTRIBUTE) { uint32_t newTypeSpecFlags; blockIndex = getAttribute(inOutValue->data, inOutValue, &newTypeSpecFlags); - TABLE_THEME(ALOGI("Resolving attr reference: blockIndex=%d, type=0x%x, data=%p\n", - (int)blockIndex, (int)inOutValue->dataType, (void*)inOutValue->data)); + if (kDebugTableTheme) { + ALOGI("Resolving attr reference: blockIndex=%d, type=0x%x, data=0x%x\n", + (int)blockIndex, (int)inOutValue->dataType, inOutValue->data); + } if (inoutTypeSpecFlags != NULL) *inoutTypeSpecFlags |= newTypeSpecFlags; //printf("Retrieved attribute new type=0x%x\n", inOutValue->dataType); if (blockIndex < 0) { @@ -3277,7 +3382,9 @@ ResTable::ResTable() { memset(&mParams, 0, sizeof(mParams)); memset(mPackageMap, 0, sizeof(mPackageMap)); - //ALOGI("Creating ResTable %p\n", this); + if (kDebugTableSuperNoisy) { + ALOGI("Creating ResTable %p\n", this); + } } ResTable::ResTable(const void* data, size_t size, const int32_t cookie, bool copyData) @@ -3287,12 +3394,16 @@ ResTable::ResTable(const void* data, size_t size, const int32_t cookie, bool cop memset(mPackageMap, 0, sizeof(mPackageMap)); addInternal(data, size, NULL, 0, cookie, copyData); LOG_FATAL_IF(mError != NO_ERROR, "Error parsing resource table"); - //ALOGI("Creating ResTable %p\n", this); + if (kDebugTableSuperNoisy) { + ALOGI("Creating ResTable %p\n", this); + } } ResTable::~ResTable() { - //ALOGI("Destroying ResTable in %p\n", this); + if (kDebugTableSuperNoisy) { + ALOGI("Destroying ResTable in %p\n", this); + } uninit(); } @@ -3421,9 +3532,10 @@ status_t ResTable::addInternal(const void* data, size_t dataSize, const void* id const bool notDeviceEndian = htods(0xf0) != 0xf0; - LOAD_TABLE_NOISY( - ALOGV("Adding resources to ResTable: data=%p, size=0x%x, cookie=%d, copy=%d " - "idmap=%p\n", data, dataSize, cookie, copyData, idmap)); + if (kDebugLoadTableNoisy) { + ALOGV("Adding resources to ResTable: data=%p, size=%zu, cookie=%d, copy=%d " + "idmap=%p\n", data, dataSize, cookie, copyData, idmapData); + } if (copyData || notDeviceEndian) { header->ownedData = malloc(dataSize); @@ -3436,9 +3548,13 @@ status_t ResTable::addInternal(const void* data, size_t dataSize, const void* id header->header = (const ResTable_header*)data; header->size = dtohl(header->header->header.size); - //ALOGI("Got size 0x%x, again size 0x%x, raw size 0x%x\n", header->size, - // dtohl(header->header->header.size), header->header->header.size); - LOAD_TABLE_NOISY(ALOGV("Loading ResTable @%p:\n", header->header)); + if (kDebugLoadTableSuperNoisy) { + ALOGI("Got size %zu, again size 0x%x, raw size 0x%x\n", header->size, + dtohl(header->header->header.size), header->header->header.size); + } + if (kDebugLoadTableNoisy) { + ALOGV("Loading ResTable @%p:\n", header->header); + } if (dtohs(header->header->header.headerSize) > header->size || header->size > dataSize) { ALOGW("Bad resource table: header size 0x%x or total size 0x%x is larger than data size 0x%x\n", @@ -3466,9 +3582,11 @@ status_t ResTable::addInternal(const void* data, size_t dataSize, const void* id if (err != NO_ERROR) { return (mError=err); } - TABLE_NOISY(ALOGV("Chunk: type=0x%x, headerSize=0x%x, size=0x%x, pos=%p\n", - dtohs(chunk->type), dtohs(chunk->headerSize), dtohl(chunk->size), - (void*)(((const uint8_t*)chunk) - ((const uint8_t*)header->header)))); + if (kDebugTableNoisy) { + ALOGV("Chunk: type=0x%x, headerSize=0x%x, size=0x%x, pos=%p\n", + dtohs(chunk->type), dtohs(chunk->headerSize), dtohl(chunk->size), + (void*)(((const uint8_t*)chunk) - ((const uint8_t*)header->header))); + } const size_t csize = dtohl(chunk->size); const uint16_t ctype = dtohs(chunk->type); if (ctype == RES_STRING_POOL_TYPE) { @@ -3512,7 +3630,9 @@ status_t ResTable::addInternal(const void* data, size_t dataSize, const void* id ALOGW("No string values found in resource table!"); } - TABLE_NOISY(ALOGV("Returning from add with mError=%d\n", mError)); + if (kDebugTableNoisy) { + ALOGV("Returning from add with mError=%d\n", mError); + } return mError; } @@ -3674,15 +3794,16 @@ ssize_t ResTable::getResource(uint32_t resID, Res_value* outValue, bool mayBeBag return BAD_VALUE; } - TABLE_NOISY(size_t len; - printf("Found value: pkg=%d, type=%d, str=%s, int=%d\n", - entry.package->header->index, - outValue->dataType, - outValue->dataType == Res_value::TYPE_STRING - ? String8(entry.package->header->values.stringAt( - outValue->data, &len)).string() - : "", - outValue->data)); + if (kDebugTableNoisy) { + size_t len; + printf("Found value: pkg=%zu, type=%d, str=%s, int=%d\n", + entry.package->header->index, + outValue->dataType, + outValue->dataType == Res_value::TYPE_STRING ? + String8(entry.package->header->values.stringAt(outValue->data, &len)).string() : + "", + outValue->data); + } if (outSpecFlags != NULL) { *outSpecFlags = entry.specFlags; @@ -3703,15 +3824,16 @@ ssize_t ResTable::resolveReference(Res_value* value, ssize_t blockIndex, while (blockIndex >= 0 && value->dataType == Res_value::TYPE_REFERENCE && value->data != 0 && count < 20) { if (outLastRef) *outLastRef = value->data; - uint32_t lastRef = value->data; uint32_t newFlags = 0; const ssize_t newIndex = getResource(value->data, value, true, 0, &newFlags, outConfig); if (newIndex == BAD_INDEX) { return BAD_INDEX; } - TABLE_THEME(ALOGI("Resolving reference %p: newIndex=%d, type=0x%x, data=%p\n", - (void*)lastRef, (int)newIndex, (int)value->dataType, (void*)value->data)); + if (kDebugTableTheme) { + ALOGI("Resolving reference 0x%x: newIndex=%d, type=0x%x, data=0x%x\n", + value->data, (int)newIndex, (int)value->dataType, value->data); + } //printf("Getting reference 0x%08x: newIndex=%d\n", value->data, newIndex); if (inoutTypeSpecFlags != NULL) *inoutTypeSpecFlags |= newFlags; if (newIndex < 0) { @@ -3818,7 +3940,9 @@ ssize_t ResTable::getBagLocked(uint32_t resID, const bag_entry** outBag, *outTypeSpecFlags = set->typeSpecFlags; } *outBag = (bag_entry*)(set+1); - //ALOGI("Found existing bag for: %p\n", (void*)resID); + if (kDebugTableSuperNoisy) { + ALOGI("Found existing bag for: 0x%x\n", resID); + } return set->numAttrs; } ALOGW("Attempt to retrieve bag 0x%08x which is invalid or in a cycle.", @@ -3844,7 +3968,9 @@ ssize_t ResTable::getBagLocked(uint32_t resID, const bag_entry** outBag, // Mark that we are currently working on this one. typeSet[e] = (bag_set*)0xFFFFFFFF; - TABLE_NOISY(ALOGI("Building bag: %p\n", (void*)resID)); + if (kDebugTableNoisy) { + ALOGI("Building bag: %x\n", resID); + } // Now collect all bag attributes Entry entry; @@ -3861,13 +3987,13 @@ ssize_t ResTable::getBagLocked(uint32_t resID, const bag_entry** outBag, size_t N = count; - TABLE_NOISY(ALOGI("Found map: size=%p parent=%p count=%d\n", - entrySize, parent, count)); + if (kDebugTableNoisy) { + ALOGI("Found map: size=%x parent=%x count=%d\n", entrySize, parent, count); // If this map inherits from another, we need to start // with its parent's values. Otherwise start out empty. - TABLE_NOISY(printf("Creating new bag, entrySize=0x%08x, parent=0x%08x\n", - entrySize, parent)); + ALOGI("Creating new bag, entrySize=0x%08x, parent=0x%08x\n", entrySize, parent); + } // This is what we are building. bag_set* set = NULL; @@ -3896,9 +4022,13 @@ ssize_t ResTable::getBagLocked(uint32_t resID, const bag_entry** outBag, if (NP > 0) { memcpy(set+1, parentBag, NP*sizeof(bag_entry)); set->numAttrs = NP; - TABLE_NOISY(ALOGI("Initialized new bag with %d inherited attributes.\n", NP)); + if (kDebugTableNoisy) { + ALOGI("Initialized new bag with %zd inherited attributes.\n", NP); + } } else { - TABLE_NOISY(ALOGI("Initialized new bag with no inherited attributes.\n")); + if (kDebugTableNoisy) { + ALOGI("Initialized new bag with no inherited attributes.\n"); + } set->numAttrs = 0; } set->availAttrs = NT; @@ -3922,10 +4052,13 @@ ssize_t ResTable::getBagLocked(uint32_t resID, const bag_entry** outBag, bag_entry* entries = (bag_entry*)(set+1); size_t curEntry = 0; uint32_t pos = 0; - TABLE_NOISY(ALOGI("Starting with set %p, entries=%p, avail=%d\n", - set, entries, set->availAttrs)); + if (kDebugTableNoisy) { + ALOGI("Starting with set %p, entries=%p, avail=%zu\n", set, entries, set->availAttrs); + } while (pos < count) { - TABLE_NOISY(printf("Now at %p\n", (void*)curOff)); + if (kDebugTableNoisy) { + ALOGI("Now at %p\n", (void*)curOff); + } if (curOff > (dtohl(entry.type->header.size)-sizeof(ResTable_map))) { ALOGW("ResTable_map at %d is beyond type chunk data %d", @@ -3950,8 +4083,10 @@ ssize_t ResTable::getBagLocked(uint32_t resID, const bag_entry** outBag, uint32_t oldName = 0; while ((isInside=(curEntry < set->numAttrs)) && (oldName=entries[curEntry].map.name.ident) < newName) { - TABLE_NOISY(printf("#%d: Keeping existing attribute: 0x%08x\n", - curEntry, entries[curEntry].map.name.ident)); + if (kDebugTableNoisy) { + ALOGI("#%zu: Keeping existing attribute: 0x%08x\n", + curEntry, entries[curEntry].map.name.ident); + } curEntry++; } @@ -3968,8 +4103,10 @@ ssize_t ResTable::getBagLocked(uint32_t resID, const bag_entry** outBag, } set->availAttrs = newAvail; entries = (bag_entry*)(set+1); - TABLE_NOISY(printf("Reallocated set %p, entries=%p, avail=%d\n", - set, entries, set->availAttrs)); + if (kDebugTableNoisy) { + ALOGI("Reallocated set %p, entries=%p, avail=%zu\n", + set, entries, set->availAttrs); + } } if (isInside) { // Going in the middle, need to make space. @@ -3977,11 +4114,13 @@ ssize_t ResTable::getBagLocked(uint32_t resID, const bag_entry** outBag, sizeof(bag_entry)*(set->numAttrs-curEntry)); set->numAttrs++; } - TABLE_NOISY(printf("#%d: Inserting new attribute: 0x%08x\n", - curEntry, newName)); + if (kDebugTableNoisy) { + ALOGI("#%zu: Inserting new attribute: 0x%08x\n", curEntry, newName); + } } else { - TABLE_NOISY(printf("#%d: Replacing existing attribute: 0x%08x\n", - curEntry, oldName)); + if (kDebugTableNoisy) { + ALOGI("#%zu: Replacing existing attribute: 0x%08x\n", curEntry, oldName); + } } bag_entry* cur = entries+curEntry; @@ -3995,9 +4134,11 @@ ssize_t ResTable::getBagLocked(uint32_t resID, const bag_entry** outBag, return UNKNOWN_ERROR; } - TABLE_NOISY(printf("Setting entry #%d %p: block=%d, name=0x%08x, type=%d, data=0x%08x\n", - curEntry, cur, cur->stringBlock, cur->map.name.ident, - cur->map.value.dataType, cur->map.value.data)); + if (kDebugTableNoisy) { + ALOGI("Setting entry #%zu %p: block=%zd, name=0x%08d, type=%d, data=0x%08x\n", + curEntry, cur, cur->stringBlock, cur->map.name.ident, + cur->map.value.dataType, cur->map.value.data); + } // On to the next! curEntry++; @@ -4017,7 +4158,9 @@ ssize_t ResTable::getBagLocked(uint32_t resID, const bag_entry** outBag, *outTypeSpecFlags = set->typeSpecFlags; } *outBag = (bag_entry*)(set+1); - TABLE_NOISY(ALOGI("Returning %d attrs\n", set->numAttrs)); + if (kDebugTableNoisy) { + ALOGI("Returning %zu attrs\n", set->numAttrs); + } return set->numAttrs; } return BAD_INDEX; @@ -4026,10 +4169,14 @@ ssize_t ResTable::getBagLocked(uint32_t resID, const bag_entry** outBag, void ResTable::setParameters(const ResTable_config* params) { mLock.lock(); - TABLE_GETENTRY(ALOGI("Setting parameters: %s\n", params->toString().string())); + if (kDebugTableGetEntry) { + ALOGI("Setting parameters: %s\n", params->toString().string()); + } mParams = *params; for (size_t i=0; i<mPackageGroups.size(); i++) { - TABLE_NOISY(ALOGI("CLEARING BAGS FOR GROUP %d!", i)); + if (kDebugTableNoisy) { + ALOGI("CLEARING BAGS FOR GROUP %zu!", i); + } mPackageGroups[i]->clearBagCache(); } mLock.unlock(); @@ -4067,7 +4214,9 @@ uint32_t ResTable::identifierForName(const char16_t* name, size_t nameLen, size_t packageLen, uint32_t* outTypeSpecFlags) const { - TABLE_SUPER_NOISY(printf("Identifier for name: error=%d\n", mError)); + if (kDebugTableSuperNoisy) { + printf("Identifier for name: error=%d\n", mError); + } // Check for internal resource identifier as the very first thing, so // that we will always find them even when there are no resources. @@ -4160,10 +4309,12 @@ nope: } nameLen = nameEnd-name; - TABLE_NOISY(printf("Looking for identifier: type=%s, name=%s, package=%s\n", - String8(type, typeLen).string(), - String8(name, nameLen).string(), - String8(package, packageLen).string())); + if (kDebugTableNoisy) { + printf("Looking for identifier: type=%s, name=%s, package=%s\n", + String8(type, typeLen).string(), + String8(name, nameLen).string(), + String8(package, packageLen).string()); + } const size_t NG = mPackageGroups.size(); for (size_t ig=0; ig<NG; ig++) { @@ -4171,7 +4322,9 @@ nope: if (strzcmp16(package, packageLen, group->name.string(), group->name.size())) { - TABLE_NOISY(printf("Skipping package group: %s\n", String8(group->name).string())); + if (kDebugTableNoisy) { + printf("Skipping package group: %s\n", String8(group->name).string()); + } continue; } @@ -4186,8 +4339,10 @@ nope: const TypeList& typeList = group->types[ti]; if (typeList.isEmpty()) { - TABLE_NOISY(printf("Expected type structure not found in package %s for index %d\n", - String8(group->name).string(), ti)); + if (kDebugTableNoisy) { + ALOGI("Expected type structure not found in package %s for index %zd\n", + String8(group->name).string(), ti); + } continue; } @@ -4686,9 +4841,11 @@ bool ResTable::stringToValue(Res_value* outValue, String16* outString, rid = Res_MAKEID( accessor->getRemappedPackage(Res_GETPACKAGE(rid)), Res_GETTYPE(rid), Res_GETENTRY(rid)); - TABLE_NOISY(printf("Incl %s:%s/%s: 0x%08x\n", - String8(package).string(), String8(type).string(), - String8(name).string(), rid)); + if (kDebugTableNoisy) { + ALOGI("Incl %s:%s/%s: 0x%08x\n", + String8(package).string(), String8(type).string(), + String8(name).string(), rid); + } } uint32_t packageId = Res_GETPACKAGE(rid) + 1; @@ -4703,9 +4860,11 @@ bool ResTable::stringToValue(Res_value* outValue, String16* outString, uint32_t rid = accessor->getCustomResourceWithCreation(package, type, name, createIfNotFound); if (rid != 0) { - TABLE_NOISY(printf("Pckg %s:%s/%s: 0x%08x\n", - String8(package).string(), String8(type).string(), - String8(name).string(), rid)); + if (kDebugTableNoisy) { + ALOGI("Pckg %s:%s/%s: 0x%08x\n", + String8(package).string(), String8(type).string(), + String8(name).string(), rid); + } uint32_t packageId = Res_GETPACKAGE(rid) + 1; if (packageId == 0x00) { outValue->data = rid; @@ -5508,8 +5667,6 @@ status_t ResTable::getEntry( } // Check if there is the desired entry in this type. - const uint8_t* const end = reinterpret_cast<const uint8_t*>(thisType) - + dtohl(thisType->header.size); const uint32_t* const eindex = reinterpret_cast<const uint32_t*>( reinterpret_cast<const uint8_t*>(thisType) + dtohs(thisType->header.headerSize)); @@ -5698,9 +5855,11 @@ status_t ResTable::parsePackage(const ResTable_package* const pkg, const uint8_t* endPos = ((const uint8_t*)pkg) + dtohs(pkg->header.size); while (((const uint8_t*)chunk) <= (endPos-sizeof(ResChunk_header)) && ((const uint8_t*)chunk) <= (endPos-dtohl(chunk->size))) { - TABLE_NOISY(ALOGV("PackageChunk: type=0x%x, headerSize=0x%x, size=0x%x, pos=%p\n", - dtohs(chunk->type), dtohs(chunk->headerSize), dtohl(chunk->size), - (void*)(((const uint8_t*)chunk) - ((const uint8_t*)header->header)))); + if (kDebugTableNoisy) { + ALOGV("PackageChunk: type=0x%x, headerSize=0x%x, size=0x%x, pos=%p\n", + dtohs(chunk->type), dtohs(chunk->headerSize), dtohl(chunk->size), + (void*)(((const uint8_t*)chunk) - ((const uint8_t*)header->header))); + } const size_t csize = dtohl(chunk->size); const uint16_t ctype = dtohs(chunk->type); if (ctype == RES_TABLE_TYPE_SPEC_TYPE) { @@ -5714,11 +5873,13 @@ status_t ResTable::parsePackage(const ResTable_package* const pkg, const size_t typeSpecSize = dtohl(typeSpec->header.size); const size_t newEntryCount = dtohl(typeSpec->entryCount); - LOAD_TABLE_NOISY(printf("TypeSpec off %p: type=0x%x, headerSize=0x%x, size=%p\n", - (void*)(base-(const uint8_t*)chunk), - dtohs(typeSpec->header.type), - dtohs(typeSpec->header.headerSize), - (void*)typeSpecSize)); + if (kDebugLoadTableNoisy) { + ALOGI("TypeSpec off %p: type=0x%x, headerSize=0x%x, size=%p\n", + (void*)(base-(const uint8_t*)chunk), + dtohs(typeSpec->header.type), + dtohs(typeSpec->header.headerSize), + (void*)typeSpecSize); + } // look for block overrun or int overflow when multiplying by 4 if ((dtohl(typeSpec->entryCount) > (INT32_MAX/sizeof(uint32_t)) || dtohs(typeSpec->header.headerSize)+(sizeof(uint32_t)*newEntryCount) @@ -5776,13 +5937,14 @@ status_t ResTable::parsePackage(const ResTable_package* const pkg, const uint32_t typeSize = dtohl(type->header.size); const size_t newEntryCount = dtohl(type->entryCount); - LOAD_TABLE_NOISY(printf("Type off %p: type=0x%x, headerSize=0x%x, size=%p\n", - (void*)(base-(const uint8_t*)chunk), - dtohs(type->header.type), - dtohs(type->header.headerSize), - (void*)typeSize)); - if (dtohs(type->header.headerSize)+(sizeof(uint32_t)*newEntryCount) - > typeSize) { + if (kDebugLoadTableNoisy) { + printf("Type off %p: type=0x%x, headerSize=0x%x, size=%u\n", + (void*)(base-(const uint8_t*)chunk), + dtohs(type->header.type), + dtohs(type->header.headerSize), + typeSize); + } + if (dtohs(type->header.headerSize)+(sizeof(uint32_t)*newEntryCount) > typeSize) { ALOGW("ResTable_type entry index to %p extends beyond chunk end 0x%x.", (void*)(dtohs(type->header.headerSize) + (sizeof(uint32_t)*newEntryCount)), typeSize); @@ -5828,11 +5990,12 @@ status_t ResTable::parsePackage(const ResTable_package* const pkg, t->configs.add(type); - TABLE_GETENTRY( + if (kDebugTableGetEntry) { ResTable_config thisConfig; thisConfig.copyFromDtoH(type->config); - ALOGI("Adding config to type %d: %s\n", - type->id, thisConfig.toString().string())); + ALOGI("Adding config to type %d: %s\n", type->id, + thisConfig.toString().string()); + } } else { ALOGV("Skipping empty ResTable_type for type %d", type->id); } @@ -5893,8 +6056,10 @@ status_t DynamicRefTable::load(const ResTable_lib_header* const header) uint32_t packageId = dtohl(entry->packageId); char16_t tmpName[sizeof(entry->packageName) / sizeof(char16_t)]; strcpy16_dtoh(tmpName, entry->packageName, sizeof(entry->packageName) / sizeof(char16_t)); - LIB_NOISY(ALOGV("Found lib entry %s with id %d\n", String8(tmpName).string(), - dtohl(entry->packageId))); + if (kDebugLibNoisy) { + ALOGV("Found lib entry %s with id %d\n", String8(tmpName).string(), + dtohl(entry->packageId)); + } if (packageId >= 256) { ALOGE("Bad package id 0x%08x", packageId); return UNKNOWN_ERROR; @@ -6074,7 +6239,7 @@ status_t ResTable::createIdmap(const ResTable& overlay, if (Res_GETTYPE(overlayResID) + 1 != static_cast<size_t>(typeMap.overlayTypeId)) { ALOGE("idmap: can't mix type ids in entry map. Resource 0x%08x maps to 0x%08x" - " but entries should map to resources of type %02x", + " but entries should map to resources of type %02zx", resID, overlayResID, typeMap.overlayTypeId); return BAD_TYPE; } @@ -6401,9 +6566,6 @@ void ResTable::print(bool inclValues) const continue; } for (size_t entryIndex=0; entryIndex<entryCount; entryIndex++) { - - const uint8_t* const end = ((const uint8_t*)type) - + dtohl(type->header.size); const uint32_t* const eindex = (const uint32_t*) (((const uint8_t*)type) + dtohs(type->header.headerSize)); diff --git a/libs/androidfw/StreamingZipInflater.cpp b/libs/androidfw/StreamingZipInflater.cpp index 1dfec23cbe63..b39b5f0b8b36 100644 --- a/libs/androidfw/StreamingZipInflater.cpp +++ b/libs/androidfw/StreamingZipInflater.cpp @@ -41,6 +41,8 @@ _rc; }) #endif +static const bool kIsDebug = false; + static inline size_t min_of(size_t a, size_t b) { return (a < b) ? a : b; } using namespace android; @@ -209,7 +211,9 @@ int StreamingZipInflater::readNextChunk() { size_t toRead = min_of(mInBufSize, mInTotalSize - mInNextChunkOffset); if (toRead > 0) { ssize_t didRead = TEMP_FAILURE_RETRY(::read(mFd, mInBuf, toRead)); - //ALOGV("Reading input chunk, size %08x didread %08x", toRead, didRead); + if (kIsDebug) { + ALOGV("Reading input chunk, size %08zx didread %08zx", toRead, didRead); + } if (didRead < 0) { ALOGE("Error reading asset data: %s", strerror(errno)); return didRead; diff --git a/libs/androidfw/ZipFileRO.cpp b/libs/androidfw/ZipFileRO.cpp index 5f6e831a0200..ef0d07295120 100644 --- a/libs/androidfw/ZipFileRO.cpp +++ b/libs/androidfw/ZipFileRO.cpp @@ -34,14 +34,6 @@ #include <assert.h> #include <unistd.h> -/* - * We must open binary files using open(path, ... | O_BINARY) under Windows. - * Otherwise strange read errors will happen. - */ -#ifndef O_BINARY -# define O_BINARY 0 -#endif - using namespace android; class _ZipEntryRO { diff --git a/libs/androidfw/tests/Android.mk b/libs/androidfw/tests/Android.mk index 597250a3d290..8aaa887a90ea 100644 --- a/libs/androidfw/tests/Android.mk +++ b/libs/androidfw/tests/Android.mk @@ -37,12 +37,16 @@ include $(CLEAR_VARS) LOCAL_MODULE := libandroidfw_tests +LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code +# gtest is broken. +LOCAL_CFLAGS += -Wno-unnamed-type-template-args + LOCAL_SRC_FILES := $(testFiles) LOCAL_STATIC_LIBRARIES := \ libandroidfw \ libutils \ libcutils \ - liblog + liblog include $(BUILD_HOST_NATIVE_TEST) @@ -54,6 +58,10 @@ include $(CLEAR_VARS) LOCAL_MODULE := libandroidfw_tests +LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code +# gtest is broken. +LOCAL_CFLAGS += -Wno-unnamed-type-template-args + LOCAL_SRC_FILES := $(testFiles) \ BackupData_test.cpp \ ObbFile_test.cpp diff --git a/libs/hwui/AmbientShadow.cpp b/libs/hwui/AmbientShadow.cpp index cb3a002b07d5..2d1cf78dcc77 100644 --- a/libs/hwui/AmbientShadow.cpp +++ b/libs/hwui/AmbientShadow.cpp @@ -121,7 +121,7 @@ inline void computeBufferSize(int* totalVertexCount, int* totalIndexCount, *totalUmbraCount = 0; if (!isCasterOpaque) { // Add the centroid if occluder is translucent. - *totalVertexCount++; + (*totalVertexCount)++; *totalIndexCount += 2 * innerVertexCount + 1; *totalUmbraCount = innerVertexCount; } diff --git a/libs/hwui/Android.mk b/libs/hwui/Android.mk index 5b74addb3e89..a09355b38cfd 100644 --- a/libs/hwui/Android.mk +++ b/libs/hwui/Android.mk @@ -13,107 +13,110 @@ LOCAL_CLANG_CFLAGS += \ # Only build libhwui when USE_OPENGL_RENDERER is # defined in the current device/board configuration ifeq ($(USE_OPENGL_RENDERER),true) - LOCAL_SRC_FILES := \ - utils/Blur.cpp \ - utils/GLUtils.cpp \ - utils/SortedListImpl.cpp \ - thread/TaskManager.cpp \ - font/CacheTexture.cpp \ - font/Font.cpp \ - AmbientShadow.cpp \ - AnimationContext.cpp \ - Animator.cpp \ - AnimatorManager.cpp \ - AssetAtlas.cpp \ - DamageAccumulator.cpp \ - FontRenderer.cpp \ - GammaFontRenderer.cpp \ - Caches.cpp \ - DisplayList.cpp \ - DeferredDisplayList.cpp \ - DeferredLayerUpdater.cpp \ - DisplayListLogBuffer.cpp \ - DisplayListRenderer.cpp \ - Dither.cpp \ - DrawProfiler.cpp \ - Extensions.cpp \ - FboCache.cpp \ - GradientCache.cpp \ - Image.cpp \ - Interpolator.cpp \ - Layer.cpp \ - LayerCache.cpp \ - LayerRenderer.cpp \ - Matrix.cpp \ - OpenGLRenderer.cpp \ - Patch.cpp \ - PatchCache.cpp \ - PathCache.cpp \ - PathTessellator.cpp \ - PixelBuffer.cpp \ - Program.cpp \ - ProgramCache.cpp \ - RenderBufferCache.cpp \ - RenderNode.cpp \ - RenderProperties.cpp \ - RenderState.cpp \ - ResourceCache.cpp \ - ShadowTessellator.cpp \ - SkiaShader.cpp \ - Snapshot.cpp \ - SpotShadow.cpp \ - StatefulBaseRenderer.cpp \ - Stencil.cpp \ - TessellationCache.cpp \ - Texture.cpp \ - TextureCache.cpp \ - TextDropShadowCache.cpp + LOCAL_SRC_FILES := \ + utils/Blur.cpp \ + utils/GLUtils.cpp \ + utils/SortedListImpl.cpp \ + thread/TaskManager.cpp \ + font/CacheTexture.cpp \ + font/Font.cpp \ + AmbientShadow.cpp \ + AnimationContext.cpp \ + Animator.cpp \ + AnimatorManager.cpp \ + AssetAtlas.cpp \ + DamageAccumulator.cpp \ + FontRenderer.cpp \ + GammaFontRenderer.cpp \ + Caches.cpp \ + DisplayList.cpp \ + DeferredDisplayList.cpp \ + DeferredLayerUpdater.cpp \ + DisplayListLogBuffer.cpp \ + DisplayListRenderer.cpp \ + Dither.cpp \ + DrawProfiler.cpp \ + Extensions.cpp \ + FboCache.cpp \ + GradientCache.cpp \ + Image.cpp \ + Interpolator.cpp \ + Layer.cpp \ + LayerCache.cpp \ + LayerRenderer.cpp \ + Matrix.cpp \ + OpenGLRenderer.cpp \ + Patch.cpp \ + PatchCache.cpp \ + PathCache.cpp \ + PathTessellator.cpp \ + PixelBuffer.cpp \ + Program.cpp \ + ProgramCache.cpp \ + RenderBufferCache.cpp \ + RenderNode.cpp \ + RenderProperties.cpp \ + RenderState.cpp \ + ResourceCache.cpp \ + ShadowTessellator.cpp \ + SkiaShader.cpp \ + Snapshot.cpp \ + SpotShadow.cpp \ + StatefulBaseRenderer.cpp \ + Stencil.cpp \ + TessellationCache.cpp \ + Texture.cpp \ + TextureCache.cpp \ + TextDropShadowCache.cpp # RenderThread stuff - LOCAL_SRC_FILES += \ - renderthread/CanvasContext.cpp \ - renderthread/DrawFrameTask.cpp \ - renderthread/EglManager.cpp \ - renderthread/RenderProxy.cpp \ - renderthread/RenderTask.cpp \ - renderthread/RenderThread.cpp \ - renderthread/TimeLord.cpp + LOCAL_SRC_FILES += \ + renderthread/CanvasContext.cpp \ + renderthread/DrawFrameTask.cpp \ + renderthread/EglManager.cpp \ + renderthread/RenderProxy.cpp \ + renderthread/RenderTask.cpp \ + renderthread/RenderThread.cpp \ + renderthread/TimeLord.cpp - intermediates := $(call intermediates-dir-for,STATIC_LIBRARIES,libRS,TARGET,) + intermediates := $(call intermediates-dir-for,STATIC_LIBRARIES,libRS,TARGET,) - LOCAL_C_INCLUDES += \ - external/skia/src/core + LOCAL_C_INCLUDES += \ + external/skia/src/core - LOCAL_CFLAGS += -DUSE_OPENGL_RENDERER -DEGL_EGLEXT_PROTOTYPES -DGL_GLEXT_PROTOTYPES - LOCAL_CFLAGS += -Wno-unused-parameter - LOCAL_MODULE_CLASS := SHARED_LIBRARIES - LOCAL_SHARED_LIBRARIES := liblog libcutils libutils libEGL libGLESv2 libskia libui libgui - LOCAL_MODULE := libhwui - LOCAL_MODULE_TAGS := optional + LOCAL_CFLAGS += -DUSE_OPENGL_RENDERER -DEGL_EGLEXT_PROTOTYPES -DGL_GLEXT_PROTOTYPES + LOCAL_CFLAGS += -Wno-unused-parameter + LOCAL_MODULE_CLASS := SHARED_LIBRARIES + LOCAL_SHARED_LIBRARIES := liblog libcutils libutils libEGL libGLESv2 libskia libui libgui + LOCAL_MODULE := libhwui + LOCAL_MODULE_TAGS := optional - ifneq (false,$(ANDROID_ENABLE_RENDERSCRIPT)) - LOCAL_CFLAGS += -DANDROID_ENABLE_RENDERSCRIPT - LOCAL_SHARED_LIBRARIES += libRS libRScpp - LOCAL_C_INCLUDES += \ - $(intermediates) \ - frameworks/rs/cpp \ - frameworks/rs \ + ifneq (false,$(ANDROID_ENABLE_RENDERSCRIPT)) + LOCAL_CFLAGS += -DANDROID_ENABLE_RENDERSCRIPT + LOCAL_SHARED_LIBRARIES += libRS libRScpp + LOCAL_C_INCLUDES += \ + $(intermediates) \ + frameworks/rs/cpp \ + frameworks/rs \ - endif + endif - ifndef HWUI_COMPILE_SYMBOLS - LOCAL_CFLAGS += -fvisibility=hidden - endif + ifndef HWUI_COMPILE_SYMBOLS + LOCAL_CFLAGS += -fvisibility=hidden + endif - ifdef HWUI_COMPILE_FOR_PERF - LOCAL_CFLAGS += -fno-omit-frame-pointer -marm -mapcs - endif + ifdef HWUI_COMPILE_FOR_PERF + # TODO: Non-arm? + LOCAL_CFLAGS += -fno-omit-frame-pointer -marm -mapcs + endif - # Defaults for ATRACE_TAG and LOG_TAG for libhwui - LOCAL_CFLAGS += -DATRACE_TAG=ATRACE_TAG_VIEW -DLOG_TAG=\"OpenGLRenderer\" + # Defaults for ATRACE_TAG and LOG_TAG for libhwui + LOCAL_CFLAGS += -DATRACE_TAG=ATRACE_TAG_VIEW -DLOG_TAG=\"OpenGLRenderer\" - include external/stlport/libstlport.mk - include $(BUILD_SHARED_LIBRARY) + LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code - include $(call all-makefiles-under,$(LOCAL_PATH)) + include external/stlport/libstlport.mk + include $(BUILD_SHARED_LIBRARY) + + include $(call all-makefiles-under,$(LOCAL_PATH)) endif diff --git a/libs/hwui/DeferredDisplayList.cpp b/libs/hwui/DeferredDisplayList.cpp index a998594747d0..fbe2d3946979 100644 --- a/libs/hwui/DeferredDisplayList.cpp +++ b/libs/hwui/DeferredDisplayList.cpp @@ -333,7 +333,7 @@ private: class RestoreToCountBatch : public Batch { public: RestoreToCountBatch(const StateOp* op, const DeferredDisplayState* state, int restoreCount) : - mOp(op), mState(state), mRestoreCount(restoreCount) {} + mState(state), mRestoreCount(restoreCount) {} virtual status_t replay(OpenGLRenderer& renderer, Rect& dirty, int index) { DEFER_LOGD("batch %p restoring to count %d", this, mRestoreCount); @@ -345,7 +345,6 @@ public: private: // we use the state storage for the RestoreToCountOp, but don't replay the op itself - const StateOp* mOp; const DeferredDisplayState* mState; /* @@ -700,7 +699,6 @@ void DeferredDisplayList::discardDrawingBatches(const unsigned int maxIndex) { for (unsigned int i = mEarliestUnclearedIndex; i <= maxIndex; i++) { // leave deferred state ops alone for simplicity (empty save restore pairs may now exist) if (mBatches[i] && mBatches[i]->purelyDrawBatch()) { - DrawBatch* b = (DrawBatch*) mBatches[i]; delete mBatches[i]; mBatches.replaceAt(NULL, i); } diff --git a/libs/hwui/DeferredDisplayList.h b/libs/hwui/DeferredDisplayList.h index 8a015b21cb47..f7f30b101bc2 100644 --- a/libs/hwui/DeferredDisplayList.h +++ b/libs/hwui/DeferredDisplayList.h @@ -79,7 +79,7 @@ public: }; class DeferredDisplayList { - friend class DeferStateStruct; // used to give access to allocator + friend struct DeferStateStruct; // used to give access to allocator public: DeferredDisplayList(const Rect& bounds, bool avoidOverdraw = true) : mBounds(bounds), mAvoidOverdraw(avoidOverdraw) { diff --git a/libs/hwui/DisplayList.h b/libs/hwui/DisplayList.h index dea109cd57b7..657632dbeda9 100644 --- a/libs/hwui/DisplayList.h +++ b/libs/hwui/DisplayList.h @@ -91,8 +91,7 @@ private: std::vector<SkPath> mTempPaths; }; -class DeferStateStruct : public PlaybackStateStruct { -public: +struct DeferStateStruct : public PlaybackStateStruct { DeferStateStruct(DeferredDisplayList& deferredList, OpenGLRenderer& renderer, int replayFlags) : PlaybackStateStruct(renderer, replayFlags, &(deferredList.mAllocator)), mDeferredList(deferredList) {} diff --git a/libs/hwui/DisplayListLogBuffer.cpp b/libs/hwui/DisplayListLogBuffer.cpp index 45aaccac7abe..bc9e7bd70609 100644 --- a/libs/hwui/DisplayListLogBuffer.cpp +++ b/libs/hwui/DisplayListLogBuffer.cpp @@ -80,7 +80,7 @@ void DisplayListLogBuffer::outputCommands(FILE *file) fprintf(file, "%*s%s\n", 2 * tmpBufferPtr->level, "", tmpBufferPtr->label); - OpLog* nextOp = tmpBufferPtr++; + tmpBufferPtr++; if (tmpBufferPtr > mBufferLast) { tmpBufferPtr = mBufferFirst; } diff --git a/libs/hwui/FontRenderer.cpp b/libs/hwui/FontRenderer.cpp index 3910381d9e1a..5b5b09820670 100644 --- a/libs/hwui/FontRenderer.cpp +++ b/libs/hwui/FontRenderer.cpp @@ -358,7 +358,7 @@ void FontRenderer::cacheBitmap(const SkGlyph& glyph, CachedGlyphInfo* cachedGlyp break; } case SkMask::kBW_Format: { - uint32_t cacheX = 0, bX = 0, cacheY = 0, bY = 0; + uint32_t cacheX = 0, cacheY = 0; uint32_t row = (startY - TEXTURE_BORDER_SIZE) * cacheWidth + startX - TEXTURE_BORDER_SIZE; static const uint8_t COLORS[2] = { 0, 255 }; diff --git a/libs/hwui/Interpolator.cpp b/libs/hwui/Interpolator.cpp index ff8ff73f030f..0e62d7780780 100644 --- a/libs/hwui/Interpolator.cpp +++ b/libs/hwui/Interpolator.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// LOG_TAG is being provided by the Makefile, reset. +#ifdef LOG_TAG +#undef LOG_TAG +#endif #define LOG_TAG "Interpolator" #include "Interpolator.h" diff --git a/libs/hwui/LayerCache.cpp b/libs/hwui/LayerCache.cpp index 833f64bc96e7..cb7a35026c27 100644 --- a/libs/hwui/LayerCache.cpp +++ b/libs/hwui/LayerCache.cpp @@ -80,8 +80,10 @@ int LayerCache::LayerEntry::compare(const LayerCache::LayerEntry& lhs, void LayerCache::deleteLayer(Layer* layer) { if (layer) { - LAYER_LOGD("Destroying layer %dx%d, fbo %d", layer->getWidth(), layer->getHeight(), - layer->getFbo()); + if (kDebugLayers) { + ALOGD("Destroying layer %dx%d, fbo %d", layer->getWidth(), layer->getHeight(), + layer->getFbo()); + } mSize -= layer->getWidth() * layer->getHeight() * 4; layer->state = Layer::kState_DeletedFromCache; Caches::getInstance().resourceCache.decrementRefcount(layer); @@ -110,9 +112,13 @@ Layer* LayerCache::get(RenderState& renderState, const uint32_t width, const uin layer->state = Layer::kState_RemovedFromCache; mSize -= layer->getWidth() * layer->getHeight() * 4; - LAYER_LOGD("Reusing layer %dx%d", layer->getWidth(), layer->getHeight()); + if (kDebugLayers) { + ALOGD("Reusing layer %dx%d", layer->getWidth(), layer->getHeight()); + } } else { - LAYER_LOGD("Creating new layer %dx%d", entry.mWidth, entry.mHeight); + if (kDebugLayers) { + ALOGD("Creating new layer %dx%d", entry.mWidth, entry.mHeight); + } layer = new Layer(Layer::kType_DisplayList, renderState, entry.mWidth, entry.mHeight); layer->setBlend(true); @@ -137,7 +143,9 @@ void LayerCache::dump() { size_t size = mCache.size(); for (size_t i = 0; i < size; i++) { const LayerEntry& entry = mCache.itemAt(i); - LAYER_LOGD(" Layer size %dx%d", entry.mWidth, entry.mHeight); + if (kDebugLayers) { + ALOGD(" Layer size %dx%d", entry.mWidth, entry.mHeight); + } } } @@ -157,8 +165,10 @@ bool LayerCache::put(Layer* layer) { deleteLayer(victim); mCache.removeAt(position); - LAYER_LOGD(" Deleting layer %.2fx%.2f", victim->layer.getWidth(), - victim->layer.getHeight()); + if (kDebugLayers) { + ALOGD(" Deleting layer %.2fx%.2f", victim->layer.getWidth(), + victim->layer.getHeight()); + } } layer->cancelDefer(); diff --git a/libs/hwui/LayerCache.h b/libs/hwui/LayerCache.h index 6b93e8fc86c5..81810acef163 100644 --- a/libs/hwui/LayerCache.h +++ b/libs/hwui/LayerCache.h @@ -26,15 +26,11 @@ namespace uirenderer { class RenderState; -/////////////////////////////////////////////////////////////////////////////// -// Defines -/////////////////////////////////////////////////////////////////////////////// - // Debug #if DEBUG_LAYERS - #define LAYER_LOGD(...) ALOGD(__VA_ARGS__) +static const bool kDebugLayers = true; #else - #define LAYER_LOGD(...) +static const bool kDebugLayers = false; #endif /////////////////////////////////////////////////////////////////////////////// diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index ce1d09fe149a..40a58f290619 100755 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -473,8 +473,6 @@ bool OpenGLRenderer::updateLayer(Layer* layer, bool inFrame) { && layer->renderNode.get() && layer->renderNode->isRenderable()) { ATRACE_CALL(); - Rect& dirty = layer->dirtyRect; - if (inFrame) { endTiling(); debugOverdraw(false, false); @@ -779,8 +777,10 @@ int OpenGLRenderer::saveLayerDeferred(float left, float top, float right, float */ bool OpenGLRenderer::createLayer(float left, float top, float right, float bottom, const SkPaint* paint, int flags, const SkPath* convexMask) { - LAYER_LOGD("Requesting layer %.2fx%.2f", right - left, bottom - top); - LAYER_LOGD("Layer cache size = %d", mCaches.layerCache.getSize()); + if (kDebugLayers) { + ALOGD("Requesting layer %.2fx%.2f", right - left, bottom - top); + ALOGD("Layer cache size = %d", mCaches.layerCache.getSize()); + } const bool fboLayer = flags & SkCanvas::kClipToLayer_SaveFlag; @@ -955,7 +955,9 @@ void OpenGLRenderer::composeLayer(const Snapshot& removed, const Snapshot& resto // Failing to add the layer to the cache should happen only if the layer is too large layer->setConvexMask(NULL); if (!mCaches.layerCache.put(layer)) { - LAYER_LOGD("Deleting layer"); + if (kDebugLayers) { + ALOGD("Deleting layer"); + } Caches::getInstance().resourceCache.decrementRefcount(layer); } } @@ -1984,8 +1986,6 @@ status_t OpenGLRenderer::drawRenderNode(RenderNode* renderNode, Rect& dirty, int } void OpenGLRenderer::drawAlphaBitmap(Texture* texture, float left, float top, const SkPaint* paint) { - int color = paint != NULL ? paint->getColor() : 0; - float x = left; float y = top; @@ -2407,7 +2407,7 @@ status_t OpenGLRenderer::drawVertexBuffer(float translateX, float translateY, setupDrawShaderUniforms(getShader(paint)); const void* vertices = vertexBuffer.getBuffer(); - bool force = mCaches.unbindMeshBuffer(); + mCaches.unbindMeshBuffer(); mCaches.bindPositionVertexPointer(true, vertices, isAA ? gAlphaVertexStride : gVertexStride); mCaches.resetTexCoordsVertexPointer(); @@ -3182,14 +3182,6 @@ status_t OpenGLRenderer::drawRects(const float* rects, int count, const SkPaint* return drawColorRects(rects, count, paint, false, true, true); } -static void mapPointFakeZ(Vector3& point, const mat4& transformXY, const mat4& transformZ) { - // map z coordinate with true 3d matrix - point.z = transformZ.mapZ(point); - - // map x,y coordinates with draw/Skia matrix - transformXY.mapPoint(point.x, point.y); -} - status_t OpenGLRenderer::drawShadow(float casterAlpha, const VertexBuffer* ambientShadowVertexBuffer, const VertexBuffer* spotShadowVertexBuffer) { if (currentSnapshot()->isIgnored()) return DrawGlInfo::kStatusDone; diff --git a/libs/hwui/PathCache.cpp b/libs/hwui/PathCache.cpp index 9ba885496f6f..a3d70197cb0f 100644 --- a/libs/hwui/PathCache.cpp +++ b/libs/hwui/PathCache.cpp @@ -212,7 +212,7 @@ void PathCache::removeTexture(PathTexture* texture) { // before attempting our cleanup const sp<Task<SkBitmap*> >& task = texture->task(); if (task != NULL) { - SkBitmap* bitmap = task->getResult(); + task->getResult(); texture->clearTask(); } else { // If there is a pending task, the path was not added diff --git a/libs/hwui/PathTessellator.cpp b/libs/hwui/PathTessellator.cpp index 281ca02c39f1..d842ed54c140 100644 --- a/libs/hwui/PathTessellator.cpp +++ b/libs/hwui/PathTessellator.cpp @@ -279,7 +279,6 @@ void getStrokeVerticesFromUnclosedVertices(const PaintInfo& paintInfo, - (vertices[lastIndex].x - vertices[lastIndex - 1].x), vertices[lastIndex].y - vertices[lastIndex - 1].y); const float dTheta = PI / (extra + 1); - const float radialScale = 2.0f / (1 + cos(dTheta)); int capOffset; for (int i = 0; i < extra; i++) { @@ -831,7 +830,6 @@ void PathTessellator::tessellatePoints(const float* points, int count, const SkP Rect bounds; // tessellate, then duplicate outline across points - int numPoints = count / 2; VertexBuffer tempBuffer; if (!paintInfo.isAA) { getFillVerticesFromPerimeter(outlineVertices, tempBuffer); diff --git a/libs/hwui/Properties.h b/libs/hwui/Properties.h index 7eb9a32843e1..8d529c64f485 100644 --- a/libs/hwui/Properties.h +++ b/libs/hwui/Properties.h @@ -244,7 +244,7 @@ enum DebugLevel { // Converts a number of kilo-bytes into bytes #define KB(s) s * 1024 -static DebugLevel readDebugLevel() { +static inline DebugLevel readDebugLevel() { char property[PROPERTY_VALUE_MAX]; if (property_get(PROPERTY_DEBUG, property, NULL) > 0) { return (DebugLevel) atoi(property); diff --git a/libs/hwui/RenderNode.cpp b/libs/hwui/RenderNode.cpp index 254492ff4384..22808e201889 100644 --- a/libs/hwui/RenderNode.cpp +++ b/libs/hwui/RenderNode.cpp @@ -736,7 +736,6 @@ void RenderNode::issueOperationsOf3dChildren(ChildrenSelectMode mode, int restoreTo = renderer.save(SkCanvas::kMatrix_SaveFlag); DrawRenderNodeOp* childOp = zTranslatedNodes[drawIndex].value; - RenderNode* child = childOp->mRenderNode; renderer.concatMatrix(childOp->mTransformFromParent); childOp->mSkipInOrderDraw = false; // this is horrible, I'm so sorry everyone @@ -885,7 +884,7 @@ void RenderNode::issueOperations(OpenGLRenderer& renderer, T& handler) { initialTransform, zTranslatedNodes, renderer, handler); - for (int opIndex = chunk.beginOpIndex; opIndex < chunk.endOpIndex; opIndex++) { + for (size_t opIndex = chunk.beginOpIndex; opIndex < chunk.endOpIndex; opIndex++) { DisplayListOp *op = mDisplayListData->displayListOps[opIndex]; #if DEBUG_DISPLAY_LIST op->output(level + 1); @@ -893,7 +892,8 @@ void RenderNode::issueOperations(OpenGLRenderer& renderer, T& handler) { logBuffer.writeCommand(level, op->name()); handler(op, saveCountOffset, properties().getClipToBounds()); - if (CC_UNLIKELY(!mProjectedNodes.isEmpty() && opIndex == projectionReceiveIndex)) { + if (CC_UNLIKELY(!mProjectedNodes.isEmpty() && projectionReceiveIndex >= 0 && + opIndex == static_cast<size_t>(projectionReceiveIndex))) { issueOperationsOfProjectedChildren(renderer, handler); } } diff --git a/libs/hwui/ShadowTessellator.cpp b/libs/hwui/ShadowTessellator.cpp index c1ffa0ab4807..93d4b317f03b 100644 --- a/libs/hwui/ShadowTessellator.cpp +++ b/libs/hwui/ShadowTessellator.cpp @@ -87,7 +87,6 @@ void ShadowTessellator::tessellateSpotShadow(bool isCasterOpaque, reverseReceiverTransform.loadInverse(receiverTransform); reverseReceiverTransform.mapPoint3d(adjustedLightCenter); - const int lightVertexCount = 8; if (CC_UNLIKELY(caches.propertyLightDiameter > 0)) { lightRadius = caches.propertyLightDiameter; } diff --git a/libs/hwui/font/Font.cpp b/libs/hwui/font/Font.cpp index ba878bac00a9..bf555580b252 100644 --- a/libs/hwui/font/Font.cpp +++ b/libs/hwui/font/Font.cpp @@ -378,7 +378,7 @@ void Font::precache(const SkPaint* paint, const char* text, int numGlyphs) { break; } - CachedGlyphInfo* cachedGlyph = getCachedGlyph(paint, glyph, true); + getCachedGlyph(paint, glyph, true); glyphsCount++; } } @@ -403,8 +403,6 @@ void Font::render(const SkPaint* paint, const char* text, uint32_t start, uint32 text += start; int glyphsCount = 0; - const SkPaint::Align align = paint->getTextAlign(); - while (glyphsCount < numGlyphs) { glyph_t glyph = GET_GLYPH(text); diff --git a/libs/hwui/font/FontUtil.h b/libs/hwui/font/FontUtil.h index c2fd5f58e02d..4e5debe33c4a 100644 --- a/libs/hwui/font/FontUtil.h +++ b/libs/hwui/font/FontUtil.h @@ -30,9 +30,12 @@ #define DEFAULT_TEXT_LARGE_CACHE_WIDTH 2048 #define DEFAULT_TEXT_LARGE_CACHE_HEIGHT 512 -#define TEXTURE_BORDER_SIZE 1 -#if TEXTURE_BORDER_SIZE != 1 -# error TEXTURE_BORDER_SIZE other than 1 is not currently supported +#ifdef TEXTURE_BORDER_SIZE + #if TEXTURE_BORDER_SIZE != 1 + #error TEXTURE_BORDER_SIZE other than 1 is not currently supported + #endif +#else + #define TEXTURE_BORDER_SIZE 1 #endif #define CACHE_BLOCK_ROUNDING_SIZE 4 @@ -44,7 +47,7 @@ #define GET_GLYPH(text) nextGlyph((const uint16_t**) &text) #define IS_END_OF_STRING(glyph) false - static glyph_t nextGlyph(const uint16_t** srcPtr) { + static inline glyph_t nextGlyph(const uint16_t** srcPtr) { const uint16_t* src = *srcPtr; glyph_t g = *src++; *srcPtr = src; diff --git a/libs/hwui/renderthread/RenderProxy.cpp b/libs/hwui/renderthread/RenderProxy.cpp index 047819de239a..c6ea82bbff30 100644 --- a/libs/hwui/renderthread/RenderProxy.cpp +++ b/libs/hwui/renderthread/RenderProxy.cpp @@ -349,8 +349,12 @@ CREATE_BRIDGE0(fence) { return NULL; } +template <typename T> +void UNUSED(T t) {} + void RenderProxy::fence() { SETUP_TASK(fence); + UNUSED(args); postAndWait(task); } diff --git a/libs/hwui/renderthread/RenderTask.cpp b/libs/hwui/renderthread/RenderTask.cpp index 7ca61e4838a9..13970bade02a 100644 --- a/libs/hwui/renderthread/RenderTask.cpp +++ b/libs/hwui/renderthread/RenderTask.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// LOG_TAG is being provided by the Makefile, reset. +#ifdef LOG_TAG +#undef LOG_TAG +#endif #define LOG_TAG "RenderTask" #include "RenderTask.h" diff --git a/libs/input/Android.mk b/libs/input/Android.mk index a7fb0e212489..2bbfdcc8a816 100644 --- a/libs/input/Android.mk +++ b/libs/input/Android.mk @@ -27,14 +27,14 @@ LOCAL_SHARED_LIBRARIES := \ libskia \ libgui \ libui \ - libinput \ - libinputflinger + libinput \ + libinputflinger LOCAL_C_INCLUDES := \ frameworks/native/services -LOCAL_CFLAGS += -Wno-unused-parameter +LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code LOCAL_MODULE:= libinputservice diff --git a/libs/input/PointerController.cpp b/libs/input/PointerController.cpp index 9af521b7aba2..11527378f586 100644 --- a/libs/input/PointerController.cpp +++ b/libs/input/PointerController.cpp @@ -25,11 +25,14 @@ #include <cutils/log.h> +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" #include <SkBitmap.h> #include <SkCanvas.h> #include <SkColor.h> #include <SkPaint.h> #include <SkXfermode.h> +#pragma GCC diagnostic pop namespace android { diff --git a/libs/input/SpriteController.cpp b/libs/input/SpriteController.cpp index 539139339197..0bc832a8fb37 100644 --- a/libs/input/SpriteController.cpp +++ b/libs/input/SpriteController.cpp @@ -24,11 +24,15 @@ #include <utils/String8.h> #include <gui/Surface.h> +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" #include <SkBitmap.h> #include <SkCanvas.h> #include <SkColor.h> #include <SkPaint.h> #include <SkXfermode.h> +#pragma GCC diagnostic pop + #include <android/native_window.h> namespace android { diff --git a/libs/storage/Android.mk b/libs/storage/Android.mk index 7a9dd6c39157..fae2bf7c3457 100644 --- a/libs/storage/Android.mk +++ b/libs/storage/Android.mk @@ -9,4 +9,6 @@ LOCAL_SRC_FILES:= \ LOCAL_MODULE:= libstorage +LOCAL_CFLAGS += -Wall -Werror + include $(BUILD_STATIC_LIBRARY) diff --git a/libs/storage/IMountService.cpp b/libs/storage/IMountService.cpp index 621de18b1685..7ac77378f0c5 100644 --- a/libs/storage/IMountService.cpp +++ b/libs/storage/IMountService.cpp @@ -207,12 +207,19 @@ public: ALOGD("getStorageUsers caught exception %d\n", err); return err; } - const int32_t numUsers = reply.readInt32(); + int32_t numUsersI = reply.readInt32(); + uint32_t numUsers; + if (numUsersI < 0) { + ALOGW("Number of users is negative: %d\n", numUsersI); + numUsers = 0; + } else { + numUsers = static_cast<uint32_t>(numUsersI); + } *users = (int32_t*)malloc(sizeof(int32_t)*numUsers); - for (int i = 0; i < numUsers; i++) { + for (size_t i = 0; i < numUsers; i++) { **users++ = reply.readInt32(); } - return numUsers; + return static_cast<int32_t>(numUsers); } int32_t getVolumeState(const String16& mountPoint) @@ -546,8 +553,8 @@ public: } }; -IMPLEMENT_META_INTERFACE(MountService, "IMountService"); +IMPLEMENT_META_INTERFACE(MountService, "IMountService") // ---------------------------------------------------------------------- -}; +} diff --git a/libs/storage/IMountServiceListener.cpp b/libs/storage/IMountServiceListener.cpp index c98a42461b15..11b53fdc1027 100644 --- a/libs/storage/IMountServiceListener.cpp +++ b/libs/storage/IMountServiceListener.cpp @@ -34,7 +34,7 @@ status_t BnMountServiceListener::onTransact( onUsbMassStorageConnectionChanged(connected); reply->writeNoException(); return NO_ERROR; - } break; + } case TRANSACTION_onStorageStateChanged: { CHECK_INTERFACE(IMountServiceListener, data, reply); String16 path = data.readString16(); @@ -50,4 +50,4 @@ status_t BnMountServiceListener::onTransact( } // ---------------------------------------------------------------------- -}; +} diff --git a/libs/storage/IMountShutdownObserver.cpp b/libs/storage/IMountShutdownObserver.cpp index 1a6fdeeac1d9..a74a768409bc 100644 --- a/libs/storage/IMountShutdownObserver.cpp +++ b/libs/storage/IMountShutdownObserver.cpp @@ -33,11 +33,11 @@ status_t BnMountShutdownObserver::onTransact( onShutDownComplete(statusCode); reply->writeNoException(); return NO_ERROR; - } break; + } default: return BBinder::onTransact(code, data, reply, flags); } } // ---------------------------------------------------------------------- -}; +} diff --git a/libs/storage/IObbActionListener.cpp b/libs/storage/IObbActionListener.cpp index eaa211ec98ab..9656e655e22c 100644 --- a/libs/storage/IObbActionListener.cpp +++ b/libs/storage/IObbActionListener.cpp @@ -30,10 +30,11 @@ public: : BpInterface<IObbActionListener>(impl) { } - virtual void onObbResult(const String16& filename, const int32_t nonce, const int32_t state) { } + virtual void onObbResult(const String16& /* filename */, const int32_t /* nonce */, + const int32_t /* state */) { } }; -IMPLEMENT_META_INTERFACE(ObbActionListener, "IObbActionListener"); +IMPLEMENT_META_INTERFACE(ObbActionListener, "IObbActionListener") // ---------------------------------------------------------------------- @@ -49,7 +50,7 @@ status_t BnObbActionListener::onTransact( onObbResult(filename, nonce, state); reply->writeNoException(); return NO_ERROR; - } break; + } default: return BBinder::onTransact(code, data, reply, flags); } @@ -57,4 +58,4 @@ status_t BnObbActionListener::onTransact( // ---------------------------------------------------------------------- -}; +} diff --git a/media/jni/Android.mk b/media/jni/Android.mk index 90fe6950335d..4ebbe2662a62 100644 --- a/media/jni/Android.mk +++ b/media/jni/Android.mk @@ -64,7 +64,7 @@ LOCAL_C_INCLUDES += \ $(PV_INCLUDES) \ $(JNI_H_INCLUDE) -LOCAL_CFLAGS += +LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code LOCAL_MODULE:= libmedia_jni diff --git a/media/jni/android_media_AmrInputStream.cpp b/media/jni/android_media_AmrInputStream.cpp index 3df653015fbd..afb5d5cbba74 100644 --- a/media/jni/android_media_AmrInputStream.cpp +++ b/media/jni/android_media_AmrInputStream.cpp @@ -50,7 +50,7 @@ struct GsmAmrEncoderState { }; static jlong android_media_AmrInputStream_GsmAmrEncoderNew - (JNIEnv *env, jclass clazz) { + (JNIEnv *env, jclass /* clazz */) { GsmAmrEncoderState* gae = new GsmAmrEncoderState(); if (gae == NULL) { jniThrowRuntimeException(env, "Out of memory"); @@ -59,7 +59,7 @@ static jlong android_media_AmrInputStream_GsmAmrEncoderNew } static void android_media_AmrInputStream_GsmAmrEncoderInitialize - (JNIEnv *env, jclass clazz, jlong gae) { + (JNIEnv *env, jclass /* clazz */, jlong gae) { GsmAmrEncoderState *state = (GsmAmrEncoderState *) gae; int32_t nResult = AMREncodeInit(&state->mEncState, &state->mSidState, false); if (nResult != OK) { @@ -69,7 +69,7 @@ static void android_media_AmrInputStream_GsmAmrEncoderInitialize } static jint android_media_AmrInputStream_GsmAmrEncoderEncode - (JNIEnv *env, jclass clazz, + (JNIEnv *env, jclass /* clazz */, jlong gae, jbyteArray pcm, jint pcmOffset, jbyteArray amr, jint amrOffset) { jbyte inBuf[BYTES_PER_FRAME]; @@ -105,7 +105,7 @@ static jint android_media_AmrInputStream_GsmAmrEncoderEncode } static void android_media_AmrInputStream_GsmAmrEncoderCleanup - (JNIEnv *env, jclass clazz, jlong gae) { + (JNIEnv* /* env */, jclass /* clazz */, jlong gae) { GsmAmrEncoderState *state = (GsmAmrEncoderState *) gae; AMREncodeExit(&state->mEncState, &state->mSidState); state->mEncState = NULL; @@ -113,7 +113,7 @@ static void android_media_AmrInputStream_GsmAmrEncoderCleanup } static void android_media_AmrInputStream_GsmAmrEncoderDelete - (JNIEnv *env, jclass clazz, jlong gae) { + (JNIEnv* /* env */, jclass /* clazz */, jlong gae) { delete (GsmAmrEncoderState*)gae; } diff --git a/media/jni/android_media_ImageReader.cpp b/media/jni/android_media_ImageReader.cpp index aaff9a2ce217..45377ad6b33d 100644 --- a/media/jni/android_media_ImageReader.cpp +++ b/media/jni/android_media_ImageReader.cpp @@ -502,7 +502,6 @@ static jint Image_imageGetPixelStride(JNIEnv* env, CpuConsumer::LockedBuffer* bu case HAL_PIXEL_FORMAT_Y8: // Single plane 8bpp data. ALOG_ASSERT(idx == 0, "Wrong index: %d", idx); - pixelStride; break; case HAL_PIXEL_FORMAT_YV12: pixelStride = 1; diff --git a/media/jni/android_media_MediaCodecList.cpp b/media/jni/android_media_MediaCodecList.cpp index 12eb7d24aed4..f8c349b54c53 100644 --- a/media/jni/android_media_MediaCodecList.cpp +++ b/media/jni/android_media_MediaCodecList.cpp @@ -42,7 +42,7 @@ static sp<IMediaCodecList> getCodecList(JNIEnv *env) { } static jint android_media_MediaCodecList_getCodecCount( - JNIEnv *env, jobject thiz) { + JNIEnv *env, jobject /* thiz */) { sp<IMediaCodecList> mcl = getCodecList(env); if (mcl == NULL) { // Runtime exception already pending. @@ -52,7 +52,7 @@ static jint android_media_MediaCodecList_getCodecCount( } static jstring android_media_MediaCodecList_getCodecName( - JNIEnv *env, jobject thiz, jint index) { + JNIEnv *env, jobject /* thiz */, jint index) { sp<IMediaCodecList> mcl = getCodecList(env); if (mcl == NULL) { // Runtime exception already pending. @@ -70,7 +70,7 @@ static jstring android_media_MediaCodecList_getCodecName( } static jint android_media_MediaCodecList_findCodecByName( - JNIEnv *env, jobject thiz, jstring name) { + JNIEnv *env, jobject /* thiz */, jstring name) { if (name == NULL) { jniThrowException(env, "java/lang/IllegalArgumentException", NULL); return -ENOENT; @@ -95,7 +95,7 @@ static jint android_media_MediaCodecList_findCodecByName( } static jboolean android_media_MediaCodecList_isEncoder( - JNIEnv *env, jobject thiz, jint index) { + JNIEnv *env, jobject /* thiz */, jint index) { sp<IMediaCodecList> mcl = getCodecList(env); if (mcl == NULL) { // Runtime exception already pending. @@ -112,7 +112,7 @@ static jboolean android_media_MediaCodecList_isEncoder( } static jarray android_media_MediaCodecList_getSupportedTypes( - JNIEnv *env, jobject thiz, jint index) { + JNIEnv *env, jobject /* thiz */, jint index) { sp<IMediaCodecList> mcl = getCodecList(env); if (mcl == NULL) { // Runtime exception already pending. @@ -144,7 +144,7 @@ static jarray android_media_MediaCodecList_getSupportedTypes( } static jobject android_media_MediaCodecList_getCodecCapabilities( - JNIEnv *env, jobject thiz, jint index, jstring type) { + JNIEnv *env, jobject /* thiz */, jint index, jstring type) { if (type == NULL) { jniThrowException(env, "java/lang/IllegalArgumentException", NULL); return NULL; @@ -262,7 +262,7 @@ static jobject android_media_MediaCodecList_getCodecCapabilities( return caps; } -static void android_media_MediaCodecList_native_init(JNIEnv *env) { +static void android_media_MediaCodecList_native_init(JNIEnv* /* env */) { } static JNINativeMethod gMethods[] = { diff --git a/media/jni/android_media_MediaCrypto.cpp b/media/jni/android_media_MediaCrypto.cpp index a6f8dcdda7ba..d2216fb97de4 100644 --- a/media/jni/android_media_MediaCrypto.cpp +++ b/media/jni/android_media_MediaCrypto.cpp @@ -224,7 +224,7 @@ static void android_media_MediaCrypto_native_finalize( } static jboolean android_media_MediaCrypto_isCryptoSchemeSupportedNative( - JNIEnv *env, jobject thiz, jbyteArray uuidObj) { + JNIEnv *env, jobject /* thiz */, jbyteArray uuidObj) { jsize uuidLength = env->GetArrayLength(uuidObj); if (uuidLength != 16) { diff --git a/media/jni/android_media_MediaDrm.cpp b/media/jni/android_media_MediaDrm.cpp index 0fed27e77ab7..91eb49975192 100644 --- a/media/jni/android_media_MediaDrm.cpp +++ b/media/jni/android_media_MediaDrm.cpp @@ -667,7 +667,7 @@ static void android_media_MediaDrm_native_finalize( } static jboolean android_media_MediaDrm_isCryptoSchemeSupportedNative( - JNIEnv *env, jobject thiz, jbyteArray uuidObj, jstring jmimeType) { + JNIEnv *env, jobject /* thiz */, jbyteArray uuidObj, jstring jmimeType) { if (uuidObj == NULL) { jniThrowException(env, "java/lang/IllegalArgumentException", NULL); @@ -1137,7 +1137,7 @@ static void android_media_MediaDrm_setPropertyByteArray( } static void android_media_MediaDrm_setCipherAlgorithmNative( - JNIEnv *env, jobject thiz, jobject jdrm, jbyteArray jsessionId, + JNIEnv *env, jobject /* thiz */, jobject jdrm, jbyteArray jsessionId, jstring jalgorithm) { sp<IDrm> drm = GetDrm(env, jdrm); @@ -1161,7 +1161,7 @@ static void android_media_MediaDrm_setCipherAlgorithmNative( } static void android_media_MediaDrm_setMacAlgorithmNative( - JNIEnv *env, jobject thiz, jobject jdrm, jbyteArray jsessionId, + JNIEnv *env, jobject /* thiz */, jobject jdrm, jbyteArray jsessionId, jstring jalgorithm) { sp<IDrm> drm = GetDrm(env, jdrm); @@ -1186,7 +1186,7 @@ static void android_media_MediaDrm_setMacAlgorithmNative( static jbyteArray android_media_MediaDrm_encryptNative( - JNIEnv *env, jobject thiz, jobject jdrm, jbyteArray jsessionId, + JNIEnv *env, jobject /* thiz */, jobject jdrm, jbyteArray jsessionId, jbyteArray jkeyId, jbyteArray jinput, jbyteArray jiv) { sp<IDrm> drm = GetDrm(env, jdrm); @@ -1217,7 +1217,7 @@ static jbyteArray android_media_MediaDrm_encryptNative( } static jbyteArray android_media_MediaDrm_decryptNative( - JNIEnv *env, jobject thiz, jobject jdrm, jbyteArray jsessionId, + JNIEnv *env, jobject /* thiz */, jobject jdrm, jbyteArray jsessionId, jbyteArray jkeyId, jbyteArray jinput, jbyteArray jiv) { sp<IDrm> drm = GetDrm(env, jdrm); @@ -1247,7 +1247,7 @@ static jbyteArray android_media_MediaDrm_decryptNative( } static jbyteArray android_media_MediaDrm_signNative( - JNIEnv *env, jobject thiz, jobject jdrm, jbyteArray jsessionId, + JNIEnv *env, jobject /* thiz */, jobject jdrm, jbyteArray jsessionId, jbyteArray jkeyId, jbyteArray jmessage) { sp<IDrm> drm = GetDrm(env, jdrm); @@ -1277,7 +1277,7 @@ static jbyteArray android_media_MediaDrm_signNative( } static jboolean android_media_MediaDrm_verifyNative( - JNIEnv *env, jobject thiz, jobject jdrm, jbyteArray jsessionId, + JNIEnv *env, jobject /* thiz */, jobject jdrm, jbyteArray jsessionId, jbyteArray jkeyId, jbyteArray jmessage, jbyteArray jsignature) { sp<IDrm> drm = GetDrm(env, jdrm); @@ -1306,7 +1306,7 @@ static jboolean android_media_MediaDrm_verifyNative( static jbyteArray android_media_MediaDrm_signRSANative( - JNIEnv *env, jobject thiz, jobject jdrm, jbyteArray jsessionId, + JNIEnv *env, jobject /* thiz */, jobject jdrm, jbyteArray jsessionId, jstring jalgorithm, jbyteArray jwrappedKey, jbyteArray jmessage) { sp<IDrm> drm = GetDrm(env, jdrm); diff --git a/media/jni/android_media_MediaMetadataRetriever.cpp b/media/jni/android_media_MediaMetadataRetriever.cpp index fbe53402c673..dae6d3bbe4a7 100644 --- a/media/jni/android_media_MediaMetadataRetriever.cpp +++ b/media/jni/android_media_MediaMetadataRetriever.cpp @@ -77,7 +77,6 @@ static MediaMetadataRetriever* getRetriever(JNIEnv* env, jobject thiz) static void setRetriever(JNIEnv* env, jobject thiz, MediaMetadataRetriever* retriever) { // No lock is needed, since it is called internally by other methods that are protected - MediaMetadataRetriever *old = (MediaMetadataRetriever*) env->GetLongField(thiz, fields.context); env->SetLongField(thiz, fields.context, (jlong) retriever); } diff --git a/media/jni/android_media_MediaMuxer.cpp b/media/jni/android_media_MediaMuxer.cpp index 3fef446f0ca1..f234a1b6b937 100644 --- a/media/jni/android_media_MediaMuxer.cpp +++ b/media/jni/android_media_MediaMuxer.cpp @@ -41,7 +41,7 @@ static fields_t gFields; using namespace android; static jint android_media_MediaMuxer_addTrack( - JNIEnv *env, jclass clazz, jlong nativeObject, jobjectArray keys, + JNIEnv *env, jclass /* clazz */, jlong nativeObject, jobjectArray keys, jobjectArray values) { sp<MediaMuxer> muxer(reinterpret_cast<MediaMuxer *>(nativeObject)); if (muxer == NULL) { @@ -71,7 +71,7 @@ static jint android_media_MediaMuxer_addTrack( } static void android_media_MediaMuxer_writeSampleData( - JNIEnv *env, jclass clazz, jlong nativeObject, jint trackIndex, + JNIEnv *env, jclass /* clazz */, jlong nativeObject, jint trackIndex, jobject byteBuf, jint offset, jint size, jlong timeUs, jint flags) { sp<MediaMuxer> muxer(reinterpret_cast<MediaMuxer *>(nativeObject)); if (muxer == NULL) { @@ -146,7 +146,7 @@ static jlong android_media_MediaMuxer_native_setup( } static void android_media_MediaMuxer_setOrientationHint( - JNIEnv *env, jclass clazz, jlong nativeObject, jint degrees) { + JNIEnv *env, jclass /* clazz */, jlong nativeObject, jint degrees) { sp<MediaMuxer> muxer(reinterpret_cast<MediaMuxer *>(nativeObject)); if (muxer == NULL) { jniThrowException(env, "java/lang/IllegalStateException", @@ -164,7 +164,7 @@ static void android_media_MediaMuxer_setOrientationHint( } static void android_media_MediaMuxer_setLocation( - JNIEnv *env, jclass clazz, jlong nativeObject, jint latitude, jint longitude) { + JNIEnv *env, jclass /* clazz */, jlong nativeObject, jint latitude, jint longitude) { MediaMuxer* muxer = reinterpret_cast<MediaMuxer *>(nativeObject); status_t res = muxer->setLocation(latitude, longitude); @@ -175,7 +175,7 @@ static void android_media_MediaMuxer_setLocation( } } -static void android_media_MediaMuxer_start(JNIEnv *env, jclass clazz, +static void android_media_MediaMuxer_start(JNIEnv *env, jclass /* clazz */, jlong nativeObject) { sp<MediaMuxer> muxer(reinterpret_cast<MediaMuxer *>(nativeObject)); if (muxer == NULL) { @@ -193,7 +193,7 @@ static void android_media_MediaMuxer_start(JNIEnv *env, jclass clazz, } -static void android_media_MediaMuxer_stop(JNIEnv *env, jclass clazz, +static void android_media_MediaMuxer_stop(JNIEnv *env, jclass /* clazz */, jlong nativeObject) { sp<MediaMuxer> muxer(reinterpret_cast<MediaMuxer *>(nativeObject)); if (muxer == NULL) { @@ -212,7 +212,7 @@ static void android_media_MediaMuxer_stop(JNIEnv *env, jclass clazz, } static void android_media_MediaMuxer_native_release( - JNIEnv *env, jclass clazz, jlong nativeObject) { + JNIEnv* /* env */, jclass clazz, jlong nativeObject) { sp<MediaMuxer> muxer(reinterpret_cast<MediaMuxer *>(nativeObject)); if (muxer != NULL) { muxer->decStrong(clazz); diff --git a/media/jni/android_media_MediaProfiles.cpp b/media/jni/android_media_MediaProfiles.cpp index 007fc1422f8d..ca9db91c5eed 100644 --- a/media/jni/android_media_MediaProfiles.cpp +++ b/media/jni/android_media_MediaProfiles.cpp @@ -34,7 +34,7 @@ MediaProfiles *sProfiles = NULL; // This function is called from a static block in MediaProfiles.java class, // which won't run until the first time an instance of this class is used. static void -android_media_MediaProfiles_native_init(JNIEnv *env) +android_media_MediaProfiles_native_init(JNIEnv* /* env */) { ALOGV("native_init"); Mutex::Autolock lock(sLock); @@ -45,14 +45,14 @@ android_media_MediaProfiles_native_init(JNIEnv *env) } static jint -android_media_MediaProfiles_native_get_num_file_formats(JNIEnv *env, jobject thiz) +android_media_MediaProfiles_native_get_num_file_formats(JNIEnv* /* env */, jobject /* thiz */) { ALOGV("native_get_num_file_formats"); return (jint) sProfiles->getOutputFileFormats().size(); } static jint -android_media_MediaProfiles_native_get_file_format(JNIEnv *env, jobject thiz, jint index) +android_media_MediaProfiles_native_get_file_format(JNIEnv *env, jobject /* thiz */, jint index) { ALOGV("native_get_file_format: %d", index); Vector<output_format> formats = sProfiles->getOutputFileFormats(); @@ -65,14 +65,15 @@ android_media_MediaProfiles_native_get_file_format(JNIEnv *env, jobject thiz, ji } static jint -android_media_MediaProfiles_native_get_num_video_encoders(JNIEnv *env, jobject thiz) +android_media_MediaProfiles_native_get_num_video_encoders(JNIEnv* /* env */, jobject /* thiz */) { ALOGV("native_get_num_video_encoders"); return sProfiles->getVideoEncoders().size(); } static jobject -android_media_MediaProfiles_native_get_video_encoder_cap(JNIEnv *env, jobject thiz, jint index) +android_media_MediaProfiles_native_get_video_encoder_cap(JNIEnv *env, jobject /* thiz */, + jint index) { ALOGV("native_get_video_encoder_cap: %d", index); Vector<video_encoder> encoders = sProfiles->getVideoEncoders(); @@ -116,14 +117,15 @@ android_media_MediaProfiles_native_get_video_encoder_cap(JNIEnv *env, jobject th } static jint -android_media_MediaProfiles_native_get_num_audio_encoders(JNIEnv *env, jobject thiz) +android_media_MediaProfiles_native_get_num_audio_encoders(JNIEnv* /* env */, jobject /* thiz */) { ALOGV("native_get_num_audio_encoders"); return (jint) sProfiles->getAudioEncoders().size(); } static jobject -android_media_MediaProfiles_native_get_audio_encoder_cap(JNIEnv *env, jobject thiz, jint index) +android_media_MediaProfiles_native_get_audio_encoder_cap(JNIEnv *env, jobject /* thiz */, + jint index) { ALOGV("native_get_audio_encoder_cap: %d", index); Vector<audio_encoder> encoders = sProfiles->getAudioEncoders(); @@ -172,7 +174,8 @@ static bool isCamcorderQualityKnown(int quality) } static jobject -android_media_MediaProfiles_native_get_camcorder_profile(JNIEnv *env, jobject thiz, jint id, jint quality) +android_media_MediaProfiles_native_get_camcorder_profile(JNIEnv *env, jobject /* thiz */, jint id, + jint quality) { ALOGV("native_get_camcorder_profile: %d %d", id, quality); if (!isCamcorderQualityKnown(quality)) { @@ -221,7 +224,8 @@ android_media_MediaProfiles_native_get_camcorder_profile(JNIEnv *env, jobject th } static jboolean -android_media_MediaProfiles_native_has_camcorder_profile(JNIEnv *env, jobject thiz, jint id, jint quality) +android_media_MediaProfiles_native_has_camcorder_profile(JNIEnv* /* env */, jobject /* thiz */, + jint id, jint quality) { ALOGV("native_has_camcorder_profile: %d %d", id, quality); if (!isCamcorderQualityKnown(quality)) { @@ -233,14 +237,15 @@ android_media_MediaProfiles_native_has_camcorder_profile(JNIEnv *env, jobject th } static jint -android_media_MediaProfiles_native_get_num_video_decoders(JNIEnv *env, jobject thiz) +android_media_MediaProfiles_native_get_num_video_decoders(JNIEnv* /* env */, jobject /* thiz */) { ALOGV("native_get_num_video_decoders"); return (jint) sProfiles->getVideoDecoders().size(); } static jint -android_media_MediaProfiles_native_get_video_decoder_type(JNIEnv *env, jobject thiz, jint index) +android_media_MediaProfiles_native_get_video_decoder_type(JNIEnv *env, jobject /* thiz */, + jint index) { ALOGV("native_get_video_decoder_type: %d", index); Vector<video_decoder> decoders = sProfiles->getVideoDecoders(); @@ -254,14 +259,15 @@ android_media_MediaProfiles_native_get_video_decoder_type(JNIEnv *env, jobject t } static jint -android_media_MediaProfiles_native_get_num_audio_decoders(JNIEnv *env, jobject thiz) +android_media_MediaProfiles_native_get_num_audio_decoders(JNIEnv* /* env */, jobject /* thiz */) { ALOGV("native_get_num_audio_decoders"); return (jint) sProfiles->getAudioDecoders().size(); } static jint -android_media_MediaProfiles_native_get_audio_decoder_type(JNIEnv *env, jobject thiz, jint index) +android_media_MediaProfiles_native_get_audio_decoder_type(JNIEnv *env, jobject /* thiz */, + jint index) { ALOGV("native_get_audio_decoder_type: %d", index); Vector<audio_decoder> decoders = sProfiles->getAudioDecoders(); @@ -275,14 +281,17 @@ android_media_MediaProfiles_native_get_audio_decoder_type(JNIEnv *env, jobject t } static jint -android_media_MediaProfiles_native_get_num_image_encoding_quality_levels(JNIEnv *env, jobject thiz, jint cameraId) +android_media_MediaProfiles_native_get_num_image_encoding_quality_levels(JNIEnv* /* env */, + jobject /* thiz */, + jint cameraId) { ALOGV("native_get_num_image_encoding_quality_levels"); return (jint) sProfiles->getImageEncodingQualityLevels(cameraId).size(); } static jint -android_media_MediaProfiles_native_get_image_encoding_quality_level(JNIEnv *env, jobject thiz, jint cameraId, jint index) +android_media_MediaProfiles_native_get_image_encoding_quality_level(JNIEnv *env, jobject /* thiz */, + jint cameraId, jint index) { ALOGV("native_get_image_encoding_quality_level"); Vector<int> levels = sProfiles->getImageEncodingQualityLevels(cameraId); diff --git a/media/jni/android_media_MediaScanner.cpp b/media/jni/android_media_MediaScanner.cpp index 321c2e3dcc44..1a9384e6b2c8 100644 --- a/media/jni/android_media_MediaScanner.cpp +++ b/media/jni/android_media_MediaScanner.cpp @@ -360,7 +360,6 @@ android_media_MediaScanner_extractAlbumArt( env->SetByteArrayRegion(array, 0, mediaAlbumArt->size(), data); } -done: free(mediaAlbumArt); // if NewByteArray() returned NULL, an out-of-memory // exception will have been raised. I just want to diff --git a/media/jni/android_media_ResampleInputStream.cpp b/media/jni/android_media_ResampleInputStream.cpp index d5a4a1795d71..1549a301772a 100644 --- a/media/jni/android_media_ResampleInputStream.cpp +++ b/media/jni/android_media_ResampleInputStream.cpp @@ -73,7 +73,7 @@ static const int nFir21 = sizeof(fir21) / sizeof(fir21[0]); static const int BUF_SIZE = 2048; -static void android_media_ResampleInputStream_fir21(JNIEnv *env, jclass clazz, +static void android_media_ResampleInputStream_fir21(JNIEnv *env, jclass /* clazz */, jbyteArray jIn, jint jInOffset, jbyteArray jOut, jint jOutOffset, jint jNpoints) { diff --git a/media/jni/android_media_Utils.cpp b/media/jni/android_media_Utils.cpp index 54c5e9bdd267..ea33a2f52fc3 100644 --- a/media/jni/android_media_Utils.cpp +++ b/media/jni/android_media_Utils.cpp @@ -136,8 +136,7 @@ static void SetMapInt32( jstring keyObj = env->NewStringUTF(key); jobject valueObj = makeIntegerObject(env, value); - jobject res = env->CallObjectMethod( - hashMapObj, hashMapPutID, keyObj, valueObj); + env->CallObjectMethod(hashMapObj, hashMapPutID, keyObj, valueObj); env->DeleteLocalRef(valueObj); valueObj = NULL; env->DeleteLocalRef(keyObj); keyObj = NULL; @@ -266,8 +265,7 @@ status_t ConvertMessageToMap( if (valueObj != NULL) { jstring keyObj = env->NewStringUTF(key); - jobject res = env->CallObjectMethod( - hashMap, hashMapPutID, keyObj, valueObj); + env->CallObjectMethod(hashMap, hashMapPutID, keyObj, valueObj); env->DeleteLocalRef(keyObj); keyObj = NULL; env->DeleteLocalRef(valueObj); valueObj = NULL; diff --git a/media/jni/android_mtp_MtpDatabase.cpp b/media/jni/android_mtp_MtpDatabase.cpp index 19b54a6d8f78..1a0675e3699a 100644 --- a/media/jni/android_mtp_MtpDatabase.cpp +++ b/media/jni/android_mtp_MtpDatabase.cpp @@ -761,7 +761,7 @@ MtpResponseCode MyMtpDatabase::getObjectPropertyList(MtpObjectHandle handle, return result; } -static void foreachentry(ExifEntry *entry, void *user) { +static void foreachentry(ExifEntry *entry, void* /* user */) { char buf[1024]; ALOGI("entry %x, format %d, size %d: %s", entry->tag, entry->format, entry->size, exif_entry_get_value(entry, buf, sizeof(buf))); @@ -779,7 +779,6 @@ static long getLongFromExifEntry(ExifEntry *e) { MtpResponseCode MyMtpDatabase::getObjectInfo(MtpObjectHandle handle, MtpObjectInfo& info) { - char date[20]; MtpString path; int64_t length; MtpObjectFormat format; @@ -807,9 +806,11 @@ MtpResponseCode MyMtpDatabase::getObjectInfo(MtpObjectHandle handle, info.mDateModified = longValues[1]; env->ReleaseLongArrayElements(mLongBuffer, longValues, 0); -// info.mAssociationType = (format == MTP_FORMAT_ASSOCIATION ? -// MTP_ASSOCIATION_TYPE_GENERIC_FOLDER : -// MTP_ASSOCIATION_TYPE_UNDEFINED); + if ((false)) { + info.mAssociationType = (format == MTP_FORMAT_ASSOCIATION ? + MTP_ASSOCIATION_TYPE_GENERIC_FOLDER : + MTP_ASSOCIATION_TYPE_UNDEFINED); + } info.mAssociationType = MTP_ASSOCIATION_TYPE_UNDEFINED; jchar* str = env->GetCharArrayElements(mStringBuffer, 0); @@ -822,7 +823,9 @@ MtpResponseCode MyMtpDatabase::getObjectInfo(MtpObjectHandle handle, ExifData *exifdata = exif_data_new_from_file(path); if (exifdata) { - //exif_data_foreach_content(exifdata, foreachcontent, NULL); + if ((false)) { + exif_data_foreach_content(exifdata, foreachcontent, NULL); + } // XXX get this from exif, or parse jpeg header instead? ExifEntry *w = exif_content_get_entry( diff --git a/media/jni/android_mtp_MtpDevice.cpp b/media/jni/android_mtp_MtpDevice.cpp index 8e013a03316e..fb1577019791 100644 --- a/media/jni/android_mtp_MtpDevice.cpp +++ b/media/jni/android_mtp_MtpDevice.cpp @@ -91,14 +91,6 @@ MtpDevice* get_device_from_object(JNIEnv* env, jobject javaDevice) return (MtpDevice*)env->GetLongField(javaDevice, field_context); } -static void checkAndClearExceptionFromCallback(JNIEnv* env, const char* methodName) { - if (env->ExceptionCheck()) { - ALOGE("An exception was thrown by callback '%s'.", methodName); - LOGE_EX(env); - env->ExceptionClear(); - } -} - // ---------------------------------------------------------------------------- static jboolean diff --git a/media/jni/audioeffect/Android.mk b/media/jni/audioeffect/Android.mk index 3b1fb19fc01e..5c22c9b96761 100644 --- a/media/jni/audioeffect/Android.mk +++ b/media/jni/audioeffect/Android.mk @@ -2,20 +2,22 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_SRC_FILES:= \ - android_media_AudioEffect.cpp \ - android_media_Visualizer.cpp + android_media_AudioEffect.cpp \ + android_media_Visualizer.cpp LOCAL_SHARED_LIBRARIES := \ - liblog \ - libcutils \ - libutils \ - libandroid_runtime \ - libnativehelper \ - libmedia + liblog \ + libcutils \ + libutils \ + libandroid_runtime \ + libnativehelper \ + libmedia LOCAL_C_INCLUDES := \ - $(call include-path-for, audio-effects) + $(call include-path-for, audio-effects) LOCAL_MODULE:= libaudioeffect_jni +LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code + include $(BUILD_SHARED_LIBRARY) diff --git a/media/jni/audioeffect/android_media_Visualizer.cpp b/media/jni/audioeffect/android_media_Visualizer.cpp index 8463d94ad3ff..9183ad2a42cf 100644 --- a/media/jni/audioeffect/android_media_Visualizer.cpp +++ b/media/jni/audioeffect/android_media_Visualizer.cpp @@ -162,10 +162,6 @@ static void captureCallback(void* user, uint8_t *fft, uint32_t samplingrate) { - int arg1 = 0; - int arg2 = 0; - size_t size; - visualizer_callback_cookie *callbackInfo = (visualizer_callback_cookie *)user; JNIEnv *env = AndroidRuntime::getJNIEnv(); @@ -486,7 +482,7 @@ android_media_visualizer_native_getEnabled(JNIEnv *env, jobject thiz) } static jintArray -android_media_visualizer_native_getCaptureSizeRange(JNIEnv *env, jobject thiz) +android_media_visualizer_native_getCaptureSizeRange(JNIEnv *env, jobject /* thiz */) { jintArray jRange = env->NewIntArray(2); jint *nRange = env->GetIntArrayElements(jRange, NULL); @@ -498,7 +494,7 @@ android_media_visualizer_native_getCaptureSizeRange(JNIEnv *env, jobject thiz) } static jint -android_media_visualizer_native_getMaxCaptureRate(JNIEnv *env, jobject thiz) +android_media_visualizer_native_getMaxCaptureRate(JNIEnv* /* env */, jobject /* thiz */) { return (jint) Visualizer::getMaxCaptureRate(); } diff --git a/media/jni/soundpool/Android.mk b/media/jni/soundpool/Android.mk index ed8d7c10f370..3382512f7444 100644 --- a/media/jni/soundpool/Android.mk +++ b/media/jni/soundpool/Android.mk @@ -2,16 +2,18 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_SRC_FILES:= \ - android_media_SoundPool_SoundPoolImpl.cpp + android_media_SoundPool_SoundPoolImpl.cpp LOCAL_SHARED_LIBRARIES := \ - liblog \ - libcutils \ - libutils \ - libandroid_runtime \ - libnativehelper \ - libmedia + liblog \ + libcutils \ + libutils \ + libandroid_runtime \ + libnativehelper \ + libmedia LOCAL_MODULE:= libsoundpool +LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code + include $(BUILD_SHARED_LIBRARY) diff --git a/media/jni/soundpool/android_media_SoundPool_SoundPoolImpl.cpp b/media/jni/soundpool/android_media_SoundPool_SoundPoolImpl.cpp index 89b2893a648a..ce20e526cf7d 100644 --- a/media/jni/soundpool/android_media_SoundPool_SoundPoolImpl.cpp +++ b/media/jni/soundpool/android_media_SoundPool_SoundPoolImpl.cpp @@ -312,7 +312,7 @@ static JNINativeMethod gMethods[] = { static const char* const kClassPathName = "android/media/SoundPool$SoundPoolImpl"; -jint JNI_OnLoad(JavaVM* vm, void* reserved) +jint JNI_OnLoad(JavaVM* vm, void* /* reserved */) { JNIEnv* env = NULL; jint result = -1; diff --git a/media/mca/filterfw/jni/Android.mk b/media/mca/filterfw/jni/Android.mk index 5aa5af17e90d..67337e03fe18 100644 --- a/media/mca/filterfw/jni/Android.mk +++ b/media/mca/filterfw/jni/Android.mk @@ -38,8 +38,8 @@ include $(LOCAL_PATH)/../native/libfilterfw.mk # Also need the JNI headers. LOCAL_C_INCLUDES += \ - $(JNI_H_INCLUDE) \ - $(LOCAL_PATH)/.. + $(JNI_H_INCLUDE) \ + $(LOCAL_PATH)/.. # Don't prelink this library. For more efficient code, you may want # to add this library to the prelink map and set this to true. However, @@ -47,5 +47,7 @@ LOCAL_C_INCLUDES += \ # part of a system image. LOCAL_PRELINK_MODULE := false +LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code + include $(BUILD_STATIC_LIBRARY) diff --git a/media/mca/filterfw/jni/jni_gl_environment.cpp b/media/mca/filterfw/jni/jni_gl_environment.cpp index 6da7b7c766fd..5f007396f287 100644 --- a/media/mca/filterfw/jni/jni_gl_environment.cpp +++ b/media/mca/filterfw/jni/jni_gl_environment.cpp @@ -20,8 +20,8 @@ #include "jni/jni_gl_environment.h" #include "jni/jni_util.h" -#include <media/mediarecorder.h> #include "native/core/gl_env.h" +#include <media/mediarecorder.h> #include <gui/IGraphicBufferProducer.h> #include <gui/Surface.h> @@ -92,8 +92,8 @@ jboolean Java_android_filterfw_core_GLEnvironment_nativeIsContextActive(JNIEnv* return gl_env ? ToJBool(gl_env->IsContextActive()) : JNI_FALSE; } -jboolean Java_android_filterfw_core_GLEnvironment_nativeIsAnyContextActive(JNIEnv* env, - jclass clazz) { +jboolean Java_android_filterfw_core_GLEnvironment_nativeIsAnyContextActive(JNIEnv* /* env */, + jclass /* clazz */) { return ToJBool(GLEnv::IsAnyContextActive()); } diff --git a/media/mca/filterfw/jni/jni_init.cpp b/media/mca/filterfw/jni/jni_init.cpp index 3b131f1478ad..956a5a5c9854 100644 --- a/media/mca/filterfw/jni/jni_init.cpp +++ b/media/mca/filterfw/jni/jni_init.cpp @@ -27,7 +27,7 @@ using namespace android::filterfw; JavaVM* g_current_java_vm_ = NULL; -jint JNI_OnLoad(JavaVM* vm, void* reserved) { +jint JNI_OnLoad(JavaVM* vm, void* /* reserved */) { // Set the current vm pointer g_current_java_vm_ = vm; diff --git a/media/mca/filterfw/native/Android.mk b/media/mca/filterfw/native/Android.mk index 46ee28302cfa..7c4703fd5172 100644 --- a/media/mca/filterfw/native/Android.mk +++ b/media/mca/filterfw/native/Android.mk @@ -39,6 +39,8 @@ include $(LOCAL_PATH)/libfilterfw.mk # gcc should always be placed at the end. LOCAL_EXPORT_LDLIBS := -llog -lgcc +LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code + # TODO: Build a shared library as well? include $(BUILD_STATIC_LIBRARY) diff --git a/media/mca/filterfw/native/core/shader_program.cpp b/media/mca/filterfw/native/core/shader_program.cpp index d92eb313200e..002327b45442 100644 --- a/media/mca/filterfw/native/core/shader_program.cpp +++ b/media/mca/filterfw/native/core/shader_program.cpp @@ -318,15 +318,15 @@ GLuint ShaderProgram::CompileShader(GLenum shader_type, const char* source) { ALOGE("Problem compiling shader! Source:"); ALOGE("%s", source); std::string src(source); - unsigned int cur_pos = 0; - unsigned int next_pos = 0; - int line_number = 1; + size_t cur_pos = 0; + size_t next_pos = 0; + size_t line_number = 1; while ( (next_pos = src.find_first_of('\n', cur_pos)) != std::string::npos) { ALOGE("%03d : %s", line_number, src.substr(cur_pos, next_pos-cur_pos).c_str()); cur_pos = next_pos + 1; line_number++; } - ALOGE("%03d : %s", line_number, src.substr(cur_pos, next_pos-cur_pos).c_str()); + ALOGE("%03zu : %s", line_number, src.substr(cur_pos, next_pos-cur_pos).c_str()); GLint log_length = 0; glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &log_length); diff --git a/media/mca/filterfw/native/core/vertex_frame.cpp b/media/mca/filterfw/native/core/vertex_frame.cpp index 822573fcc32a..9fb9eaa92721 100644 --- a/media/mca/filterfw/native/core/vertex_frame.cpp +++ b/media/mca/filterfw/native/core/vertex_frame.cpp @@ -25,10 +25,6 @@ namespace android { namespace filterfw { -// GL Extensions that are dynamically looked up at runtime -static PFNGLMAPBUFFEROESPROC GLMapBufferOES = NULL; -static PFNGLUNMAPBUFFEROESPROC GLUnmapBufferOES = NULL; - VertexFrame::VertexFrame(int size) : vbo_(0), size_(size) { diff --git a/media/mca/filterpacks/Android.mk b/media/mca/filterpacks/Android.mk index 6e54f604baa0..d030749da172 100644 --- a/media/mca/filterpacks/Android.mk +++ b/media/mca/filterpacks/Android.mk @@ -28,6 +28,8 @@ LOCAL_SRC_FILES := native/base/geometry.cpp \ LOCAL_CFLAGS := -DANDROID +LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code + include external/stlport/libstlport.mk include $(BUILD_STATIC_LIBRARY) @@ -50,4 +52,6 @@ LOCAL_SHARED_LIBRARIES := liblog libutils libfilterfw LOCAL_PRELINK_MODULE := false +LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code + include $(BUILD_SHARED_LIBRARY) diff --git a/media/mca/filterpacks/native/imageproc/invert.c b/media/mca/filterpacks/native/imageproc/invert.c index 5938aac05ffc..f5f9e2728a85 100644 --- a/media/mca/filterpacks/native/imageproc/invert.c +++ b/media/mca/filterpacks/native/imageproc/invert.c @@ -16,12 +16,14 @@ #include <android/log.h> +#define ATTRIBUTE_UNUSED __attribute__((unused)) + int invert_process(const char** inputs, const int* input_sizes, int input_count, char* output, int output_size, - void* user_data) { + void* user_data ATTRIBUTE_UNUSED) { // Make sure we have exactly one input if (input_count != 1) return 0; diff --git a/media/mca/filterpacks/native/imageproc/to_rgba.c b/media/mca/filterpacks/native/imageproc/to_rgba.c index bf4db2afdd76..80094c0e703e 100644 --- a/media/mca/filterpacks/native/imageproc/to_rgba.c +++ b/media/mca/filterpacks/native/imageproc/to_rgba.c @@ -16,12 +16,14 @@ #include <stdlib.h> +#define ATTRIBUTE_UNUSED __attribute__((unused)) + int gray_to_rgb_process(const char** inputs, const int* input_sizes, int input_count, char* output, int output_size, - void* user_data) { + void* user_data ATTRIBUTE_UNUSED) { // Make sure we have exactly one input if (input_count != 1) return 0; @@ -52,7 +54,7 @@ int rgba_to_rgb_process(const char** inputs, int input_count, char* output, int output_size, - void* user_data) { + void* user_data ATTRIBUTE_UNUSED) { // Make sure we have exactly one input if (input_count != 1) return 0; @@ -84,7 +86,7 @@ int gray_to_rgba_process(const char** inputs, int input_count, char* output, int output_size, - void* user_data) { + void* user_data ATTRIBUTE_UNUSED) { // Make sure we have exactly one input if (input_count != 1) return 0; @@ -116,7 +118,7 @@ int rgb_to_rgba_process(const char** inputs, int input_count, char* output, int output_size, - void* user_data) { + void* user_data ATTRIBUTE_UNUSED) { // Make sure we have exactly one input if (input_count != 1) return 0; diff --git a/native/android/Android.mk b/native/android/Android.mk index cda38e06270b..b3a74a87801f 100644 --- a/native/android/Android.mk +++ b/native/android/Android.mk @@ -34,6 +34,8 @@ LOCAL_C_INCLUDES += \ frameworks/base/native/include \ frameworks/base/core/jni/android -LOCAL_MODULE:= libandroid +LOCAL_MODULE := libandroid + +LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code include $(BUILD_SHARED_LIBRARY) diff --git a/native/graphics/jni/Android.mk b/native/graphics/jni/Android.mk index 31540307f586..88954f04cd33 100644 --- a/native/graphics/jni/Android.mk +++ b/native/graphics/jni/Android.mk @@ -6,27 +6,29 @@ include $(CLEAR_VARS) # setup for skia optimizations # ifneq ($(ARCH_ARM_HAVE_VFP),true) - LOCAL_CFLAGS += -DSK_SOFTWARE_FLOAT + LOCAL_CFLAGS += -DSK_SOFTWARE_FLOAT endif ifeq ($(ARCH_ARM_HAVE_NEON),true) - LOCAL_CFLAGS += -D__ARM_HAVE_NEON + LOCAL_CFLAGS += -D__ARM_HAVE_NEON endif # our source files # LOCAL_SRC_FILES:= \ - bitmap.cpp + bitmap.cpp LOCAL_SHARED_LIBRARIES := \ libandroid_runtime \ libskia LOCAL_C_INCLUDES += \ - frameworks/base/native/include \ - frameworks/base/core/jni/android/graphics + frameworks/base/native/include \ + frameworks/base/core/jni/android/graphics LOCAL_MODULE:= libjnigraphics +LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code + include $(BUILD_SHARED_LIBRARY) diff --git a/native/graphics/jni/bitmap.cpp b/native/graphics/jni/bitmap.cpp index df0751d0fe5f..ea32edc9955e 100644 --- a/native/graphics/jni/bitmap.cpp +++ b/native/graphics/jni/bitmap.cpp @@ -15,7 +15,11 @@ */ #include <android/bitmap.h> + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" #include <GraphicsJNI.h> +#pragma GCC diagnostic pop int AndroidBitmap_getInfo(JNIEnv* env, jobject jbitmap, AndroidBitmapInfo* info) { diff --git a/tools/aidl/aidl.cpp b/tools/aidl/aidl.cpp index 45dd23b911e3..14c9f95a247b 100644 --- a/tools/aidl/aidl.cpp +++ b/tools/aidl/aidl.cpp @@ -228,7 +228,8 @@ check_filename(const char* filename, const char* package, buffer_type* name) } #endif -#ifdef OS_CASE_SENSITIVE + // aidl assumes case-insensitivity on Mac Os and Windows. +#if defined(__linux__) valid = (expected == p); #else valid = !strcasecmp(expected.c_str(), p); |