[{"id":19113,"web_url":"https://patchwork.libcamera.org/comment/19113/","msgid":"<YSex2CcK6dfqvs6p@pendragon.ideasonboard.com>","date":"2021-08-26T15:23:04","subject":"Re: [libcamera-devel] [PATCH 1/2] libcamera: camera configuration:\n\tRemove operator[] from doc","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nThank you for the patch.\n\nOn Wed, Aug 25, 2021 at 06:13:02PM +0200, Jacopo Mondi wrote:\n> The documentation suggests to use CameraConfiguration::operator[] to\n> access the StreamConfiguration it contains, but as CameraConfiguration\n> instances are generated by the Camera class and are returned wrapped in\n> a unique_ptr<>. The usage of operator[] would require an awkward syntax such\n> as (*config)[i].\n> \n> Better to suggest the usage of the CameraConfiguration::at() function\n> instead to access the StreamConfigurations.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  src/libcamera/camera.cpp | 6 +++---\n>  1 file changed, 3 insertions(+), 3 deletions(-)\n> \n> diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\n> index c20e05014fb9..c4d576b3985b 100644\n> --- a/src/libcamera/camera.cpp\n> +++ b/src/libcamera/camera.cpp\n> @@ -114,9 +114,9 @@ LOG_DECLARE_CATEGORY(Camera)\n>   * The CameraConfiguration holds an ordered list of stream configurations. It\n>   * supports iterators and operates as a vector of StreamConfiguration instances.\n>   * The stream configurations are inserted by addConfiguration(), and the\n> - * operator[](int) returns a reference to the StreamConfiguration based on its\n> - * insertion index. Accessing a stream configuration with an invalid index\n> - * results in undefined behaviour.\n> + * at(unsigned int) function returns a reference to the StreamConfiguration\n\nWe could say \"at(unsigned int) function or operator[](int)\" too. I'm\nfine with either.\n\nAnother small comment, I'd drop the type and just write at() (and\npossibly operator[]()) as that's unambiguous. With or without this,\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> + * based on its insertion index. Accessing a stream configuration with an\n> + * invalid index results in undefined behaviour.\n>   *\n>   * CameraConfiguration instances are retrieved from the camera with\n>   * Camera::generateConfiguration(). Applications may then inspect the","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 6F5D1BD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 26 Aug 2021 15:23:18 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DFD7F68928;\n\tThu, 26 Aug 2021 17:23:17 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 417B3688A2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 26 Aug 2021 17:23:17 +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 B827A191F;\n\tThu, 26 Aug 2021 17:23:16 +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=\"SY/uGBQw\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1629991396;\n\tbh=rTCmIOtAfzWIiMvgb22m/aOjq2CevWjbP6PRkfqV0w4=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=SY/uGBQwrQ0X4KzVZsmLp2uPPt6wI6LJKBmz1zugwrS3o2BBNYYKFtbs6SeSlrj5A\n\tPfWjpV0M/31947GutlyVE/kW51fgkjfCUJYsJ/6FNeHdlwinVRQfG+kYBKm1WUeeGX\n\t+JudtJdoLsm7d7szQr3dXUJq4ayZj3uha3MdMMk4=","Date":"Thu, 26 Aug 2021 18:23:04 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<YSex2CcK6dfqvs6p@pendragon.ideasonboard.com>","References":"<20210825161303.48955-1-jacopo@jmondi.org>\n\t<20210825161303.48955-2-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20210825161303.48955-2-jacopo@jmondi.org>","Subject":"Re: [libcamera-devel] [PATCH 1/2] libcamera: camera configuration:\n\tRemove operator[] from doc","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>"}}]