All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rocksdb: Fix compile error for DEBUG_BUILD
@ 2020-01-08  6:09 Robert Yang
  2020-01-08  9:27 ` Adrian Bunk
  0 siblings, 1 reply; 7+ messages in thread
From: Robert Yang @ 2020-01-08  6:09 UTC (permalink / raw)
  To: openembedded-devel

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]

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
 .../0001-db-write_thread.cc-Initialize-state.patch | 31 ++++++++++++++++++++++
 meta-oe/recipes-dbs/rocksdb/rocksdb_git.bb         |  1 +
 2 files changed, 32 insertions(+)
 create mode 100644 meta-oe/recipes-dbs/rocksdb/files/0001-db-write_thread.cc-Initialize-state.patch

diff --git a/meta-oe/recipes-dbs/rocksdb/files/0001-db-write_thread.cc-Initialize-state.patch b/meta-oe/recipes-dbs/rocksdb/files/0001-db-write_thread.cc-Initialize-state.patch
new file mode 100644
index 0000000..97ddbce
--- /dev/null
+++ b/meta-oe/recipes-dbs/rocksdb/files/0001-db-write_thread.cc-Initialize-state.patch
@@ -0,0 +1,31 @@
+From 49dcd22dcf1aae5995c42eac0fda68516fc1cd43 Mon Sep 17 00:00:00 2001
+From: Robert Yang <liezhi.yang@windriver.com>
+Date: Wed, 19 Jun 2019 17:57:24 +0800
+Subject: [PATCH] db/write_thread.cc: Initialize state
+
+Fixed an error when compiled without -O2:
+db/write_thread.cc:183:14: error: 'state' may be used uninitialized in this function [-Werror=maybe-uninitialized]
+
+Upstream-Status: Pending
+
+Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
+---
+ db/write_thread.cc | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/db/write_thread.cc b/db/write_thread.cc
+index 835992c..6f99a11 100644
+--- a/db/write_thread.cc
++++ b/db/write_thread.cc
+@@ -59,7 +59,7 @@ uint8_t WriteThread::BlockingAwaitState(Writer* w, uint8_t goal_mask) {
+ 
+ uint8_t WriteThread::AwaitState(Writer* w, uint8_t goal_mask,
+                                 AdaptationContext* ctx) {
+-  uint8_t state;
++  uint8_t state = 0;
+ 
+   // 1. Busy loop using "pause" for 1 micro sec
+   // 2. Else SOMETIMES busy loop using "yield" for 100 micro sec (default)
+-- 
+2.7.4
+
diff --git a/meta-oe/recipes-dbs/rocksdb/rocksdb_git.bb b/meta-oe/recipes-dbs/rocksdb/rocksdb_git.bb
index 68c6bc2..44a451c 100644
--- a/meta-oe/recipes-dbs/rocksdb/rocksdb_git.bb
+++ b/meta-oe/recipes-dbs/rocksdb/rocksdb_git.bb
@@ -12,6 +12,7 @@ PV = "6.5.2"
 
 SRC_URI = "git://github.com/facebook/${BPN}.git;branch=${SRCBRANCH} \
            file://0001-Fix-build-breakage-from-lock_guard-error-6161.patch \
+           file://0001-db-write_thread.cc-Initialize-state.patch \
           "
 
 S = "${WORKDIR}/git"
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] rocksdb: Fix compile error for DEBUG_BUILD
  2020-01-08  6:09 [PATCH] rocksdb: Fix compile error for DEBUG_BUILD Robert Yang
@ 2020-01-08  9:27 ` Adrian Bunk
  2020-01-09  7:13   ` Robert Yang
  0 siblings, 1 reply; 7+ messages in thread
From: Adrian Bunk @ 2020-01-08  9:27 UTC (permalink / raw)
  To: Robert Yang; +Cc: openembedded-devel

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?

cu
Adrian


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] rocksdb: Fix compile error for DEBUG_BUILD
  2020-01-08  9:27 ` Adrian Bunk
@ 2020-01-09  7:13   ` Robert Yang
  2020-01-09  7:23     ` Khem Raj
  2020-01-09  8:14     ` Adrian Bunk
  0 siblings, 2 replies; 7+ messages in thread
From: Robert Yang @ 2020-01-09  7:13 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: openembedded-devel



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.

// Robert

> 
> cu
> Adrian
> 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] rocksdb: Fix compile error for DEBUG_BUILD
  2020-01-09  7:13   ` Robert Yang
@ 2020-01-09  7:23     ` Khem Raj
  2020-01-09  8:14     ` Adrian Bunk
  1 sibling, 0 replies; 7+ messages in thread
From: Khem Raj @ 2020-01-09  7:23 UTC (permalink / raw)
  To: Robert Yang; +Cc: openembeded-devel, Adrian Bunk

On Wed, Jan 8, 2020 at 11:15 PM Robert Yang <liezhi.yang@windriver.com> 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?
>

I think this should be used when we have warnings which we have no
easy control over
and no good fixes.

> Yes, it works.
>
> I think that the correct way to fix it is initialize it rather than ignore the
> error.

Thats fine, Also submit this patch to rocksdb upstream as well.

>
> // Robert
>
> >
> > cu
> > Adrian
> >
> --
> _______________________________________________
> Openembedded-devel mailing list
> Openembedded-devel@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-devel


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] rocksdb: Fix compile error for DEBUG_BUILD
  2020-01-09  7:13   ` Robert Yang
  2020-01-09  7:23     ` Khem Raj
@ 2020-01-09  8:14     ` Adrian Bunk
  2020-01-09  8:30       ` Robert Yang
  1 sibling, 1 reply; 7+ messages in thread
From: Adrian Bunk @ 2020-01-09  8:14 UTC (permalink / raw)
  To: Robert Yang; +Cc: openembedded-devel

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.

> // Robert

cu
Adrian


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] rocksdb: Fix compile error for DEBUG_BUILD
  2020-01-09  8:14     ` Adrian Bunk
@ 2020-01-09  8:30       ` Robert Yang
  2020-01-09  9:01         ` Adrian Bunk
  0 siblings, 1 reply; 7+ messages in thread
From: Robert Yang @ 2020-01-09  8:30 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: openembedded-devel



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.

// Robert

> 
>> // Robert
> 
> cu
> Adrian
> 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] rocksdb: Fix compile error for DEBUG_BUILD
  2020-01-09  8:30       ` Robert Yang
@ 2020-01-09  9:01         ` Adrian Bunk
  0 siblings, 0 replies; 7+ messages in thread
From: Adrian Bunk @ 2020-01-09  9:01 UTC (permalink / raw)
  To: Robert Yang; +Cc: openembedded-devel

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-01-09  9:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-08  6:09 [PATCH] rocksdb: Fix compile error for DEBUG_BUILD Robert Yang
2020-01-08  9:27 ` Adrian Bunk
2020-01-09  7:13   ` Robert Yang
2020-01-09  7:23     ` Khem Raj
2020-01-09  8:14     ` Adrian Bunk
2020-01-09  8:30       ` Robert Yang
2020-01-09  9:01         ` Adrian Bunk

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.