diff options
author | Marcus Meissner <marcus@jet.franken.de> | 2020-08-31 12:09:21 +0200 |
---|---|---|
committer | Marcus Meissner <marcus@jet.franken.de> | 2020-08-31 12:09:21 +0200 |
commit | d7debd083cc09a32dd8e65736ff46f6c9f8ffce0 (patch) | |
tree | 843123de029363d13e1b92f8e0f9e5fe3a1f23e0 /camlibs/ax203 | |
parent | 9904ec873e4abab3d02625a3a4cacb9bd85a1445 (diff) | |
download | libgphoto2-d7debd083cc09a32dd8e65736ff46f6c9f8ffce0.tar.gz |
fixed various integer signedness mismatches
Diffstat (limited to 'camlibs/ax203')
-rw-r--r-- | camlibs/ax203/ax203.c | 19 | ||||
-rw-r--r-- | camlibs/ax203/ax203.h | 6 | ||||
-rw-r--r-- | camlibs/ax203/ax203_compress_jpeg.c | 5 |
3 files changed, 17 insertions, 13 deletions
diff --git a/camlibs/ax203/ax203.c b/camlibs/ax203/ax203.c index e16b0e685..db696110d 100644 --- a/camlibs/ax203/ax203.c +++ b/camlibs/ax203/ax203.c @@ -595,7 +595,7 @@ static int ax203_read_parameter_block(Camera *camera) uint8_t buf[32], expect[32]; int i, param_offset = 0, resolution_offset = 0; int compression_offset = -1, abfs_start_offset = 0, expect_size = 0; - const int valid_resolutions[][2] = { + const unsigned int valid_resolutions[][2] = { { 96, 64 }, { 120, 160 }, { 128, 128 }, @@ -1121,8 +1121,8 @@ ax203_decode_image(Camera *camera, char *src, int src_size, int **dest) } if (!row_skip) { tinyjpeg_get_size (camera->pl->jdec, &width, &height); - if ((int)width != camera->pl->width || - (int)height != camera->pl->height) { + if (width != camera->pl->width || + height != camera->pl->height) { gp_log (GP_LOG_ERROR, "ax203", "Hdr dimensions %ux%u don't match lcd %dx%d", width, height, @@ -1193,12 +1193,12 @@ ax203_decode_image(Camera *camera, char *src, int src_size, int **dest) /* Returns the number of bytes of dest used or a negative error code */ static int -ax203_encode_image(Camera *camera, int **src, char *dest, int dest_size) +ax203_encode_image(Camera *camera, int **src, char *dest, unsigned int dest_size) { #ifdef HAVE_LIBGD int size = ax203_filesize (camera); #ifdef HAVE_LIBJPEG - int x, y; + unsigned int x, y; struct jpeg_compress_struct cinfo; struct jpeg_error_mgr jcerr; JOCTET *jpeg_dest = NULL; @@ -1207,7 +1207,10 @@ ax203_encode_image(Camera *camera, int **src, char *dest, int dest_size) JSAMPROW row_pointer[1] = { row }; #endif - if (dest_size < size) + if (size < GP_OK) + return size; + + if (dest_size < (unsigned int)size) return GP_ERROR_FIXED_LIMIT_EXCEEDED; switch (camera->pl->compression_version) { @@ -1239,8 +1242,8 @@ ax203_encode_image(Camera *camera, int **src, char *dest, int dest_size) cinfo.in_color_space = JCS_RGB; jpeg_set_defaults (&cinfo); jpeg_start_compress (&cinfo, TRUE); - for (y = 0; y < cinfo.image_height; y++) { - for (x = 0; x < cinfo.image_width; x++) { + for (y = 0; y < (unsigned int)cinfo.image_height; y++) { + for (x = 0; x < (unsigned int)cinfo.image_width; x++) { int p = src[y][x]; row[x * 3 + 0] = gdTrueColorGetRed(p); row[x * 3 + 1] = gdTrueColorGetGreen(p); diff --git a/camlibs/ax203/ax203.h b/camlibs/ax203/ax203.h index 4fc5e611b..d1d389093 100644 --- a/camlibs/ax203/ax203.h +++ b/camlibs/ax203/ax203.h @@ -95,8 +95,8 @@ struct _CameraPrivateLibrary { int sector_dirty[4194304 / SPI_EEPROM_SECTOR_SIZE]; int fs_start; /* LCD display attributes */ - int width; - int height; + unsigned int width; + unsigned int height; /* USB "bridge" / firmware attributes */ enum ax203_version frame_version; enum ax203_compression compression_version; @@ -200,7 +200,7 @@ ax203_encode_yuv_delta(int **src, char *dest, int width, int height); int ax206_compress_jpeg(Camera *camera, int **in, uint8_t *outbuf, int out_size, - int width, int height); + unsigned int width, unsigned int height); #endif diff --git a/camlibs/ax203/ax203_compress_jpeg.c b/camlibs/ax203/ax203_compress_jpeg.c index 50efa9ff5..1ec7534ff 100644 --- a/camlibs/ax203/ax203_compress_jpeg.c +++ b/camlibs/ax203/ax203_compress_jpeg.c @@ -114,7 +114,7 @@ add_mcu_info(uint8_t *outbuf, int block_nr, int last_Y, int last_Cb, int ax206_compress_jpeg(Camera *camera, int **in, uint8_t *outbuf, int out_size, - int width, int height) + unsigned int width, unsigned int height) { struct jpeg_compress_struct cinfo; struct jpeg_decompress_struct dinfo; @@ -122,7 +122,8 @@ ax206_compress_jpeg(Camera *camera, int **in, uint8_t *outbuf, int out_size, JSAMPROW row_pointer[1]; JOCTET *buf = NULL, *regular_jpeg = NULL; jvirt_barray_ptr *in_coefficients; - int i, x, y, stop, size, ret, outc; + unsigned int i, x, y; + int stop, size, ret, outc; unsigned long regular_jpeg_size = 0, buf_size = 0; int last_dc_val[3] = { 0, 0, 0 }; |