From 338f0889100c635cc8e2281e66b2d2e34d3b37e8 Mon Sep 17 00:00:00 2001 From: Cristy Date: Sat, 10 Dec 2016 12:12:35 -0500 Subject: [PATCH] Ensure source compiles with pedantic C++ compiler --- MagickCore/cache.c | 3 ++- MagickCore/image.c | 4 ++-- MagickCore/string.c | 2 -- coders/bmp.c | 4 ++-- coders/histogram.c | 4 ++-- coders/json.c | 2 +- coders/meta.c | 4 ++-- coders/ps2.c | 2 +- coders/ps3.c | 47 +++++++++++++++++++++++++-------------------- coders/psd.c | 10 ++++++---- 10 files changed, 44 insertions(+), 38 deletions(-) diff --git a/MagickCore/cache.c b/MagickCore/cache.c index 88ddbe7c4..b7ac75441 100644 --- a/MagickCore/cache.c +++ b/MagickCore/cache.c @@ -881,7 +881,8 @@ static inline void RelinquishPixelCachePixels(CacheInfo *cache_info) } #endif if (cache_info->mapped == MagickFalse) - cache_info->pixels=RelinquishAlignedMemory(cache_info->pixels); + cache_info->pixels=(Quantum *) RelinquishAlignedMemory( + cache_info->pixels); else (void) UnmapBlob(cache_info->pixels,(size_t) cache_info->length); RelinquishMagickResource(MemoryResource,cache_info->length); diff --git a/MagickCore/image.c b/MagickCore/image.c index ae1f3a20e..a07421b0e 100644 --- a/MagickCore/image.c +++ b/MagickCore/image.c @@ -3209,8 +3209,8 @@ MagickExport MagickBooleanType SetImageRegionMask(Image *image, pixel; pixel=0; - if (((x >= region->x) && (x < (region->x+region->width))) && - ((y >= region->y) && (y < (region->y+region->height)))) + if (((x >= region->x) && (x < (region->x+(ssize_t) region->width))) && + ((y >= region->y) && (y < (region->y+(ssize_t) region->height)))) pixel=QuantumRange; switch (type) { diff --git a/MagickCore/string.c b/MagickCore/string.c index a26a5b203..56056d1e4 100644 --- a/MagickCore/string.c +++ b/MagickCore/string.c @@ -752,8 +752,6 @@ MagickExport size_t CopyMagickString(char *destination,const char *source, register size_t n; - if (source == (const char *) NULL) - return(0); p=source; q=destination; for (n=length; n > 4; n-=4) diff --git a/coders/bmp.c b/coders/bmp.c index 303f6d5a7..d68897cd5 100644 --- a/coders/bmp.c +++ b/coders/bmp.c @@ -1682,8 +1682,8 @@ static MagickBooleanType WriteBMPImage(const ImageInfo *image_info,Image *image, bmp_info.file_size+=extra_size; bmp_info.offset_bits+=extra_size; } - if ((image->columns != (signed int) image->columns) || - (image->rows != (signed int) image->rows)) + if (((ssize_t) image->columns != (signed int) image->columns) || + ((ssize_t) image->rows != (signed int) image->rows)) ThrowWriterException(ImageError,"WidthOrHeightExceedsLimit"); bmp_info.width=(ssize_t) image->columns; bmp_info.height=(ssize_t) image->rows; diff --git a/coders/histogram.c b/coders/histogram.c index d5a40874a..ffce5545f 100644 --- a/coders/histogram.c +++ b/coders/histogram.c @@ -375,10 +375,10 @@ static MagickBooleanType WriteHISTOGRAMImage(const ImageInfo *image_info, (LocaleCompare(write_info->magick,"HISTOGRAM") == 0)) (void) FormatLocaleString(histogram_image->filename,MagickPathExtent, "miff:%s",write_info->filename); - histogram_image->blob=DetachBlob(histogram_image->blob); + histogram_image->blob=(BlobInfo *) DetachBlob(histogram_image->blob); histogram_image->blob=CloneBlobInfo(image->blob); status=WriteImage(write_info,histogram_image,exception); - image->blob=DetachBlob(image->blob); + image->blob=(BlobInfo *) DetachBlob(image->blob); image->blob=CloneBlobInfo(histogram_image->blob); histogram_image=DestroyImage(histogram_image); write_info=DestroyImageInfo(write_info); diff --git a/coders/json.c b/coders/json.c index d1460b883..ab32137bd 100644 --- a/coders/json.c +++ b/coders/json.c @@ -653,7 +653,7 @@ static ssize_t PrintChannelPerceptualHash(Image *image,FILE *file, if (j < (MaximumNumberOfPerceptualHashes-1)) n+=FormatLocaleFile(file,",\n"); } - if (i < (GetPixelChannels(image)-1)) + if (i < (ssize_t) (GetPixelChannels(image)-1)) n+=FormatLocaleFile(file,"\n },\n"); } n+=FormatLocaleFile(file,"\n }\n"); diff --git a/coders/meta.c b/coders/meta.c index 2a153c53e..9dbaa5c35 100644 --- a/coders/meta.c +++ b/coders/meta.c @@ -407,7 +407,7 @@ static ssize_t parse8BIM(Image *ifile, Image *ofile) *s = &token[next-1]; codes_length=convertHTMLcodes(s, strlen(s)); - if (codes_length > len) + if ((ssize_t) codes_length > len) len=0; else len-=codes_length; @@ -710,7 +710,7 @@ static ssize_t parse8BIMW(Image *ifile, Image *ofile) *s = &token[next-1]; codes_length=convertHTMLcodes(s, strlen(s)); - if (codes_length > len) + if ((ssize_t) codes_length > len) len=0; else len-=codes_length; diff --git a/coders/ps2.c b/coders/ps2.c index 363b9c9b8..f4105d981 100644 --- a/coders/ps2.c +++ b/coders/ps2.c @@ -298,7 +298,7 @@ static MagickBooleanType WritePS2Image(const ImageInfo *image_info,Image *image, " {", " /DataSource pixel_stream %s", " <<", - " /K "CCITTParam, + " /K " CCITTParam, " /Columns columns", " /Rows rows", " >> /CCITTFaxDecode filter", diff --git a/coders/ps3.c b/coders/ps3.c index 66727dfcb..fa346ee77 100644 --- a/coders/ps3.c +++ b/coders/ps3.c @@ -486,37 +486,42 @@ static MagickBooleanType WritePS3MaskImage(const ImageInfo *image_info, default: { (void) FormatLocaleString(buffer,MagickPathExtent, - "currentfile %.20g %.20g "PS3_NoCompression" ByteStreamDecodeFilter\n", - (double) image->columns,(double) image->rows); + "currentfile %.20g %.20g " PS3_NoCompression + " ByteStreamDecodeFilter\n",(double) image->columns,(double) + image->rows); break; } case FaxCompression: case Group4Compression: { (void) FormatLocaleString(buffer,MagickPathExtent, - "currentfile %.20g %.20g "PS3_FaxCompression" ByteStreamDecodeFilter\n", - (double) image->columns,(double) image->rows); + "currentfile %.20g %.20g " PS3_FaxCompression + " ByteStreamDecodeFilter\n",(double) image->columns,(double) + image->rows); break; } case LZWCompression: { (void) FormatLocaleString(buffer,MagickPathExtent, - "currentfile %.20g %.20g "PS3_LZWCompression" ByteStreamDecodeFilter\n", - (double) image->columns,(double) image->rows); + "currentfile %.20g %.20g " PS3_LZWCompression + " ByteStreamDecodeFilter\n",(double) image->columns,(double) + image->rows); break; } case RLECompression: { (void) FormatLocaleString(buffer,MagickPathExtent, - "currentfile %.20g %.20g "PS3_RLECompression" ByteStreamDecodeFilter\n", - (double) image->columns,(double) image->rows); + "currentfile %.20g %.20g " PS3_RLECompression + " ByteStreamDecodeFilter\n",(double) image->columns,(double) + image->rows); break; } case ZipCompression: { (void) FormatLocaleString(buffer,MagickPathExtent, - "currentfile %.20g %.20g "PS3_ZipCompression" ByteStreamDecodeFilter\n", - (double) image->columns,(double) image->rows); + "currentfile %.20g %.20g " PS3_ZipCompression + " ByteStreamDecodeFilter\n",(double) image->columns,(double) + image->rows); break; } } @@ -623,25 +628,25 @@ static MagickBooleanType WritePS3Image(const ImageInfo *image_info,Image *image, " /z exch def", " /r exch def", " /c exch def", - " z "PS3_NoCompression" eq { /ASCII85Decode filter } if", - " z "PS3_FaxCompression" eq", + " z " PS3_NoCompression " eq { /ASCII85Decode filter } if", + " z " PS3_FaxCompression " eq", " {", " <<", - " /K "CCITTParam, + " /K " CCITTParam, " /Columns c", " /Rows r", " >>", " /CCITTFaxDecode filter", " } if", - " z "PS3_JPEGCompression" eq { /DCTDecode filter } if", - " z "PS3_LZWCompression" eq { /LZWDecode filter } if", - " z "PS3_RLECompression" eq { /RunLengthDecode filter } if", - " z "PS3_ZipCompression" eq { /FlateDecode filter } if", + " z " PS3_JPEGCompression " eq { /DCTDecode filter } if", + " z " PS3_LZWCompression " eq { /LZWDecode filter } if", + " z " PS3_RLECompression " eq { /RunLengthDecode filter } if", + " z " PS3_ZipCompression " eq { /FlateDecode filter } if", "} bind def", "", "/DirectClassImageDict", "{", - " colorspace "PS3_RGBColorspace" eq", + " colorspace " PS3_RGBColorspace " eq", " {", " /DeviceRGB setcolorspace", " <<", @@ -666,7 +671,7 @@ static MagickBooleanType WritePS3Image(const ImageInfo *image_info,Image *image, " /MultipleDataSources false", " /ImageMatrix [columns 0 0 rows neg 0 rows]", " /Decode", - " compression "PS3_JPEGCompression" eq", + " compression " PS3_JPEGCompression " eq", " { [1 0 1 0 1 0 1 0] }", " { [0 1 0 1 0 1 0 1] }", " ifelse", @@ -699,7 +704,7 @@ static MagickBooleanType WritePS3Image(const ImageInfo *image_info,Image *image, " {", " % RGB colormap.", " /colormap colors 3 mul string def", - " compression "PS3_NoCompression" eq", + " compression " PS3_NoCompression " eq", " { currentfile /ASCII85Decode filter colormap readstring pop pop }", " { currentfile colormap readstring pop pop }", " ifelse", @@ -719,7 +724,7 @@ static MagickBooleanType WritePS3Image(const ImageInfo *image_info,Image *image, "", "/NonMaskedImageDict", "{", - " class "PS3_PseudoClass" eq", + " class " PS3_PseudoClass " eq", " { PseudoClassImageDict }", " { DirectClassImageDict }", " ifelse", diff --git a/coders/psd.c b/coders/psd.c index 10e948254..e2e3041c0 100644 --- a/coders/psd.c +++ b/coders/psd.c @@ -2525,7 +2525,8 @@ static size_t WritePSDChannel(const PSDInfo *psd_info, #ifdef MAGICKCORE_ZLIB_DELEGATE if (next_image->compression == ZipCompression) { - compressed_pixels=AcquireQuantumMemory(CHUNK,sizeof(*compressed_pixels)); + compressed_pixels=(unsigned char *) AcquireQuantumMemory(CHUNK, + sizeof(*compressed_pixels)); if (compressed_pixels == (unsigned char *) NULL) { quantum_info=DestroyQuantumInfo(quantum_info); @@ -2614,7 +2615,7 @@ static unsigned char *AcquireCompactPixels(const Image *image, return(compact_pixels); } -static MagickBooleanType WritePSDChannels(const PSDInfo *psd_info, +static size_t WritePSDChannels(const PSDInfo *psd_info, const ImageInfo *image_info,Image *image,Image *next_image, MagickOffsetType size_offset,const MagickBooleanType separate, ExceptionInfo *exception) @@ -2879,7 +2880,7 @@ static void RemoveICCProfileFromResourceBlock(StringInfo *bim_profile) quantum; quantum=PSDQuantum(count)+12; - if ((quantum >= 12) && (quantum < length)) + if ((quantum >= 12) && (quantum < (ssize_t) length)) { if ((q+quantum < (datum+length-16))) (void) CopyMagickMemory(q,q+quantum,length-quantum-(q-datum)); @@ -3383,7 +3384,8 @@ static MagickBooleanType WritePSDImage(const ImageInfo *image_info, else rounded_size=size; (void) WritePSDSize(&psd_info,image,rounded_size,size_offset); - layer_size_offsets=RelinquishMagickMemory(layer_size_offsets); + layer_size_offsets=(MagickOffsetType *) RelinquishMagickMemory( + layer_size_offsets); /* Remove the opacity mask from the registry */ -- 2.40.0