[{"id":18991,"web_url":"https://patchwork.libcamera.org/comment/18991/","msgid":"<YSD05F7JxzsFsAfs@pendragon.ideasonboard.com>","date":"2021-08-21T12:43:16","subject":"Re: [libcamera-devel] [PATCH v1] test: gstreamer: Clean up memory\n\tmanagement","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Vedant,\n\nThank you for the patch.\n\nOn Sat, Aug 21, 2021 at 02:09:57PM +0530, Vedant Paranjape wrote:\n> This patch fixes memory management, i.e., replaced bare gpointers with\n> g_autoptr or g_autofree according to use case.\n\nI'd say \"simplifies\" instead of \"fixes\" as it's not broken.\n\ns/replaced/by replacing/\n\n> Signed-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com>\n> ---\n>  test/gstreamer/gstreamer_single_stream_test.cpp | 12 ++++--------\n>  1 file changed, 4 insertions(+), 8 deletions(-)\n> \n> diff --git a/test/gstreamer/gstreamer_single_stream_test.cpp b/test/gstreamer/gstreamer_single_stream_test.cpp\n> index a805fb8a..349dcfa4 100644\n> --- a/test/gstreamer/gstreamer_single_stream_test.cpp\n> +++ b/test/gstreamer/gstreamer_single_stream_test.cpp\n> @@ -55,12 +55,10 @@ protected:\n>  \t\tsetenv(\"ASAN_OPTIONS\", \"verify_asan_link_order=0\", 1);\n>  \n>  \t\t/* Initialize GStreamer */\n> -\t\tGError *errInit = nullptr;\n> +\t\tg_autoptr(GError) errInit = NULL;\n>  \t\tif (!gst_init_check(nullptr, nullptr, &errInit)) {\n>  \t\t\tg_printerr(\"Could not initialize GStreamer: %s\\n\",\n>  \t\t\t\t   errInit ? errInit->message : \"unknown error\");\n> -\t\t\tif (errInit)\n> -\t\t\t\tg_error_free(errInit);\n>  \n>  \t\t\treturn TestFail;\n>  \t\t}\n> @@ -138,7 +136,7 @@ protected:\n>  \t\t/* Wait until error or EOS or timeout after 2 seconds */\n>  \t\tconstexpr GstMessageType msgType =\n>  \t\t\tstatic_cast<GstMessageType>(GST_MESSAGE_ERROR | GST_MESSAGE_EOS);\n> -\t\tconstexpr GstClockTime timeout = 2000000000;\n> +\t\tconstexpr GstClockTime timeout = 2 * GST_SECOND;\n\nThis isn't about memory management. No need to split it to a separate\npatch, you can just mention it in the commit message with a \"While at\nit, ...\".\n\nWith this,\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n>  \n>  \t\tg_autoptr(GstBus) bus = gst_element_get_bus(pipeline_);\n>  \t\tg_autoptr(GstMessage) msg = gst_bus_timed_pop_filtered(bus, timeout, msgType);\n> @@ -167,16 +165,14 @@ protected:\n>  private:\n>  \tvoid gstreamer_print_error(GstMessage *msg)\n>  \t{\n> -\t\tGError *err;\n> -\t\tgchar *debug_info;\n> +\t\tg_autoptr(GError) err = NULL;\n> +\t\tg_autofree gchar *debug_info = NULL;\n>  \n>  \t\tgst_message_parse_error(msg, &err, &debug_info);\n>  \t\tg_printerr(\"Error received from element %s: %s\\n\",\n>  \t\t\t   GST_OBJECT_NAME(msg->src), err->message);\n>  \t\tg_printerr(\"Debugging information: %s\\n\",\n>  \t\t\t   debug_info ? debug_info : \"none\");\n> -\t\tg_clear_error(&err);\n> -\t\tg_free(debug_info);\n>  \t}\n>  \n>  \tGstElement *pipeline_;","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 7C36FBD87D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 21 Aug 2021 12:43:28 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B49C768895;\n\tSat, 21 Aug 2021 14:43:27 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7FE3A6025E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 21 Aug 2021 14:43:25 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E2C438F;\n\tSat, 21 Aug 2021 14:43:24 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"ES4x5Vf1\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1629549805;\n\tbh=LkI+uaVoik/KuXqbQxxhqT1e3EzZKU2yiHOGnYjtveg=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=ES4x5Vf1HY+P80cGHXe8PHp2rR14P7Qr8gQWrx5es1iqDJNNFtxV5zgjmFahXqNTW\n\tmHqc7ZDl1umJ1rPkiV0jDAQHKGILGbEs3mgfi2bPY4nac2pP8O3TUu0h9XxJLwsQHI\n\taswpBqLfP4Vt5W3FIr/SrpUeGNqwf+MEgltu+zAM=","Date":"Sat, 21 Aug 2021 15:43:16 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Vedant Paranjape <vedantparanjape160201@gmail.com>","Message-ID":"<YSD05F7JxzsFsAfs@pendragon.ideasonboard.com>","References":"<20210821083957.2989120-1-vedantparanjape160201@gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20210821083957.2989120-1-vedantparanjape160201@gmail.com>","Subject":"Re: [libcamera-devel] [PATCH v1] test: gstreamer: Clean up memory\n\tmanagement","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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]