[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master ecc1cfc1: Library (dimension.h): variable init
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master ecc1cfc1: Library (dimension.h): variable initialization for compiler warnings |
Date: |
Thu, 15 Sep 2022 22:50:51 -0400 (EDT) |
branch: master
commit ecc1cfc1ef1a4b1a62146e5fa9a74fd26194668a
Author: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Library (dimension.h): variable initialization for compiler warnings
Until now, the newly added sort-based collapsing functions in the library
would cause compilation warnings about un-initialized values (which were
logically no problem, but the compiler can't know). This also happend in
the function of 'bin/arithmetic/arithmetic.c' that called those library
functions.
With this commit, the problematic variables are initialized with basic
values that will cause a crash when not set later (and help find/fix the
bug in the unexpected case that it happens!).
---
bin/arithmetic/arithmetic.c | 2 +-
lib/dimension.c | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/bin/arithmetic/arithmetic.c b/bin/arithmetic/arithmetic.c
index 84f622aa..0ddafdf5 100644
--- a/bin/arithmetic/arithmetic.c
+++ b/bin/arithmetic/arithmetic.c
@@ -929,7 +929,7 @@ static void
arithmetic_collapse(struct arithmeticparams *p, char *token, int operator)
{
long dim;
- float p1, p2;
+ float p1=NAN, p2=NAN;
int qmm=p->cp.quietmmap;
gal_data_t *dimension=NULL, *input=NULL;
size_t nt=p->cp.numthreads, mms=p->cp.minmapsize;
diff --git a/lib/dimension.c b/lib/dimension.c
index 1e03537b..ad7d8a40 100644
--- a/lib/dimension.c
+++ b/lib/dimension.c
@@ -903,9 +903,9 @@ dimension_collapse_sortbased_worker(void *in_prm)
gal_data_t *in=p->in;
/* Subsequent definitions. */
- size_t a, b, c, bc, sind;
- gal_data_t *work, *stat;
- size_t i, j, f, index, c_dim=p->c_dim, wdsize=in->dsize[c_dim];
+ gal_data_t *work, *stat=NULL;
+ size_t a, b, c, sind=GAL_BLANK_SIZE_T;
+ size_t i, j, index, c_dim=p->c_dim, wdsize=in->dsize[c_dim];
/* Allocate the dataset that will be sorted. */
work=gal_data_alloc(NULL, in->type, 1, &wdsize, NULL, 0,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnuastro-commits] master ecc1cfc1: Library (dimension.h): variable initialization for compiler warnings,
Mohammad Akhlaghi <=