Merge "libgralloc: use proper types and type casts"
diff --git a/libcopybit/copybit.cpp b/libcopybit/copybit.cpp
index c0246e3..645cd81 100644
--- a/libcopybit/copybit.cpp
+++ b/libcopybit/copybit.cpp
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2008 The Android Open Source Project
- * Copyright (c) 2010 - 2013, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2010 - 2014, The Linux Foundation. All rights reserved.
  *
  * Not a Contribution, Apache license notifications and license are retained
  * for attribution purposes only.
@@ -154,7 +154,7 @@
     img->width      = rhs->w;
     img->height     = rhs->h;
     img->format     = get_format(rhs->format);
-    img->offset     = hnd->offset;
+    img->offset     = (uint32_t)hnd->offset;
     img->memory_id  = hnd->fd;
 }
 /** setup rectangles */
@@ -162,9 +162,7 @@
                       struct mdp_blit_req *e,
                       const struct copybit_rect_t *dst,
                       const struct copybit_rect_t *src,
-                      const struct copybit_rect_t *scissor,
-                      uint32_t horiz_padding,
-                      uint32_t vert_padding) {
+                      const struct copybit_rect_t *scissor) {
     struct copybit_rect_t clip;
     intersect(&clip, scissor, dst);
 
@@ -312,7 +310,7 @@
             case COPYBIT_PLANE_ALPHA:
                 if (value < 0)      value = MDP_ALPHA_NOP;
                 if (value >= 256)   value = 255;
-                ctx->mAlpha = value;
+                ctx->mAlpha = (uint8_t)value;
                 break;
             case COPYBIT_DITHER:
                 if (value == COPYBIT_ENABLE) {
@@ -491,7 +489,8 @@
                 return -EINVAL;
             }
         }
-        const uint32_t maxCount = sizeof(list->req)/sizeof(list->req[0]);
+        const uint32_t maxCount =
+                (uint32_t)(sizeof(list->req)/sizeof(list->req[0]));
         const struct copybit_rect_t bounds = { 0, 0, (int)dst->w, (int)dst->h };
         struct copybit_rect_t clip;
         status = 0;
@@ -508,7 +507,7 @@
             set_infos(ctx, req, flags);
             set_image(&req->dst, dst);
             set_image(&req->src, src);
-            set_rects(ctx, req, dst_rect, src_rect, &clip, src->horiz_padding, src->vert_padding);
+            set_rects(ctx, req, dst_rect, src_rect, &clip);
 
             if (req->src_rect.w<=0 || req->src_rect.h<=0)
                 continue;
@@ -553,6 +552,9 @@
 static int finish_copybit(struct copybit_device_t *dev)
 {
     // NOP for MDP copybit
+    if(!dev)
+       return -EINVAL;
+
     return 0;
 }
 static int clear_copybit(struct copybit_device_t *dev,
@@ -702,6 +704,10 @@
                         struct hw_device_t** device)
 {
     int status = -EINVAL;
+
+    if (!strcmp(name, COPYBIT_HARDWARE_COPYBIT0)) {
+        return COPYBIT_FAILURE;
+    }
     copybit_context_t *ctx;
     ctx = (copybit_context_t *)malloc(sizeof(copybit_context_t));
     memset(ctx, 0, sizeof(*ctx));
diff --git a/libcopybit/copybit_c2d.cpp b/libcopybit/copybit_c2d.cpp
index 231bb2d..852b8c0 100644
--- a/libcopybit/copybit_c2d.cpp
+++ b/libcopybit/copybit_c2d.cpp
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2008 The Android Open Source Project
- * Copyright (c) 2010-2013, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2010-2014, The Linux Foundation. All rights reserved.
  *
  * Not a Contribution, Apache license notifications and license are retained
  * for attribution purposes only.
@@ -80,8 +80,8 @@
 
 C2D_STATUS (*LINK_c2dDestroySurface)( uint32 surface_id );
 
-C2D_STATUS (*LINK_c2dMapAddr) ( int mem_fd, void * hostptr, uint32 len,
-                                uint32 offset, uint32 flags, void ** gpuaddr);
+C2D_STATUS (*LINK_c2dMapAddr) ( int mem_fd, void * hostptr, size_t len,
+                                size_t offset, uint32 flags, void ** gpuaddr);
 
 C2D_STATUS (*LINK_c2dUnMapAddr) ( void * gpuaddr);
 
@@ -147,7 +147,7 @@
     alloc_data temp_src_buffer;
     alloc_data temp_dst_buffer;
     unsigned int dst[NUM_SURFACE_TYPES]; // dst surfaces
-    unsigned int mapped_gpu_addr[MAX_SURFACES]; // GPU addresses mapped inside copybit
+    uintptr_t mapped_gpu_addr[MAX_SURFACES]; // GPU addresses mapped inside copybit
     int blit_rgb_count;         // Total RGB surfaces being blit
     int blit_yuv_2_plane_count; // Total 2 plane YUV surfaces being
     int blit_yuv_3_plane_count; // Total 3 plane YUV  surfaces being blit
@@ -182,8 +182,8 @@
     int yStride;       //luma stride
     int plane1_stride;
     int plane2_stride;
-    int plane1_offset;
-    int plane2_offset;
+    size_t plane1_offset;
+    size_t plane2_offset;
 };
 
 /**
@@ -334,10 +334,11 @@
     return c2dBpp;
 }
 
-static uint32 c2d_get_gpuaddr(copybit_context_t* ctx,
+static size_t c2d_get_gpuaddr(copybit_context_t* ctx,
                               struct private_handle_t *handle, int &mapped_idx)
 {
-    uint32 memtype, *gpuaddr = 0;
+    uint32 memtype;
+    size_t *gpuaddr = 0;
     C2D_STATUS rc;
     int freeindex = 0;
     bool mapaddr = false;
@@ -374,11 +375,11 @@
         if (rc == C2D_STATUS_OK) {
             // We have mapped the GPU address inside copybit. We need to unmap
             // this address after the blit. Store this address
-            ctx->mapped_gpu_addr[freeindex] = (uint32) gpuaddr;
+            ctx->mapped_gpu_addr[freeindex] = (size_t)gpuaddr;
             mapped_idx = freeindex;
         }
     }
-    return (uint32) gpuaddr;
+    return (size_t)gpuaddr;
 }
 
 static void unmap_gpuaddr(copybit_context_t* ctx, int mapped_idx)
@@ -498,7 +499,7 @@
     struct private_handle_t* handle = (struct private_handle_t*)rhs->handle;
     C2D_SURFACE_TYPE surfaceType;
     int status = COPYBIT_SUCCESS;
-    uint32 gpuaddr = 0;
+    uintptr_t gpuaddr = 0;
     int c2d_format;
     mapped_idx = -1;
 
@@ -542,7 +543,7 @@
             ((flags & FLAGS_PREMULTIPLIED_ALPHA) ? C2D_FORMAT_PREMULTIPLIED : 0);
         surfaceDef.width = rhs->w;
         surfaceDef.height = rhs->h;
-        int aligned_width = ALIGN(surfaceDef.width,32);
+        int aligned_width = ALIGN((int)surfaceDef.width,32);
         surfaceDef.stride = (aligned_width * c2diGetBpp(surfaceDef.format))>>3;
 
         if(LINK_c2dUpdateSurface( surfaceId,C2D_TARGET | C2D_SOURCE, surfaceType,
@@ -730,7 +731,8 @@
        (ctx->trg_transform & C2D_TARGET_ROTATE_180)) {
         /* target rotation is 270 */
         c2dObject->target_rect.x        = (dst->t)<<16;
-        c2dObject->target_rect.y        = ctx->fb_width?(ALIGN(ctx->fb_width,32)- dst->r):dst->r;
+        c2dObject->target_rect.y        = ctx->fb_width?
+                (ALIGN(ctx->fb_width,32)- dst->r):dst->r;
         c2dObject->target_rect.y        = c2dObject->target_rect.y<<16;
         c2dObject->target_rect.height   = ((dst->r) - (dst->l))<<16;
         c2dObject->target_rect.width    = ((dst->b) - (dst->t))<<16;
