aboutsummaryrefslogtreecommitdiffstats
path: root/utils/common/media-info.cpp
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2018-02-09 11:01:06 +0100
committerHans Verkuil <hans.verkuil@cisco.com>2018-02-09 11:01:06 +0100
commit5924340b32ce8738c1dd0dc6a6f663ae69a4f695 (patch)
tree569447f790425b9a91d683474c7a05344724d2bf /utils/common/media-info.cpp
parentdc9dbc4c1ef79ddbe0dffc0f26ed47c0eb3433ee (diff)
media-info: don't add 'FAIL'/'WARNING' if is_invalid == NULL
It is confusing to see these 'FAIL'/'WARNING' prefixes in v4l2-ctl. Only show them if the caller is actually interested in whether the function is valid or not. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Diffstat (limited to 'utils/common/media-info.cpp')
-rw-r--r--utils/common/media-info.cpp35
1 files changed, 24 insertions, 11 deletions
diff --git a/utils/common/media-info.cpp b/utils/common/media-info.cpp
index d9281ad7..af71a197 100644
--- a/utils/common/media-info.cpp
+++ b/utils/common/media-info.cpp
@@ -261,26 +261,39 @@ static const flag_def entity_functions_def[] = {
std::string entfunction2s(__u32 function, bool *is_invalid)
{
+ std::string s;
+
if ((function & MEDIA_ENT_TYPE_MASK) == MEDIA_ENT_F_OLD_BASE &&
function > MEDIA_ENT_T_DEVNODE_DVB) {
- if (is_invalid)
- *is_invalid = true;
- return "FAIL: Unknown legacy device node type (" + num2s(function) + ")";
+ s = "Unknown legacy device node type (" + num2s(function) + ")";
+ if (!is_invalid)
+ return s;
+ *is_invalid = true;
+ return "FAIL: " + s;
}
if ((function & MEDIA_ENT_TYPE_MASK) == MEDIA_ENT_F_OLD_SUBDEV_BASE &&
function > MEDIA_ENT_F_TUNER) {
- if (is_invalid)
- *is_invalid = true;
- return "FAIL: Unknown legacy sub-device type (" + num2s(function) + ")";
+ s = "Unknown legacy sub-device type (" + num2s(function) + ")";
+ if (!is_invalid)
+ return s;
+ *is_invalid = true;
+ return "FAIL: " + s;
}
- for (unsigned i = 0; entity_functions_def[i].str; i++)
+ for (unsigned i = 0; entity_functions_def[i].str; i++) {
if (function == entity_functions_def[i].flag) {
- if (is_invalid)
- *is_invalid = !memcmp(entity_functions_def[i].str, "FAIL:", 5);
- return entity_functions_def[i].str;
+ bool fail = !memcmp(entity_functions_def[i].str, "FAIL: ", 6);
+
+ if (is_invalid) {
+ *is_invalid = fail;
+ return entity_functions_def[i].str;
+ }
+ return fail ? entity_functions_def[i].str + 6 : entity_functions_def[i].str;
}
- return "WARNING: Unknown Function (" + num2s(function) + "), is v4l2-compliance out-of-date?";
+ }
+ if (is_invalid)
+ return "WARNING: Unknown Function (" + num2s(function) + "), is v4l2-compliance out-of-date?";
+ return "Unknown Function (" + num2s(function) + ")";
}
static const flag_def pad_flags_def[] = {

Privacy Policy