Skip to contentSkip to conversation

ot-br-posix: Fix build with gcc

PATCH In review Khem Raj 2 participants 2 messages Apr 21, 2022

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/1 ot-br-posix: Fix build with gcc

Cc Stefan Schmidt <[email protected]>
---
 ...sable-nonnull-compare-warning-on-gcc.patch | 40 +++++++++++++++++++
 .../openthread/ot-br-posix_git.bb             |  1 +
 2 files changed, 41 insertions(+)
 create mode 100644 meta-networking/recipes-connectivity/openthread/ot-br-posix/0001-cmake-Disable-nonnull-compare-warning-on-gcc.patch
meta-networking/recipes-connectivity/openthread/ot-br-posix/0001-cmake-Disable-nonnull-compare-warning-on-gcc.patch new file +40 -0
new file mode 100644
index 0000000000..f0bb392a9f
@@ -0,0 +1,40 @@
+From aa706d714294b83db696de2beca9a722a512796f Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Tue, 19 Apr 2022 14:04:40 -0700
+Subject: [PATCH] cmake: Disable nonnull-compare warning on gcc
+
+GCC finds a legit warning which clang does not on code like this
+
+class Message;
+void SendResponse(Message & aMessage)
+{
+    if ((&aMessage) != nullptr) { return; }
+}
+
+Perhaps it should be fixed upstream but for now disable treating this
+warning as error when using gcc
+
+Upstream-Status: Pending
+Signed-off-by: Khem Raj <[email protected]>
+---
+ CMakeLists.txt | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 59a567e729..3134740ff6 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -57,6 +57,10 @@ endif()
+ 
+ set(CMAKE_CXX_EXTENSIONS OFF)
+ 
++if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
++	add_compile_options(-Wno-error=nonnull-compare)
++endif()
++
+ if (OTBR_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
+     message(STATUS "Coverage: ON")
+     target_compile_options(otbr-config INTERFACE -g -O0 --coverage)
+-- 
+2.36.0
+
meta-networking/recipes-connectivity/openthread/ot-br-posix_git.bb +1 -0
index c1af388627..a16b77849e 100644
@@ -16,6 +16,7 @@ PV = "0.3.0+git${SRCPV}"
 
 SRC_URI = "gitsm://github.com/openthread/ot-br-posix.git;protocol=https;branch=main \
            file://0001-otbr-agent.service.in-remove-pre-exec-hook-for-mdns-.patch \
+           file://0001-cmake-Disable-nonnull-compare-warning-on-gcc.patch \
            "
 
 S = "${WORKDIR}/git"
Signature · 1 line
2.36.0
#1 lore raw

Hello Khem.

Quoted 60 lines · Khem Raj
Cc Stefan Schmidt <[email protected]>
---
  ...sable-nonnull-compare-warning-on-gcc.patch | 40 +++++++++++++++++++
  .../openthread/ot-br-posix_git.bb             |  1 +
  2 files changed, 41 insertions(+)

create mode 100644 meta-networking/recipes-connectivity/openthread/ot-br-posix/0001-cmake-Disable-nonnull-compare-warning-on-gcc.patch

meta-networking/recipes-connectivity/openthread/ot-br-posix/0001-cmake-Disable-nonnull-compare-warning-on-gcc.patch new file +40 -0
new file mode 100644
index 0000000000..f0bb392a9f
@@ -0,0 +1,40 @@
+From aa706d714294b83db696de2beca9a722a512796f Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Tue, 19 Apr 2022 14:04:40 -0700
+Subject: [PATCH] cmake: Disable nonnull-compare warning on gcc
+
+GCC finds a legit warning which clang does not on code like this
+
+class Message;
+void SendResponse(Message & aMessage)
+{
+    if ((&aMessage) != nullptr) { return; }
+}
+
+Perhaps it should be fixed upstream but for now disable treating this
+warning as error when using gcc
+
+Upstream-Status: Pending
+Signed-off-by: Khem Raj <[email protected]>
+---
+ CMakeLists.txt | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 59a567e729..3134740ff6 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -57,6 +57,10 @@ endif()
+
+ set(CMAKE_CXX_EXTENSIONS OFF)
+
++if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
++	add_compile_options(-Wno-error=nonnull-compare)
++endif()
++
+ if (OTBR_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
+     message(STATUS "Coverage: ON")
+     target_compile_options(otbr-config INTERFACE -g -O0 --coverage)
+--
+2.36.0
+
meta-networking/recipes-connectivity/openthread/ot-br-posix_git.bb +0 -0
index c1af388627..a16b77849e 100644

meta-networking/recipes-connectivity/openthread/ot-br-posix_git.bb PV = "0.3.0+git${SRCPV}" · line 22

Quoted 7 lines
meta-networking/recipes-connectivity/openthread/ot-br-posix_git.bb +1 -0
@@ -16,6 +16,7 @@ PV = "0.3.0+git${SRCPV}"
 
  SRC_URI = "gitsm://github.com/openthread/ot-br-posix.git;protocol=https;branch=main \
             file://0001-otbr-agent.service.in-remove-pre-exec-hook-for-mdns-.patch \
+           file://0001-cmake-Disable-nonnull-compare-warning-on-gcc.patch \
             "
 
  S = "${WORKDIR}/git"

LGTM

regards
Stefan Schmidt