Skip to content

Commit

Permalink
Print what the checksum should be when it's wrong.
Browse files Browse the repository at this point in the history
  • Loading branch information
nwnk committed Oct 16, 2008
1 parent d46102f commit 94ad028
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions edid-decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ static int has_name_descriptor = 0;
static int name_descriptor_terminated = 0;
static int has_range_descriptor = 0;
static int has_preferred_timing = 0;
static int has_valid_checksum = 0;
static int has_valid_checksum = 1;
static int has_valid_cvt = 1;
static int has_valid_dummy_block = 1;
static int has_valid_week = 0;
Expand Down Expand Up @@ -398,14 +398,18 @@ detailed_block(unsigned char *x, int in_extension)
static void
do_checksum(unsigned char *x)
{
printf("Checksum: 0x%hx\n", x[0x7f]);
printf("Checksum: 0x%hx", x[0x7f]);
{
unsigned char sum = 0;
int i;
for (i = 0; i < 128; i++)
sum += x[i];
has_valid_checksum = !sum;
if (sum) {
printf(" (should be 0x%hx)", (unsigned char)(x[0x7f] - sum));
has_valid_checksum = 0;
}
}
printf("\n");
}

/* CEA extension */
Expand Down

0 comments on commit 94ad028

Please sign in to comment.