summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dmidecode.c4
-rw-r--r--src/dmixml.c24
2 files changed, 21 insertions, 7 deletions
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);