From patchwork Sat Aug 21 08:39:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vedant Paranjape X-Patchwork-Id: 13424 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 D836ABD87D for ; Sat, 21 Aug 2021 08:40:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3029E688A5; Sat, 21 Aug 2021 10:40:13 +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="ilCcjrIe"; dkim-atps=neutral Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 891EA6025B for ; Sat, 21 Aug 2021 10:40:11 +0200 (CEST) Received: by mail-pj1-x1032.google.com with SMTP id n13-20020a17090a4e0d00b0017946980d8dso15391632pjh.5 for ; Sat, 21 Aug 2021 01:40:11 -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=dwf2QalhblF7sRl7woO6rbk5bo8MCFRQYBktJJKazcg=; b=ilCcjrIe47XdajKI9vF8f17dL4XSR8UE0ak8ZD/f9YR9GPysdpFJ3xDDibtAz5j/1Z rTdla9vtl00JB5I0yverWQXDmfrQ2I4NtsbjLCptXGYORgMAAY4k5d1Tc+WbPH3Bk6gj e+g1wLl8uBAvRWBy2ngJY5hOJJId1yRYeUQ5NQMIppy3r+vGIpI521RQAxjSLQyKpK8y mBdMtc+atxdjG8xQ+ZMaWy+SwNFlyU2Am5HlvT8sXB9pSJZsKWPXQ9ybTJ7Y/773xOhI JhLDjoSAnRKq444x2C7mjQzOxrF467FOwo98YMw6E1styPUu1VivN1fLBQuy/AlNyAd/ dsKg== 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=dwf2QalhblF7sRl7woO6rbk5bo8MCFRQYBktJJKazcg=; b=ExNbrstbZ9MSjw6mmGczO75d76BBuPom1emFjaHhJN4U3hLeHfjD2O4cnj1vNNTBEl uswrQgVbqRmB4yER9yQyZFIdT2lfg3enojMzdSFLU5cSMGEPYmiqfQGg1zvJ2ZnLPtLP W0GUpSAaSni0VwArBY4xV2468ZP8cZf63VsSnEyaZGX5UBEGZKpYYRFotHq5RZYfxqAj 5qK03x+3S65b3bB0Mt8lBYNbIfbqj6uS/kUvp9odZRjgOLqJxZOi2zgVKPBX8rBBgSKe mJ/kgjDcSn2rOXYXz8WvWD+19zV0FLiCt7hNDuFKNpYc51z+oFm88rg9EaxGRh0+dveT xBKg== X-Gm-Message-State: AOAM532umt/jp16pdpwGguCGxxpZjjSassFNHfznKR9pW/QVg0WWZ3zt gyFCTgl4OpdRVcN3rowNkJ8H3IL/RZ/vig== X-Google-Smtp-Source: ABdhPJzelFc4rVN/nj5Sxwg18dEMdFDOYSMywzDd/qZjb7cy6zW/C7j0cVEQL8oFQm91tNmwCXio3Q== X-Received: by 2002:a17:90a:648b:: with SMTP id h11mr9227395pjj.141.1629535209495; Sat, 21 Aug 2021 01:40:09 -0700 (PDT) Received: from localhost.localdomain ([110.226.224.21]) by smtp.googlemail.com with ESMTPSA id y13sm12439126pjr.50.2021.08.21.01.40.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Aug 2021 01:40:08 -0700 (PDT) From: Vedant Paranjape To: libcamera-devel@lists.libcamera.org Date: Sat, 21 Aug 2021 14:09:57 +0530 Message-Id: <20210821083957.2989120-1-vedantparanjape160201@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1] 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 fixes memory management, i.e., replaced bare gpointers with g_autoptr or g_autofree according to use case. 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_;