@@ -743,7 +745,8 @@
     } else if(ctx->trg_transform & C2D_TARGET_ROTATE_180) {
         c2dObject->target_rect.y        = ctx->fb_height?(ctx->fb_height - dst->b):dst->b;
         c2dObject->target_rect.y        = c2dObject->target_rect.y<<16;
-        c2dObject->target_rect.x        = ctx->fb_width?(ALIGN(ctx->fb_width,32) - dst->r):dst->r;
+        c2dObject->target_rect.x        = ctx->fb_width?
+                (ALIGN(ctx->fb_width,32) - dst->r):dst->r;
         c2dObject->target_rect.x        = c2dObject->target_rect.x<<16;
         c2dObject->target_rect.height   = ((dst->b) - (dst->t))<<16;
         c2dObject->target_rect.width    = ((dst->r) - (dst->l))<<16;
@@ -957,7 +960,7 @@
  */
 static size_t get_size(const bufferInfo& info)
 {
-    size_t size = 0;
+    int size = 0;
     int w = info.width;
     int h = info.height;
     int aligned_w = ALIGN(w, 32);
@@ -1067,8 +1070,7 @@
     }
 }
 
-static bool need_to_execute_draw(struct copybit_context_t* ctx,
-                                          eC2DFlags flags)
+static bool need_to_execute_draw(eC2DFlags flags)
 {
     if (flags & FLAGS_TEMP_SRC_DST) {
         return true;
@@ -1185,7 +1187,7 @@
         dst_hnd->fd = ctx->temp_dst_buffer.fd;
         dst_hnd->size = ctx->temp_dst_buffer.size;
         dst_hnd->flags = ctx->temp_dst_buffer.allocType;
-        dst_hnd->base = (int)(ctx->temp_dst_buffer.base);
+        dst_hnd->base = (uintptr_t)(ctx->temp_dst_buffer.base);
         dst_hnd->offset = ctx->temp_dst_buffer.offset;
         dst_hnd->gpuaddr = 0;
         dst_image.handle = dst_hnd;
@@ -1270,7 +1272,7 @@
         src_hnd->fd = ctx->temp_src_buffer.fd;
         src_hnd->size = ctx->temp_src_buffer.size;
         src_hnd->flags = ctx->temp_src_buffer.allocType;
-        src_hnd->base = (int)(ctx->temp_src_buffer.base);
+        src_hnd->base = (uintptr_t)(ctx->temp_src_buffer.base);
         src_hnd->offset = ctx->temp_src_buffer.offset;
         src_hnd->gpuaddr = 0;
         src_image.handle = src_hnd;
@@ -1354,7 +1356,7 @@
 
     // Check if we need to perform an early draw-finish.
     flags |= (need_temp_dst || need_temp_src) ? FLAGS_TEMP_SRC_DST : 0;
-    if (need_to_execute_draw(ctx, (eC2DFlags)flags))
+    if (need_to_execute_draw((eC2DFlags)flags))
     {
         finish_copybit(dev);
     }
@@ -1388,8 +1390,11 @@
 }
 
 static int set_sync_copybit(struct copybit_device_t *dev,
-    int acquireFenceFd)
+    int /*acquireFenceFd*/)
 {
+    if(!dev)
+        return -EINVAL;
+
     return 0;
 }
 
@@ -1432,9 +1437,12 @@
 static int fill_color(struct copybit_device_t *dev,
                       struct copybit_image_t const *dst,
                       struct copybit_rect_t const *rect,
-                      uint32_t color)
+                      uint32_t /*color*/)
 {
     // TODO: Implement once c2d driver supports color fill
+    if(!dev || !dst || !rect)
+       return -EINVAL;
+
     return -EINVAL;
 }
 
