diff options
author | David Sommerseth <davids@redhat.com> | 2010-02-05 20:27:09 +0100 |
---|---|---|
committer | David Sommerseth <davids@redhat.com> | 2010-02-05 20:27:09 +0100 |
commit | 2f943473c302495940e282f0229c1497e1d8c716 (patch) | |
tree | d3f3800ff1e47c35949433244d2ce17a2b8f09fd | |
parent | 5abd4b52f056ba09b1c134870586393a223ccc79 (diff) | |
download | python-dmidecode-2f943473c302495940e282f0229c1497e1d8c716.tar.gz python-dmidecode-2f943473c302495940e282f0229c1497e1d8c716.tar.xz python-dmidecode-2f943473c302495940e282f0229c1497e1d8c716.zip |
Improved DMIerror message tag when decoding is not possible
Plus some minor code style clean up
-rw-r--r-- | src/dmidecode.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/dmidecode.c b/src/dmidecode.c index e64d12f..02dd9b0 100644 --- a/src/dmidecode.c +++ b/src/dmidecode.c @@ -4934,9 +4934,17 @@ static void dmi_table(Log_t *logp, int type, u32 base, u16 len, u16 num, u16 ver } else { handle_n = xmlNewChild(xmlnode, NULL, (xmlChar *) "DMIerror", NULL); assert( handle_n != NULL ); - dmixml_AddTextContent(handle_n, "Data is truncated"); + dmixml_AddTextContent(handle_n, "Data is truncated %i bytes on type 0x%02X", + (next - buf - len), h.type); dmixml_AddAttribute(handle_n, "type", "%i", h.type); dmixml_AddAttribute(handle_n, "truncated", "1"); + dmixml_AddAttribute(handle_n, "length", "%i", (next - buf)); + dmixml_AddAttribute(handle_n, "expected_length", "%i", len); + + log_append(logp, LOGFL_NODUPS, LOG_WARNING, + "DMI/SMBIOS type 0x%02X is exceeding the expected buffer " + "size by %i bytes. Will not decode this entry.", + h.type, (next - buf - len)); } dmixml_AddAttribute(handle_n, "handle", "0x%04x", h.handle); dmixml_AddAttribute(handle_n, "size", "%d", h.length); @@ -4955,14 +4963,16 @@ static void dmi_table(Log_t *logp, int type, u32 base, u16 len, u16 num, u16 ver dmixml_AddAttribute(handle_n, "notfound", "1"); } - if(i != num) + if(i != num) { + log_append(logp, LOGFL_NODUPS, LOG_WARNING, + "Wrong DMI structures count: %d announced, only %d decoded.", num, i); + } + + if(data - buf != len) { log_append(logp, LOGFL_NODUPS, LOG_WARNING, - "Wrong DMI structures count: %d announced, only %d decoded.", num, i); - if(data - buf != len) - log_append(logp, LOGFL_NODUPS, LOG_WARNING, "Wrong DMI structures length: %d bytes announced, structures occupy %d bytes.", len, (unsigned int)(data - buf)); - + } free(buf); } |