From: dirk Date: Wed, 6 Apr 2016 21:45:46 +0000 (+0200) Subject: Renamed IsValidColormapIndex to ValidateColormapValue and changed the return type... X-Git-Tag: 7.0.1-0~59 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1b3613e5d2d955cb2e4725b6795b748fb04fd065;p=imagemagick Renamed IsValidColormapIndex to ValidateColormapValue and changed the return type to void. --- diff --git a/MagickCore/colormap-private.h b/MagickCore/colormap-private.h index 28eeecb86..756e7f9af 100644 --- a/MagickCore/colormap-private.h +++ b/MagickCore/colormap-private.h @@ -38,7 +38,7 @@ static inline ssize_t ConstrainColormapIndex(Image *image,const ssize_t index, return((ssize_t) index); } -static inline MagickBooleanType IsValidColormapIndex(Image *image, +static inline void ValidateColormapValue(Image *image, const ssize_t index,Quantum *target,ExceptionInfo *exception) { if ((index < 0) || (index >= (ssize_t) image->colors)) @@ -46,10 +46,9 @@ static inline MagickBooleanType IsValidColormapIndex(Image *image, (void) ThrowMagickException(exception,GetMagickModule(),CorruptImageError, "InvalidColormapIndex","`%s'",image->filename); *target=(Quantum) 0; - return(MagickFalse); } - *target=(Quantum) index; - return(MagickTrue); + else + *target=(Quantum) index; } #if defined(__cplusplus) || defined(c_plusplus) diff --git a/coders/bmp.c b/coders/bmp.c index a8e9181c6..f9cc26c5a 100644 --- a/coders/bmp.c +++ b/coders/bmp.c @@ -1099,18 +1099,17 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception) break; for (x=0; x < ((ssize_t) image->columns-1); x+=2) { - (void) IsValidColormapIndex(image,(*p >> 4) & 0x0f,&index, - exception); + ValidateColormapValue(image,(*p >> 4) & 0x0f,&index,exception); SetPixelIndex(image,index,q); q+=GetPixelChannels(image); - (void) IsValidColormapIndex(image,*p & 0x0f,&index,exception); + ValidateColormapValue(image,*p & 0x0f,&index,exception); SetPixelIndex(image,index,q); q+=GetPixelChannels(image); p++; } if ((image->columns % 2) != 0) { - IsValidColormapIndex(image,(*p >> 4) & 0xf,&index,exception); + ValidateColormapValue(image,(*p >> 4) & 0xf,&index,exception); SetPixelIndex(image,index,q); q+=GetPixelChannels(image); p++; @@ -1147,7 +1146,7 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception) break; for (x=(ssize_t) image->columns; x != 0; --x) { - (void) IsValidColormapIndex(image,*p++,&index,exception); + ValidateColormapValue(image,*p++,&index,exception); SetPixelIndex(image,index,q); q+=GetPixelChannels(image); } diff --git a/coders/rle.c b/coders/rle.c index 2af1bb3a7..2a8b69457 100644 --- a/coders/rle.c +++ b/coders/rle.c @@ -458,9 +458,7 @@ static Image *ReadRLEImage(const ImageInfo *image_info,ExceptionInfo *exception) if (number_colormaps == 1) for (i=0; i < (ssize_t) number_pixels; i++) { - if (IsValidColormapIndex(image,*p & mask,&index,exception) == - MagickFalse) - break; + ValidateColormapValue(image,*p & mask,&index,exception); *p=colormap[(ssize_t) index]; p++; } @@ -469,9 +467,8 @@ static Image *ReadRLEImage(const ImageInfo *image_info,ExceptionInfo *exception) for (i=0; i < (ssize_t) number_pixels; i++) for (x=0; x < (ssize_t) number_planes; x++) { - if (IsValidColormapIndex(image,(size_t) (x*map_length+ - (*p & mask)),&index,exception) == MagickFalse) - break; + ValidateColormapValue(image,(size_t) (x*map_length+ + (*p & mask)),&index,exception); *p=colormap[(ssize_t) index]; p++; } @@ -591,19 +588,13 @@ static Image *ReadRLEImage(const ImageInfo *image_info,ExceptionInfo *exception) break; for (x=0; x < (ssize_t) image->columns; x++) { - if (IsValidColormapIndex(image,(ssize_t) *p++,&index, - exception) == MagickFalse) - break; + ValidateColormapValue(image,(ssize_t) *p++,&index,exception); SetPixelRed(image,ClampToQuantum(image->colormap[(ssize_t) index].red),q); - if (IsValidColormapIndex(image,(ssize_t) *p++,&index, - exception) == MagickFalse) - break; + ValidateColormapValue(image,(ssize_t) *p++,&index,exception); SetPixelGreen(image,ClampToQuantum(image->colormap[(ssize_t) index].green),q); - if (IsValidColormapIndex(image,(ssize_t) *p++,&index, - exception) == MagickFalse) - break; + ValidateColormapValue(image,(ssize_t) *p++,&index,exception); SetPixelBlue(image,ClampToQuantum(image->colormap[(ssize_t) index].blue),q); SetPixelAlpha(image,ScaleCharToQuantum(*p++),q);