Re: [PATCH] evaluate.c: fix a gcc 'may be used uninitialized' warning

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

 



On Sun, Jun 21, 2020 at 08:34:31PM +0100, Ramsay Jones wrote:
> 
> Signed-off-by: Ramsay Jones <ramsay@xxxxxxxxxxxxxxxxxxxx>
> ---
> 
> Hi Luc,
> 
> Thanks for v0.6.2! :-D
> 
> However, I am seeing a gcc compiler warning:
> 
>     CC      evaluate.o
>   evaluate.c: In function ‘evaluate_generic_selection’:
>   evaluate.c:3310:38: warning: ‘base’ may be used uninitialized in this function [-Wmaybe-uninitialized]
>      if (base->type == SYM_ARRAY && base->array_size) {
>                                     ~~~~^~~~~~~~~~~~
> 
> This patch is just an FYI/quick-fix for this warning. The patch
> I wanted to send, moved the declaration of the base symbol into
> a new block at the 'if (stype->type == SYM_NODE)' conditional,
> which would now include the (indented) SYM_ARRAY conditional
> block. This, of course, meant that the SYM_ARRAY conditional was
> indented too far to the right ... ;-)
> 
> [perhaps this argues for that code to be refactored into a function]

I just saw this warning too. Of course, *after* the release is made.
 
What I had in made while writing the code was:
		base = stype;
		if (stype->type == SYM_NODE)
			base = stype->ctype.base_type;

Your patch here below will work correctly but is not semantically
correct if stype->type != SYM_NODE. Fortunately, it's guaranteed
to always be a SYM_NODE (typename() is so). So, I'll probably
commit the following:

-               if (stype->type == SYM_NODE)
-                       base = stype->ctype.base_type;
-
+               base = stype->ctype.base_type;

Thanks for the bug report and for giving a try to the release.
-- Luc



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux