diff options
-rw-r--r-- | contrib/python-dmidecode.spec | 2 | ||||
-rwxr-xr-x | examples/dmidump.py | 10 | ||||
-rw-r--r-- | src/dmidecode.c | 4 | ||||
-rw-r--r-- | src/dmixml.c | 24 |
4 files changed, 27 insertions, 13 deletions
diff --git a/contrib/python-dmidecode.spec b/contrib/python-dmidecode.spec index da818e4..1645bc1 100644 --- a/contrib/python-dmidecode.spec +++ b/contrib/python-dmidecode.spec @@ -31,7 +31,7 @@ cd .. %install rm -rf $RPM_BUILD_ROOT -python src/setup.py install --root $RPM_BUILD_ROOT +python src/setup.py install --root $RPM_BUILD_ROOT --prefix=%{_prefix} %clean rm -rf $RPM_BUILD_ROOT diff --git a/examples/dmidump.py b/examples/dmidump.py index 977504f..11b04ff 100755 --- a/examples/dmidump.py +++ b/examples/dmidump.py @@ -55,14 +55,16 @@ if not root_user: print -#. Test all functions using /dev/mem... Using the legacy API +#. Test for presence of important functions using /dev/mem... Using the legacy API +#. This does not print any decoded info. If the call fails, either a warning will +#. be issued or an exception will be raised. This test is now only used to check +#. for presence of the legacy API, which "under the hood" uses +#. dmidecode.QuerySection(name), where name can be 'bios', 'system', etc. if root_user: print "*** bios ***\n"; dmidecode.bios() print_warnings() print "*** system ***\n"; dmidecode.system() print_warnings() - print "*** system ***\n"; dmidecode.system() - print_warnings() print "*** baseboard ***\n"; dmidecode.baseboard() print_warnings() print "*** chassis ***\n"; dmidecode.chassis() @@ -101,8 +103,6 @@ print "*** bios ***\n"; pprint(dmidecode.QuerySection('bios')) print_warnings() print "*** system ***\n"; pprint(dmidecode.QuerySection('system')) print_warnings() -print "*** system ***\n"; pprint(dmidecode.QuerySection('system')) -print_warnings() print "*** baseboard ***\n"; pprint(dmidecode.QuerySection('baseboard')) print_warnings() print "*** chassis ***\n"; pprint(dmidecode.QuerySection('chassis')) diff --git a/src/dmidecode.c b/src/dmidecode.c index 02dd9b0..b89c163 100644 --- a/src/dmidecode.c +++ b/src/dmidecode.c @@ -4890,8 +4890,8 @@ static void dmi_table(Log_t *logp, int type, u32 base, u16 len, u16 num, u16 ver */ if(h.length < 4) { log_append(logp, LOGFL_NORMAL, LOG_WARNING, - "Invalid entry length (%i). DMI table is broken! Stop.", - (unsigned int)h.length); + "Invalid entry length (%i) for type %i. DMI table is broken! Stop.", + (unsigned int)h.length, type); break; } diff --git a/src/dmixml.c b/src/dmixml.c index ba285e8..3b05ad4 100644 --- a/src/dmixml.c +++ b/src/dmixml.c @@ -92,13 +92,18 @@ xmlAttr *dmixml_AddAttribute(xmlNode *node, const char *atrname, const char *fmt xmlAttr *res = NULL; va_list ap; - if( (node == NULL) || (atrname == NULL) || (fmt == NULL) ) { + if( (node == NULL) || (atrname == NULL) ) { return NULL; } atrname_s = xmlCharStrdup(atrname); assert( atrname_s != NULL ); + if( fmt == NULL ) { + res = xmlNewProp(node, atrname_s, NULL); + goto exit; + } + va_start(ap, fmt); val_s = dmixml_buildstr(2048, fmt, ap); va_end(ap); @@ -106,8 +111,9 @@ xmlAttr *dmixml_AddAttribute(xmlNode *node, const char *atrname, const char *fmt res = xmlNewProp(node, atrname_s, (xmlStrcmp(val_s, (xmlChar *) "(null)") == 0 ? NULL : val_s)); - free(atrname_s); free(val_s); + exit: + free(atrname_s); assert( res != NULL ); return res; @@ -129,13 +135,18 @@ xmlNode *dmixml_AddTextChild(xmlNode *node, const char *tagname, const char *fmt xmlNode *res = NULL; va_list ap; - if( (node == NULL) || (tagname == NULL) || (fmt == NULL) ) { + if( (node == NULL) || (tagname == NULL) ) { return NULL; } tagname_s = xmlCharStrdup(tagname); assert( tagname_s != NULL ); + if( fmt == NULL ) { + res = xmlNewChild(node, NULL, tagname_s, NULL); + goto exit; + } + va_start(ap, fmt); val_s = dmixml_buildstr(2048, fmt, ap); va_end(ap); @@ -144,8 +155,9 @@ xmlNode *dmixml_AddTextChild(xmlNode *node, const char *tagname, const char *fmt res = xmlNewTextChild(node, NULL, tagname_s, (xmlStrcmp(val_s, (xmlChar *) "(null)") == 0 ? NULL : val_s)); - free(tagname_s); free(val_s); + exit: + free(tagname_s); assert( res != NULL ); return res; @@ -165,7 +177,9 @@ xmlNode *dmixml_AddTextContent(xmlNode *node, const char *fmt, ...) va_list ap; if( (node == NULL) || (fmt == NULL) ) { - return NULL; + // Return node and not NULL, as node may not be NULL but fmt can be, + // thus doing a similar string check (val_s != "(null)") as later on + return node; } va_start(ap, fmt); |