display: Enable clang for all display modules

Change-Id: I71e3fa3f7d44253b8e01d1eafe086b1898d65a8e
diff --git a/hdmi_cec/Android.mk b/hdmi_cec/Android.mk
index ed06da1..3b794e3 100644
--- a/hdmi_cec/Android.mk
+++ b/hdmi_cec/Android.mk
@@ -8,7 +8,8 @@
 LOCAL_C_INCLUDES              := $(common_includes)
 LOCAL_SHARED_LIBRARIES        := $(common_libs) libqservice libbinder libqdutils
 
-LOCAL_CFLAGS                  := $(common_flags) -DLOG_TAG=\"qdhdmi_cec\"
+LOCAL_CFLAGS                  := $(common_flags) -DLOG_TAG=\"qdhdmi_cec\" -Wno-sign-conversion
+LOCAL_CLANG                   := true
 LOCAL_ADDITIONAL_DEPENDENCIES := $(common_deps)
 LOCAL_SRC_FILES               := qhdmi_cec.cpp \
                                  QHDMIClient.cpp
diff --git a/libcopybit/Android.mk b/libcopybit/Android.mk
index f6f7ed5..a165826 100644
--- a/libcopybit/Android.mk
+++ b/libcopybit/Android.mk
@@ -26,8 +26,9 @@
 LOCAL_MODULE_TAGS             := optional
 LOCAL_C_INCLUDES              := $(common_includes) $(kernel_includes)
 LOCAL_SHARED_LIBRARIES        := $(common_libs) libdl libmemalloc
-LOCAL_CFLAGS                  := $(common_flags) -DLOG_TAG=\"qdcopybit\"
+LOCAL_CFLAGS                  := $(common_flags) -DLOG_TAG=\"qdcopybit\" -Wno-sign-conversion
 LOCAL_ADDITIONAL_DEPENDENCIES := $(common_deps)
+LOCAL_CLANG                   := true
 
 ifeq ($(TARGET_USES_C2D_COMPOSITION),true)
     LOCAL_CFLAGS += -DCOPYBIT_Z180=1 -DC2D_SUPPORT_DISPLAY=1
diff --git a/libcopybit/copybit_c2d.cpp b/libcopybit/copybit_c2d.cpp
index 9936eb6..240ba26 100644
--- a/libcopybit/copybit_c2d.cpp
+++ b/libcopybit/copybit_c2d.cpp
@@ -194,22 +194,22 @@
                         struct hw_device_t** device);
 
 static struct hw_module_methods_t copybit_module_methods = {
-open:  open_copybit
+    .open = open_copybit,
 };
 
 /*
  * The COPYBIT Module
  */
 struct copybit_module_t HAL_MODULE_INFO_SYM = {
-common: {
-tag: HARDWARE_MODULE_TAG,
-     version_major: 1,
-     version_minor: 0,
-     id: COPYBIT_HARDWARE_MODULE_ID,
-     name: "QCT COPYBIT C2D 2.0 Module",
-     author: "Qualcomm",
-     methods: &copybit_module_methods
-        }
+    .common = {
+        .tag =  HARDWARE_MODULE_TAG,
+        .version_major = 1,
+        .version_minor = 0,
+        .id = COPYBIT_HARDWARE_MODULE_ID,
+        .name = "QCT COPYBIT C2D 2.0 Module",
+        .author = "Qualcomm",
+        .methods =  &copybit_module_methods
+    }
 };
 
 
@@ -925,27 +925,6 @@
     return value;
 }
 
