[{"id":28142,"web_url":"https://patchwork.libcamera.org/comment/28142/","msgid":"<20231123075138.GC15697@pendragon.ideasonboard.com>","date":"2023-11-23T07:51:38","subject":"Re: [libcamera-devel] [PATCH] gstreamer: Fix unused variable error","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jaslo,\n\nThank you for sending a quick fix, much appreciated.\n\nOn Wed, Nov 22, 2023 at 08:15:47PM +0100, Jaslo Ziska via libcamera-devel wrote:\n> Fix unused variable error introduced in fd84180d.\n\nMissing Signed-off-by: tag. A Fixes: tag is also needed. The commit\nmessage could read\n\n--------\nCommit fd84180d7a09 (\"gstreamer: Implement element EOS handling\") has\nintroduced a compilation warning with clang:\n\n../../src/gstreamer/gstlibcamerasrc.cpp:768:23: error: unused variable 'oldEvent' [-Werror,-Wunused-variable]\n                g_autoptr(GstEvent) oldEvent = self->pending_eos.exchange(event);\n                                    ^\n\nThis seems to be a false positive, but nonetheless breaks the build. Fix\nit.\n\nFixes: fd84180d7a09 (\"gstreamer: Implement element EOS handling\")\nSigned-off-by: Jaslo Ziska <jaslo@ziska.de>\n--------\n\n> ---\n> This patch fixes the unused variable error raised by Laurent.\n> \n>  src/gstreamer/gstlibcamerasrc.cpp | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n> \n> diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp\n> index 767017db..b0eb2dd7 100644\n> --- a/src/gstreamer/gstlibcamerasrc.cpp\n> +++ b/src/gstreamer/gstlibcamerasrc.cpp\n> @@ -765,7 +765,7 @@ gst_libcamera_src_send_event(GstElement *element, GstEvent *event)\n> \n>  \tswitch (GST_EVENT_TYPE(event)) {\n>  \tcase GST_EVENT_EOS: {\n> -\t\tg_autoptr(GstEvent) oldEvent = self->pending_eos.exchange(event);\n> +\t\t[[maybe_unused]] g_autoptr(GstEvent) oldEvent = self->pending_eos.exchange(event);\n\nI prefer Nicolas' proposal:\n\n\t\tGstEvent *oldEvent = self->pending_eos.exchange(event);\n\t\tgst_clear_event(&oldEvent);\n\nThis is more explicit, I'm slightly worried that the [[maybe_unused]]\nmay lead to an incorrect optimization with clang. If clang believes that\nthe variable is unused, it may just omit it and fail to handle the\ncleanup.\n\nI'll send a v2 of this (keeping your authorship of course). Please let\nme know if you're fine with the changes by reviewing v2, and I'll push\nthe fix.\n\nI also apologize for the long mail threads and the conflicted revert\nthat was posted, there's been some miscommunication.\n\n> \n>  \t\tret = TRUE;\n>  \t\tbreak;","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id DAD79BDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 23 Nov 2023 07:51:33 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2A71B629BC;\n\tThu, 23 Nov 2023 08:51:33 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id F0F3E61DA6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 Nov 2023 08:51:31 +0100 (CET)","from pendragon.ideasonboard.com (213-243-189-158.bb.dnainternet.fi\n\t[213.243.189.158])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 24D9125A;\n\tThu, 23 Nov 2023 08:51:00 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1700725893;\n\tbh=3jOh1vW1+0NRBruYxxkKCjdVydMO1+ivtLbC80xnPt0=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=L1GNn+ieeJXP7Sqgbfihv8uLIGFRD3Y9g4NMQ2pKoFcxJCy+EhsRwWHzrB9AAiGOu\n\tyXn433g/TkMbVJ4nhq6tYTKbe+cxKI0a6SA8SyJXnz3ypQ0xKjEKOvbuWLzj6plqyb\n\t9HT6BjOZ9v/uqBBhXyeirwCjAkRQ/eC0wZ/iNnfSTltrfYXcxGv2oN1mvt0AHBmysw\n\t04PujQ4CfKE9IlR7sd0R2cKkZSFaQcNkQlsQP0uCIV3GBDz6vxfcuiD3icRU7EDFnT\n\tCMRU46NwGUtBJFjQk2oJE7nrAFfaL7sDyUR8ZRN4aBSqwb3gPZRBOSMJ7EhFwap6d6\n\tIxxwBUCcRMqvw==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1700725860;\n\tbh=3jOh1vW1+0NRBruYxxkKCjdVydMO1+ivtLbC80xnPt0=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=ssFlbOmgGYKCQm12PL4cRyuwVWHRE5HQh2skJF/cdut7X7DRf4BbOlcAy6oJLPgmz\n\tfhc1ugNU8mnVAtpPEODSxP2tR35Bsaw2tpF6ukMYy1MNIq19KO3pyMGZawxkEoVI5+\n\tIYrp24FdK5TIzNxJOhDqXG1201pgTdcQyIJqSGwk="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"ssFlbOmg\"; dkim-atps=neutral","Date":"Thu, 23 Nov 2023 09:51:38 +0200","To":"Jaslo Ziska <jaslo@ziska.de>","Message-ID":"<20231123075138.GC15697@pendragon.ideasonboard.com>","References":"<20231122191753.42997-1-jaslo@ziska.de>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20231122191753.42997-1-jaslo@ziska.de>","Subject":"Re: [libcamera-devel] [PATCH] gstreamer: Fix unused variable error","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]