Skip to content

Commit

Permalink
eliminate compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristy committed Aug 6, 2023
1 parent 7bd113a commit 0682575
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 24 deletions.
50 changes: 27 additions & 23 deletions magick/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);
}
/*
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
/*
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion magick/image-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0682575

Please sign in to comment.