From patchwork Sat Aug 21 13:12:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vedant Paranjape X-Patchwork-Id: 13426 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 56766BD87C for ; Sat, 21 Aug 2021 13:12:27 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 87FEA68895; Sat, 21 Aug 2021 15:12:26 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="HHBCw+m0"; dkim-atps=neutral Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E6F996025E for ; Sat, 21 Aug 2021 15:12:24 +0200 (CEST) Received: by mail-pg1-x532.google.com with SMTP id r2so12012823pgl.10 for ; Sat, 21 Aug 2021 06:12:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=OeSKpN3Jcmy009D4E90Pwrj579TdeaQ4c/VCA+D3rp4=; b=HHBCw+m0oIpE4FiBIXf9lMvKlcv8A4PxnNMCLnPaPCxwKtmDuvA9Y136ClNOwYNhSC X7p8Xyv/pntihTYpawQ8WynRcZCbDkxTvQVfcQak50tuLOeNWQo8ylFTi38cpHKLyj8X /9oWTLPrMtc95tJjz+/+WSLbskYX5vn4Fv0jVSCl0w1CH1wZZI6WjI2SScqy9BlEmk0M P7jZr+uFCNXS9ZFoPLWSimN86rP7JWMX7hQZeZ2CAW4Hm5/50FeqwRd7bJ6A22AjHNHU JpQ3BHXxYkYxAoMxH4Yz0P+fQKSZ9HTzyqdmX/a6EK8qlGlFYOAKM3Y8kyLMQvIk2FGg TAkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=OeSKpN3Jcmy009D4E90Pwrj579TdeaQ4c/VCA+D3rp4=; b=k3JfMviY33StNWZVxR4WR72wrsBwSi9K+tCLw4ACfrxQIFTAZ7w2uPXjnHDsq1i9V3 6ekiA8kE5x+kLfjovvv96tNr1jLiqX6zV7xubQKCEZju61D5cUns8GxW2mdwMkf0UiqW OrBNNcHad8ow6gXDlEs9nyEyrTMmhKmrIXyAQrZ3iKDoNWAbn7toyqrq8LF5e3B9hx+u tsyaFfixJd/CD9OR3KRqy207Way8xulkD1Oz7EqxMKB71tO3pZPlReKfoslAJrFbTV9s GbJzvJu7bU289PHwAAwz3wOOKWEZPQ5Ftrnb5AZwktlqK8swDv9oKKXO/QcIwgto4svk Cv5g== X-Gm-Message-State: AOAM532jUndsPdFHxuexcNKYIL2CluwPuGQrL3F2hbYwpm7zXjSeDpgA 9N5oq8y4HqjCVpWjdXxwaESXjP/Hqx4PWA== X-Google-Smtp-Source: ABdhPJy0nfl8qCKHWMvBFHyU9bUrgz9wHMagjh2VbBZKPrZv8N4R1mF1tlbunPosVzS54wqURE/Uag== X-Received: by 2002:a63:db4a:: with SMTP id x10mr9667977pgi.30.1629551542851; Sat, 21 Aug 2021 06:12:22 -0700 (PDT) Received: from localhost.localdomain ([110.226.224.21]) by smtp.googlemail.com with ESMTPSA id g85sm2029084pfb.172.2021.08.21.06.12.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Aug 2021 06:12:22 -0700 (PDT) From: Vedant Paranjape To: libcamera-devel@lists.libcamera.org Date: Sat, 21 Aug 2021 18:42:02 +0530 Message-Id: <20210821131202.3029523-1-vedantparanjape160201@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2] test: gstreamer: Clean up memory management X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vedant Paranjape Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" This patch simplifies memory management, i.e., by replacing bare gpointers with g_autoptr or g_autofree according to use case. While at it also updated time representation of timeout variable with GST_SECOND Signed-off-by: Vedant Paranjape Reviewed-by: Laurent Pinchart --- test/gstreamer/gstreamer_single_stream_test.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/test/gstreamer/gstreamer_single_stream_test.cpp b/test/gstreamer/gstreamer_single_stream_test.cpp index a805fb8a..349dcfa4 100644 --- a/test/gstreamer/gstreamer_single_stream_test.cpp +++ b/test/gstreamer/gstreamer_single_stream_test.cpp @@ -55,12 +55,10 @@ protected: setenv("ASAN_OPTIONS", "verify_asan_link_order=0", 1); /* Initialize GStreamer */ - GError *errInit = nullptr; + g_autoptr(GError) errInit = NULL; if (!gst_init_check(nullptr, nullptr, &errInit)) { g_printerr("Could not initialize GStreamer: %s\n", errInit ? errInit->message : "unknown error"); - if (errInit) - g_error_free(errInit); return TestFail; } @@ -138,7 +136,7 @@ protected: /* Wait until error or EOS or timeout after 2 seconds */ constexpr GstMessageType msgType = static_cast(GST_MESSAGE_ERROR | GST_MESSAGE_EOS); - constexpr GstClockTime timeout = 2000000000; + constexpr GstClockTime timeout = 2 * GST_SECOND; g_autoptr(GstBus) bus = gst_element_get_bus(pipeline_); g_autoptr(GstMessage) msg = gst_bus_timed_pop_filtered(bus, timeout, msgType); @@ -167,16 +165,14 @@ protected: private: void gstreamer_print_error(GstMessage *msg) { - GError *err; - gchar *debug_info; + g_autoptr(GError) err = NULL; + g_autofree gchar *debug_info = NULL; gst_message_parse_error(msg, &err, &debug_info); g_printerr("Error received from element %s: %s\n", GST_OBJECT_NAME(msg->src), err->message); g_printerr("Debugging information: %s\n", debug_info ? debug_info : "none"); - g_clear_error(&err); - g_free(debug_info); } GstElement *pipeline_;