From patchwork Mon Aug 19 17:02:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 1853 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AA9C560C1E for ; Mon, 19 Aug 2019 19:02:58 +0200 (CEST) Received: from pendragon.bb.dnainternet.fi (dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi [IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2E90F510 for ; Mon, 19 Aug 2019 19:02:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1566234178; bh=6xsj+Kq80Z609TFHGYbAqyZ/9YH2OvUVN8AMA8ltOIQ=; h=From:To:Subject:Date:From; b=sAiEtdnNksZHN2or2N3juQAT2GNntL0LmsSdsTBP+tedfKHyOJuL7XDnEMu+7J0RX q7p3McURXdIsytnTxfWfotbOep0k029CWCJEF4oWh+n6ic4ig/Q9t//2p3r2YM/DFx uXYIO7bKmZ0re3BvEq8NQVG0fNoxK6zm1H5v/3ss= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 19 Aug 2019 20:02:48 +0300 Message-Id: <20190819170249.11177-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/2] libcamera: process: Properly ignore unused result with gcc X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Aug 2019 17:02:58 -0000 Casting the return value of a function to (void) doesn't ignore the unused result warning with gcc. Use a #pragma to fix this properly, to fix compilation with _FORTIFY_SOURCE. Fixes: df23ab95f3d7 ("libcamera: process: fix compilation on Chromium OS") Signed-off-by: Laurent Pinchart Reviewed-by: Paul Elder --- src/libcamera/process.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/libcamera/process.cpp b/src/libcamera/process.cpp index ab716a9cd57f..3b4d0f10da67 100644 --- a/src/libcamera/process.cpp +++ b/src/libcamera/process.cpp @@ -68,10 +68,15 @@ namespace { void sigact(int signal, siginfo_t *info, void *ucontext) { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" + /* + * We're in a signal handler so we can't log any message, and we need + * to continue anyway. + */ char data = 0; - /* We're in a signal handler so we can't log any message, - * and we need to continue anyway. */ - (void)write(ProcessManager::instance()->writePipe(), &data, sizeof(data)); + write(ProcessManager::instance()->writePipe(), &data, sizeof(data)); +#pragma GCC diagnostic pop const struct sigaction &oldsa = ProcessManager::instance()->oldsa(); if (oldsa.sa_flags & SA_SIGINFO) { From patchwork Mon Aug 19 17:02:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 1854 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E9D6C60C1E for ; Mon, 19 Aug 2019 19:02:58 +0200 (CEST) Received: from pendragon.bb.dnainternet.fi (dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi [IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8602DD45 for ; Mon, 19 Aug 2019 19:02:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1566234178; bh=f+TvTBf/xc7IhuURUSZsdh9zaNardu56Oqy+QP+vHE4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=JXSQKM7tOB2ZwWGKrOssGuRvXXQZhI8XZILjwI21DOBScrcP5jwDW9CQvtSoLI82p 1Te0aedZyMqnDv5BrrfIh4+psiT1kWuV2d7HadSxRzmifQI5PcJW1+qXRkI2dPOBBi HkJpRRmMk15r8yepi2cROiI1+6Vik2OirRnCh6rA= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 19 Aug 2019 20:02:49 +0300 Message-Id: <20190819170249.11177-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190819170249.11177-1-laurent.pinchart@ideasonboard.com> References: <20190819170249.11177-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/2] meson: Define _FORTIFY_SOURCE for optimised builds X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Aug 2019 17:02:59 -0000 _FORTIFY_SOURCE adds useful checks during compilation. The option is enabled by default by gcc on all non-optimised builds (as it requires -O1 or higher). Enable it explicitly for clang. Signed-off-by: Laurent Pinchart Acked-by: Kieran Bingham --- Changes since v1: - Condition _FORTIFY_SOURCE on the optimisation level, not the build type - Enable _FORTIFY_SOURCE on clang only as gcc does it by default This patch has been tested with gcc5, gcc6, gcc7, gcc8, gcc9, clang7 and clang8, with all the meson built types (plain, debug, debugoptimized, release and minsize). --- meson.build | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/meson.build b/meson.build index 13d0605f903c..c30287e262a5 100644 --- a/meson.build +++ b/meson.build @@ -38,12 +38,22 @@ common_arguments = [ c_arguments = common_arguments cpp_arguments = common_arguments -# Use libc++ by default if available instead of libstdc++ when compiling with -# clang. -if cc.get_id() == 'clang' and cc.find_library('libc++', required: false).found() - cpp_arguments += [ - '-stdlib=libc++', - ] +if cc.get_id() == 'clang' + # Turn _FORTIFY_SOURCE by default on optimised builds (as it requires -O1 + # or higher). This is needed on clang only as gcc enables it by default. + if get_option('optimization') != '0' + common_arguments += [ + '-D_FORTIFY_SOURCE=1', + ] + endif + + # Use libc++ by default if available instead of libstdc++ when compiling + # with clang. + if cc.find_library('libc++', required: false).found() + cpp_arguments += [ + '-stdlib=libc++', + ] + endif endif add_project_arguments(c_arguments, language : 'c')