[PATCHv2 1/8] edid-decode: fix broken bit tests

Hans Verkuil hverkuil at xs4all.nl
Fri Sep 8 10:31:57 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 7aaeacee..0c93d104 100644
--- a/edid-decode.c
+++ b/edid-decode.c
@@ -1638,7 +1638,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]);
 	}
     }
@@ -1659,14 +1659,14 @@ cea_hdr_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