From 894806318be4aaea0ebe853221b95d10d1d6b786 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Tue, 24 Mar 2026 17:10:23 -0400
Subject: [PATCH 44/98] FIXME: simplify

---
 div-by-zero-1.c | 375 +-----------------------------------------------
 1 file changed, 2 insertions(+), 373 deletions(-)

diff --git a/div-by-zero-1.c b/div-by-zero-1.c
index 12871e538ec0..47ddc745adcf 100644
--- a/div-by-zero-1.c
+++ b/div-by-zero-1.c
@@ -16715,6 +16715,7 @@ static fxFltType inline GetIntensity(FxInfo *pfx, ssize_t ImgNum,
          GetPixelIntensity(img, quantum_pixel);
 }
 
+//#error need this
 static MagickBooleanType ExecuteRPN(FxInfo *pfx, fxRtT *pfxrt,
                                     fxFltType *result,
                                     const PixelChannel channel,
@@ -17793,6 +17794,7 @@ static MagickBooleanType ExecuteRPN(FxInfo *pfx, fxRtT *pfxrt,
   return MagickTrue;
 }
 
+//#error need this
 __attribute__((visibility("hidden"))) MagickBooleanType
 FxEvaluateChannelExpression(FxInfo *pfx, const PixelChannel channel,
                             const ssize_t x, const ssize_t y, double *result,
@@ -17854,376 +17856,3 @@ FxEvaluateChannelExpression(FxInfo *pfx, const PixelChannel channel,
 
   return MagickTrue;
 }
-
-static FxInfo *AcquireFxInfoPrivate(const Image *images, const char *expression,
-                                    MagickBooleanType CalcAllStats,
-                                    ExceptionInfo *exception) {
-  char chLimit;
-
-  FxInfo *pfx = (FxInfo *)AcquireCriticalMemory(sizeof(*pfx));
-
-  memset(pfx, 0, sizeof(*pfx));
-
-  if (!InitFx(pfx, images, CalcAllStats, exception)) {
-    pfx = (FxInfo *)RelinquishMagickMemory(pfx);
-    return ((void *)0);
-  }
-
-  if (!BuildRPN(pfx)) {
-    (void)DeInitFx(pfx);
-    pfx = (FxInfo *)RelinquishMagickMemory(pfx);
-    return ((FxInfo *)((void *)0));
-  }
-
-  if ((*expression == '@') && (strlen(expression) > 1)) {
-    MagickBooleanType status;
-
-    status = IsRightsAuthorized(PathPolicyDomain, ReadPolicyRights, expression);
-    if (status != MagickFalse)
-      pfx->expression = FileToString(expression + 1, ~0UL, exception);
-    else {
-
-      (*__errno_location()) = 1;
-      (void)ThrowMagickException(exception, "MagickCore/fx.c", __func__,
-                                 (unsigned long)4051, PolicyError,
-                                 "NotAuthorized", "`%s'", expression);
-    }
-  }
-  if (pfx->expression == (char *)((void *)0))
-    pfx->expression = ConstantString(expression);
-  pfx->pex = (char *)pfx->expression;
-
-  pfx->teDepth = 0;
-  if (!TranslateStatementList(pfx, ";", &chLimit)) {
-    (void)DestroyRPN(pfx);
-    pfx->expression = DestroyString(pfx->expression);
-    pfx->pex = ((void *)0);
-    (void)DeInitFx(pfx);
-    pfx = (FxInfo *)RelinquishMagickMemory(pfx);
-    return ((void *)0);
-  }
-
-  if (pfx->teDepth) {
-    (void)ThrowMagickException(
-        pfx->exception, "MagickCore/fx.c", __func__, (unsigned long)4071,
-        OptionError, "Translate expression depth", "(%i) not 0", pfx->teDepth);
-
-    (void)DestroyRPN(pfx);
-    pfx->expression = DestroyString(pfx->expression);
-    pfx->pex = ((void *)0);
-    (void)DeInitFx(pfx);
-    pfx = (FxInfo *)RelinquishMagickMemory(pfx);
-    return ((void *)0);
-  }
-
-  if (chLimit != '\0' && chLimit != ';') {
-    (void)ThrowMagickException(
-        pfx->exception, "MagickCore/fx.c", __func__, (unsigned long)4085,
-        OptionError, "AcquireFxInfo: TranslateExpression did not exhaust input",
-        "(chLimit=%i) at'%s'", (int)chLimit, pfx->pex);
-
-    (void)DestroyRPN(pfx);
-    pfx->expression = DestroyString(pfx->expression);
-    pfx->pex = ((void *)0);
-    (void)DeInitFx(pfx);
-    pfx = (FxInfo *)RelinquishMagickMemory(pfx);
-    return ((void *)0);
-  }
-
-  if (pfx->NeedStats && pfx->runType == rtEntireImage && !pfx->statistics) {
-    if (!CollectStatistics(pfx)) {
-      (void)DestroyRPN(pfx);
-      pfx->expression = DestroyString(pfx->expression);
-      pfx->pex = ((void *)0);
-      (void)DeInitFx(pfx);
-      pfx = (FxInfo *)RelinquishMagickMemory(pfx);
-      return ((void *)0);
-    }
-  }
-
-  if (pfx->DebugOpt) {
-    DumpTables(stderr);
-    DumpUserSymbols(pfx, stderr);
-    (void)DumpRPN(pfx, stderr);
-  }
-
-  {
-    size_t number_threads = (size_t)GetMagickResourceLimit(ThreadResource);
-    ssize_t t;
-
-    pfx->fxrts = (fxRtT *)AcquireQuantumMemory(number_threads, sizeof(fxRtT));
-    if (!pfx->fxrts) {
-      (void)ThrowMagickException(pfx->exception, "MagickCore/fx.c", __func__,
-                                 (unsigned long)4121, ResourceLimitFatalError,
-                                 "fxrts", "%lu", (unsigned long)number_threads);
-      (void)DestroyRPN(pfx);
-      pfx->expression = DestroyString(pfx->expression);
-      pfx->pex = ((void *)0);
-      (void)DeInitFx(pfx);
-      pfx = (FxInfo *)RelinquishMagickMemory(pfx);
-      return ((void *)0);
-    }
-    for (t = 0; t < (ssize_t)number_threads; t++) {
-      if (!AllocFxRt(pfx, &pfx->fxrts[t])) {
-        (void)ThrowMagickException(pfx->exception, "MagickCore/fx.c", __func__,
-                                   (unsigned long)4134, ResourceLimitFatalError,
-                                   "AllocFxRt t=", "%g", (double)t);
-        {
-          ssize_t t2;
-          for (t2 = t - 1; t2 >= 0; t2--) {
-            DestroyFxRt(&pfx->fxrts[t]);
-          }
-        }
-        pfx->fxrts = (fxRtT *)RelinquishMagickMemory(pfx->fxrts);
-        (void)DestroyRPN(pfx);
-        pfx->expression = DestroyString(pfx->expression);
-        pfx->pex = ((void *)0);
-        (void)DeInitFx(pfx);
-        pfx = (FxInfo *)RelinquishMagickMemory(pfx);
-        return ((void *)0);
-      }
-    }
-  }
-  return pfx;
-}
-
-FxInfo *AcquireFxInfo(const Image *images, const char *expression,
-                      ExceptionInfo *exception) {
-  return AcquireFxInfoPrivate(images, expression, MagickFalse, exception);
-}
-
-FxInfo *DestroyFxInfo(FxInfo *pfx) {
-  ssize_t t;
-
-  ((void)sizeof((pfx != ((void *)0)) ? 1 : 0), __extension__({
-     if (pfx != ((void *)0))
-       ;
-     else
-       __assert_fail("pfx != NULL", "MagickCore/fx.c", 4165,
-                     __extension__ __PRETTY_FUNCTION__);
-   }));
-
-  ((void)sizeof((pfx->image != ((void *)0)) ? 1 : 0), __extension__({
-     if (pfx->image != ((void *)0))
-       ;
-     else
-       __assert_fail("pfx->image != NULL", "MagickCore/fx.c", 4166,
-                     __extension__ __PRETTY_FUNCTION__);
-   }));
-
-  ((void)sizeof((pfx->Images != ((void *)0)) ? 1 : 0), __extension__({
-     if (pfx->Images != ((void *)0))
-       ;
-     else
-       __assert_fail("pfx->Images != NULL", "MagickCore/fx.c", 4167,
-                     __extension__ __PRETTY_FUNCTION__);
-   }));
-
-  ((void)sizeof((pfx->Imgs != ((void *)0)) ? 1 : 0), __extension__({
-     if (pfx->Imgs != ((void *)0))
-       ;
-     else
-       __assert_fail("pfx->Imgs != NULL", "MagickCore/fx.c", 4168,
-                     __extension__ __PRETTY_FUNCTION__);
-   }));
-
-  ((void)sizeof((pfx->fxrts != ((void *)0)) ? 1 : 0), __extension__({
-     if (pfx->fxrts != ((void *)0))
-       ;
-     else
-       __assert_fail("pfx->fxrts != NULL", "MagickCore/fx.c", 4169,
-                     __extension__ __PRETTY_FUNCTION__);
-   }));
-
-  for (t = 0; t < (ssize_t)GetMagickResourceLimit(ThreadResource); t++) {
-    DestroyFxRt(&pfx->fxrts[t]);
-  }
-  pfx->fxrts = (fxRtT *)RelinquishMagickMemory(pfx->fxrts);
-
-  DestroyRPN(pfx);
-
-  pfx->expression = DestroyString(pfx->expression);
-  pfx->pex = ((void *)0);
-
-  (void)DeInitFx(pfx);
-
-  pfx = (FxInfo *)RelinquishMagickMemory(pfx);
-
-  return ((void *)0);
-}
-
-__attribute__((visibility("default"))) Image *
-FxImage(const Image *image, const char *expression, ExceptionInfo *exception) {
-
-  CacheView *fx_view, *image_view;
-
-  Image *fx_image;
-
-  MagickBooleanType status;
-
-  MagickOffsetType progress;
-
-  ssize_t y;
-
-  FxInfo *pfx;
-
-  ((void)sizeof((image != (Image *)((void *)0)) ? 1 : 0), __extension__({
-     if (image != (Image *)((void *)0))
-       ;
-     else
-       __assert_fail("image != (Image *) NULL", "MagickCore/fx.c", 4214,
-                     __extension__ __PRETTY_FUNCTION__);
-   }));
-
-  ((void)sizeof((image->signature == 0xabacadabUL) ? 1 : 0), __extension__({
-     if (image->signature == 0xabacadabUL)
-       ;
-     else
-       __assert_fail("image->signature == MagickCoreSignature",
-                     "MagickCore/fx.c", 4215,
-                     __extension__ __PRETTY_FUNCTION__);
-   }));
-  if (IsEventLogging() != MagickFalse)
-    (void)LogMagickEvent(TraceEvent, "MagickCore/fx.c", __func__,
-                         (unsigned long)4217, "%s", image->filename);
-  if (expression == (const char *)((void *)0))
-    return (CloneImage(image, 0, 0, MagickTrue, exception));
-  fx_image = CloneImage(image, 0, 0, MagickTrue, exception);
-  if (!fx_image)
-    return ((void *)0);
-  if (SetImageStorageClass(fx_image, DirectClass, exception) == MagickFalse) {
-    fx_image = DestroyImage(fx_image);
-    return ((void *)0);
-  }
-
-  pfx = AcquireFxInfoPrivate(image, expression, MagickTrue, exception);
-
-  if (!pfx) {
-    fx_image = DestroyImage(fx_image);
-    return ((void *)0);
-  }
-
-  ((void)sizeof((pfx->image != ((void *)0)) ? 1 : 0), __extension__({
-     if (pfx->image != ((void *)0))
-       ;
-     else
-       __assert_fail("pfx->image != NULL", "MagickCore/fx.c", 4234,
-                     __extension__ __PRETTY_FUNCTION__);
-   }));
-
-  ((void)sizeof((pfx->Images != ((void *)0)) ? 1 : 0), __extension__({
-     if (pfx->Images != ((void *)0))
-       ;
-     else
-       __assert_fail("pfx->Images != NULL", "MagickCore/fx.c", 4235,
-                     __extension__ __PRETTY_FUNCTION__);
-   }));
-
-  ((void)sizeof((pfx->Imgs != ((void *)0)) ? 1 : 0), __extension__({
-     if (pfx->Imgs != ((void *)0))
-       ;
-     else
-       __assert_fail("pfx->Imgs != NULL", "MagickCore/fx.c", 4236,
-                     __extension__ __PRETTY_FUNCTION__);
-   }));
-
-  ((void)sizeof((pfx->fxrts != ((void *)0)) ? 1 : 0), __extension__({
-     if (pfx->fxrts != ((void *)0))
-       ;
-     else
-       __assert_fail("pfx->fxrts != NULL", "MagickCore/fx.c", 4237,
-                     __extension__ __PRETTY_FUNCTION__);
-   }));
-
-  status = MagickTrue;
-  progress = 0;
-  image_view = AcquireVirtualCacheView(image, pfx->exception);
-  fx_view = AcquireAuthenticCacheView(fx_image, pfx->exception);
-
-  for (y = 0; y < (ssize_t)fx_image->rows; y++) {
-    const int id = GetOpenMPThreadId();
-
-    const Quantum *__restrict__ p;
-
-    Quantum *__restrict__ q;
-
-    ssize_t x;
-
-    fxFltType result = 0.0;
-
-    if (status == MagickFalse)
-      continue;
-    p = GetCacheViewVirtualPixels(image_view, 0, y, image->columns, 1,
-                                  pfx->exception);
-    q = QueueCacheViewAuthenticPixels(fx_view, 0, y, fx_image->columns, 1,
-                                      pfx->exception);
-    if ((p == (const Quantum *)((void *)0)) || (q == (Quantum *)((void *)0))) {
-      status = MagickFalse;
-      continue;
-    }
-    for (x = 0; x < (ssize_t)fx_image->columns; x++) {
-      ssize_t i;
-
-      pfx->fxrts[id].thisPixel = (Quantum *)p;
-
-      for (i = 0; i < (ssize_t)GetPixelChannels(image); i++) {
-        PixelChannel channel = GetPixelChannelChannel(image, i);
-        PixelTrait traits = GetPixelChannelTraits(image, channel);
-        PixelTrait fx_traits = GetPixelChannelTraits(fx_image, channel);
-        if ((traits == UndefinedPixelTrait) ||
-            (fx_traits == UndefinedPixelTrait))
-          continue;
-        if ((fx_traits & CopyPixelTrait) != 0) {
-          SetPixelChannel(fx_image, channel, p[i], q);
-          continue;
-        }
-
-        if (!ExecuteRPN(pfx, &pfx->fxrts[id], &result, channel, x, y)) {
-          status = MagickFalse;
-          break;
-        }
-
-        q[i] = ClampToQuantum((MagickRealType)(65535.0f * result));
-      }
-      p += GetPixelChannels(image);
-      q += GetPixelChannels(fx_image);
-    }
-    if (SyncCacheViewAuthenticPixels(fx_view, pfx->exception) == MagickFalse)
-      status = MagickFalse;
-    if (image->progress_monitor != (MagickProgressMonitor)((void *)0)) {
-      MagickBooleanType proceed;
-
-      progress++;
-      proceed = SetImageProgress(image, "FxNew/Image", progress, image->rows);
-      if (proceed == MagickFalse)
-        status = MagickFalse;
-    }
-  }
-
-  fx_view = DestroyCacheView(fx_view);
-  image_view = DestroyCacheView(image_view);
-
-  if (pfx->DebugOpt && pfx->usedUserSymbols) {
-    int t, i;
-    char UserSym[4096];
-    fprintf(stderr, "User symbols (%i):\n", pfx->usedUserSymbols);
-    for (t = 0; t < (int)GetMagickResourceLimit(ThreadResource); t++) {
-      for (i = 0; i < (int)pfx->usedUserSymbols; i++) {
-        fprintf(stderr, "th=%i us=%i '%s': %.*Lg\n", t, i,
-                NameOfUserSym(pfx, i, UserSym), pfx->precision,
-                pfx->fxrts[t].UserSymVals[i]);
-      }
-    }
-  }
-
-  if (pfx->exception->severity != UndefinedException) {
-    status = MagickFalse;
-  }
-
-  if (status == MagickFalse)
-    fx_image = DestroyImage(fx_image);
-
-  pfx = DestroyFxInfo(pfx);
-
-  return (fx_image);
-}
-- 
2.49.0

