Re: [PATCH 3/4] ref-filter: merge get_obj and get_object

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

 



> This causes GCC to complain thusly:
> 
> 
> ```
> 2018-07-10T04:59:38.6368270Z ref-filter.c:1477:6: error: variable 'eaten' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
> 2018-07-10T04:59:38.6468620Z         if (oi->info.contentp) {
> 2018-07-10T04:59:38.6568710Z             ^~~~~~~~~~~~~~~~~
> 2018-07-10T04:59:38.6669970Z ref-filter.c:1489:7: note: uninitialized use occurs here
> 2018-07-10T04:59:38.6774240Z         if (!eaten)
> 2018-07-10T04:59:38.6874860Z              ^~~~~
> 2018-07-10T04:59:38.6976740Z ref-filter.c:1477:2: note: remove the 'if' if its condition is always true
> 2018-07-10T04:59:38.7072330Z         if (oi->info.contentp) {
> 2018-07-10T04:59:38.7172760Z         ^~~~~~~~~~~~~~~~~~~~~~~
> 2018-07-10T04:59:38.7274040Z ref-filter.c:1466:11: note: initialize the variable 'eaten' to silence this warning
> 2018-07-10T04:59:38.7374670Z         int eaten;
> 2018-07-10T04:59:38.7474870Z                  ^
> 2018-07-10T04:59:38.7575690Z                   = 0
> ```
> 
> (See
> https://mseng.visualstudio.com/VSOnline/_build/results?buildId=6640204&view=logs
> for details)
> 
> I think that GCC is correct, and at the same time, it isn't. Because it
> does not matter whether `eaten` is uninitialized here: 

It's undefined behaviour; 'eaten' is int, and an int may have padding
bits and trap representations.

> if it is, then
> `buf` is NULL, and the `free(buf);` call does nothing in particular.




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux