gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master db2fe45: Building: initialized some variables


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master db2fe45: Building: initialized some variables to avoid compiler warnings
Date: Sat, 17 Apr 2021 21:56:29 -0400 (EDT)

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

    Building: initialized some variables to avoid compiler warnings
    
    Until now, some of the variables in Gnuastro had the potential to trigger
    "may be used un-initalized" warnings. I just noticed them recently on my
    own computer! Looking into the code, these could never cause a problem (the
    program would abort with an informative message if they weren't set), but
    well, this is too high-level for compiler, so it prints these warnings.
    
    With this commit those variables (all were pointers) are initalized to
    'NULL' and the warnings have been silenced.
---
 bin/fits/keywords.c | 2 +-
 lib/wcs.c           | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/bin/fits/keywords.c b/bin/fits/keywords.c
index 4a1d483..a869966 100644
--- a/bin/fits/keywords.c
+++ b/bin/fits/keywords.c
@@ -444,7 +444,7 @@ keywords_wcs_convert(struct fitsparams *p)
   size_t ndim, *insize;
   char *suffix, *output;
   gal_data_t *data=NULL;
-  struct wcsprm *inwcs, *outwcs;
+  struct wcsprm *inwcs, *outwcs=NULL;
   size_t *dsize, defaultsize[2]={2000,2000};
 
   /* If the extension has any data, read it, otherwise just make an empty
diff --git a/lib/wcs.c b/lib/wcs.c
index 0b2b33a..83f435f 100644
--- a/lib/wcs.c
+++ b/lib/wcs.c
@@ -959,9 +959,8 @@ gal_wcs_coordsys_convert(struct wcsprm *wcs, int 
outcoordsys)
   char *alt=NULL;                 /* Only concerned with primary wcs. */
   double equinox=0.0f;            /* To preserve current value.       */
   struct wcsprm *out=NULL;
-  char *clng, *clat, *radesys;
   double lng2p1=NAN, lat2p1=NAN, lng1p2=NAN;
-
+  char *clng=NULL, *clat=NULL, *radesys=NULL;
 
   /* Just incase the input is a NULL pointer. */
   if(wcs==NULL) return NULL;



reply via email to

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