[libcamera-devel,1/3] libcamera: media_object: Remove unneeded destructors
diff mbox series

Message ID 20201023051021.16389-2-laurent.pinchart@ideasonboard.com
State Accepted
Headers show
Series
  • libcamera: Miscellaneous constructors and destructors cleanups
Related show

Commit Message

Laurent Pinchart Oct. 23, 2020, 5:10 a.m. UTC
The MediaEntity, MediaLink and MediaPad classes don't need custom
destructors. For MediaEntity and MediaPad, the destructors clear a
vector embedded in the classes, which will be done by the default
destructor. For MediaLink, the destructor is already empty. Remove them.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 include/libcamera/internal/media_object.h |  3 ---
 src/libcamera/media_object.cpp            | 18 ------------------
 2 files changed, 21 deletions(-)

Comments

Umang Jain Oct. 23, 2020, 5:21 a.m. UTC | #1
Hi Laurent,

Thank you for the patch.

On 10/23/20 10:40 AM, Laurent Pinchart wrote:
> The MediaEntity, MediaLink and MediaPad classes don't need custom
> destructors. For MediaEntity and MediaPad, the destructors clear a
> vector embedded in the classes, which will be done by the default
> destructor. For MediaLink, the destructor is already empty. Remove them.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <email@uajain.com>
> ---
>   include/libcamera/internal/media_object.h |  3 ---
>   src/libcamera/media_object.cpp            | 18 ------------------
>   2 files changed, 21 deletions(-)
>
> diff --git a/include/libcamera/internal/media_object.h b/include/libcamera/internal/media_object.h
> index be6fb8961349..54311c14895b 100644
> --- a/include/libcamera/internal/media_object.h
> +++ b/include/libcamera/internal/media_object.h
> @@ -51,7 +51,6 @@ private:
>   	MediaLink(const struct media_v2_link *link,
>   		  MediaPad *source, MediaPad *sink);
>   	MediaLink(const MediaLink &) = delete;
> -	~MediaLink() {}
>   
>   	MediaPad *source_;
>   	MediaPad *sink_;
> @@ -73,7 +72,6 @@ private:
>   
>   	MediaPad(const struct media_v2_pad *pad, MediaEntity *entity);
>   	MediaPad(const MediaPad &) = delete;
> -	~MediaPad();
>   
>   	unsigned int index_;
>   	MediaEntity *entity_;
> @@ -105,7 +103,6 @@ private:
>   	MediaEntity(MediaDevice *dev, const struct media_v2_entity *entity,
>   		    unsigned int major = 0, unsigned int minor = 0);
>   	MediaEntity(const MediaEntity &) = delete;
> -	~MediaEntity();
>   
>   	void addPad(MediaPad *pad);
>   
> diff --git a/src/libcamera/media_object.cpp b/src/libcamera/media_object.cpp
> index b7bf048c985d..056036635902 100644
> --- a/src/libcamera/media_object.cpp
> +++ b/src/libcamera/media_object.cpp
> @@ -191,15 +191,6 @@ MediaPad::MediaPad(const struct media_v2_pad *pad, MediaEntity *entity)
>   {
>   }
>   
> -MediaPad::~MediaPad()
> -{
> -	/*
> -	 * Don't delete the links as we only borrow the reference owned by
> -	 * MediaDevice.
> -	 */
> -	links_.clear();
> -}
> -
>   /**
>    * \fn MediaPad::index()
>    * \brief Retrieve the pad index
> @@ -371,15 +362,6 @@ MediaEntity::MediaEntity(MediaDevice *dev,
>   {
>   }
>   
> -MediaEntity::~MediaEntity()
> -{
> -	/*
> -	 * Don't delete the pads as we only borrow the reference owned by
> -	 * MediaDevice.
> -	 */
> -	pads_.clear();
> -}
> -
>   /**
>    * \brief Add \a pad to the entity's list of pads
>    * \param[in] pad The pad to add to the list
Kieran Bingham Oct. 23, 2020, 8:45 a.m. UTC | #2
Hi Laurent,

On 23/10/2020 06:10, Laurent Pinchart wrote:
> The MediaEntity, MediaLink and MediaPad classes don't need custom
> destructors. For MediaEntity and MediaPad, the destructors clear a
> vector embedded in the classes, which will be done by the default
> destructor. For MediaLink, the destructor is already empty. Remove them.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> ---
>  include/libcamera/internal/media_object.h |  3 ---
>  src/libcamera/media_object.cpp            | 18 ------------------
>  2 files changed, 21 deletions(-)
> 
> diff --git a/include/libcamera/internal/media_object.h b/include/libcamera/internal/media_object.h
> index be6fb8961349..54311c14895b 100644
> --- a/include/libcamera/internal/media_object.h
> +++ b/include/libcamera/internal/media_object.h
> @@ -51,7 +51,6 @@ private:
>  	MediaLink(const struct media_v2_link *link,
>  		  MediaPad *source, MediaPad *sink);
>  	MediaLink(const MediaLink &) = delete;
> -	~MediaLink() {}
>  
>  	MediaPad *source_;
>  	MediaPad *sink_;
> @@ -73,7 +72,6 @@ private:
>  
>  	MediaPad(const struct media_v2_pad *pad, MediaEntity *entity);
>  	MediaPad(const MediaPad &) = delete;
> -	~MediaPad();
>  
>  	unsigned int index_;
>  	MediaEntity *entity_;
> @@ -105,7 +103,6 @@ private:
>  	MediaEntity(MediaDevice *dev, const struct media_v2_entity *entity,
>  		    unsigned int major = 0, unsigned int minor = 0);
>  	MediaEntity(const MediaEntity &) = delete;
> -	~MediaEntity();
>  
>  	void addPad(MediaPad *pad);
>  
> diff --git a/src/libcamera/media_object.cpp b/src/libcamera/media_object.cpp
> index b7bf048c985d..056036635902 100644
> --- a/src/libcamera/media_object.cpp
> +++ b/src/libcamera/media_object.cpp
> @@ -191,15 +191,6 @@ MediaPad::MediaPad(const struct media_v2_pad *pad, MediaEntity *entity)
>  {
>  }
>  
> -MediaPad::~MediaPad()
> -{
> -	/*
> -	 * Don't delete the links as we only borrow the reference owned by
> -	 * MediaDevice.
> -	 */
> -	links_.clear();
> -}
> -
>  /**
>   * \fn MediaPad::index()
>   * \brief Retrieve the pad index
> @@ -371,15 +362,6 @@ MediaEntity::MediaEntity(MediaDevice *dev,
>  {
>  }
>  
> -MediaEntity::~MediaEntity()
> -{
> -	/*
> -	 * Don't delete the pads as we only borrow the reference owned by
> -	 * MediaDevice.
> -	 */
> -	pads_.clear();
> -}
> -
>  /**
>   * \brief Add \a pad to the entity's list of pads
>   * \param[in] pad The pad to add to the list
>
Jacopo Mondi Oct. 24, 2020, 4:36 p.m. UTC | #3
Hi Laurent,

On Fri, Oct 23, 2020 at 08:10:19AM +0300, Laurent Pinchart wrote:
> The MediaEntity, MediaLink and MediaPad classes don't need custom
> destructors. For MediaEntity and MediaPad, the destructors clear a
> vector embedded in the classes, which will be done by the default
> destructor. For MediaLink, the destructor is already empty. Remove them.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Youth mistakes ;)

Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

Thanks
  j

> ---
>  include/libcamera/internal/media_object.h |  3 ---
>  src/libcamera/media_object.cpp            | 18 ------------------
>  2 files changed, 21 deletions(-)
>
> diff --git a/include/libcamera/internal/media_object.h b/include/libcamera/internal/media_object.h
> index be6fb8961349..54311c14895b 100644
> --- a/include/libcamera/internal/media_object.h
> +++ b/include/libcamera/internal/media_object.h
> @@ -51,7 +51,6 @@ private:
>  	MediaLink(const struct media_v2_link *link,
>  		  MediaPad *source, MediaPad *sink);
>  	MediaLink(const MediaLink &) = delete;
> -	~MediaLink() {}
>
>  	MediaPad *source_;
>  	MediaPad *sink_;
> @@ -73,7 +72,6 @@ private:
>
>  	MediaPad(const struct media_v2_pad *pad, MediaEntity *entity);
>  	MediaPad(const MediaPad &) = delete;
> -	~MediaPad();
>
>  	unsigned int index_;
>  	MediaEntity *entity_;
> @@ -105,7 +103,6 @@ private:
>  	MediaEntity(MediaDevice *dev, const struct media_v2_entity *entity,
>  		    unsigned int major = 0, unsigned int minor = 0);
>  	MediaEntity(const MediaEntity &) = delete;
> -	~MediaEntity();
>
>  	void addPad(MediaPad *pad);
>
> diff --git a/src/libcamera/media_object.cpp b/src/libcamera/media_object.cpp
> index b7bf048c985d..056036635902 100644
> --- a/src/libcamera/media_object.cpp
> +++ b/src/libcamera/media_object.cpp
> @@ -191,15 +191,6 @@ MediaPad::MediaPad(const struct media_v2_pad *pad, MediaEntity *entity)
>  {
>  }
>
> -MediaPad::~MediaPad()
> -{
> -	/*
> -	 * Don't delete the links as we only borrow the reference owned by
> -	 * MediaDevice.
> -	 */
> -	links_.clear();
> -}
> -
>  /**
>   * \fn MediaPad::index()
>   * \brief Retrieve the pad index
> @@ -371,15 +362,6 @@ MediaEntity::MediaEntity(MediaDevice *dev,
>  {
>  }
>
> -MediaEntity::~MediaEntity()
> -{
> -	/*
> -	 * Don't delete the pads as we only borrow the reference owned by
> -	 * MediaDevice.
> -	 */
> -	pads_.clear();
> -}
> -
>  /**
>   * \brief Add \a pad to the entity's list of pads
>   * \param[in] pad The pad to add to the list
> --
> Regards,
>
> Laurent Pinchart
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch
diff mbox series

diff --git a/include/libcamera/internal/media_object.h b/include/libcamera/internal/media_object.h
index be6fb8961349..54311c14895b 100644
--- a/include/libcamera/internal/media_object.h
+++ b/include/libcamera/internal/media_object.h
@@ -51,7 +51,6 @@  private:
 	MediaLink(const struct media_v2_link *link,
 		  MediaPad *source, MediaPad *sink);
 	MediaLink(const MediaLink &) = delete;
-	~MediaLink() {}
 
 	MediaPad *source_;
 	MediaPad *sink_;
@@ -73,7 +72,6 @@  private:
 
 	MediaPad(const struct media_v2_pad *pad, MediaEntity *entity);
 	MediaPad(const MediaPad &) = delete;
-	~MediaPad();
 
 	unsigned int index_;
 	MediaEntity *entity_;
@@ -105,7 +103,6 @@  private:
 	MediaEntity(MediaDevice *dev, const struct media_v2_entity *entity,
 		    unsigned int major = 0, unsigned int minor = 0);
 	MediaEntity(const MediaEntity &) = delete;
-	~MediaEntity();
 
 	void addPad(MediaPad *pad);
 
diff --git a/src/libcamera/media_object.cpp b/src/libcamera/media_object.cpp
index b7bf048c985d..056036635902 100644
--- a/src/libcamera/media_object.cpp
+++ b/src/libcamera/media_object.cpp
@@ -191,15 +191,6 @@  MediaPad::MediaPad(const struct media_v2_pad *pad, MediaEntity *entity)
 {
 }
 
-MediaPad::~MediaPad()
-{
-	/*
-	 * Don't delete the links as we only borrow the reference owned by
-	 * MediaDevice.
-	 */
-	links_.clear();
-}
-
 /**
  * \fn MediaPad::index()
  * \brief Retrieve the pad index
@@ -371,15 +362,6 @@  MediaEntity::MediaEntity(MediaDevice *dev,
 {
 }
 
-MediaEntity::~MediaEntity()
-{
-	/*
-	 * Don't delete the pads as we only borrow the reference owned by
-	 * MediaDevice.
-	 */
-	pads_.clear();
-}
-
 /**
  * \brief Add \a pad to the entity's list of pads
  * \param[in] pad The pad to add to the list