[edid-decode] [PATCH 2/2] Calculate DisplayID checksums. Refactor do_checksum.

Mark Ferry mark at cognomen.co.uk
Mon Feb 6 13:53:02 UTC 2017


Finally returning to this:

On Tue, 13 Dec 2016 16:51:07 +0100, walter harms wrote:
> 
> >> Am 10.12.2016 20:44, schrieb Mark Ferry:
> >>> +    printf("Checksum: 0x%hx", x[len -1]);
> >>> +
> >>> +    for (i = 0; i < len; i++)
> >>> +        sum += x[i];
> >>> +
> >>> +    if (sum) {
> >>> +        printf(" (should be 0x%hx)", (unsigned char)(x[len-1] - sum));
> >>> +    } else printf(" (valid)");
> >>> +
> >>>      printf("\n");
> >>
> 
> But your are printing (x[len-1] - sum), where  x[len-1]== checksum
> perhaps you wanted to print -sum ? (I assume the "checksum" is just
> the diff to 0).
> 
> INHO the code should be like this:
> 
> exp_chk= x[len -1]; // expected sum
> 
> for (i = 0; i < len-1; i++) sum += x[i];  // real sum, notice len-1
> 
> if (exp_chk+sum != 0 )
> 	printf("expected %02x found 0x02x\"n, 255-exp_chk, sum);
> 
> 

Your way is clearer. v2 patch (following) incorporates this.

I also appreciate the rule-of-silence in your printfs but I prefer to keep
the format of the output unchanged. I think modifications to output
ought to be part of a more general cleanup patch with an obvious version
bump.

Also I'll post the binary EDID patch for testing this feature separately.

-- 
Cognomen Ltd
http://cognomen.co.uk
+44 7855 790184
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <https://lists.x.org/archives/xorg-devel/attachments/20170206/397e0ed6/attachment.sig>


More information about the xorg-devel mailing list