Hi,
Same case here.
matrix/iupmatrix.c: In function ‘iMatrixComputeNaturalSizeMethod’:
matrix/iupmatrix.c:1994:19: warning: ‘full_height’ may be used uninitialized in 
this function [-Wmaybe-uninitialized]
       full_height += sb_h;
                   ^~
matrix/iupmatrix.c:1991:13: warning: ‘full_width’ may be used uninitialized in 
this function [-Wmaybe-uninitialized]
     else if (*w == full_width) /* all columns can be visible, */
             
The vars are initialized in function int iMatrixGetNaturalWidth(Ihandle* ih, 
int *full_width)
But var * full_width set value is protected by  if (ih->data->limit_expand)
So if (ih->data->limit_expand) fail, full_witdth will be trash.

Best.
Ranier
________________________________________
De: Antonio Scuri <[email protected]>
Enviado: domingo, 10 de dezembro de 2017 18:22
Para: IUP discussion list.
Assunto: Re: [Iup-users]        Silence gcc warning: ‘vert_alignment’ may be 
used uninitialized in this function

  No, I think gcc was smarter than that. There are several situations in the 
code that the declaration is:

int var;
init_var(&var);

  Add gcc does not complains. I think in that case it actually parse the 
iFlatTabsGetAlignment function and reported the error.

Best,
Scuri


2017-12-10 16:16 GMT-02:00 Ranier VF 
<[email protected]<mailto:[email protected]>>:
Hi,
It's always a good idea, initialize vars like horiz_alignment and 
horiz_alignment, with default value.
Because, function like iFlatTabsGetAlignment can fail in set value and these 
vars can be trash when
function returns.

That's the reason what compiler emits this warning.

Best.

Ranier
________________________________________
De: Antonio Scuri <[email protected]<mailto:[email protected]>>
Enviado: domingo, 10 de dezembro de 2017 17:47
Para: IUP discussion list.
Assunto: Re: [Iup-users]        Silence gcc warning: ‘vert_alignment’ may be 
used uninitialized in this function

  Those variables are initialized 20 lines bellow in:

  iFlatTabsGetAlignment(alignment, &horiz_alignment, &vert_alignment);

  And they are not used before that. But iFlatTabsGetAlignment should 
initialize even in "alignment" is NULL. That was missing. Actually I did a full 
check on ALIGMENT attributes on all controls that use horizontalxvertical 
alignment options and found some minor errors too. Fixed and committed to SVN.

Best,
Scuri


2017-12-10 11:23 GMT-02:00 Ranier VF 
<[email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>>>:
Hi,
initialize vars to silence gcc warning

--- iup/iup/src/iup_flattabs.c  2017-09-04 18:44:26.000000000 -0300
+++ iup_dev/iup/src/iup_flattabs.c      2017-12-10 11:19:01.570274940 -0200
@@ -443,7 +443,7 @@
   int title_height = iFlatTabsGetTitleHeight(ih, &title_width, 1);
   int fixedwidth = iupAttribGetInt(ih, "FIXEDWIDTH");
   Ihandle* child;
-  int pos, horiz_alignment, vert_alignment, tab_x = 0;
+  int pos, horiz_alignment = 0, vert_alignment = 0, tab_x = 0;
   unsigned char line_r = 0, line_g = 0, line_b = 0;
   int show_close = iupAttribGetBoolean(ih, "SHOWCLOSE");
   int tab_highlighted = iupAttribGetInt(ih, "_IUPFTABS_HIGHLIGHTED");

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Iup-users mailing list
[email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>>
https://lists.sourceforge.net/lists/listinfo/iup-users


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Iup-users mailing list
[email protected]<mailto:[email protected]>
https://lists.sourceforge.net/lists/listinfo/iup-users


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Iup-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/iup-users

Reply via email to