[{"id":348,"web_url":"https://patchwork.libcamera.org/comment/348/","msgid":"<20190115222910.GJ7393@bigcity.dyn.berto.se>","date":"2019-01-15T22:29:10","subject":"Re: [libcamera-devel] [PATCH v2 6/8] libcamera: device_enumerator:\n\tDon't mark the search() function as const","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Laurent,\n\nThanks for your patch.\n\nOn 2019-01-15 17:18:47 +0200, Laurent Pinchart wrote:\n> While the DeviceEnumerator::search() function doesn't modify the\n> instance directly, it returns a non-const pointer to a MediaEntity that\n> is owned by the DeviceEnumerator instance. This breaks the const\n> semantics. Don't mark the function as const.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> ---\n>  src/libcamera/device_enumerator.cpp       | 2 +-\n>  src/libcamera/include/device_enumerator.h | 2 +-\n>  2 files changed, 2 insertions(+), 2 deletions(-)\n> \n> diff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp\n> index 1653e4f4651a..18d7e86843e8 100644\n> --- a/src/libcamera/device_enumerator.cpp\n> +++ b/src/libcamera/device_enumerator.cpp\n> @@ -245,7 +245,7 @@ int DeviceEnumerator::addDevice(const std::string &devnode)\n>   *\n>   * \\return pointer to the matching MediaDevice, or nullptr if no match is found\n>   */\n> -MediaDevice *DeviceEnumerator::search(const DeviceMatch &dm) const\n> +MediaDevice *DeviceEnumerator::search(const DeviceMatch &dm)\n>  {\n>  \tfor (MediaDevice *dev : devices_) {\n>  \t\tif (dev->busy())\n> diff --git a/src/libcamera/include/device_enumerator.h b/src/libcamera/include/device_enumerator.h\n> index 29737da7a225..b68c815827dd 100644\n> --- a/src/libcamera/include/device_enumerator.h\n> +++ b/src/libcamera/include/device_enumerator.h\n> @@ -41,7 +41,7 @@ public:\n>  \tvirtual int init() = 0;\n>  \tvirtual int enumerate() = 0;\n>  \n> -\tMediaDevice *search(const DeviceMatch &dm) const;\n> +\tMediaDevice *search(const DeviceMatch &dm);\n>  \n>  protected:\n>  \tint addDevice(const std::string &devnode);\n> -- \n> Regards,\n> \n> Laurent Pinchart\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from mail-lf1-x143.google.com (mail-lf1-x143.google.com\n\t[IPv6:2a00:1450:4864:20::143])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B722D60C6A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 15 Jan 2019 23:29:12 +0100 (CET)","by mail-lf1-x143.google.com with SMTP id n18so3339039lfh.6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 15 Jan 2019 14:29:12 -0800 (PST)","from localhost (89-233-230-99.cust.bredband2.com. [89.233.230.99])\n\tby smtp.gmail.com with ESMTPSA id\n\ts17sm935913lfk.9.2019.01.15.14.29.11\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tTue, 15 Jan 2019 14:29:11 -0800 (PST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to\n\t:user-agent; bh=PsSw6Of8OltgTF2YMO+qBxy9GGBEk+Bi6kDPgLqQEto=;\n\tb=O2Mbjqm/zw0XD/wqbAyObSutOPHfO2SRCvWZ83K9qpyIkZX/fxeUp1qGmZh+PIwY9V\n\t1mwZuh/Wabm/k5gGgaVK8QaJCCsSxU4gWmRbYq5XYz4m+WFvoBKv+s60jFmXMEmjk+Ar\n\t7Q6FSdV3jPUHZ40f6CDXNVSIuzpRG2NXbl3jsHfooBctG9pNmsAGiem5wRzaqRf6nce8\n\t7Nrtg+t0XEovqxcEcCt2aJRTGerTrXI7RttXKVgpL4rAV9lMo/R3ysuJAH/2OoeRlEDd\n\t1bCMk7cWSOM9UPjJuzsXUPL5VSkhqR4n5ilqmLVW6J1MMjPzuYAR/dBubUd1IazIHQTR\n\t0axg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to:user-agent;\n\tbh=PsSw6Of8OltgTF2YMO+qBxy9GGBEk+Bi6kDPgLqQEto=;\n\tb=oHJRuKTXbhpJc3cX24N5QwaJbWMBbIDdN6dRHWB2pBgnkCCHe67DDEncSECJkVspA+\n\t6Ym1bgyjZtC+ixQ3qXZnhcgijjBUfs/+aNrOsQB7kCx1s3o5P72cpgk+XIVZAMuxKF3g\n\tJ/U32nnq37HoWF6eCIdO4rmwvUouP4t3OJcIVzMJkvXDY02zE0dBEbm3qhBIPot6j3s9\n\t623WcqL2c9z+2G9Junspy+x1As5KyjVFOCSh3CdZTQFWU03OvYMjfdn5ogJt5JjWbWg8\n\tZSP/1vlVlVoK8YeKna/oTGXwSMZc3qh/VkaXQGApedTRvlnpJs2Sz/L9doGjGLX1AihD\n\tNP5w==","X-Gm-Message-State":"AJcUukeXN3BuhCLJn9hvP8v4hUHlOeMZwMcURKdW/6zxJE4SRdimNd2I\n\tIe5L3PZ3pWSZWc+jZF3pRtXh3bQhP5Y=","X-Google-Smtp-Source":"ALg8bN6L8xTxIZLgMvqX1tUnmQPcIgLZ1rXb15+sRnzIZVxPM4Sti+tUDE8ysK25HQyiGuo40WMJrA==","X-Received":"by 2002:a19:cd50:: with SMTP id\n\td77mr4371558lfg.125.1547591351978; \n\tTue, 15 Jan 2019 14:29:11 -0800 (PST)","Date":"Tue, 15 Jan 2019 23:29:10 +0100","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190115222910.GJ7393@bigcity.dyn.berto.se>","References":"<20190115151849.1547-1-laurent.pinchart@ideasonboard.com>\n\t<20190115151849.1547-7-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20190115151849.1547-7-laurent.pinchart@ideasonboard.com>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v2 6/8] libcamera: device_enumerator:\n\tDon't mark the search() function as const","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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>","X-List-Received-Date":"Tue, 15 Jan 2019 22:29:13 -0000"}}]