[PATCH 8/8] edid-decode: fix broken bit tests
Hans Verkuil
hverkuil at xs4all.nl
Thu Sep 7 18:03:31 UTC 2017
From: Hans Verkuil <hans.verkuil at cisco.com>
'if (x[0] >> i)' is not how you test if bit i is set.
'if (x[0] & (1 << i))' works a lot better!
Signed-off-by: Hans Verkuil <hans.verkuil at cisco.com>
---
edid-decode.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/edid-decode.c b/edid-decode.c
index cdba099d..ca6f57b9 100644
--- a/edid-decode.c
+++ b/edid-decode.c
@@ -1816,7 +1816,7 @@ cea_colorimetry_block(unsigned char *x)
if (length >= 3) {
for (i = 0; i < ARRAY_SIZE(colorimetry_map); i++) {
- if (x[2] >> i)
+ if (x[2] & (1 << i))
printf(" %s\n", colorimetry_map[i]);
}
if (x[3] & 0x80)
@@ -1840,14 +1840,14 @@ cea_hdr_static_metadata_block(unsigned char *x)
if (length >= 3) {
printf(" Electro optical transfer functions:\n");
for (i = 0; i < 6; i++) {
- if (x[2] >> i) {
+ if (x[2] & (1 << i)) {
printf(" %s\n", i < ARRAY_SIZE(eotf_map) ?
eotf_map[i] : "Unknown");
}
}
printf(" Supported static metadata descriptors:\n");
for (i = 0; i < 8; i++) {
- if (x[3] >> i)
+ if (x[3] & (1 << i))
printf(" Static metadata type %d\n", i + 1);
}
}
--
2.14.1
More information about the xorg-devel
mailing list