[v2,3/4] libcamera: media_device: Use MediaLink string helper
diff mbox series

Message ID 20240911211816.73763-4-kieran.bingham@ideasonboard.com
State Accepted
Commit 4035f5754e1dd6a857b86c183d5d344353e16b2c
Headers show
Series
  • MediaLink: Provide a string representation
Related show

Commit Message

Kieran Bingham Sept. 11, 2024, 9:18 p.m. UTC
Replace the two open-coded implementations of a link representation
with the operator<< overload string representation to simplify
the code and unify appearance of reporting MediaLinks.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 src/libcamera/media_device.cpp | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

Comments

Stefan Klug Sept. 12, 2024, 9:01 a.m. UTC | #1
Hi Kieran,

Thank you for the patch. 

On Wed, Sep 11, 2024 at 11:18:15PM +0200, Kieran Bingham wrote:
> Replace the two open-coded implementations of a link representation
> with the operator<< overload string representation to simplify
> the code and unify appearance of reporting MediaLinks.
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

Now on the v2
Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com> 

Regards,
Stefan

> ---
>  src/libcamera/media_device.cpp | 12 ++----------
>  1 file changed, 2 insertions(+), 10 deletions(-)
> 
> diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp
> index bd054552a093..d71dad74df70 100644
> --- a/src/libcamera/media_device.cpp
> +++ b/src/libcamera/media_device.cpp
> @@ -818,20 +818,12 @@ int MediaDevice::setupLink(const MediaLink *link, unsigned int flags)
>  	if (ret) {
>  		ret = -errno;
>  		LOG(MediaDevice, Error)
> -			<< "Failed to setup link "
> -			<< source->entity()->name() << "["
> -			<< source->index() << "] -> "
> -			<< sink->entity()->name() << "["
> -			<< sink->index() << "]: "
> +			<< "Failed to setup link " << *link << ": "
>  			<< strerror(-ret);
>  		return ret;
>  	}
>  
> -	LOG(MediaDevice, Debug)
> -		<< source->entity()->name() << "["
> -		<< source->index() << "] -> "
> -		<< sink->entity()->name() << "["
> -		<< sink->index() << "]: " << flags;
> +	LOG(MediaDevice, Debug) << *link << ": " << flags;
>  
>  	return 0;
>  }
> -- 
> 2.46.0
>

Patch
diff mbox series

diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp
index bd054552a093..d71dad74df70 100644
--- a/src/libcamera/media_device.cpp
+++ b/src/libcamera/media_device.cpp
@@ -818,20 +818,12 @@  int MediaDevice::setupLink(const MediaLink *link, unsigned int flags)
 	if (ret) {
 		ret = -errno;
 		LOG(MediaDevice, Error)
-			<< "Failed to setup link "
-			<< source->entity()->name() << "["
-			<< source->index() << "] -> "
-			<< sink->entity()->name() << "["
-			<< sink->index() << "]: "
+			<< "Failed to setup link " << *link << ": "
 			<< strerror(-ret);
 		return ret;
 	}
 
-	LOG(MediaDevice, Debug)
-		<< source->entity()->name() << "["
-		<< source->index() << "] -> "
-		<< sink->entity()->name() << "["
-		<< sink->index() << "]: " << flags;
+	LOG(MediaDevice, Debug) << *link << ": " << flags;
 
 	return 0;
 }