diff mbox series

[5/7] media-info: fix NULL check

Message ID 20200420184649.4202-5-rosenp@gmail.com (mailing list archive)
State New, archived
Headers show
Series [1/7] treewide: fix mismatching declarations | expand

Commit Message

Rosen Penev April 20, 2020, 6:46 p.m. UTC
Found with clang-tidy's bugprone-bool-pointer-implicit-conversion

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 utils/common/media-info.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Hans Verkuil April 21, 2020, 8:41 a.m. UTC | #1
On 20/04/2020 20:46, Rosen Penev wrote:
> Found with clang-tidy's bugprone-bool-pointer-implicit-conversion
> 
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> ---
>  utils/common/media-info.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/utils/common/media-info.cpp b/utils/common/media-info.cpp
> index b0f0bc41..cb48d0df 100644
> --- a/utils/common/media-info.cpp
> +++ b/utils/common/media-info.cpp
> @@ -357,7 +357,7 @@ std::string mi_entfunction2s(__u32 function, bool *is_invalid)
>  			return fail ? entity_functions_def[i].str + 6 : entity_functions_def[i].str;
>  		}
>  	}
> -	if (is_invalid)
> +	if (is_invalid != NULL)
>  		return "WARNING: Unknown Function (" + num2s(function) + "), is v4l2-compliance out-of-date?";
>  	return "Unknown Function (" + num2s(function) + ")";
>  }
> 

This makes no sense: why just this instance when there are a lot more
'if (is_invalid)' checks in this function?

In any case, this is also normal idiom and I don't want to apply this patch.

Regards,

	Hans
diff mbox series

Patch

diff --git a/utils/common/media-info.cpp b/utils/common/media-info.cpp
index b0f0bc41..cb48d0df 100644
--- a/utils/common/media-info.cpp
+++ b/utils/common/media-info.cpp
@@ -357,7 +357,7 @@  std::string mi_entfunction2s(__u32 function, bool *is_invalid)
 			return fail ? entity_functions_def[i].str + 6 : entity_functions_def[i].str;
 		}
 	}
-	if (is_invalid)
+	if (is_invalid != NULL)
 		return "WARNING: Unknown Function (" + num2s(function) + "), is v4l2-compliance out-of-date?";
 	return "Unknown Function (" + num2s(function) + ")";
 }