[libcamera-devel] libcamera: log: Fix unknown log level representation

Message ID 20190114100256.17777-1-kieran.bingham@ideasonboard.com
State Accepted
Commit bced32d514bb36b97f4dd045f4ee6919e1642aa0
Headers show
Series
  • [libcamera-devel] libcamera: log: Fix unknown log level representation
Related show

Commit Message

Kieran Bingham Jan. 14, 2019, 10:02 a.m. UTC
Commit 99a3e7bcfb38 ("libcamera: log: Add a LogFatal log level")
expanded the text representation of the log levels to support the FATAL
string, but left the default unknown match at four characters.

This code should never expect to be executed, but for completeness match
the string lengths by adding an extra character to the result.

Fixes: 99a3e7bcfb38 ("libcamera: log: Add a LogFatal log level")
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 src/libcamera/log.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Laurent Pinchart Jan. 14, 2019, 4:52 p.m. UTC | #1
Hi Kieran,

Thank you for the patch.

On Monday, 14 January 2019 12:02:56 EET Kieran Bingham wrote:
> Commit 99a3e7bcfb38 ("libcamera: log: Add a LogFatal log level")
> expanded the text representation of the log levels to support the FATAL
> string, but left the default unknown match at four characters.
> 
> This code should never expect to be executed, but for completeness match
> the string lengths by adding an extra character to the result.
> 
> Fixes: 99a3e7bcfb38 ("libcamera: log: Add a LogFatal log level")
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  src/libcamera/log.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/log.cpp b/src/libcamera/log.cpp
> index 281e31d963f5..9b2ae1bac8c8 100644
> --- a/src/libcamera/log.cpp
> +++ b/src/libcamera/log.cpp
> @@ -77,7 +77,7 @@ static const char *log_severity_name(LogSeverity severity)
> if (static_cast<unsigned int>(severity) < ARRAY_SIZE(names))
>  		return names[severity];
>  	else
> -		return "UNKN";
> +		return "UNKWN";
>  }
> 
>  /**

Patch

diff --git a/src/libcamera/log.cpp b/src/libcamera/log.cpp
index 281e31d963f5..9b2ae1bac8c8 100644
--- a/src/libcamera/log.cpp
+++ b/src/libcamera/log.cpp
@@ -77,7 +77,7 @@  static const char *log_severity_name(LogSeverity severity)
 	if (static_cast<unsigned int>(severity) < ARRAY_SIZE(names))
 		return names[severity];
 	else
-		return "UNKN";
+		return "UNKWN";
 }
 
 /**