-static int is_alpha(int cformat)
-{
-    int alpha = 0;
-    switch (cformat & 0xFF) {
-        case C2D_COLOR_FORMAT_8888_ARGB:
-        case C2D_COLOR_FORMAT_8888_RGBA:
-        case C2D_COLOR_FORMAT_5551_RGBA:
-        case C2D_COLOR_FORMAT_4444_ARGB:
-            alpha = 1;
-            break;
-        default:
-            alpha = 0;
-            break;
-    }
-
-    if(alpha && (cformat&C2D_FORMAT_DISABLE_ALPHA))
-        alpha = 0;
-
-    return alpha;
-}
-
 /* Function to check if we need a temporary buffer for the blit.
  * This would happen if the requested destination stride and the
  * C2D stride do not match. We ignore RGB buffers, since their
diff --git a/libgralloc/Android.mk b/libgralloc/Android.mk
index 412f1be..03da814 100644
--- a/libgralloc/Android.mk
+++ b/libgralloc/Android.mk
@@ -23,7 +23,8 @@
 LOCAL_C_INCLUDES              := $(common_includes) $(kernel_includes)
 LOCAL_SHARED_LIBRARIES        := $(common_libs) libmemalloc libqdMetaData
 LOCAL_SHARED_LIBRARIES        += libqdutils libGLESv1_CM
-LOCAL_CFLAGS                  := $(common_flags) -DLOG_TAG=\"qdgralloc\"
+LOCAL_CFLAGS                  := $(common_flags) -DLOG_TAG=\"qdgralloc\" -Wno-sign-conversion
+LOCAL_CLANG                   := true
 LOCAL_ADDITIONAL_DEPENDENCIES := $(common_deps) $(kernel_deps)
 LOCAL_SRC_FILES               := gpu.cpp gralloc.cpp framebuffer.cpp mapper.cpp
 LOCAL_COPY_HEADERS_TO         := $(common_header_export_path)
@@ -38,7 +39,8 @@
 LOCAL_MODULE_TAGS             := optional
 LOCAL_C_INCLUDES              := $(common_includes) $(kernel_includes)
 LOCAL_SHARED_LIBRARIES        := $(common_libs) libqdutils libdl
-LOCAL_CFLAGS                  := $(common_flags) -DLOG_TAG=\"qdmemalloc\"
+LOCAL_CFLAGS                  := $(common_flags) -DLOG_TAG=\"qdmemalloc\" -Wno-sign-conversion
+LOCAL_CLANG                   := true
 LOCAL_ADDITIONAL_DEPENDENCIES := $(common_deps) $(kernel_deps)
 LOCAL_SRC_FILES               := ionalloc.cpp alloc_controller.cpp
 LOCAL_COPY_HEADERS            := alloc_controller.h memalloc.h
diff --git a/libgralloc/alloc_controller.cpp b/libgralloc/alloc_controller.cpp
index 4e9e264..7411c38 100644
--- a/libgralloc/alloc_controller.cpp
+++ b/libgralloc/alloc_controller.cpp
@@ -646,7 +646,7 @@
             size = alignedw * alignedh * ASTC_BLOCK_SIZE;
             break;
         default:
-            ALOGE("Unrecognized pixel format: 0x%x", __FUNCTION__, format);
+            ALOGE("%s: Unrecognized pixel format: 0x%x", __FUNCTION__, format);
             return 0;
     }
     return size;
diff --git a/libgralloc/framebuffer.cpp b/libgralloc/framebuffer.cpp
index 0ebc3db..5c297c1 100644
--- a/libgralloc/framebuffer.cpp
+++ b/libgralloc/framebuffer.cpp
@@ -43,14 +43,6 @@
 #include <profiler.h>
 
 #define EVEN_OUT(x) if (x & 0x0001) {x--;}
-/** min of int a, b */
-static inline int min(int a, int b) {
-    return (a<b) ? a : b;
-}
-/** max of int a, b */
-static inline int max(int a, int b) {
-    return (a>b) ? a : b;
-}
 
 enum {
     PAGE_FLIP = 0x00000001,
diff --git a/libgralloc/gralloc.cpp b/libgralloc/gralloc.cpp
index c0aa8cb..237b8a8 100644
--- a/libgralloc/gralloc.cpp
+++ b/libgralloc/gralloc.cpp
@@ -61,36 +61,36 @@
 
 // HAL module methods
 static struct hw_module_methods_t gralloc_module_methods = {
-    open: gralloc_device_open
+    .open = gralloc_device_open
 };
 
 // HAL module initialize
 struct private_module_t HAL_MODULE_INFO_SYM = {
-    base: {
-        common: {
-            tag: HARDWARE_MODULE_TAG,
-            version_major: 1,
-            version_minor: 0,
-            id: GRALLOC_HARDWARE_MODULE_ID,
-            name: "Graphics Memory Allocator Module",
-            author: "The Android Open Source Project",
-            methods: &gralloc_module_methods,
-            dso: 0,
-            reserved: {0},
+    .base = {
+        .common = {
+            .tag = HARDWARE_MODULE_TAG,
+            .version_major = 1,
+            .version_minor = 0,
+            .id = GRALLOC_HARDWARE_MODULE_ID,
+            .name = "Graphics Memory Allocator Module",
+            .author = "The Android Open Source Project",
+            .methods = &gralloc_module_methods,
+            .dso = 0,
+            .reserved = {0},
         },
-        registerBuffer: gralloc_register_buffer,
-        unregisterBuffer: gralloc_unregister_buffer,
-        lock: gralloc_lock,
-        unlock: gralloc_unlock,
-        perform: gralloc_perform,
-        lock_ycbcr: gralloc_lock_ycbcr,
+        .registerBuffer = gralloc_register_buffer,
+        .unregisterBuffer = gralloc_unregister_buffer,
+        .lock = gralloc_lock,
+        .unlock = gralloc_unlock,
+        .perform = gralloc_perform,
+        .lock_ycbcr = gralloc_lock_ycbcr,
     },
-    framebuffer: 0,
-    fbFormat: 0,
-    flags: 0,
-    numBuffers: 0,
-    bufferMask: 0,
-    lock: PTHREAD_MUTEX_INITIALIZER,
+    .framebuffer = 0,
+    .fbFormat = 0,
+    .flags = 0,
+    .numBuffers = 0,
+    .bufferMask = 0,
+    .lock = PTHREAD_MUTEX_INITIALIZER,
 };
 
 // Open Gralloc device
diff --git a/libgralloc/mapper.cpp b/libgralloc/mapper.cpp
index 5e8e59f..37e83bc 100644
--- a/libgralloc/mapper.cpp
+++ b/libgralloc/mapper.cpp
@@ -118,7 +118,7 @@
     if(hnd->base) {
         err = memalloc->unmap_buffer((void*)hnd->base, hnd->size, hnd->offset);
         if (err) {
-            ALOGE("Could not unmap memory at address %p, %s", hnd->base,
+            ALOGE("Could not unmap memory at address %p, %s", (void*) hnd->base,
                     strerror(errno));
             return -errno;
         }
@@ -131,7 +131,7 @@
                 size, hnd->offset_metadata);
         if (err) {
             ALOGE("Could not unmap memory at address %p, %s",
-                    hnd->base_metadata, strerror(errno));
+                    (void*) hnd->base_metadata, strerror(errno));
             return -errno;
         }
         hnd->base_metadata = 0;
diff --git a/liblight/Android.mk b/liblight/Android.mk
index 977fc55..8aff542 100644
--- a/liblight/Android.mk
+++ b/liblight/Android.mk
@@ -21,6 +21,7 @@
 LOCAL_MODULE_RELATIVE_PATH := hw
 LOCAL_SHARED_LIBRARIES := liblog
 LOCAL_CFLAGS := $(common_flags) -DLOG_TAG=\"qdlights\"
+LOCAL_CLANG  := true
 LOCAL_MODULE := lights.$(TARGET_BOARD_PLATFORM)
 LOCAL_MODULE_TAGS := optional
 
diff --git a/libmemtrack/Android.mk b/libmemtrack/Android.mk
index 3ed37a3..4e7a09f 100644
--- a/libmemtrack/Android.mk
+++ b/libmemtrack/Android.mk
@@ -20,7 +20,8 @@
 
 LOCAL_MODULE_RELATIVE_PATH := hw
 LOCAL_C_INCLUDES += hardware/libhardware/include
-LOCAL_CFAGS := -Wconversion -Wall -Werror
+LOCAL_CFLAGS := -Wconversion -Wall -Werror -Wno-sign-conversion
+LOCAL_CLANG  := true
 LOCAL_SHARED_LIBRARIES := liblog
 LOCAL_SRC_FILES := memtrack_msm.c kgsl.c
 LOCAL_MODULE := memtrack.$(TARGET_BOARD_PLATFORM)
diff --git a/libmemtrack/kgsl.c b/libmemtrack/kgsl.c
index 6dc9774..958859a 100644
--- a/libmemtrack/kgsl.c
+++ b/libmemtrack/kgsl.c
@@ -45,14 +45,12 @@
                              size_t *num_records)
 {
     size_t allocated_records = min(*num_records, ARRAY_SIZE(record_templates));
-    int i;
     FILE *fp;
     char line[1024];
     char tmp[128];
     bool is_surfaceflinger = false;
     size_t accounted_size = 0;
     size_t unaccounted_size = 0;
-    unsigned long smaps_addr = 0;
 
     *num_records = ARRAY_SIZE(record_templates);
 
diff --git a/libmemtrack/memtrack_msm.c b/libmemtrack/memtrack_msm.c
index 8adff96..e369d5f 100644
--- a/libmemtrack/memtrack_msm.c
+++ b/libmemtrack/memtrack_msm.c
@@ -47,17 +47,17 @@
 };
 
 struct memtrack_module HAL_MODULE_INFO_SYM = {
-    common: {
-        tag: HARDWARE_MODULE_TAG,
-        module_api_version: MEMTRACK_MODULE_API_VERSION_0_1,
-        hal_api_version: HARDWARE_HAL_API_VERSION,
-        id: MEMTRACK_HARDWARE_MODULE_ID,
-        name: "MSM Memory Tracker HAL",
-        author: "The Android Open Source Project",
-        methods: &memtrack_module_methods,
+    .common = {
+        .tag = HARDWARE_MODULE_TAG,
+        .module_api_version = MEMTRACK_MODULE_API_VERSION_0_1,
+        .hal_api_version = HARDWARE_HAL_API_VERSION,
+        .id = MEMTRACK_HARDWARE_MODULE_ID,
+        .name = "MSM Memory Tracker HAL",
+        .author = "The Android Open Source Project",
+        .methods = &memtrack_module_methods,
     },
 
-    init: msm_memtrack_init,
-    getMemory: msm_memtrack_get_memory,
+    .init = msm_memtrack_init,
+    .getMemory = msm_memtrack_get_memory,
 };
 
diff --git a/libqdutils/Android.mk b/libqdutils/Android.mk
index 475fa3b..f56f774 100644
--- a/libqdutils/Android.mk
+++ b/libqdutils/Android.mk
@@ -6,7 +6,8 @@
 LOCAL_MODULE_TAGS             := optional
 LOCAL_SHARED_LIBRARIES        := $(common_libs) libui libbinder libqservice
 LOCAL_C_INCLUDES              := $(common_includes) $(kernel_includes)
-LOCAL_CFLAGS                  := $(common_flags) -DLOG_TAG=\"qdutils\"
+LOCAL_CFLAGS                  := $(common_flags) -DLOG_TAG=\"qdutils\" -Wno-sign-conversion
+LOCAL_CLANG                   := true
 LOCAL_ADDITIONAL_DEPENDENCIES := $(common_deps)
 LOCAL_COPY_HEADERS_TO         := $(common_header_export_path)
 LOCAL_COPY_HEADERS            := display_config.h
@@ -23,8 +24,9 @@
 LOCAL_C_INCLUDES                := $(common_includes)
 LOCAL_ADDITIONAL_DEPENDENCIES   := $(common_deps)
 LOCAL_SRC_FILES                 := qdMetaData.cpp
-LOCAL_CFLAGS                    := $(common_flags)
+LOCAL_CFLAGS                    := $(common_flags) -Wno-sign-conversion
 LOCAL_CFLAGS                    += -DLOG_TAG=\"DisplayMetaData\"
+LOCAL_CLANG                     := true
 LOCAL_MODULE_TAGS               := optional
 LOCAL_MODULE                    := libqdMetaData
 include $(BUILD_SHARED_LIBRARY)
diff --git a/libqservice/Android.mk b/libqservice/Android.mk
index 287e6ce..285afca 100644
--- a/libqservice/Android.mk
+++ b/libqservice/Android.mk
@@ -6,7 +6,8 @@
 LOCAL_MODULE_TAGS             := optional
 LOCAL_C_INCLUDES              := $(common_includes) $(kernel_includes)
 LOCAL_SHARED_LIBRARIES        := $(common_libs) libbinder
-LOCAL_CFLAGS                  := $(common_flags) -DLOG_TAG=\"qdqservice\"
+LOCAL_CFLAGS                  := $(common_flags) -DLOG_TAG=\"qdqservice\" -Wno-sign-conversion
+LOCAL_CLANG                   := true
 LOCAL_ADDITIONAL_DEPENDENCIES := $(common_deps)
 LOCAL_SRC_FILES               := QService.cpp \
                                  IQService.cpp \