Bug 1162901 - Fix warnings in BootAnimation. r=mwu
authorBoris Chiou <boris.chiou@gmail.com>
Fri, 08 May 2015 03:19:00 +0200
changeset 243368 4dc3b7ec47d032204949ed8362f871c4d28d940a
parent 243367 631022de92332885d349ace119a650fd8744b276
child 243369 ad6016b26dbd7547c06b5b7a39bbb9a15280e718
push id28738
push usercbook@mozilla.com
push dateTue, 12 May 2015 14:11:31 +0000
treeherdermozilla-central@bedce1b405a3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmwu
bugs1162901
milestone40.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1162901 - Fix warnings in BootAnimation. r=mwu
widget/gonk/libdisplay/BootAnimation.cpp
--- a/widget/gonk/libdisplay/BootAnimation.cpp
+++ b/widget/gonk/libdisplay/BootAnimation.cpp
@@ -274,17 +274,17 @@ RawReader(png_structp png_ptr, png_bytep
     state->offset += length;
 }
 
 static void
 TransformTo565(png_structp png_ptr, png_row_infop row_info, png_bytep data)
 {
     uint16_t *outbuf = (uint16_t *)data;
     uint8_t *inbuf = (uint8_t *)data;
-    for (int i = 0; i < row_info->rowbytes; i += 3) {
+    for (uint32_t i = 0; i < row_info->rowbytes; i += 3) {
         *outbuf++ = ((inbuf[i]     & 0xF8) << 8) |
                     ((inbuf[i + 1] & 0xFC) << 3) |
                     ((inbuf[i + 2]       ) >> 3);
     }
 }
 
 void
 AnimationFrame::ReadPngFrame(int outputFormat)
@@ -382,17 +382,17 @@ AnimationFrame::ReadPngFrame(int outputF
     }
 
     // An extra row is added to give libpng enough space when
     // decoding 3/4 bytepp inputs for 2 bytepp output surfaces
     buf = (char *)malloc(width * (height + 1) * bytepp);
 
     vector<char *> rows(height + 1);
     uint32_t stride = width * bytepp;
-    for (int i = 0; i < height; i++) {
+    for (uint32_t i = 0; i < height; i++) {
         rows[i] = buf + (stride * i);
     }
     rows[height] = nullptr;
     png_set_strip_16(pngread);
     png_set_palette_to_rgb(pngread);
     png_set_gray_to_rgb(pngread);
     png_read_image(pngread, (png_bytepp)&rows.front());
     png_destroy_read_struct(&pngread, &pnginfo, nullptr);
@@ -542,22 +542,22 @@ AnimationThread(void *)
             AnimationFrame &frame = part.frames.back();
             strcpy(frame.path, name.c_str());
             frame.file = reader.GetLocalEntry(entry);
         }
 
         sort(part.frames.begin(), part.frames.end());
     }
 
-    uint32_t frameDelayUs = 1000000 / fps;
+    long int frameDelayUs = 1000000 / fps;
 
     for (uint32_t i = 0; i < parts.size(); i++) {
         AnimationPart &part = parts[i];
 
-        uint32_t j = 0;
+        int32_t j = 0;
         while (sRunAnimation && (!part.count || j++ < part.count)) {
             for (uint32_t k = 0; k < part.frames.size(); k++) {
                 struct timeval tv1, tv2;
                 gettimeofday(&tv1, nullptr);
                 AnimationFrame &frame = part.frames[k];
                 if (!frame.buf) {
                     frame.ReadPngFrame(format);
                 }
@@ -580,46 +580,46 @@ AnimationThread(void *)
                 }
 
                 if (frame.has_bgcolor) {
                     wchar_t bgfill = AsBackgroundFill(frame.bgcolor, format);
                     wmemset((wchar_t*)vaddr, bgfill,
                             (buf->height * buf->stride * frame.bytepp) / sizeof(wchar_t));
                 }
 
-                if (buf->height == frame.height && buf->stride == frame.width) {
+                if ((uint32_t)buf->height == frame.height && (uint32_t)buf->stride == frame.width) {
                     memcpy(vaddr, frame.buf,
                            frame.width * frame.height * frame.bytepp);
-                } else if (buf->height >= frame.height &&
-                           buf->width >= frame.width) {
+                } else if ((uint32_t)buf->height >= frame.height &&
+                           (uint32_t)buf->width >= frame.width) {
                     int startx = (buf->width - frame.width) / 2;
                     int starty = (buf->height - frame.height) / 2;
 
                     int src_stride = frame.width * frame.bytepp;
                     int dst_stride = buf->stride * frame.bytepp;
 
                     char *src = frame.buf;
                     char *dst = (char *) vaddr + starty * dst_stride + startx * frame.bytepp;
 
-                    for (int i = 0; i < frame.height; i++) {
+                    for (uint32_t i = 0; i < frame.height; i++) {
                         memcpy(dst, src, src_stride);
                         src += src_stride;
                         dst += dst_stride;
                     }
                 }
                 grmodule->unlock(grmodule, buf->handle);
 
                 gettimeofday(&tv2, nullptr);
 
                 timersub(&tv2, &tv1, &tv2);
 
                 if (tv2.tv_usec < frameDelayUs) {
                     usleep(frameDelayUs - tv2.tv_usec);
                 } else {
-                    LOGW("Frame delay is %d us but decoding took %d us",
+                    LOGW("Frame delay is %ld us but decoding took %ld us",
                          frameDelayUs, tv2.tv_usec);
                 }
 
                 display->QueueBuffer(buf);
 
                 if (part.count && j >= part.count) {
                     free(frame.buf);
                     frame.buf = nullptr;