gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master 5b1d580: Library (wcs.h): initialized variable


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 5b1d580: Library (wcs.h): initialized variable to avoid compiler warning
Date: Wed, 14 Apr 2021 11:05:07 -0400 (EDT)

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

    Library (wcs.h): initialized variable to avoid compiler warning
    
    Until now, the 'gal_options_read_wcslinearmatrix' function (which is in
    charge of reading the value to the new '--wcslinearmatrix' option) would
    produce an "may be used uninitialized" warning on some compilers for the
    'value' variable. In practice, if there is a problem in reading the user's
    value control would never reach that stage and the program will abort, but
    the compilers don't know about this higher-level logic.
    
    With this commit the variable 'value' has been initialized to the "invalid"
    identifier to avoid this compiler warning and help in having a clean
    compilation output.
    
    While doing this, I noticed that the invalid value for the linear
    transformation matrix ('GAL_WCS_LINEAR_MATRIX_INVALID') was wrongly named,
    so it has been corrected and added into the book. I also noticed that the
    comment indendation for the 'GAL_WCS_COORDSYS' set of macros didn't align
    with the others, so that has also been corrected for readability.
    
    This issue was reported by Carlos Morales Socorro.
---
 doc/gnuastro.texi  |  1 +
 lib/gnuastro/wcs.h | 18 +++++++++---------
 lib/options.c      |  2 +-
 3 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index f521541..935af48 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -25784,6 +25784,7 @@ In the equatorial and ecliptic coordinates, 
@code{B1950} stands for the Besselia
 
 @deffn  Macro GAL_WCS_LINEAR_MATRIX_PC
 @deffnx Macro GAL_WCS_LINEAR_MATRIX_CD
+@deffnx Macro GAL_WCS_LINEAR_MATRIX_INVALID
 Identifiers of the linear transformation matrix: either in the @code{PCi_j} or 
the @code{CDi_j} formalism.
 For more, see the description of @option{--wcslinearmatrix} in @ref{Input 
output options}.
 @end deffn
diff --git a/lib/gnuastro/wcs.h b/lib/gnuastro/wcs.h
index 1ae01b9..dfe430a 100644
--- a/lib/gnuastro/wcs.h
+++ b/lib/gnuastro/wcs.h
@@ -73,20 +73,20 @@ enum gal_wcs_distortions
 /* Macros to identify coordinate system for convesions. */
 enum gal_wcs_coordsys
 {
-  GAL_WCS_COORDSYS_INVALID,         /* Invalid (=0 by C standard).    */
-
-  GAL_WCS_COORDSYS_EQB1950,         /* Equatorial B1950 */
-  GAL_WCS_COORDSYS_EQJ2000,         /* Equatorial J2000 */
-  GAL_WCS_COORDSYS_ECB1950,         /* Ecliptic B1950 */
-  GAL_WCS_COORDSYS_ECJ2000,         /* Ecliptic J2000 */
-  GAL_WCS_COORDSYS_GALACTIC,        /* Galactic */
-  GAL_WCS_COORDSYS_SUPERGALACTIC,   /* Super-galactic */
+  GAL_WCS_COORDSYS_INVALID,           /* Invalid (=0 by C standard).    */
+
+  GAL_WCS_COORDSYS_EQB1950,           /* Equatorial B1950 */
+  GAL_WCS_COORDSYS_EQJ2000,           /* Equatorial J2000 */
+  GAL_WCS_COORDSYS_ECB1950,           /* Ecliptic B1950 */
+  GAL_WCS_COORDSYS_ECJ2000,           /* Ecliptic J2000 */
+  GAL_WCS_COORDSYS_GALACTIC,          /* Galactic */
+  GAL_WCS_COORDSYS_SUPERGALACTIC,     /* Super-galactic */
 };
 
 /* Macros to identify the type of distortion for conversions. */
 enum gal_wcs_linear_matrix
 {
-  GAL_WCS_MATRIX_INVALID,            /* Invalid (=0 by C standard).    */
+  GAL_WCS_LINEAR_MATRIX_INVALID,      /* Invalid (=0 by C standard).    */
 
   GAL_WCS_LINEAR_MATRIX_PC,
   GAL_WCS_LINEAR_MATRIX_CD,
diff --git a/lib/options.c b/lib/options.c
index 73f33e5..ba51988 100644
--- a/lib/options.c
+++ b/lib/options.c
@@ -482,7 +482,7 @@ gal_options_read_wcslinearmatrix(struct argp_option 
*option, char *arg,
                                  char *filename, size_t lineno, void *junk)
 {
   char *str;
-  uint8_t value;
+  uint8_t value=GAL_WCS_LINEAR_MATRIX_INVALID;
   if(lineno==-1)
     {
       /* The output must be an allocated string (will be 'free'd later). */



reply via email to

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