OCamlPro / owi

WebAssembly Swissknife & cross-language bugfinder
https://ocamlpro.github.io/owi/
GNU Affero General Public License v3.0
137 stars 18 forks source link

libdisplay-info fixes #457

Open emersion opened 6 days ago

emersion commented 6 days ago

A bunch of fixes to make owi work with libdisplay-info.

Test with:

owi c -I include/ *.c di-edid-decode/*.c

It reached the owi_assert(0) in the patch below after 27 minutes of execution time.

libdisplay-info patch ```diff diff --git a/di-edid-decode/main.c b/di-edid-decode/main.c index bb3d9e7e0999..78d3265548a4 100644 --- a/di-edid-decode/main.c +++ b/di-edid-decode/main.c @@ -3,20 +3,22 @@ #include #include #include -#include +//#include #include #include #include +#include + #include "di-edid-decode.h" struct uncommon_features uncommon_features = {0}; -static const struct option long_options[] = { +/*static const struct option long_options[] = { { "help", no_argument, 0, 'h' }, { 0, 0, 0, 0 } -}; +};*/ static void usage(void) { @@ -95,7 +97,8 @@ main(int argc, char *argv[]) in = stdin; while (1) { int option_index = 0; - opt = getopt_long(argc, argv, "h", long_options, &option_index); + //opt = getopt_long(argc, argv, "h", long_options, &option_index); + opt = getopt(argc, argv, "h"); if (opt == -1) break; @@ -117,7 +120,7 @@ main(int argc, char *argv[]) } } - while (!feof(in)) { + /*while (!feof(in)) { size += fread(&raw[size], 1, sizeof(raw) - size, in); if (ferror(in)) { perror("fread failed"); @@ -128,7 +131,12 @@ main(int argc, char *argv[]) } } - fclose(in); + fclose(in);*/ + + size = 128; + for (size_t i = 0; i < size; i++) { + raw[i] = owi_char(); + } info = di_info_parse_edid(raw, size); if (!info) { diff --git a/edid.c b/edid.c index 2383fa91e9f2..716d46f1ff41 100644 --- a/edid.c +++ b/edid.c @@ -4,6 +4,8 @@ #include #include +#include + #include "bits.h" #include "dmt.h" #include "edid.h" @@ -337,9 +339,9 @@ parse_standard_timing(struct di_edid *edid, return true; } if (data[0] == 0x00) { - add_failure_until(edid, 4, + /*add_failure_until(edid, 4, "Use 0x0101 as the invalid Standard Timings code, not 0x%02x%02x.", - data[0], data[1]); + data[0], data[1]);*/ return true; } @@ -1275,6 +1277,8 @@ _di_edid_parse(const void *data, size_t size, FILE *failure_msg_file) } } + owi_assert(0); + for (i = 0; i < EDID_BYTE_DESCRIPTOR_COUNT; i++) { byte_desc_data = (const uint8_t *) data + 0x36 + i * EDID_BYTE_DESCRIPTOR_SIZE; ```

I also had to add #define __ASSERT_FUNCTION NULL otherwise it would fail compilation because it's undefined.

zapashcanon commented 6 days ago

Thanks for the various patches!

It reached the owi_assert(0) in the patch below after 27 minutes of execution time.

Great! This is a little bit long. I'm going to see if I can make this faster. Have you tried to push it further ?

zapashcanon commented 6 days ago
+   size = 128;

I have a question regarding the initial size. 128 is the maximum allowed size, right? What is the minimum one? It could help a lot to use a smaller one for my investigation in order to reduce execution time.

emersion commented 6 days ago

128 is the minimum valid size for an EDID blob. To expand on this a bit: an EDID blob is made up of 1 or more blocks, and each block takes 128 bytes.