diff options
author | Burt P <pburt0@gmail.com> | 2019-08-19 23:09:51 -0500 |
---|---|---|
committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2019-08-22 23:10:17 +0200 |
commit | a688b9caa64c1a75c8d151fa58ca74a94afe0d85 (patch) | |
tree | f4396d70cf2415eae0ff6bd58fb1802c88a4c7d3 | |
parent | 9e76aac27ea1a5ce8d40a087054adf08f80ad262 (diff) |
util_edid: allow hex dump of sizes not a multiple of 16
Signed-off-by: Burt P <pburt0@gmail.com>
-rw-r--r-- | deps/sysobj_early/src/util_edid.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/deps/sysobj_early/src/util_edid.c b/deps/sysobj_early/src/util_edid.c index 7c9f9a05..2aa595fa 100644 --- a/deps/sysobj_early/src/util_edid.c +++ b/deps/sysobj_early/src/util_edid.c @@ -498,7 +498,7 @@ edid *edid_new_from_hex(const char *hex_string) { char *edid_dump_hex(edid *e, int tabs, int breaks) { if (!e) return NULL; - int lines = e->len / 16; + int lines = 1 + (e->len / 16); int blen = lines * 35 + 1; unsigned int pc = 0; char *ret = malloc(blen); @@ -506,10 +506,11 @@ char *edid_dump_hex(edid *e, int tabs, int breaks) { uint8_t *u8 = e->u8; char *p = ret; for(; lines; lines--) { - int i; + int i, d = MIN(16, (e->len - pc)); + if (!d) break; for(i = 0; i < tabs; i++) sprintf(p++, "\t"); - for(i = 0; i < 16; i++) { + for(i = d; i; i--) { sprintf(p, "%02x", (unsigned int)*u8); p+=2; u8++; @@ -707,8 +708,6 @@ char *edid_cea_speaker_allocation_describe(int bitfield, int short_version) { char *edid_cea_block_describe(struct edid_cea_block *blk) { gchar *ret = NULL; - gchar *tmp[3] = {}; - if (blk) { char *hb = hex_bytes(blk->header.ptr, blk->header.len+1); switch(blk->header.type) { |