Unify the type of the buffer size from 'unsigned int'/'unsigned long' to 'size_t' 72/171672/2
authorJiyong Min <jiyong.min@samsung.com>
Tue, 6 Mar 2018 10:01:32 +0000 (19:01 +0900)
committerJiyong Min <jiyong.min@samsung.com>
Tue, 6 Mar 2018 10:27:18 +0000 (19:27 +0900)
Change-Id: I80782f8457a3ace220bc74426fbf8b4aaeb5daf4
Signed-off-by: Jiyong Min <jiyong.min@samsung.com>
src/image_util_decode.c
src/image_util_encode.c

index c273aaa741478cbda74d5ed0fae106e36415bb93..2c61ee7a9b869ee453f2cfbcba1b39f3060f2132 100755 (executable)
@@ -352,7 +352,7 @@ static int _image_util_decode_internal(decode_encode_s * _handle)
                        if (_handle->path)
                                        err = mm_util_decode_from_jpeg_file_with_downscale(_handle->path, TYPECAST_COLOR_BY_TYPE(_handle->colorspace, IMAGE_UTIL_JPEG), _convert_decode_scale_tbl[_handle->down_scale], jpeg_data);
                        else
-                                       err = mm_util_decode_from_jpeg_memory_with_downscale(_handle->src_buffer[0], (unsigned int)_handle->src_size, TYPECAST_COLOR_BY_TYPE(_handle->colorspace, IMAGE_UTIL_JPEG), _convert_decode_scale_tbl[_handle->down_scale], jpeg_data);
+                                       err = mm_util_decode_from_jpeg_memory_with_downscale(_handle->src_buffer[0], (size_t)_handle->src_size, TYPECAST_COLOR_BY_TYPE(_handle->colorspace, IMAGE_UTIL_JPEG), _convert_decode_scale_tbl[_handle->down_scale], jpeg_data);
 
                        if (err == MM_UTIL_ERROR_NONE) {
                                *(_handle->dst_buffer) = jpeg_data->data;
@@ -369,11 +369,11 @@ static int _image_util_decode_internal(decode_encode_s * _handle)
                        if (_handle->path)
                                err = mm_util_decode_from_png_file(_handle->path, png_data);
                        else
-                               err = mm_util_decode_from_png_memory(_handle->src_buffer[0], _handle->src_size, png_data);
+                               err = mm_util_decode_from_png_memory(_handle->src_buffer[0], (size_t)_handle->src_size, png_data);
 
                        if (err == MM_UTIL_ERROR_NONE) {
                                *(_handle->dst_buffer) = png_data->data;
-                               _handle->dst_size = png_data->size;
+                               _handle->dst_size = (unsigned long long)png_data->size;
                                _handle->width = png_data->width;
                                _handle->height = png_data->height;
                        }
@@ -403,11 +403,11 @@ static int _image_util_decode_internal(decode_encode_s * _handle)
                        if (_handle->path)
                                err = mm_util_decode_from_bmp_file(_handle->path, bmp_data);
                        else
-                               err = mm_util_decode_from_bmp_memory(_handle->src_buffer[0], _handle->src_size, bmp_data);
+                               err = mm_util_decode_from_bmp_memory(_handle->src_buffer[0], (size_t)_handle->src_size, bmp_data);
 
                        if (err == MM_UTIL_ERROR_NONE) {
                                *(_handle->dst_buffer) = bmp_data->data;
-                               _handle->dst_size = bmp_data->size;
+                               _handle->dst_size = (unsigned long long)bmp_data->size;
                                _handle->width = bmp_data->width;
                                _handle->height = bmp_data->height;
                        }
@@ -601,7 +601,7 @@ int image_util_decode_jpeg_from_memory_with_downscale(const unsigned char *jpeg_
        mm_util_jpeg_yuv_data decoded;
        memset(&decoded, 0, sizeof(mm_util_jpeg_yuv_data));
 
-       err = mm_util_decode_from_jpeg_memory_with_downscale((void *)jpeg_buffer, (unsigned int)jpeg_size, TYPECAST_COLOR_BY_TYPE(colorspace, IMAGE_UTIL_JPEG), _convert_decode_scale_tbl[downscale], &decoded);
+       err = mm_util_decode_from_jpeg_memory_with_downscale((void *)jpeg_buffer, (size_t)jpeg_size, TYPECAST_COLOR_BY_TYPE(colorspace, IMAGE_UTIL_JPEG), _convert_decode_scale_tbl[downscale], &decoded);
 
        if (err == MM_UTIL_ERROR_NONE) {
                *image_buffer = decoded.data;
index bfd9f332ff9b4323645f894aa15258bdcd388040..14b779161538b45eac57c29cf1014c4688601cb3 100755 (executable)
@@ -395,7 +395,7 @@ static int _image_util_encode_internal(decode_encode_s * _handle)
        case IMAGE_UTIL_JPEG:
                {
                        mm_util_jpeg_yuv_data *jpeg_data = (mm_util_jpeg_yuv_data *) _handle->image_h;
-                       unsigned int size = 0;
+                       size_t size = 0;
 
                        jpeg_data->data = _handle->src_buffer[0];
                        jpeg_data->format = TYPECAST_COLOR_BY_TYPE(_handle->colorspace, IMAGE_UTIL_JPEG);
@@ -461,15 +461,12 @@ static int _image_util_encode_internal(decode_encode_s * _handle)
                        size_t size = 0;
 
                        bmp_data->data = _handle->src_buffer[0];
-                       if (_handle->path) {
+
+                       if (_handle->path)
                                err = mm_util_encode_bmp_to_file(bmp_data, _handle->path);
-                       } else {
+                       else
                                err = mm_util_encode_bmp_to_memory(bmp_data, _handle->dst_buffer, &size);
-                               if (err == MM_UTIL_ERROR_NONE)
-                                       bmp_data->size = (unsigned long long)size;
-                               else
-                                       bmp_data->size = 0;
-                       }
+
                        if (err == MM_UTIL_ERROR_NONE)
                                _handle->dst_size = (unsigned long long)size;
                }