From patchwork Wed Jun 29 12:55:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 16436 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 60C90BE173 for ; Wed, 29 Jun 2022 12:56:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A094965635; Wed, 29 Jun 2022 14:56:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656507365; bh=uUeEM+bTmfxHMOC2BDRIKGb7c1yaykikzoEXy8vxFOI=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=Z5YxocV3ODG4mr1lD8vvIa3Mz+UMU2pPOh8DB1ODbUtbdrW5zvopl/TWoIecb6blx 4v1vgS75uVKXM4oNCVRroVmD2yYE41myPaJg7ey9Duf92xRDUFW2bzQszYcU5/CN2y 2e5JVXNqt3MtimMQPqmh6XQMBC5t2pepUHuijjN2B4ZPBH/gO+H/7qHVRMZ6hBIVZr 7h39/NBH+4MkhcrHC7ygg5Ib6o98f0WE+LnVOcn1al6X2jXyMQ4sRJePwhxnGFSpiZ O2ZNljASVpJCFCpRavXX+Wr0Quj/nMS+PMU6ZSmjdO8kLzK8RntAHslq6bcSWk3vZV OIGLmwHYOVruA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C0F0960412 for ; Wed, 29 Jun 2022 14:56:03 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="SgC+8j2P"; dkim-atps=neutral Received: from perceval.ideasonboard.com (unknown [IPv6:2401:4900:1f3f:ca21:e286:106b:5da4:9482]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 548AA3D7; Wed, 29 Jun 2022 14:56:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1656507363; bh=uUeEM+bTmfxHMOC2BDRIKGb7c1yaykikzoEXy8vxFOI=; h=From:To:Cc:Subject:Date:From; b=SgC+8j2PMmMV9bhOLfR3xG7rkk3nCVH2x1uaU1KNL13a+9+vie43OWxpwGC+mSw/D eCEyE5rWcT+R2d7I20/jdh5+6d6z9IqWLEeTuOM4YrIOWq/+sPKBIf9sWCXQPdBdx4 5LJn8FTHEX64AQWFgw5F/tODK/70L8vNLXB2BL2s= To: libcamera-devel@lists.libcamera.org Date: Wed, 29 Jun 2022 18:25:51 +0530 Message-Id: <20220629125551.330470-1-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] gstreamer: Be pedantic on srcpads access 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: , X-Patchwork-Original-From: Umang Jain via libcamera-devel From: Umang Jain Reply-To: Umang Jain Cc: nicolas.dufresne@collabora.com, vedantparanjape160201@gmail.com Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" While the "src" pad is added to the element, it is accessed via a index number. If multiple pads are added(in future) and tracked in state->srcpads_, the index might need re-adjusting. Use the std::vector::back() instead of index, which corresponds to std::vector::push_back() for tracking of pads. It also slightly helps with readability. No functional changes intended. Signed-off-by: Umang Jain Reviewed-by: Vedant Paranjape --- src/gstreamer/gstlibcamerasrc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp index 46fd02d2..4813ab96 100644 --- a/src/gstreamer/gstlibcamerasrc.cpp +++ b/src/gstreamer/gstlibcamerasrc.cpp @@ -631,7 +631,7 @@ gst_libcamera_src_init(GstLibcameraSrc *self) gst_task_set_lock(self->task, &self->stream_lock); state->srcpads_.push_back(gst_pad_new_from_template(templ, "src")); - gst_element_add_pad(GST_ELEMENT(self), state->srcpads_[0]); + gst_element_add_pad(GST_ELEMENT(self), state->srcpads_.back()); /* C-style friend. */ state->src_ = self;