[libcamera-devel] [PATCH v2 1/2] libcamera: process: Properly ignore unused result with gcc

Paul Elder paul.elder at ideasonboard.com
Thu Aug 22 05:42:40 CEST 2019


On Mon, Aug 19, 2019 at 08:02:48PM +0300, Laurent Pinchart wrote:
> 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 <laurent.pinchart at ideasonboard.com>

Looks good to me.

Reviewed-by: Paul Elder <paul.elder at ideasonboard.com>

> ---
>  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) {
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel at lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel


More information about the libcamera-devel mailing list