From d3267035346a479d15d6356acd927e2ddcf4cac9 Mon Sep 17 00:00:00 2001 From: Cristy Date: Sat, 29 Sep 2018 19:32:45 -0400 Subject: [PATCH] Eliminate c++ compiler warnings --- MagickCore/blob.c | 3 +- MagickCore/channel.c | 9 ++++-- MagickCore/draw.c | 20 ++++++++----- MagickCore/image.c | 71 ++++++++++++++++++++++++++++++++++++-------- MagickCore/list.c | 4 +-- coders/meta.c | 25 ++++++---------- coders/pcx.c | 2 +- coders/pdf.c | 4 +-- coders/png.c | 6 ++-- coders/pnm.c | 2 +- coders/rle.c | 2 +- coders/sgi.c | 8 ++--- coders/xpm.c | 2 +- 13 files changed, 103 insertions(+), 55 deletions(-) diff --git a/MagickCore/blob.c b/MagickCore/blob.c index b3b27746c..6f569959c 100644 --- a/MagickCore/blob.c +++ b/MagickCore/blob.c @@ -1214,7 +1214,8 @@ MagickExport int EOFBlob(const Image *image) case ZipStream: { #if defined(MAGICKCORE_ZLIB_DELEGATE) - blob_info->eof=gzeof(blob_info->file_info.gzfile); + blob_info->eof=gzeof(blob_info->file_info.gzfile) != 0 ? MagickTrue : + MagickFalse; #endif break; } diff --git a/MagickCore/channel.c b/MagickCore/channel.c index 1cbc9d08d..88149aaa6 100644 --- a/MagickCore/channel.c +++ b/MagickCore/channel.c @@ -378,17 +378,20 @@ MagickExport Image *ChannelFxImage(const Image *image,const char *expression, } case CompositeMaskPixelChannel: { - destination_image->channels|=CompositeMaskChannel; + destination_image->channels=(ChannelType) + (destination_image->channels | CompositeMaskChannel); break; } case ReadMaskPixelChannel: { - destination_image->channels|=ReadMaskChannel; + destination_image->channels=(ChannelType) + (destination_image->channels | ReadMaskChannel); break; } case WriteMaskPixelChannel: { - destination_image->channels|=WriteMaskChannel; + destination_image->channels=(ChannelType) + (destination_image->channels | WriteMaskChannel); break; } case MetaPixelChannel: diff --git a/MagickCore/draw.c b/MagickCore/draw.c index 98f2f2ac7..58190521e 100644 --- a/MagickCore/draw.c +++ b/MagickCore/draw.c @@ -1420,7 +1420,8 @@ static MagickBooleanType DrawBoundingRectangles(Image *image, end.x=(double) (polygon_info->edges[i].bounds.x2+mid); end.y=(double) (polygon_info->edges[i].bounds.y2+mid); primitive_info[0].primitive=RectanglePrimitive; - status&=TraceRectangle(primitive_info,start,end); + if (TraceRectangle(primitive_info,start,end) == MagickFalse) + status=MagickFalse; primitive_info[0].method=ReplaceMethod; coordinates=(ssize_t) primitive_info[0].coordinates; primitive_info[coordinates].primitive=UndefinedPrimitive; @@ -1446,7 +1447,8 @@ static MagickBooleanType DrawBoundingRectangles(Image *image, end.x=(double) (bounds.x2+mid); end.y=(double) (bounds.y2+mid); primitive_info[0].primitive=RectanglePrimitive; - status&=TraceRectangle(primitive_info,start,end); + if (TraceRectangle(primitive_info,start,end) == MagickFalse) + status=MagickFalse; primitive_info[0].method=ReplaceMethod; coordinates=(ssize_t) primitive_info[0].coordinates; primitive_info[coordinates].primitive=UndefinedPrimitive; @@ -2251,8 +2253,8 @@ static MagickBooleanType CheckPrimitiveExtent(MVGInfo *mvg_info, { if (extent <= (double) *mvg_info->extent) return(MagickTrue); - *mvg_info->primitive_info=ResizeQuantumMemory(*mvg_info->primitive_info, - (size_t) extent,quantum); + *mvg_info->primitive_info=(PrimitiveInfo *) ResizeQuantumMemory( + *mvg_info->primitive_info,(size_t) extent,quantum); if (*mvg_info->primitive_info != (PrimitiveInfo *) NULL) { (void) memset(*mvg_info->primitive_info+*mvg_info->extent,0, @@ -2269,7 +2271,8 @@ static MagickBooleanType CheckPrimitiveExtent(MVGInfo *mvg_info, if (*mvg_info->primitive_info != (PrimitiveInfo *) NULL) *mvg_info->primitive_info=(PrimitiveInfo *) RelinquishMagickMemory( *mvg_info->primitive_info); - *mvg_info->primitive_info=AcquireCriticalMemory(PrimitiveExtentPad*quantum); + *mvg_info->primitive_info=(PrimitiveInfo *) AcquireCriticalMemory( + PrimitiveExtentPad*quantum); (void) memset(*mvg_info->primitive_info,0,PrimitiveExtentPad*quantum); *mvg_info->extent=1; return(MagickFalse); @@ -2489,7 +2492,7 @@ static MagickBooleanType RenderMVGContent(Image *image, { status=SetImageAlphaChannel(image,OpaqueAlphaChannel,exception); if (status == MagickFalse) - return(status); + return(status != 0 ? MagickTrue : MagickFalse); } primitive=(char *) NULL; if (*draw_info->primitive != '@') @@ -6024,7 +6027,8 @@ static MagickBooleanType TraceArcPath(MVGInfo *mvg_info,const PointInfo start, points[2].y); if (i == (ssize_t) (arc_segments-1)) (p+3)->point=end; - status&=TraceBezier(mvg_info,4); + if (TraceBezier(mvg_info,4) == MagickFalse) + status=MagickFalse; p=(*mvg_info->primitive_info)+mvg_info->offset; mvg_info->offset+=p->coordinates; p+=p->coordinates; @@ -6963,7 +6967,7 @@ static PrimitiveInfo *TraceStrokePolygon(const Image *image, const DrawInfo *draw_info,const PrimitiveInfo *primitive_info) { #define CheckPathExtent(pad) \ - if ((q+(pad)) >= (ssize_t) max_strokes) \ + if ((ssize_t) (q+(pad)) >= (ssize_t) max_strokes) \ { \ if (~max_strokes < (pad)) \ { \ diff --git a/MagickCore/image.c b/MagickCore/image.c index cd3d8c7de..06911a396 100644 --- a/MagickCore/image.c +++ b/MagickCore/image.c @@ -3199,17 +3199,40 @@ MagickExport MagickBooleanType SetImageMask(Image *image,const PixelMask type, { switch (type) { - case ReadPixelMask: image->channels&=(~ReadMaskChannel); break; - case WritePixelMask: image->channels&=(~WriteMaskChannel); break; - default: image->channels&=(~CompositeMaskChannel); break; + case ReadPixelMask: + { + image->channels=(ChannelType) (image->channels & ~ReadMaskChannel); + break; + } + case WritePixelMask: + { + image->channels=(ChannelType) (image->channels & ~WriteMaskChannel); + } + default: + { + image->channels=(ChannelType) (image->channels & ~CompositeMaskChannel); + break; + } } return(SyncImagePixelCache(image,exception)); } switch (type) { - case ReadPixelMask: image->channels|=ReadMaskChannel; break; - case WritePixelMask: image->channels|=WriteMaskChannel; break; - default: image->channels|=CompositeMaskChannel; break; + case ReadPixelMask: + { + image->channels=(ChannelType) (image->channels | ~ReadMaskChannel); + break; + } + case WritePixelMask: + { + image->channels=(ChannelType) (image->channels | ~WriteMaskChannel); + break; + } + default: + { + image->channels=(ChannelType) (image->channels | ~CompositeMaskChannel); + break; + } } if (SyncImagePixelCache(image,exception) == MagickFalse) return(MagickFalse); @@ -3332,17 +3355,41 @@ MagickExport MagickBooleanType SetImageRegionMask(Image *image, { switch (type) { - case ReadPixelMask: image->channels&=(~ReadMaskChannel); break; - case WritePixelMask: image->channels&=(~WriteMaskChannel); break; - default: image->channels&=(~CompositeMaskChannel); break; + case ReadPixelMask: + { + image->channels=(ChannelType) (image->channels & ~ReadMaskChannel); + break; + } + case WritePixelMask: + { + image->channels=(ChannelType) (image->channels & ~WriteMaskChannel); + break; + } + default: + { + image->channels=(ChannelType) (image->channels & ~CompositeMaskChannel); + break; + } } return(SyncImagePixelCache(image,exception)); } switch (type) { - case ReadPixelMask: image->channels|=ReadMaskChannel; break; - case WritePixelMask: image->channels|=WriteMaskChannel; break; - default: image->channels|=CompositeMaskChannel; break; + case ReadPixelMask: + { + image->channels=(ChannelType) (image->channels | ReadMaskChannel); + break; + } + case WritePixelMask: + { + image->channels=(ChannelType) (image->channels | WriteMaskChannel); + break; + } + default: + { + image->channels=(ChannelType) (image->channels | CompositeMaskChannel); + break; + } } if (SyncImagePixelCache(image,exception) == MagickFalse) return(MagickFalse); diff --git a/MagickCore/list.c b/MagickCore/list.c index 0631e8fff..b27ec8be5 100644 --- a/MagickCore/list.c +++ b/MagickCore/list.c @@ -257,8 +257,8 @@ MagickExport Image *CloneImages(const Image *images,const char *scenes, if (last > (ssize_t) length) last=(ssize_t) length; } - first=MagickMin(MagickMax(first,0),length); - last=MagickMin(MagickMax(last,0),length); + first=MagickMin(MagickMax(first,0),(ssize_t) length); + last=MagickMin(MagickMax(last,0),(ssize_t) length); step=(ssize_t) (first > last ? -1 : 1); for ( ; first != (last+step); first+=step) { diff --git a/coders/meta.c b/coders/meta.c index 7ed42ea1f..eda1f5741 100644 --- a/coders/meta.c +++ b/coders/meta.c @@ -231,22 +231,15 @@ static size_t convertHTMLcodes(char *s) *s=value; return(o); } + for (i=0; i < (ssize_t) (sizeof(html_codes)/sizeof(html_code)); i++) { - int - codes; - - codes=sizeof(html_codes)/sizeof(html_code); - for (i=0; i < codes; i++) - { - if (html_codes[i].len <= length) - if (stringnicmp(s,html_codes[i].code,(size_t) (html_codes[i].len)) == 0) - { - (void) memmove(s+1,s+html_codes[i].len,strlen(s+html_codes[i].len)+ - 1); - *s=html_codes[i].val; - return(html_codes[i].len-1); - } - } + if (html_codes[i].len <= (ssize_t) length) + if (stringnicmp(s,html_codes[i].code,(size_t) (html_codes[i].len)) == 0) + { + (void) memmove(s+1,s+html_codes[i].len,strlen(s+html_codes[i].len)+1); + *s=html_codes[i].val; + return(html_codes[i].len-1); + } } return(0); } @@ -2241,7 +2234,7 @@ static int format8BIM(Image *ifile, Image *ofile) } } count=(ssize_t) ReadBlobMSBSignedLong(ifile); - if ((count < 0) || (count > GetBlobSize(ifile))) + if ((count < 0) || (count > (ssize_t) GetBlobSize(ifile))) { PString=(unsigned char *) RelinquishMagickMemory(PString); return -1; diff --git a/coders/pcx.c b/coders/pcx.c index b4779d33d..7bdd7050d 100644 --- a/coders/pcx.c +++ b/coders/pcx.c @@ -356,7 +356,7 @@ static Image *ReadPCXImage(const ImageInfo *image_info,ExceptionInfo *exception) if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0)) if (image->scene >= (image_info->scene+image_info->number_scenes-1)) break; - if ((MagickOffsetType) (image->columns*image->rows/255) > GetBlobSize(image)) + if ((MagickSizeType) (image->columns*image->rows/255) > GetBlobSize(image)) ThrowPCXException(CorruptImageError,"InsufficientImageDataInFile"); status=SetImageExtent(image,image->columns,image->rows,exception); if (status == MagickFalse) diff --git a/coders/pdf.c b/coders/pdf.c index b44a7bad9..4e621b625 100644 --- a/coders/pdf.c +++ b/coders/pdf.c @@ -1451,7 +1451,7 @@ RestoreMSCWarning if (value != (const char *) NULL) (void) CopyMagickString(create_date,value,MagickPathExtent); (void) FormatMagickTime(time((time_t *) NULL),MagickPathExtent,timestamp); - url=MagickAuthoritativeURL; + url=(char *) MagickAuthoritativeURL; escape=EscapeParenthesis(basename); i=FormatLocaleString(xmp_profile,MagickPathExtent,XMPProfile, XMPProfileMagick,modify_date,create_date,timestamp,url,escape,url); @@ -2979,7 +2979,7 @@ RestoreMSCWarning (void) WriteBlobString(image,buffer); (void) FormatLocaleString(buffer,MagickPathExtent,"/ModDate (%s)\n",date); (void) WriteBlobString(image,buffer); - url=MagickAuthoritativeURL; + url=(char *) MagickAuthoritativeURL; escape=EscapeParenthesis(url); (void) FormatLocaleString(buffer,MagickPathExtent,"/Producer (%s)\n",escape); escape=DestroyString(escape); diff --git a/coders/png.c b/coders/png.c index 18dfc21a5..ae1031367 100644 --- a/coders/png.c +++ b/coders/png.c @@ -2449,8 +2449,8 @@ static Image *ReadOnePNGImage(MngInfo *mng_info, #if (PNG_LIBPNG_VER >= 10401) option=GetImageOption(image_info,"png:chunk-malloc-max"); if (option != (const char *) NULL) - png_set_chunk_malloc_max(ping,(png_alloc_size_t) MagickMin(PNG_SIZE_MAX, - StringToLong(option))); + png_set_chunk_malloc_max(ping,(png_alloc_size_t) MagickMin((ssize_t) + PNG_SIZE_MAX,StringToLong(option))); else png_set_chunk_malloc_max(ping,(png_alloc_size_t) GetMaxMemoryRequest()); #endif @@ -6228,7 +6228,7 @@ static Image *ReadOneMNGImage(MngInfo* mng_info, const ImageInfo *image_info, else { - if (loop_iters > GetMagickResourceLimit(ListLengthResource)) + if ((MagickSizeType) loop_iters > GetMagickResourceLimit(ListLengthResource)) loop_iters=GetMagickResourceLimit(ListLengthResource); if (loop_iters >= 2147483647L) loop_iters=2147483647L; diff --git a/coders/pnm.c b/coders/pnm.c index 09eee0dac..efb0dfa9e 100644 --- a/coders/pnm.c +++ b/coders/pnm.c @@ -440,7 +440,7 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception) if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0)) if (image->scene >= (image_info->scene+image_info->number_scenes-1)) break; - if ((MagickOffsetType) (image->columns*image->rows/8) > GetBlobSize(image)) + if ((MagickSizeType) (image->columns*image->rows/8) > GetBlobSize(image)) ThrowPNMException(CorruptImageError,"InsufficientImageDataInFile"); status=SetImageExtent(image,image->columns,image->rows,exception); if (status == MagickFalse) diff --git a/coders/rle.c b/coders/rle.c index a89d1cbc0..bb82760cc 100644 --- a/coders/rle.c +++ b/coders/rle.c @@ -317,7 +317,7 @@ static Image *ReadRLEImage(const ImageInfo *image_info,ExceptionInfo *exception) if (comment == (char *) NULL) ThrowRLEException(ResourceLimitError,"MemoryAllocationFailed"); count=ReadBlob(image,length-1,(unsigned char *) comment); - if (count != (length-1)) + if (count != (ssize_t) (length-1)) { comment=DestroyString(comment); ThrowRLEException(CorruptImageError,"UnexpectedEndOfFile"); diff --git a/coders/sgi.c b/coders/sgi.c index 38fd2b152..07c96cfa6 100644 --- a/coders/sgi.c +++ b/coders/sgi.c @@ -373,7 +373,7 @@ static Image *ReadSGIImage(const ImageInfo *image_info,ExceptionInfo *exception) if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0)) if (image->scene >= (image_info->scene+image_info->number_scenes-1)) break; - if ((MagickOffsetType) (image->columns*image->rows/255) > GetBlobSize(image)) + if ((MagickSizeType) (image->columns*image->rows/255) > GetBlobSize(image)) ThrowReaderException(CorruptImageError,"InsufficientImageDataInFile"); status=SetImageExtent(image,image->columns,image->rows,exception); if (status != MagickFalse) @@ -416,7 +416,7 @@ static Image *ReadSGIImage(const ImageInfo *image_info,ExceptionInfo *exception) for (y=0; y < (ssize_t) iris_info.rows; y++) { count=ReadBlob(image,bytes_per_pixel*iris_info.columns,scanline); - if (count != (bytes_per_pixel*iris_info.columns)) + if (count != (ssize_t) (bytes_per_pixel*iris_info.columns)) break; if (bytes_per_pixel == 2) for (x=0; x < (ssize_t) iris_info.columns; x++) @@ -517,7 +517,7 @@ static Image *ReadSGIImage(const ImageInfo *image_info,ExceptionInfo *exception) } count=ReadBlob(image,(size_t) runlength[y+z*iris_info.rows], packets); - if (count != runlength[y+z*iris_info.rows]) + if (count != (ssize_t) runlength[y+z*iris_info.rows]) break; offset+=(ssize_t) runlength[y+z*iris_info.rows]; status=SGIDecode(bytes_per_pixel,(ssize_t) @@ -557,7 +557,7 @@ static Image *ReadSGIImage(const ImageInfo *image_info,ExceptionInfo *exception) } count=ReadBlob(image,(size_t) runlength[y+z*iris_info.rows], packets); - if (count != runlength[y+z*iris_info.rows]) + if (count != (ssize_t) runlength[y+z*iris_info.rows]) break; offset+=(ssize_t) runlength[y+z*iris_info.rows]; status=SGIDecode(bytes_per_pixel,(ssize_t) diff --git a/coders/xpm.c b/coders/xpm.c index 05395996e..e0ff7eee2 100644 --- a/coders/xpm.c +++ b/coders/xpm.c @@ -382,7 +382,7 @@ static Image *ReadXPMImage(const ImageInfo *image_info,ExceptionInfo *exception) if (next == (char *) NULL) break; length=MagickMin((size_t) width,MagickPathExtent-1); - if (CopyXPMColor(key,p,length) != length) + if (CopyXPMColor(key,p,length) != (ssize_t) length) break; status=AddValueToSplayTree(xpm_colors,ConstantString(key),(void *) j); /* -- 2.40.0