[oe] [PATCH] rocksdb: Fix compile error for DEBUG_BUILD

Adrian Bunk bunk at stusta.de
Thu Jan 9 09:01:12 UTC 2020


On Thu, Jan 09, 2020 at 04:30:41PM +0800, Robert Yang wrote:
> On 1/9/20 4:14 PM, Adrian Bunk wrote:
> > On Thu, Jan 09, 2020 at 03:13:57PM +0800, Robert Yang wrote:
> > > 
> > > 
> > > On 1/8/20 5:27 PM, Adrian Bunk wrote:
> > > > On Wed, Jan 08, 2020 at 02:09:03PM +0800, Robert Yang wrote:
> > > > > Fixed do_compile error when DEBUG_BUILD = "1":
> > > > > db/write_thread.cc:183:14: error: 'state' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> > > > > ...
> > > > 
> > > > -Og warnings are not 100% reliable, and in general -Werror is
> > > > problematic for distributions.
> > > > 
> > > > Does building with -DFAIL_ON_WARNINGS=OFF fix this problem?
> > > 
> > > Yes, it works.
> > > 
> > > I think that the correct way to fix it is initialize it rather than ignore
> > > the error.
> > 
> > Is the error a bug in the code, or is it a bogus warning from the compiler?
> > 
> > When the warning happens only with -Og this is a known case of bogus
> > warnings in gcc, and the correct way to fix it is to ignore the bogus
> > warning.
> 
> I checked the code, it won't be used before uninitialized. But I still think
> that assign it an initial value is better than ignore the warnings, there
>  might be other vars really have this issue.

Silencing a warning can be worse than ignoring it.

The first question should be *why* a variable has this problem.

Often the problem is that something is wrong with the code that was 
supposed to set the variable, and just setting some default might
also result in misbehaving code - only the warning is no longer
visible hiding the problem.

>From a distribution point of view it does not make sense to fix random 
warnings in the old codebases of the few upstreams that default to 
-Werror while noone cares about warnings indicating actual problems
in all the other recipes - -Werror is a very useful tool for upstream
but mostly pain for distributions.

> // Robert

cu
Adrian


More information about the Openembedded-devel mailing list