gnuastro-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnuastro-commits] master 94f1010: NoiseChisel: corrected compiler warni


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 94f1010: NoiseChisel: corrected compiler warning
Date: Wed, 25 Nov 2020 13:26:10 -0500 (EST)

branch: master
commit 94f10106031ddb94e4bc4b4679f2f058843e2ceb
Author: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>

    NoiseChisel: corrected compiler warning
    
    Until now, the printing (when '--quiet' isn't ginve) of completion of the
    growing phase was being reported just after the function that done the
    actual growing. While testing the build on an older computer, I saw a
    compiler warning about a possibly un-initialized variable.
    
    To keep things clean, the printing of the status is now taken within the
    same 'if' statement that does the growing, thus removing this warning, and
    also making the code more cleaner.
---
 bin/noisechisel/detection.c | 51 ++++++++++++++++++++++++++-------------------
 1 file changed, 29 insertions(+), 22 deletions(-)

diff --git a/bin/noisechisel/detection.c b/bin/noisechisel/detection.c
index 631d642..0435cc8 100644
--- a/bin/noisechisel/detection.c
+++ b/bin/noisechisel/detection.c
@@ -1151,32 +1151,39 @@ detection(struct noisechiselparams *p)
   if(!p->cp.quiet) gettimeofday(&t1, NULL);
   if(p->detgrowquant!=1.0f)
     {
+      /* Grow the detections and report the number of expanded (if
+         necessary). */
       num_expanded=detection_quantile_expand(p, workbin);
       if(num_expanded!=GAL_BLANK_SIZE_T)
-        num_true_initial=num_expanded;
-    }
-
-
-  /* Update the user on the progress, if necessary. */
-  if(!p->cp.quiet && p->detgrowquant!=1.0f && num_expanded!=GAL_BLANK_SIZE_T )
-    {
-      /* If the user hasn't asked for a labeled image, then don't confuse
-         them with the number of detections, just let them know that growth
-         is complete. */
-      if(p->label)
-        {
-          if( asprintf(&msg, "%zu detections after growth to %.3f "
-                       "quantile.", num_true_initial, p->detgrowquant)<0 )
-            error(EXIT_FAILURE, 0, "%s: asprintf allocation", __func__);
-        }
-      else
         {
-          if( asprintf(&msg, "Growth to %.3f quantile complete.",
-                       p->detgrowquant)<0 )
-            error(EXIT_FAILURE, 0, "%s: asprintf allocation", __func__);
+          /* Set the number of expanded objects. */
+          num_true_initial=num_expanded;
+
+          /* If not in quiet-mode, let the user know how its going. */
+          if(!p->cp.quiet)
+            {
+              /* If the user hasn't asked for a labeled image, then don't
+                 confuse them with the number of detections, just let them
+                 know that growth is complete. */
+              if(p->label)
+                {
+                  if( asprintf(&msg, "%zu detections after growth to %.3f "
+                               "quantile.", num_true_initial,
+                               p->detgrowquant)<0 )
+                    error(EXIT_FAILURE, 0, "%s: asprintf allocation",
+                          __func__);
+                }
+              else
+                {
+                  if( asprintf(&msg, "Growth to %.3f quantile complete.",
+                               p->detgrowquant)<0 )
+                    error(EXIT_FAILURE, 0, "%s: asprintf allocation",
+                          __func__);
+                }
+              gal_timing_report(&t1, msg, 2);
+              free(msg);
+            }
         }
-      gal_timing_report(&t1, msg, 2);
-      free(msg);
     }
 
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]