[libcamera-devel,6/9] libcamera: device_enumerator: Constify argument to search function

Message ID 20190103013110.6849-6-laurent.pinchart@ideasonboard.com
State Accepted
Headers show
Series
  • [libcamera-devel,1/9] libcamera: camera_manager: Remove put() method
Related show

Commit Message

Laurent Pinchart Jan. 3, 2019, 1:31 a.m. UTC
The DeviceEnumerator::search() function doesn't need to modify its
DeviceMatch argument, make it const.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/libcamera/device_enumerator.cpp       | 2 +-
 src/libcamera/include/device_enumerator.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Niklas Söderlund Jan. 3, 2019, 9:25 p.m. UTC | #1
Hi Laurent,

Thanks for your patch.

On 2019-01-03 03:31:07 +0200, Laurent Pinchart wrote:
> The DeviceEnumerator::search() function doesn't need to modify its
> DeviceMatch argument, make it const.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

> ---
>  src/libcamera/device_enumerator.cpp       | 2 +-
>  src/libcamera/include/device_enumerator.h | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp
> index ecd51bc1d108..a301420f39e1 100644
> --- a/src/libcamera/device_enumerator.cpp
> +++ b/src/libcamera/device_enumerator.cpp
> @@ -215,7 +215,7 @@ int DeviceEnumerator::addDevice(const std::string &devnode)
>   *
>   * \return pointer to the matching MediaDevice, nullptr if no match is found
>   */
> -MediaDevice *DeviceEnumerator::search(DeviceMatch &dm) const
> +MediaDevice *DeviceEnumerator::search(const DeviceMatch &dm) const
>  {
>  	for (MediaDevice *dev : devices_) {
>  		if (dev->busy())
> diff --git a/src/libcamera/include/device_enumerator.h b/src/libcamera/include/device_enumerator.h
> index 0d104667323b..29737da7a225 100644
> --- a/src/libcamera/include/device_enumerator.h
> +++ b/src/libcamera/include/device_enumerator.h
> @@ -41,7 +41,7 @@ public:
>  	virtual int init() = 0;
>  	virtual int enumerate() = 0;
>  
> -	MediaDevice *search(DeviceMatch &dm) const;
> +	MediaDevice *search(const DeviceMatch &dm) const;
>  
>  protected:
>  	int addDevice(const std::string &devnode);
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp
index ecd51bc1d108..a301420f39e1 100644
--- a/src/libcamera/device_enumerator.cpp
+++ b/src/libcamera/device_enumerator.cpp
@@ -215,7 +215,7 @@  int DeviceEnumerator::addDevice(const std::string &devnode)
  *
  * \return pointer to the matching MediaDevice, nullptr if no match is found
  */
-MediaDevice *DeviceEnumerator::search(DeviceMatch &dm) const
+MediaDevice *DeviceEnumerator::search(const DeviceMatch &dm) const
 {
 	for (MediaDevice *dev : devices_) {
 		if (dev->busy())
diff --git a/src/libcamera/include/device_enumerator.h b/src/libcamera/include/device_enumerator.h
index 0d104667323b..29737da7a225 100644
--- a/src/libcamera/include/device_enumerator.h
+++ b/src/libcamera/include/device_enumerator.h
@@ -41,7 +41,7 @@  public:
 	virtual int init() = 0;
 	virtual int enumerate() = 0;
 
-	MediaDevice *search(DeviceMatch &dm) const;
+	MediaDevice *search(const DeviceMatch &dm) const;
 
 protected:
 	int addDevice(const std::string &devnode);