Commit 3b5dd62f8 for imagemagick.org
commit 3b5dd62f872e86c9865b8656f682437ac25521f3
Author: Cristy <urban-warrior@imagemagick.org>
Date: Fri Sep 4 19:17:55 2026 -0400
eliminate compiler warnings
diff --git a/MagickCore/annotate.c b/MagickCore/annotate.c
index 2773f415f..002aa3d69 100644
--- a/MagickCore/annotate.c
+++ b/MagickCore/annotate.c
@@ -338,8 +338,8 @@ MagickExport MagickBooleanType AnnotateImage(Image *image,
/*
Position text relative to image.
*/
- annotate_info->affine.tx=geometry_info.xi-image->page.x;
- annotate_info->affine.ty=geometry_info.psi-image->page.y;
+ annotate_info->affine.tx=geometry_info.xi-(double) image->page.x;
+ annotate_info->affine.ty=geometry_info.psi-(double) image->page.y;
(void) CloneString(&annotate->text,textlist[i]);
if ((metrics.width == 0) || (annotate->gravity != NorthWestGravity))
(void) GetTypeMetrics(image,annotate,&metrics,exception);
diff --git a/MagickCore/colorspace-private.h b/MagickCore/colorspace-private.h
index 623d31fe9..b741db4a7 100644
--- a/MagickCore/colorspace-private.h
+++ b/MagickCore/colorspace-private.h
@@ -509,7 +509,7 @@ static inline void ConvertHWBToRGB(const double hue,const double whiteness,
return;
}
i=CastDoubleToSsizeT(floor(6.0*hue));
- f=6.0*hue-i;
+ f=6.0*hue-(double) i;
if ((i & 0x01) != 0)
f=1.0-f;
n=whiteness+f*(v-whiteness); /* linear interpolation */
diff --git a/MagickCore/image-private.h b/MagickCore/image-private.h
index a9f407b4c..5e4b0d5eb 100644
--- a/MagickCore/image-private.h
+++ b/MagickCore/image-private.h
@@ -25,6 +25,7 @@ extern "C" {
#define MagickMax(x,y) (((x) > (y)) ? (x) : (y))
#define MagickMin(x,y) (((x) < (y)) ? (x) : (y))
+#include <limits.h>
#include "MagickCore/pixel-accessor.h"
#include "MagickCore/quantum-private.h"
@@ -113,30 +114,6 @@ static inline ptrdiff_t CastDoubleToPtrdiffT(const double x)
return((ptrdiff_t) value);
}
-static inline QuantumAny CastDoubleToQuantumAny(const double x)
-{
- double
- value;
-
- if (IsNaN(x) != 0)
- {
- errno=ERANGE;
- return(0);
- }
- value=(x < 0.0) ? ceil(x) : floor(x);
- if (value < 0.0)
- {
- errno=ERANGE;
- return(0);
- }
- if (value >= ((double) ((QuantumAny) ~0)))
- {
- errno=ERANGE;
- return((QuantumAny) ~0);
- }
- return((QuantumAny) value);
-}
-
static inline size_t CastDoubleToSizeT(const double x)
{
double
@@ -262,25 +239,6 @@ static inline double DegreesToRadians(const double degrees)
return((double) (MagickPI*degrees/180.0));
}
-static inline size_t GetImageChannels(const Image *image)
-{
- ssize_t
- i;
-
- size_t
- channels;
-
- channels=0;
- for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
- {
- PixelChannel channel = GetPixelChannelChannel(image,i);
- PixelTrait traits = GetPixelChannelTraits(image,channel);
- if ((traits & UpdatePixelTrait) != 0)
- channels++;
- }
- return(channels == 0 ? (size_t) 1 : channels);
-}
-
static inline double RadiansToDegrees(const double radians)
{
return((double) (180.0*radians/MagickPI));
diff --git a/MagickCore/pixel-accessor.h b/MagickCore/pixel-accessor.h
index 615a0f9c1..25c518dc1 100644
--- a/MagickCore/pixel-accessor.h
+++ b/MagickCore/pixel-accessor.h
@@ -24,6 +24,7 @@
#include "MagickCore/colorspace.h"
#include "MagickCore/gem.h"
#include "MagickCore/image.h"
+#include "MagickCore/image-private.h"
#include "MagickCore/memory_.h"
#if defined(__cplusplus) || defined(c_plusplus)
@@ -138,9 +139,9 @@ static inline PixelTrait GetPixelChannelTraits(
}
static inline size_t GetPixelChannels(const Image *magick_restrict image)
-{
+{
return(image->number_channels);
-}
+}
static inline Quantum GetPixelCompositeMask(
const Image *magick_restrict image,const Quantum *magick_restrict pixel)
@@ -234,7 +235,7 @@ static inline MagickRealType GetPixelInfoChannel(
case AlphaPixelChannel:
{
if (pixel_info->alpha_trait == UndefinedPixelTrait)
- return(OpaqueAlpha);
+ return((MagickRealType) OpaqueAlpha);
return(pixel_info->alpha);
}
case IndexPixelChannel: return(pixel_info->index);
@@ -364,10 +365,10 @@ static inline void GetPixelInfoRGBA(const Quantum red,const Quantum green,
const Quantum blue,const Quantum alpha,PixelInfo *magick_restrict pixel)
{
GetPixelInfo((Image *) NULL,pixel);
- pixel->red=red;
- pixel->green=green;
- pixel->blue=blue;
- pixel->alpha=alpha;
+ pixel->red=(MagickRealType) red;
+ pixel->green=(MagickRealType) green;
+ pixel->blue=(MagickRealType) blue;
+ pixel->alpha=(MagickRealType) alpha;
}
static inline Quantum GetPixelWriteMask(
@@ -493,6 +494,30 @@ static inline MagickRealType AbsolutePixelValue(const MagickRealType x)
return(x < 0.0 ? -x : x);
}
+static inline QuantumAny CastDoubleToQuantumAny(const double x)
+{
+ double
+ value;
+
+ if (IsNaN(x) != 0)
+ {
+ errno=ERANGE;
+ return(0);
+ }
+ value=(x < 0.0) ? ceil(x) : floor(x);
+ if (value < 0.0)
+ {
+ errno=ERANGE;
+ return(0);
+ }
+ if (value >= ((double) ((QuantumAny) ~0)))
+ {
+ errno=ERANGE;
+ return((QuantumAny) ~0);
+ }
+ return((QuantumAny) value);
+}
+
static inline MagickBooleanType IsPixelAtDepth(const Quantum pixel,
const QuantumAny range)
{
@@ -505,8 +530,9 @@ static inline MagickBooleanType IsPixelAtDepth(const Quantum pixel,
quantum=(Quantum) (((double) QuantumRange*((QuantumAny) (((double) range*
pixel)/(double) QuantumRange+0.5)))/(double) range+0.5);
#else
- quantum=(Quantum) (((double) QuantumRange*((QuantumAny) (((double) range*
- (double) pixel)/(double) QuantumRange+0.5)))/(double) range);
+ quantum=(Quantum) (((double) QuantumRange*((double) CastDoubleToQuantumAny(
+ ((double) range*(double) pixel)/(double) QuantumRange+0.5)))/
+ (double) range);
#endif
return(pixel == quantum ? MagickTrue : MagickFalse);
}
@@ -951,6 +977,25 @@ static inline void SetPixelYTraits(Image *image,const PixelTrait traits)
image->channel_map[YPixelChannel].traits=traits;
}
+static inline size_t GetImageChannels(const Image *image)
+{
+ ssize_t
+ i;
+
+ size_t
+ channels;
+
+ channels=0;
+ for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
+ {
+ PixelChannel channel = GetPixelChannelChannel(image,i);
+ PixelTrait traits = GetPixelChannelTraits(image,channel);
+ if ((traits & UpdatePixelTrait) != 0)
+ channels++;
+ }
+ return(channels == 0 ? (size_t) 1 : channels);
+}
+
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif
diff --git a/MagickCore/quantum-private.h b/MagickCore/quantum-private.h
index 0d88ebd4b..c60b835eb 100644
--- a/MagickCore/quantum-private.h
+++ b/MagickCore/quantum-private.h
@@ -18,6 +18,7 @@
#ifndef MAGICKCORE_QUANTUM_PRIVATE_H
#define MAGICKCORE_QUANTUM_PRIVATE_H
+#include <stddef.h>
#include "MagickCore/memory_.h"
#include "MagickCore/cache.h"
#include "MagickCore/image-private.h"
@@ -334,7 +335,7 @@ static inline Quantum ScaleAnyToQuantum(const QuantumAny quantum,
return((Quantum) ((double) QuantumRange*(quantum*
MagickSafeReciprocal((double) range))+0.5));
#else
- return((Quantum) ((double) QuantumRange*(quantum*
+ return((Quantum) ((double) QuantumRange*((double) quantum*
MagickSafeReciprocal((double) range))));
#endif
}
@@ -347,9 +348,9 @@ static inline QuantumAny ScaleQuantumToAny(const Quantum quantum,
#else
if ((IsNaN(quantum) != 0) || (quantum <= 0.0f))
return((QuantumAny) 0UL);
- if (((double) range*quantum/(double) QuantumRange) >= 18446744073709551615.0)
+ if (((double) range*(double) quantum/(double) QuantumRange) >= 18446744073709551615.0)
return((QuantumAny) MagickULLConstant(18446744073709551615));
- return((QuantumAny) (range*(double) quantum/(double) QuantumRange+0.5));
+ return((QuantumAny) ((double) range*(double) quantum/(double) QuantumRange+0.5));
#endif
}
@@ -474,7 +475,7 @@ static inline Quantum ScaleLongLongToQuantum(const MagickSizeType value)
#if !defined(MAGICKCORE_HDRI_SUPPORT)
return((Quantum) ((value)/MagickULLConstant(281479271743489)));
#else
- return((Quantum) (value/281479271743489.0));
+ return((Quantum) ((double) value/281479271743489.0));
#endif
}
diff --git a/MagickCore/string-private.h b/MagickCore/string-private.h
index e758b2bc7..7910fb8fd 100644
--- a/MagickCore/string-private.h
+++ b/MagickCore/string-private.h
@@ -26,7 +26,7 @@ extern "C" {
#endif
/* Custom implementation so we can use sscanf without defining _CRT_SECURE_NO_WARNINGS */
-static inline int MagickSscanf(const char* buffer,const char* format, ...)
+static inline int MagickSscanf(const char *buffer,const char *format,...)
{
int
ret;
diff --git a/coders/ghostscript-private.h b/coders/ghostscript-private.h
index ee64ab13c..ca569fa1a 100644
--- a/coders/ghostscript-private.h
+++ b/coders/ghostscript-private.h
@@ -57,8 +57,8 @@ static double GhostscriptVersion(const GhostInfo *ghost_info)
if ((ghost_info->revision)(&revision,(int) sizeof(revision)) != 0)
return(0.0);
if (revision.revision > 1000)
- return(revision.revision/1000.0);
- return(revision.revision/100.0);
+ return((double) revision.revision/1000.0);
+ return((double) revision.revision/100.0);
}
#endif