@@ -1502,10 +1510,13 @@
                         struct hw_device_t** device)
 {
     int status = COPYBIT_SUCCESS;
+    if (strcmp(name, COPYBIT_HARDWARE_COPYBIT0)) {
+        return COPYBIT_FAILURE;
+    }
+
     C2D_RGB_SURFACE_DEF surfDefinition = {0};
     C2D_YUV_SURFACE_DEF yuvSurfaceDef = {0} ;
     struct copybit_context_t *ctx;
-    char fbName[64];
 
     ctx = (struct copybit_context_t *)malloc(sizeof(struct copybit_context_t));
     if(!ctx) {
diff --git a/libcopybit/software_converter.cpp b/libcopybit/software_converter.cpp
index e26b795..71e685e 100644
--- a/libcopybit/software_converter.cpp
+++ b/libcopybit/software_converter.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -52,7 +52,7 @@
     unsigned int   width   = src->w - src->horiz_padding;
     unsigned int   height  = src->h;
     unsigned int   y_size  = stride * src->h;
-    unsigned int   c_width = ALIGN(stride/2, 16);
+    unsigned int   c_width = ALIGN(stride/2, (unsigned int)16);
     unsigned int   c_size  = c_width * src->h/2;
     unsigned int   chromaPadding = c_width - width/2;
     unsigned int   chromaSize = c_size * 2;
@@ -128,19 +128,20 @@
     int height;
     int src_stride;
     int dst_stride;
-    int src_plane1_offset;
-    int src_plane2_offset;
-    int dst_plane1_offset;
-    int dst_plane2_offset;
+    size_t src_plane1_offset;
+    size_t src_plane2_offset;
+    size_t dst_plane1_offset;
+    size_t dst_plane2_offset;
 };
 
 /* Internal function to do the actual copy of source to destination */
-static int copy_source_to_destination(const int src_base, const int dst_base,
+static int copy_source_to_destination(const uintptr_t src_base,
+                                      const uintptr_t dst_base,
                                       copyInfo& info)
 {
     if (!src_base || !dst_base) {
-        ALOGE("%s: invalid memory src_base = 0x%x dst_base=0x%x",
-             __FUNCTION__, src_base, dst_base);
+        ALOGE("%s: invalid memory src_base = 0x%p dst_base=0x%p",
+             __FUNCTION__, (void*)src_base, (void*)dst_base);
          return COPYBIT_FAILURE;
     }
 
diff --git a/libhwcomposer/hwc.cpp b/libhwcomposer/hwc.cpp
index bfcfa78..48937c8 100644
--- a/libhwcomposer/hwc.cpp
+++ b/libhwcomposer/hwc.cpp
@@ -115,7 +115,7 @@
         // cache we need to reset it.
         // We can probably rethink that later on
         if (LIKELY(list && list->numHwLayers > 0)) {
-            for(uint32_t j = 0; j < list->numHwLayers; j++) {
+            for(size_t j = 0; j < list->numHwLayers; j++) {
                 if(list->hwLayers[j].compositionType != HWC_FRAMEBUFFER_TARGET)
                     list->hwLayers[j].compositionType = HWC_FRAMEBUFFER;
             }
@@ -135,7 +135,7 @@
                  */
                 ctx->isPaddingRound = true;
             }
-            ctx->mPrevHwLayerCount[i] = list->numHwLayers;
+            ctx->mPrevHwLayerCount[i] = (int)list->numHwLayers;
         } else {
             ctx->mPrevHwLayerCount[i] = 0;
         }
@@ -160,29 +160,31 @@
 
 static void scaleDisplayFrame(hwc_context_t *ctx, int dpy,
                             hwc_display_contents_1_t *list) {
-    float origXres = ctx->dpyAttr[dpy].xres_orig;
-    float origYres = ctx->dpyAttr[dpy].yres_orig;
-    float fakeXres = ctx->dpyAttr[dpy].xres;
-    float fakeYres = ctx->dpyAttr[dpy].yres;
-    float xresRatio = origXres / fakeXres;
-    float yresRatio = origYres / fakeYres;
+    uint32_t origXres = ctx->dpyAttr[dpy].xres_orig;
+    uint32_t origYres = ctx->dpyAttr[dpy].yres_orig;
+    uint32_t fakeXres = ctx->dpyAttr[dpy].xres;
+    uint32_t fakeYres = ctx->dpyAttr[dpy].yres;
+    float xresRatio = (float)origXres / (float)fakeXres;
+    float yresRatio = (float)origYres / (float)fakeYres;
     for (size_t i = 0; i < list->numHwLayers; i++) {
         hwc_layer_1_t *layer = &list->hwLayers[i];
         hwc_rect_t& displayFrame = layer->displayFrame;
         hwc_rect_t sourceCrop = integerizeSourceCrop(layer->sourceCropf);
-        float layerWidth = displayFrame.right - displayFrame.left;
-        float layerHeight = displayFrame.bottom - displayFrame.top;
-        float sourceWidth = sourceCrop.right - sourceCrop.left;
-        float sourceHeight = sourceCrop.bottom - sourceCrop.top;
+        uint32_t layerWidth = displayFrame.right - displayFrame.left;
+        uint32_t layerHeight = displayFrame.bottom - displayFrame.top;
+        uint32_t sourceWidth = sourceCrop.right - sourceCrop.left;
+        uint32_t sourceHeight = sourceCrop.bottom - sourceCrop.top;
 
-        if (isEqual(layerWidth / sourceWidth, xresRatio) &&
-                isEqual(layerHeight / sourceHeight, yresRatio))
+        if (isEqual(((float)layerWidth / (float)sourceWidth), xresRatio) &&
+                isEqual(((float)layerHeight / (float)sourceHeight), yresRatio))
             break;
 
-        displayFrame.left = xresRatio * displayFrame.left;
-        displayFrame.top = yresRatio * displayFrame.top;
-        displayFrame.right = displayFrame.left + layerWidth * xresRatio;
-        displayFrame.bottom = displayFrame.top + layerHeight * yresRatio;
+        displayFrame.left = (int)(xresRatio * (float)displayFrame.left);
+        displayFrame.top = (int)(yresRatio * (float)displayFrame.top);
+        displayFrame.right = (int)((float)displayFrame.left +
+                                   (float)layerWidth * xresRatio);
+        displayFrame.bottom = (int)((float)displayFrame.top +
+                                    (float)layerHeight * yresRatio);
     }
 }
 
@@ -198,7 +200,7 @@
         if (ctx->dpyAttr[dpy].customFBSize)
             scaleDisplayFrame(ctx, dpy, list);
 
-        reset_layer_prop(ctx, dpy, list->numHwLayers - 1);
+        reset_layer_prop(ctx, dpy, (int)list->numHwLayers - 1);
         setListStats(ctx, list, dpy);
 
         fbComp = (ctx->mMDPComp[dpy]->prepare(ctx, list) < 0);
@@ -226,7 +228,7 @@
     if (LIKELY(list && list->numHwLayers > 1) &&
             ctx->dpyAttr[dpy].isActive &&
             ctx->dpyAttr[dpy].connected) {
-        reset_layer_prop(ctx, dpy, list->numHwLayers - 1);
+        reset_layer_prop(ctx, dpy, (int)list->numHwLayers - 1);
         if(!ctx->dpyAttr[dpy].isPause) {
             ctx->dpyAttr[dpy].isConfiguring = false;
             setListStats(ctx, list, dpy);
@@ -261,13 +263,13 @@
 
     //Will be unlocked at the end of set
     ctx->mDrawLock.lock();
-    reset(ctx, numDisplays, displays);
+    reset(ctx, (int)numDisplays, displays);
 
     ctx->mOverlay->configBegin();
     ctx->mRotMgr->configBegin();
     overlay::Writeback::configBegin();
 
-    for (int32_t i = (numDisplays-1); i >= 0; i--) {
+    for (int32_t i = ((int32_t)numDisplays-1); i >=0 ; i--) {
         hwc_display_contents_1_t *list = displays[i];
         int dpy = getDpyforExternalDisplay(ctx, i);
         switch(dpy) {
@@ -496,7 +498,7 @@
     int ret = 0;
     const int dpy = HWC_DISPLAY_PRIMARY;
     if (LIKELY(list) && ctx->dpyAttr[dpy].isActive) {
-        uint32_t last = list->numHwLayers - 1;
+        size_t last = list->numHwLayers - 1;
         hwc_layer_1_t *fbLayer = &list->hwLayers[last];
         int fd = -1; //FenceFD from the Copybit(valid in async mode)
         bool copybitDone = false;
@@ -552,7 +554,7 @@
     if (LIKELY(list) && ctx->dpyAttr[dpy].isActive &&
         ctx->dpyAttr[dpy].connected &&
         !ctx->dpyAttr[dpy].isPause) {
-        uint32_t last = list->numHwLayers - 1;
+        size_t last = list->numHwLayers - 1;
         hwc_layer_1_t *fbLayer = &list->hwLayers[last];
         int fd = -1; //FenceFD from the Copybit(valid in async mode)
         bool copybitDone = false;
@@ -605,7 +607,7 @@
 {
     int ret = 0;
     hwc_context_t* ctx = (hwc_context_t*)(dev);
-    for (uint32_t i = 0; i < numDisplays; i++) {
+    for (int i = 0; i < (int)numDisplays; i++) {
         hwc_display_contents_1_t* list = displays[i];
         int dpy = getDpyforExternalDisplay(ctx, i);
         switch(dpy) {
@@ -685,7 +687,7 @@
         HWC_DISPLAY_NO_ATTRIBUTE,
     };
 
-    const int NUM_DISPLAY_ATTRIBUTES = (sizeof(DISPLAY_ATTRIBUTES) /
+    const size_t NUM_DISPLAY_ATTRIBUTES = (sizeof(DISPLAY_ATTRIBUTES) /
             sizeof(DISPLAY_ATTRIBUTES)[0]);
 
     for (size_t i = 0; i < NUM_DISPLAY_ATTRIBUTES - 1; i++) {
diff --git a/libhwcomposer/hwc_ad.cpp b/libhwcomposer/hwc_ad.cpp
index 236093b..be3793a 100644
--- a/libhwcomposer/hwc_ad.cpp
+++ b/libhwcomposer/hwc_ad.cpp
@@ -82,7 +82,7 @@
     if(adFd >= 0) {
         char opStr[4] = "";
         snprintf(opStr, sizeof(opStr), "%d", value);
-        int ret = write(adFd, opStr, strlen(opStr));
+        ssize_t ret = write(adFd, opStr, strlen(opStr));
         if(ret < 0) {
             ALOGE("%s: Failed to write %d with error %s",
                     __func__, value, strerror(errno));
@@ -206,7 +206,8 @@
         return false;
     }
 
-    int tmpW, tmpH, size;
+    int tmpW, tmpH;
+    size_t size;
     int format = ovutils::getHALFormat(wb->getOutputFormat());
     if(format < 0) {
         ALOGE("%s invalid format %d", __func__, format);
@@ -217,7 +218,7 @@
     size = getBufferSizeAndDimensions(hnd->width, hnd->height,
                 format, tmpW, tmpH);
 
-    if(!wb->configureMemory(size)) {
+    if(!wb->configureMemory((uint32_t)size)) {
         ALOGE("%s: config memory failed", __func__);
         mDoable = false;
         return false;
diff --git a/libhwcomposer/hwc_copybit.cpp b/libhwcomposer/hwc_copybit.cpp
index b111661..dc9a813 100644
--- a/libhwcomposer/hwc_copybit.cpp
+++ b/libhwcomposer/hwc_copybit.cpp
@@ -38,7 +38,7 @@
 
     region_iterator(hwc_region_t region) {
         mRegion = region;
-        r.end = region.numRects;
+        r.end = (int)region.numRects;
         r.current = 0;
         this->next = iterate;
     }
@@ -193,8 +193,8 @@
                          __FUNCTION__, dst_w,src_w,dst_h,src_h);
               return false;
             }
-            dx = (float)dst_w/src_w;
-            dy = (float)dst_h/src_h;
+            dx = (float)dst_w/(float)src_w;
+            dy = (float)dst_h/(float)src_h;
 
             if (dx > MAX_SCALE_FACTOR || dx < MIN_SCALE_FACTOR)
                 return false;
@@ -273,7 +273,7 @@
 
     //render buffer
     if (ctx->mMDP.version == qdutils::MDP_V3_0_4) {
-        last = list->numHwLayers - 1;
+        last = (uint32_t)list->numHwLayers - 1;
         renderBuffer = (private_handle_t *)list->hwLayers[last].handle;
     } else {
         renderBuffer = getCurrentRenderBuffer();
@@ -462,8 +462,8 @@
         return -1;
     }
 
-    float dsdx = (float)screen_w/src_crop_width;
-    float dtdy = (float)screen_h/src_crop_height;
+    float dsdx = (float)screen_w/(float)src_crop_width;
+    float dtdy = (float)screen_h/(float)src_crop_height;
 
     float scaleLimitMax = copybitsMaxScale * copybitsMaxScale;
     float scaleLimitMin = copybitsMinScale * copybitsMinScale;
@@ -494,14 +494,14 @@
        int tmp_h =  src_crop_height;
 
        if (dsdx > copybitsMaxScale || dtdy > copybitsMaxScale ){
-         tmp_w = src_crop_width*copybitsMaxScale;
-         tmp_h = src_crop_height*copybitsMaxScale;
+         tmp_w = (int)((float)src_crop_width*copybitsMaxScale);
+         tmp_h = (int)((float)src_crop_height*copybitsMaxScale);
        }else if (dsdx < 1/copybitsMinScale ||dtdy < 1/copybitsMinScale ){
          // ceil the tmp_w and tmp_h value to maintain proper ratio
          // b/w src and dst (should not cross the desired scale limit
          // due to float -> int )
-         tmp_w = ceil(src_crop_width/copybitsMinScale);
-         tmp_h = ceil(src_crop_height/copybitsMinScale);
+         tmp_w = (int)ceil((float)src_crop_width/copybitsMinScale);
+         tmp_h = (int)ceil((float)src_crop_height/copybitsMinScale);
        }
        ALOGD("%s:%d::tmp_w = %d,tmp_h = %d",__FUNCTION__,__LINE__,tmp_w,tmp_h);
 
diff --git a/libhwcomposer/hwc_dump_layers.cpp b/libhwcomposer/hwc_dump_layers.cpp
index bebcc18..6d084f3 100644
--- a/libhwcomposer/hwc_dump_layers.cpp
+++ b/libhwcomposer/hwc_dump_layers.cpp
@@ -211,7 +211,7 @@
 void HwcDebug::logLayer(size_t layerIndex, hwc_layer_1_t hwLayers[])
 {
     if (NULL == hwLayers) {
-        ALOGE("Display[%s] Layer[%d] Error. No hwc layers to log.",
+        ALOGE("Display[%s] Layer[%zu] Error. No hwc layers to log.",
             mDisplayName, layerIndex);
         return;
     }
@@ -238,7 +238,7 @@
         getHalPixelFormatStr(hnd->format, pixFormatStr);
 
     // Log Line 1
-    ALOGI("Display[%s] Layer[%d] SrcBuff[%dx%d] SrcCrop[%dl, %dt, %dr, %db] "
+    ALOGI("Display[%s] Layer[%zu] SrcBuff[%dx%d] SrcCrop[%dl, %dt, %dr, %db] "
         "DispFrame[%dl, %dt, %dr, %db] VisRegsScr%s", mDisplayName, layerIndex,
         (hnd)? getWidth(hnd) : -1, (hnd)? getHeight(hnd) : -1,
         sourceCrop.left, sourceCrop.top,
@@ -247,7 +247,7 @@
         displayFrame.right, displayFrame.bottom,
         hwcVisRegsScrLog.string());
     // Log Line 2
-    ALOGI("Display[%s] Layer[%d] LayerCompType = %s, Format = %s, "
+    ALOGI("Display[%s] Layer[%zu] LayerCompType = %s, Format = %s, "
         "Orientation = %s, Flags = %s%s%s, Hints = %s%s%s, "
         "Blending = %s%s%s", mDisplayName, layerIndex,
         (layer->compositionType == HWC_FRAMEBUFFER)? "Framebuffer(GPU)":
@@ -292,7 +292,7 @@
         return;
 
     if (NULL == hwLayers) {
-        ALOGE("Display[%s] Layer[%d] %s%s Error: No hwc layers to dump.",
+        ALOGE("Display[%s] Layer[%zu] %s%s Error: No hwc layers to dump.",
             mDisplayName, layerIndex, dumpLogStrRaw, dumpLogStrPng);
         return;
     }
@@ -302,7 +302,7 @@
     char pixFormatStr[32] = "None";
 
     if (NULL == hnd) {
-        ALOGI("Display[%s] Layer[%d] %s%s Skipping dump: Bufferless layer.",
+        ALOGI("Display[%s] Layer[%zu] %s%s Skipping dump: Bufferless layer.",
             mDisplayName, layerIndex, dumpLogStrRaw, dumpLogStrPng);
         return;
     }
@@ -315,7 +315,7 @@
         SkBitmap *tempSkBmp = new SkBitmap();
         SkBitmap::Config tempSkBmpConfig = SkBitmap::kNo_Config;
         snprintf(dumpFilename, sizeof(dumpFilename),
-            "%s/sfdump%03d.layer%d.%s.png", mDumpDirPng,
+            "%s/sfdump%03d.layer%zu.%s.png", mDumpDirPng,
             mDumpCntrPng, layerIndex, mDisplayName);
 
         switch (hnd->format) {
@@ -337,11 +337,11 @@
             tempSkBmp->setPixels((void*)hnd->base);
             bResult = SkImageEncoder::EncodeFile(dumpFilename,
                                     *tempSkBmp, SkImageEncoder::kPNG_Type, 100);
-            ALOGI("Display[%s] Layer[%d] %s Dump to %s: %s",
+            ALOGI("Display[%s] Layer[%zu] %s Dump to %s: %s",
                 mDisplayName, layerIndex, dumpLogStrPng,
                 dumpFilename, bResult ? "Success" : "Fail");
         } else {
-            ALOGI("Display[%s] Layer[%d] %s Skipping dump: Unsupported layer"
+            ALOGI("Display[%s] Layer[%zu] %s Skipping dump: Unsupported layer"
                 " format %s for png encoder",
                 mDisplayName, layerIndex, dumpLogStrPng, pixFormatStr);
         }
@@ -352,7 +352,7 @@
         char dumpFilename[PATH_MAX];
         bool bResult = false;
         snprintf(dumpFilename, sizeof(dumpFilename),
-            "%s/sfdump%03d.layer%d.%dx%d.%s.%s.raw",
+            "%s/sfdump%03d.layer%zu.%dx%d.%s.%s.raw",
             mDumpDirRaw, mDumpCntrRaw,
             layerIndex, getWidth(hnd), getHeight(hnd),
             pixFormatStr, mDisplayName);
@@ -361,7 +361,7 @@
             bResult = (bool) fwrite((void*)hnd->base, hnd->size, 1, fp);
             fclose(fp);
         }
-        ALOGI("Display[%s] Layer[%d] %s Dump to %s: %s",
+        ALOGI("Display[%s] Layer[%zu] %s Dump to %s: %s",
             mDisplayName, layerIndex, dumpLogStrRaw,
             dumpFilename, bResult ? "Success" : "Fail");
     }
@@ -432,7 +432,8 @@
             strlcpy(pixFormatStr, "YCbCr_420_SP_VENUS", sizeof(pixFormatStr));
             break;
         default:
-            snprintf(pixFormatStr, sizeof(pixFormatStr), "Unknown0x%X", format);
+            size_t len = sizeof(pixFormatStr);
+            snprintf(pixFormatStr, len, "Unknown0x%X", format);
             break;
     }
 }
diff --git a/libhwcomposer/hwc_fbupdate.cpp b/libhwcomposer/hwc_fbupdate.cpp
index bf2aee5..b51b2ea 100644
--- a/libhwcomposer/hwc_fbupdate.cpp
+++ b/libhwcomposer/hwc_fbupdate.cpp
@@ -239,7 +239,7 @@
     overlay::Overlay& ov = *(ctx->mOverlay);
     ovutils::eDest dest = mDest;
     int fd = hnd->fd;
-    uint32_t offset = hnd->offset;
+    uint32_t offset = (uint32_t)hnd->offset;
     if(mRot) {
         if(!mRot->queueBuffer(fd, offset))
             return false;
@@ -396,14 +396,14 @@
     bool ret = true;
     overlay::Overlay& ov = *(ctx->mOverlay);
     if(mDestLeft != ovutils::OV_INVALID) {
-        if (!ov.queueBuffer(hnd->fd, hnd->offset, mDestLeft)) {
+        if (!ov.queueBuffer(hnd->fd, (uint32_t)hnd->offset, mDestLeft)) {
             ALOGE("%s: queue failed for left of dpy = %d",
                   __FUNCTION__, mDpy);
             ret = false;
         }
     }
     if(mDestRight != ovutils::OV_INVALID) {
-        if (!ov.queueBuffer(hnd->fd, hnd->offset, mDestRight)) {
+        if (!ov.queueBuffer(hnd->fd, (uint32_t)hnd->offset, mDestRight)) {
             ALOGE("%s: queue failed for right of dpy = %d",
                   __FUNCTION__, mDpy);
             ret = false;
diff --git a/libhwcomposer/hwc_mdpcomp.cpp b/libhwcomposer/hwc_mdpcomp.cpp
index 12b4256..ab175cb 100644
--- a/libhwcomposer/hwc_mdpcomp.cpp
+++ b/libhwcomposer/hwc_mdpcomp.cpp
@@ -149,7 +149,8 @@
             ALOGE("%s: failed to instantiate idleInvalidator object",
                   __FUNCTION__);
         } else {
-            idleInvalidator->init(timeout_handler, ctx, idle_timeout);
+            idleInvalidator->init(timeout_handler, ctx,
+                                  (unsigned int)idle_timeout);
         }
     }
 
@@ -268,7 +269,7 @@
 }
 
 void MDPComp::LayerCache::cacheAll(hwc_display_contents_1_t* list) {
-    const int numAppLayers = list->numHwLayers - 1;
+    const int numAppLayers = (int)list->numHwLayers - 1;
     for(int i = 0; i < numAppLayers; i++) {
         hnd[i] = list->hwLayers[i].handle;
     }
@@ -1126,10 +1127,8 @@
              mCurrentFrame.fbCount);
 }
 
-hwc_rect_t MDPComp::getUpdatingFBRect(hwc_context_t *ctx,
-        hwc_display_contents_1_t* list){
+hwc_rect_t MDPComp::getUpdatingFBRect(hwc_display_contents_1_t* list){
     hwc_rect_t fbRect = (struct hwc_rect){0, 0, 0, 0};
-    hwc_layer_1_t *fbLayer = &list->hwLayers[mCurrentFrame.layerCount];
 
     /* Update only the region of FB needed for composition */
     for(int i = 0; i < mCurrentFrame.layerCount; i++ ) {
@@ -1146,7 +1145,7 @@
         hwc_display_contents_1_t* list) {
 
     //Capability checks
-    if(!resourceCheck(ctx, list)) {
+    if(!resourceCheck()) {
         ALOGD_IF(isDebug(), "%s: resource check failed", __FUNCTION__);
         return false;
     }
@@ -1159,7 +1158,7 @@
 
     //Configure framebuffer first if applicable
     if(mCurrentFrame.fbZ >= 0) {
-        hwc_rect_t fbRect = getUpdatingFBRect(ctx, list);
+        hwc_rect_t fbRect = getUpdatingFBRect(list);
         if(!ctx->mFBUpdate[mDpy]->prepare(ctx, list, fbRect, mCurrentFrame.fbZ))
         {
             ALOGD_IF(isDebug(), "%s configure framebuffer failed",
@@ -1220,8 +1219,7 @@
     return true;
 }
 
-bool MDPComp::resourceCheck(hwc_context_t *ctx,
-        hwc_display_contents_1_t *list) {
+bool MDPComp::resourceCheck() {
     const bool fbUsed = mCurrentFrame.fbCount;
     if(mCurrentFrame.mdpCount > sMaxPipesPerMixer - fbUsed) {
         ALOGD_IF(isDebug(), "%s: Exceeds MAX_PIPES_PER_MIXER",__FUNCTION__);
@@ -1275,7 +1273,6 @@
 int MDPComp::prepare(hwc_context_t *ctx, hwc_display_contents_1_t* list) {
     int ret = 0;
     const int numLayers = ctx->listStats[mDpy].numAppLayers;
-    MDPVersion& mdpVersion = qdutils::MDPVersion::getInstance();
 
     //Do not cache the information for next draw cycle.
     if(numLayers > MAX_NUM_APP_LAYERS or (!numLayers)) {
@@ -1520,7 +1517,7 @@
             ovutils::eDest indexL = pipe_info.lIndex;
             ovutils::eDest indexR = pipe_info.rIndex;
             int fd = hnd->fd;
-            uint32_t offset = hnd->offset;
+            uint32_t offset = (uint32_t)hnd->offset;
             if(rot) {
                 rot->queueBuffer(fd, offset);
                 fd = rot->getDstMemId();
@@ -1566,7 +1563,7 @@
                     hnd, dest );
 
             int fd = hnd->fd;
-            uint32_t offset = hnd->offset;
+            uint32_t offset = (uint32_t)hnd->offset;
 
             Rotator *rot = mCurrentFrame.mdpToLayer[mdpIndex].rot;
             if(rot) {
@@ -1766,7 +1763,7 @@
             ovutils::eDest indexL = pipe_info.lIndex;
             ovutils::eDest indexR = pipe_info.rIndex;
             int fd = hnd->fd;
-            uint32_t offset = hnd->offset;
+            uint32_t offset = (uint32_t)hnd->offset;
             if(rot) {
                 rot->queueBuffer(fd, offset);
                 fd = rot->getDstMemId();
@@ -1803,7 +1800,7 @@
             ovutils::eDest indexR = pipe_info.rIndex;
 
             int fd = hnd->fd;
-            int offset = hnd->offset;
+            int offset = (uint32_t)hnd->offset;
 
             if(ctx->mAD->isModeOn()) {
                 if(ctx->mAD->draw(ctx, fd, offset)) {
diff --git a/libhwcomposer/hwc_mdpcomp.h b/libhwcomposer/hwc_mdpcomp.h
index 2d65755..b6615ad 100644
--- a/libhwcomposer/hwc_mdpcomp.h
+++ b/libhwcomposer/hwc_mdpcomp.h
@@ -213,9 +213,8 @@
             hwc_display_contents_1_t* list);
     void reset(hwc_context_t *ctx);
     bool isSupportedForMDPComp(hwc_context_t *ctx, hwc_layer_1_t* layer);
-    bool resourceCheck(hwc_context_t *ctx, hwc_display_contents_1_t *list);
-    hwc_rect_t getUpdatingFBRect(hwc_context_t *ctx,
-            hwc_display_contents_1_t* list);
+    bool resourceCheck();
+    hwc_rect_t getUpdatingFBRect(hwc_display_contents_1_t* list);
 
     int mDpy;
     static bool sEnabled;
diff --git a/libhwcomposer/hwc_uevents.cpp b/libhwcomposer/hwc_uevents.cpp
index 7bc29bc..e1f7827 100644
--- a/libhwcomposer/hwc_uevents.cpp
+++ b/libhwcomposer/hwc_uevents.cpp
@@ -323,7 +323,7 @@
     }
 
     while(1) {
-        len = uevent_next_event(udata, sizeof(udata) - 2);
+        len = uevent_next_event(udata, (int)sizeof(udata) - 2);
         handle_uevent(ctx, udata, len);
     }
 
diff --git a/libhwcomposer/hwc_utils.cpp b/libhwcomposer/hwc_utils.cpp
index 8742990..19716d6 100644
--- a/libhwcomposer/hwc_utils.cpp
+++ b/libhwcomposer/hwc_utils.cpp
@@ -123,12 +123,12 @@
     if (int(info.width) <= 0 || int(info.height) <= 0) {
         // the driver doesn't return that information
         // default to 160 dpi
-        info.width  = ((info.xres * 25.4f)/160.0f + 0.5f);
-        info.height = ((info.yres * 25.4f)/160.0f + 0.5f);
+        info.width  = (int)(((float)info.xres * 25.4f)/160.0f + 0.5f);
+        info.height = (int)(((float)info.yres * 25.4f)/160.0f + 0.5f);
     }
 
-    float xdpi = (info.xres * 25.4f) / info.width;
-    float ydpi = (info.yres * 25.4f) / info.height;
+    float xdpi = ((float)info.xres * 25.4f) / (float)info.width;
+    float ydpi = ((float)info.yres * 25.4f) / (float)info.height;
 
 #ifdef MSMFB_METADATA_GET
     struct msmfb_metadata metadata;
@@ -142,7 +142,7 @@
         return -errno;
     }
 
-    float fps  = metadata.data.panel_frame_rate;
+    float fps  = (float)metadata.data.panel_frame_rate;
 #else
     //XXX: Remove reserved field usage on all baselines
     //The reserved[3] field is used to store FPS by the driver.
@@ -163,7 +163,8 @@
     ctx->dpyAttr[HWC_DISPLAY_PRIMARY].yres = info.yres;
     ctx->dpyAttr[HWC_DISPLAY_PRIMARY].xdpi = xdpi;
     ctx->dpyAttr[HWC_DISPLAY_PRIMARY].ydpi = ydpi;
-    ctx->dpyAttr[HWC_DISPLAY_PRIMARY].vsync_period = 1000000000l / fps;
+    ctx->dpyAttr[HWC_DISPLAY_PRIMARY].vsync_period =
+            (uint32_t)(1000000000l / fps);
 
     //To change resolution of primary display
     changeResolution(ctx, info.xres, info.yres);
@@ -388,26 +389,26 @@
 
     float asX = 0;
     float asY = 0;
-    float asW = fbWidth;
-    float asH = fbHeight;
+    float asW = (float)fbWidth;
+    float asH = (float)fbHeight;
 
     // based on the action safe ratio, get the Action safe rectangle
-    asW = fbWidth * (1.0f -  asWidthRatio / 100.0f);
-    asH = fbHeight * (1.0f -  asHeightRatio / 100.0f);
-    asX = (fbWidth - asW) / 2;
-    asY = (fbHeight - asH) / 2;
+    asW = ((float)fbWidth * (1.0f -  (float)asWidthRatio / 100.0f));
+    asH = ((float)fbHeight * (1.0f -  (float)asHeightRatio / 100.0f));
+    asX = ((float)fbWidth - asW) / 2;
+    asY = ((float)fbHeight - asH) / 2;
 
     // calculate the position ratio
-    xRatio = (float)x/fbWidth;
-    yRatio = (float)y/fbHeight;
-    wRatio = (float)w/fbWidth;
-    hRatio = (float)h/fbHeight;
+    xRatio = (float)x/(float)fbWidth;
+    yRatio = (float)y/(float)fbHeight;
+    wRatio = (float)w/(float)fbWidth;
+    hRatio = (float)h/(float)fbHeight;
 
     //Calculate the position...
-    x = (xRatio * asW) + asX;
-    y = (yRatio * asH) + asY;
-    w = (wRatio * asW);
-    h = (hRatio * asH);
+    x = int((xRatio * asW) + asX);
+    y = int((yRatio * asH) + asY);
+    w = int(wRatio * asW);
+    h = int(hRatio * asH);
 
     // Convert it back to hwc_rect_t
     rect.left = x;
@@ -423,8 +424,8 @@
 void getAspectRatioPosition(hwc_context_t* ctx, int dpy, int extOrientation,
                             hwc_rect_t& inRect, hwc_rect_t& outRect) {
     // Physical display resolution
-    float fbWidth  = ctx->dpyAttr[dpy].xres;
-    float fbHeight = ctx->dpyAttr[dpy].yres;
+    float fbWidth  = (float)ctx->dpyAttr[dpy].xres;
+    float fbHeight = (float)ctx->dpyAttr[dpy].yres;
     //display position(x,y,w,h) in correct aspectratio after rotation
     int xPos = 0;
     int yPos = 0;
@@ -445,7 +446,7 @@
     Dim outPos(outRect.left, outRect.top, outRect.right - outRect.left,
                 outRect.bottom - outRect.top);
 
-    Whf whf(fbWidth, fbHeight, 0);
+    Whf whf((uint32_t)fbWidth, (uint32_t)fbHeight, 0);
     eTransform extorient = static_cast<eTransform>(extOrientation);
     // To calculate the destination co-ordinates in the new orientation
     preRotateSource(extorient, whf, inPos);
@@ -453,24 +454,23 @@
     if(extOrientation & HAL_TRANSFORM_ROT_90) {
         // Swap width/height for input position
         swapWidthHeight(actualWidth, actualHeight);
-        getAspectRatioPosition(fbWidth, fbHeight, (int)actualWidth,
+        getAspectRatioPosition((int)fbWidth, (int)fbHeight, (int)actualWidth,
                                (int)actualHeight, rect);
         xPos = rect.left;
         yPos = rect.top;
-        width = rect.right - rect.left;
-        height = rect.bottom - rect.top;
+        width = float(rect.right - rect.left);
+        height = float(rect.bottom - rect.top);
     }
-    xRatio = inPos.x/actualWidth;
-    yRatio = inPos.y/actualHeight;
-    wRatio = inPos.w/actualWidth;
-    hRatio = inPos.h/actualHeight;
+    xRatio = (float)(inPos.x/actualWidth);
+    yRatio = (float)(inPos.y/actualHeight);
+    wRatio = (float)(inPos.w/actualWidth);
+    hRatio = (float)(inPos.h/actualHeight);
 
-
-    //Calculate the position...
-    outPos.x = (xRatio * width) + xPos;
-    outPos.y = (yRatio * height) + yPos;
-    outPos.w = wRatio * width;
-    outPos.h = hRatio * height;
+    //Calculate the pos9ition...
+    outPos.x = uint32_t((xRatio * width) + (float)xPos);
+    outPos.y = uint32_t((yRatio * height) + (float)yPos);
+    outPos.w = uint32_t(wRatio * width);
+    outPos.h = uint32_t(hRatio * height);
     ALOGD_IF(HWC_UTILS_DEBUG, "%s: Calculated AspectRatio Position: x = %d,"
                  "y = %d w = %d h = %d", __FUNCTION__, outPos.x, outPos.y,
                  outPos.w, outPos.h);
@@ -483,22 +483,23 @@
                         isOrientationPortrait(ctx)) {
         hwc_rect_t r = {0, 0, 0, 0};
         //Calculate the position
-        xRatio = (outPos.x - xPos)/width;
+        xRatio = (float)(outPos.x - xPos)/width;
         // GetaspectRatio -- tricky to get the correct aspect ratio
         // But we need to do this.
-        getAspectRatioPosition(width, height, width, height, r);
+        getAspectRatioPosition((int)width, (int)height,
+                               (int)width,(int)height, r);
         xPos = r.left;
         yPos = r.top;
-        float tempHeight = r.bottom - r.top;
-        yRatio = yPos/height;
-        wRatio = outPos.w/width;
+        float tempHeight = float(r.bottom - r.top);
+        yRatio = (float)yPos/height;
+        wRatio = (float)outPos.w/width;
         hRatio = tempHeight/height;
 
         //Map the coordinates back to Framebuffer domain
-        outPos.x = (xRatio * fbWidth);
-        outPos.y = (yRatio * fbHeight);
-        outPos.w = wRatio * fbWidth;
-        outPos.h = hRatio * fbHeight;
+        outPos.x = uint32_t(xRatio * fbWidth);
+        outPos.y = uint32_t(yRatio * fbHeight);
+        outPos.w = uint32_t(wRatio * fbWidth);
+        outPos.h = uint32_t(hRatio * fbHeight);
 
         ALOGD_IF(HWC_UTILS_DEBUG, "%s: Calculated AspectRatio for device in"
                  "portrait: x = %d,y = %d w = %d h = %d", __FUNCTION__,
@@ -511,18 +512,18 @@
             ctx->mExtDisplay->getAttributes(extW, extH);
         else
             ctx->mVirtualDisplay->getAttributes(extW, extH);
-        fbWidth  = ctx->dpyAttr[dpy].xres;
-        fbHeight = ctx->dpyAttr[dpy].yres;
+        fbWidth  = (float)ctx->dpyAttr[dpy].xres;
+        fbHeight = (float)ctx->dpyAttr[dpy].yres;
         //Calculate the position...
-        xRatio = outPos.x/fbWidth;
-        yRatio = outPos.y/fbHeight;
-        wRatio = outPos.w/fbWidth;
-        hRatio = outPos.h/fbHeight;
+        xRatio = (float)outPos.x/fbWidth;
+        yRatio = (float)outPos.y/fbHeight;
+        wRatio = (float)outPos.w/fbWidth;
+        hRatio = (float)outPos.h/fbHeight;
 
-        outPos.x = xRatio * extW;
-        outPos.y = yRatio * extH;
-        outPos.w = wRatio * extW;
-        outPos.h = hRatio * extH;
+        outPos.x = uint32_t(xRatio * (float)extW);
+        outPos.y = uint32_t(yRatio * (float)extH);
+        outPos.w = uint32_t(wRatio * (float)extW);
+        outPos.h = uint32_t(hRatio * (float)extH);
     }
     // Convert Dim to hwc_rect_t
     outRect.left = outPos.x;
@@ -585,8 +586,8 @@
                 int extW, extH;
                 // if downscale is enabled, map the co-ordinates to new
                 // domain(downscaled)
-                float fbWidth  = ctx->dpyAttr[dpy].xres;
-                float fbHeight = ctx->dpyAttr[dpy].yres;
+                float fbWidth  = (float)ctx->dpyAttr[dpy].xres;
+                float fbHeight = (float)ctx->dpyAttr[dpy].yres;
                 // query MDP configured attributes
                 if(dpy == HWC_DISPLAY_EXTERNAL)
                     ctx->mExtDisplay->getAttributes(extW, extH);
@@ -597,10 +598,10 @@
                 float hRatio = ((float)extH)/fbHeight;
 
                 //convert Dim to hwc_rect_t
-                displayFrame.left *= wRatio;
-                displayFrame.top *= hRatio;
-                displayFrame.right *= wRatio;
-                displayFrame.bottom *= hRatio;
+                displayFrame.left = int(wRatio*(float)displayFrame.left);
+                displayFrame.top = int(hRatio*(float)displayFrame.top);
+                displayFrame.right = int(wRatio*(float)displayFrame.right);
+                displayFrame.bottom = int(hRatio*(float)displayFrame.bottom);
             }
         }else {
             if(extOrient || ctx->dpyAttr[dpy].mDownScaleMode) {
@@ -767,10 +768,10 @@
                 transform,
                 (hwc_rect_t&)crop,
                 (hwc_rect_t&)list->hwLayers[i].displayFrame);
-        layer->sourceCropf.left = crop.left;
-        layer->sourceCropf.right = crop.right;
-        layer->sourceCropf.top = crop.top;
-        layer->sourceCropf.bottom = crop.bottom;
+        layer->sourceCropf.left = (float)crop.left;
+        layer->sourceCropf.right = (float)crop.right;
+        layer->sourceCropf.top = (float)crop.top;
+        layer->sourceCropf.bottom = (float)crop.bottom;
     }
 }
 
@@ -800,8 +801,8 @@
         hwc_display_contents_1_t *list, int dpy) {
     const int prevYuvCount = ctx->listStats[dpy].yuvCount;
     memset(&ctx->listStats[dpy], 0, sizeof(ListStats));
-    ctx->listStats[dpy].numAppLayers = list->numHwLayers - 1;
-    ctx->listStats[dpy].fbLayerIndex = list->numHwLayers - 1;
+    ctx->listStats[dpy].numAppLayers = (int)list->numHwLayers - 1;
+    ctx->listStats[dpy].fbLayerIndex = (int)list->numHwLayers - 1;
     ctx->listStats[dpy].skipCount = 0;
     ctx->listStats[dpy].preMultipliedAlpha = false;
     ctx->listStats[dpy].isSecurePresent = false;
@@ -853,22 +854,20 @@
 
         if (UNLIKELY(isYuvBuffer(hnd))) {
             int& yuvCount = ctx->listStats[dpy].yuvCount;
-            ctx->listStats[dpy].yuvIndices[yuvCount] = i;
+            ctx->listStats[dpy].yuvIndices[yuvCount] = (int)i;
             yuvCount++;
 
             if(UNLIKELY(is4kx2kYuvBuffer(hnd))){
                 int& yuv4k2kCount = ctx->listStats[dpy].yuv4k2kCount;
-                ctx->listStats[dpy].yuv4k2kIndices[yuv4k2kCount] = i;
+                ctx->listStats[dpy].yuv4k2kIndices[yuv4k2kCount] = (int)i;
                 yuv4k2kCount++;
             }
 
             if((layer->transform & HWC_TRANSFORM_ROT_90) &&
-                    canUseRotator(ctx, dpy)) {
-                if( (dpy == HWC_DISPLAY_PRIMARY) &&
-                        ctx->mOverlay->isPipeTypeAttached(OV_MDP_PIPE_DMA)) {
-                    ctx->isPaddingRound = true;
-                }
-                Overlay::setDMAMode(Overlay::DMA_BLOCK_MODE);
+               canUseRotator(ctx, dpy)) {
+               if(ctx->mOverlay->isPipeTypeAttached(OV_MDP_PIPE_DMA))
+                  ctx->isPaddingRound = true;
+               Overlay::setDMAMode(Overlay::DMA_BLOCK_MODE);
             }
         }
         if(layer->blending == HWC_BLENDING_PREMULT)
@@ -876,7 +875,7 @@
 
 
         if(UNLIKELY(isExtOnly(hnd))){
-            ctx->listStats[dpy].extOnlyLayerIndex = i;
+            ctx->listStats[dpy].extOnlyLayerIndex = (int)i;
         }
     }
     if(ctx->listStats[dpy].yuvCount > 0) {
@@ -1142,7 +1141,7 @@
 }
 
 void optimizeLayerRects(const hwc_display_contents_1_t *list) {
-    int i=list->numHwLayers-2;
+    int i= (int)list->numHwLayers-2;
     while(i > 0) {
         //see if there is no blending required.
         //If it is opaque see if we can substract this region from below
@@ -1168,10 +1167,10 @@
                      qhwc::calculate_crop_rects(bottomCrop, bottomframe,
                                                 dest_rect, transform);
                      //Update layer sourceCropf
-                     layer->sourceCropf.left = bottomCrop.left;
-                     layer->sourceCropf.top = bottomCrop.top;
-                     layer->sourceCropf.right = bottomCrop.right;
-                     layer->sourceCropf.bottom = bottomCrop.bottom;
+                     layer->sourceCropf.left =(float)bottomCrop.left;
+                     layer->sourceCropf.top = (float)bottomCrop.top;
+                     layer->sourceCropf.right = (float)bottomCrop.right;
+                     layer->sourceCropf.bottom = (float)bottomCrop.bottom;
                   }
                }
                j--;
@@ -1184,7 +1183,7 @@
 void getNonWormholeRegion(hwc_display_contents_1_t* list,
                               hwc_rect_t& nwr)
 {
-    uint32_t last = list->numHwLayers - 1;
+    size_t last = list->numHwLayers - 1;
     hwc_rect_t fbDisplayFrame = list->hwLayers[last].displayFrame;
     //Initiliaze nwr to first frame
     nwr.left =  list->hwLayers[0].displayFrame.left;
@@ -1192,7 +1191,7 @@
     nwr.right =  list->hwLayers[0].displayFrame.right;
     nwr.bottom =  list->hwLayers[0].displayFrame.bottom;
 
-    for (uint32_t i = 1; i < last; i++) {
+    for (size_t i = 1; i < last; i++) {
         hwc_rect_t displayFrame = list->hwLayers[i].displayFrame;
         nwr = getUnion(nwr, displayFrame);
     }
@@ -1325,12 +1324,11 @@
     if(ret < 0) {
         ALOGE("%s: ioctl MSMFB_BUFFER_SYNC failed, err=%s",
                   __FUNCTION__, strerror(errno));
-        ALOGE("%s: acq_fen_fd_cnt=%d flags=%d fd=%d dpy=%d numHwLayers=%d",
+        ALOGE("%s: acq_fen_fd_cnt=%d flags=%d fd=%d dpy=%d numHwLayers=%zu",
               __FUNCTION__, data.acq_fen_fd_cnt, data.flags, fbFd,
               dpy, list->numHwLayers);
     }
 
-    LayerProp *layerProp = ctx->layerProp[dpy];
     for(uint32_t i = 0; i < list->numHwLayers; i++) {
         if(list->hwLayers[i].compositionType == HWC_OVERLAY ||
            list->hwLayers[i].compositionType == HWC_BLIT ||
@@ -1579,7 +1577,7 @@
     int downscale = 0;
     int rotFlags = ovutils::ROT_FLAGS_NONE;
     uint32_t format = ovutils::getMdpFormat(hnd->format, isTileRendered(hnd));
-    Whf whf(getWidth(hnd), getHeight(hnd), format, hnd->size);
+    Whf whf(getWidth(hnd), getHeight(hnd), format, (uint32_t)hnd->size);
 
     // Handle R/B swap
     if (layer->flags & HWC_FORMAT_RB_SWAP) {
@@ -1686,7 +1684,7 @@
     const int downscale = 0;
     int rotFlags = ROT_FLAGS_NONE;
     uint32_t format = ovutils::getMdpFormat(hnd->format, isTileRendered(hnd));
-    Whf whf(getWidth(hnd), getHeight(hnd), format, hnd->size);
+    Whf whf(getWidth(hnd), getHeight(hnd), format, (uint32_t)hnd->size);
 
     // Handle R/B swap
     if (layer->flags & HWC_FORMAT_RB_SWAP) {
@@ -1833,7 +1831,7 @@
     eZorder rz = (eZorder)(z + 1);
 
     Whf whf(getWidth(hnd), getHeight(hnd),
-            getMdpFormat(hnd->format), hnd->size);
+            getMdpFormat(hnd->format), (uint32_t)hnd->size);
 
     /* Calculate the external display position based on MDP downscale,
        ActionSafe, and extorientation features. */
diff --git a/libhwcomposer/hwc_utils.h b/libhwcomposer/hwc_utils.h
index ad023ad..ed68988 100644
--- a/libhwcomposer/hwc_utils.h
+++ b/libhwcomposer/hwc_utils.h
@@ -189,7 +189,7 @@
 }
 
 inline hwc_rect_t integerizeSourceCrop(const hwc_frect_t& cropF) {
-    hwc_rect_t cropI = {0};
+    hwc_rect_t cropI = {0,0,0,0};
     cropI.left = int(ceilf(cropF.left));
     cropI.top = int(ceilf(cropF.top));
     cropI.right = int(floorf(cropF.right));
diff --git a/libhwcomposer/hwc_virtual.cpp b/libhwcomposer/hwc_virtual.cpp
index 37d87e2..f68d08f 100644
--- a/libhwcomposer/hwc_virtual.cpp
+++ b/libhwcomposer/hwc_virtual.cpp
@@ -95,8 +95,8 @@
     const int dpy = HWC_DISPLAY_VIRTUAL;
 
     if (list && list->outbuf && list->numHwLayers > 0) {
-        reset_layer_prop(ctx, dpy, list->numHwLayers - 1);
-        uint32_t last = list->numHwLayers - 1;
+        reset_layer_prop(ctx, dpy, (int)list->numHwLayers - 1);
+        uint32_t last = (uint32_t)list->numHwLayers - 1;
         hwc_layer_1_t *fbLayer = &list->hwLayers[last];
         int fbWidth = 0, fbHeight = 0;
         getLayerResolution(fbLayer, fbWidth, fbHeight);
@@ -147,7 +147,7 @@
     const int dpy = HWC_DISPLAY_VIRTUAL;
 
     if (list && list->outbuf && list->numHwLayers > 0) {
-        uint32_t last = list->numHwLayers - 1;
+        uint32_t last = (uint32_t)list->numHwLayers - 1;
         hwc_layer_1_t *fbLayer = &list->hwLayers[last];
 
         if(ctx->dpyAttr[dpy].connected
@@ -188,7 +188,8 @@
                 ret = -1;
             }
 
-            Writeback::getInstance()->queueBuffer(ohnd->fd, ohnd->offset);
+            Writeback::getInstance()->queueBuffer(ohnd->fd,
+                                        (uint32_t)ohnd->offset);
             if(!Overlay::displayCommit(ctx->dpyAttr[dpy].fd)) {
                 ALOGE("%s: display commit fail!", __FUNCTION__);
                 ret = -1;
@@ -252,7 +253,7 @@
             ctx->dpyAttr[dpy].isActive &&
             ctx->dpyAttr[dpy].connected &&
             canUseMDPforVirtualDisplay(ctx,list)) {
-        reset_layer_prop(ctx, dpy, list->numHwLayers - 1);
+        reset_layer_prop(ctx, dpy, (int)list->numHwLayers - 1);
         if(!ctx->dpyAttr[dpy].isPause) {
             ctx->dpyAttr[dpy].isConfiguring = false;
             setListStats(ctx, list, dpy);
@@ -284,7 +285,7 @@
             ctx->dpyAttr[dpy].connected &&
             (!ctx->dpyAttr[dpy].isPause) &&
             canUseMDPforVirtualDisplay(ctx,list)) {
-        uint32_t last = list->numHwLayers - 1;
+        uint32_t last = (uint32_t)list->numHwLayers - 1;
         hwc_layer_1_t *fbLayer = &list->hwLayers[last];
         int fd = -1; //FenceFD from the Copybit(valid in async mode)
         bool copybitDone = false;
diff --git a/libhwcomposer/hwc_vsync.cpp b/libhwcomposer/hwc_vsync.cpp
index 6781e7b..7bde83b 100644
--- a/libhwcomposer/hwc_vsync.cpp
+++ b/libhwcomposer/hwc_vsync.cpp
@@ -156,8 +156,8 @@
                 for (int dpy = HWC_DISPLAY_PRIMARY; dpy < num_displays; dpy++) {
                     for(size_t ev = 0; ev < num_events; ev++) {
                         if (pfd[dpy][ev].revents & POLLPRI) {
-                            err = pread(pfd[dpy][ev].fd, vdata, MAX_DATA, 0);
-                            if (UNLIKELY(err < 0)) {
+                            ssize_t len = pread(pfd[dpy][ev].fd, vdata, MAX_DATA, 0);
+                            if (UNLIKELY(len < 0)) {
                                 // If the read was just interrupted - it is not
                                 // a fatal error. Just continue in this case
                                 ALOGE ("%s: Unable to read event:%zu for \