From 0682575dd496f8077eddeecdcfa3bd32a1d8ef89 Mon Sep 17 00:00:00 2001 From: Cristy Date: Sat, 5 Aug 2023 22:52:43 -0400 Subject: [PATCH] eliminate compiler warnings --- magick/cache.c | 50 +++++++++++++++++++++++------------------- magick/image-private.h | 2 +- 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/magick/cache.c b/magick/cache.c index 76ecc2650..2597a00a6 100644 --- a/magick/cache.c +++ b/magick/cache.c @@ -838,7 +838,7 @@ static MagickBooleanType ClonePixelCacheOnDisk( number_bytes=write(clone_info->file,buffer,(size_t) count); if (number_bytes != count) break; - extent+=number_bytes; + extent+=(size_t) number_bytes; } buffer=(unsigned char *) RelinquishMagickMemory(buffer); if (extent != cache_info->length) @@ -3024,14 +3024,14 @@ MagickExport const PixelPacket *GetVirtualPixelCacheNexus(const Image *image, MagickTrue : MagickFalse,nexus_info,exception); if (pixels == (PixelPacket *) NULL) return((const PixelPacket *) NULL); - offset=(MagickOffsetType) nexus_info->region.y*cache_info->columns+ + offset=nexus_info->region.y*(MagickOffsetType) cache_info->columns+ nexus_info->region.x; length=(MagickSizeType) (nexus_info->region.height-1L)*cache_info->columns+ nexus_info->region.width-1L; number_pixels=(MagickSizeType) cache_info->columns*cache_info->rows; if ((offset >= 0) && (((MagickSizeType) offset+length) < number_pixels)) - if ((x >= 0) && ((ssize_t) (x+columns) <= (ssize_t) cache_info->columns) && - (y >= 0) && ((ssize_t) (y+rows) <= (ssize_t) cache_info->rows)) + if ((x >= 0) && ((x+(ssize_t) columns) <= (ssize_t) cache_info->columns) && + (y >= 0) && ((y+(ssize_t) rows) <= (ssize_t) cache_info->rows)) { MagickBooleanType status; @@ -3110,13 +3110,14 @@ MagickExport const PixelPacket *GetVirtualPixelCacheNexus(const Image *image, if ((virtual_pixel_method == EdgeVirtualPixelMethod) || (virtual_pixel_method == UndefinedVirtualPixelMethod)) y_offset=EdgeY(y_offset,cache_info->rows); - for (u=0; u < (ssize_t) columns; u+=length) + for (u=0; u < (ssize_t) columns; u+=(ssize_t) length) { ssize_t x_offset; x_offset=x+u; - length=(MagickSizeType) MagickMin(cache_info->columns-x_offset,columns-u); + length=(MagickSizeType) MagickMin((ssize_t) cache_info->columns-x_offset, + (ssize_t) columns-u); if (((x_offset < 0) || (x_offset >= (ssize_t) cache_info->columns)) || ((y_offset < 0) || (y_offset >= (ssize_t) cache_info->rows)) || (length == 0)) @@ -3794,11 +3795,11 @@ static inline MagickOffsetType WritePixelCacheRegion( for (i=0; i < (MagickOffsetType) length; i+=count) { #if !defined(MAGICKCORE_HAVE_PWRITE) - count=write(cache_info->file,buffer+i,(size_t) MagickMin(length-i,(size_t) - MAGICK_SSIZE_MAX)); + count=write(cache_info->file,buffer+i,(size_t) MagickMin(length- + (MagickSizeType) i,MAGICK_SSIZE_MAX)); #else - count=pwrite(cache_info->file,buffer+i,(size_t) MagickMin(length-i,(size_t) - MAGICK_SSIZE_MAX),offset+i); + count=pwrite(cache_info->file,buffer+i,(size_t) MagickMin(length- + (MagickSizeType) i,MAGICK_SSIZE_MAX),offset+i); #endif if (count <= 0) { @@ -4291,7 +4292,8 @@ MagickExport MagickBooleanType PersistPixelCache(Image *image, cache_info->offset=(*offset); if (OpenPixelCache(image,ReadMode,exception) == MagickFalse) return(MagickFalse); - *offset+=cache_info->length+page_size-(cache_info->length % page_size); + *offset=(*offset+(MagickOffsetType) cache_info->length+page_size- + ((MagickOffsetType) cache_info->length % page_size)); return(MagickTrue); } /* @@ -4320,7 +4322,8 @@ MagickExport MagickBooleanType PersistPixelCache(Image *image, status=OpenPixelCacheOnDisk(clone_info,WriteMode); if (status != MagickFalse) status=ClonePixelCacheRepository(clone_info,cache_info,exception); - *offset+=cache_info->length+page_size-(cache_info->length % page_size); + *offset=(*offset+(MagickOffsetType) cache_info->length+page_size- + ((MagickOffsetType) cache_info->length % page_size)); clone_info=(CacheInfo *) DestroyPixelCache(clone_info); return(status); } @@ -4406,11 +4409,12 @@ MagickExport PixelPacket *QueueAuthenticPixelCacheNexus(Image *image, "PixelsAreNotAuthentic","`%s'",image->filename); return((PixelPacket *) NULL); } - offset=(MagickOffsetType) y*cache_info->columns+x; + offset=y*(MagickOffsetType) cache_info->columns+x; if (offset < 0) return((PixelPacket *) NULL); number_pixels=(MagickSizeType) cache_info->columns*cache_info->rows; - offset+=(MagickOffsetType) (rows-1)*cache_info->columns+columns-1; + offset+=((MagickOffsetType) rows-1)*(MagickOffsetType) cache_info->columns+ + (MagickOffsetType) columns-1; if ((MagickSizeType) offset >= number_pixels) return((PixelPacket *) NULL); /* @@ -4601,11 +4605,11 @@ static inline MagickOffsetType ReadPixelCacheRegion( for (i=0; i < (MagickOffsetType) length; i+=count) { #if !defined(MAGICKCORE_HAVE_PREAD) - count=read(cache_info->file,buffer+i,(size_t) MagickMin(length-i,(size_t) - MAGICK_SSIZE_MAX)); + count=read(cache_info->file,buffer+i,(size_t) MagickMin(length- + (MagickSizeType) i,(size_t) MAGICK_SSIZE_MAX)); #else - count=pread(cache_info->file,buffer+i,(size_t) MagickMin(length-i,(size_t) - MAGICK_SSIZE_MAX),offset+i); + count=pread(cache_info->file,buffer+i,(size_t) MagickMin(length- + (MagickSizeType) i,(size_t) MAGICK_SSIZE_MAX),offset+i); #endif if (count <= 0) { @@ -4642,7 +4646,7 @@ static MagickBooleanType ReadPixelCacheIndexes( return(MagickFalse); if (nexus_info->authentic_pixel_cache != MagickFalse) return(MagickTrue); - offset=(MagickOffsetType) nexus_info->region.y*cache_info->columns+ + offset=nexus_info->region.y*(MagickOffsetType)cache_info->columns+ nexus_info->region.x; length=(MagickSizeType) nexus_info->region.width*sizeof(IndexPacket); rows=nexus_info->region.height; @@ -4701,7 +4705,7 @@ static MagickBooleanType ReadPixelCacheIndexes( sizeof(PixelPacket)+offset*sizeof(*q),length,(unsigned char *) q); if (count < (MagickOffsetType) length) break; - offset+=cache_info->columns; + offset+=(MagickOffsetType) cache_info->columns; q+=nexus_info->region.width; } if (IsFileDescriptorLimitExceeded() != MagickFalse) @@ -4872,7 +4876,7 @@ static MagickBooleanType ReadPixelCachePixels( sizeof(*q),length,(unsigned char *) q); if (count < (MagickOffsetType) length) break; - offset+=cache_info->columns; + offset+=(MagickOffsetType) cache_info->columns; q+=nexus_info->region.width; } if (IsFileDescriptorLimitExceeded() != MagickFalse) @@ -5813,7 +5817,7 @@ static MagickBooleanType WritePixelCacheIndexes(CacheInfo *cache_info, if (count < (MagickOffsetType) length) break; p+=nexus_info->region.width; - offset+=cache_info->columns; + offset+=(MagickOffsetType) cache_info->columns; } if (IsFileDescriptorLimitExceeded() != MagickFalse) (void) ClosePixelCacheOnDisk(cache_info); @@ -5977,7 +5981,7 @@ static MagickBooleanType WritePixelCachePixels(CacheInfo *cache_info, if (count < (MagickOffsetType) length) break; p+=nexus_info->region.width; - offset+=cache_info->columns; + offset+=(MagickOffsetType) cache_info->columns; } if (IsFileDescriptorLimitExceeded() != MagickFalse) (void) ClosePixelCacheOnDisk(cache_info); diff --git a/magick/image-private.h b/magick/image-private.h index d3b148e6a..8e037c718 100644 --- a/magick/image-private.h +++ b/magick/image-private.h @@ -50,7 +50,7 @@ extern "C" { #define MagickSQ2PI 2.50662827463100024161235523934010416269302368164062 #define MAGICK_SIZE_MAX (SIZE_MAX) #define MAGICK_SSIZE_MAX (SSIZE_MAX) -#define MAGICK_SSIZE_MIN (-(SSIZE_MAX)-1) +#define MAGICK_SSIZE_MIN (-SSIZE_MAX-1) #define MatteColor "#bdbdbd" /* gray */ #define MatteColorRGBA ScaleShortToQuantum(0xbdbd),\ ScaleShortToQuantum(0xbdbd),ScaleShortToQuantum(0xbdbd),OpaqueOpacity