提交 e756333d 编写于 作者: S Sri Ramanujam 提交者: Matthias Bolte

hyperv: Silence clang alignment warnings in serialization code

Slight refactor of the WMI serialization code to minimize mixing
openwsman and libxml2 APIs that triggered clang alignment warnings.

The only usage of libxml2 APIs now is in creating CDATA blocks,
because the openwsman API does not provide that functionality. The
clang alignment warning in this case is silenced by casting to a
void pointer first.
上级 97197ce2
...@@ -489,17 +489,14 @@ hypervSerializeSimpleParam(hypervParamPtr p, const char *resourceUri, ...@@ -489,17 +489,14 @@ hypervSerializeSimpleParam(hypervParamPtr p, const char *resourceUri,
static int static int
hypervSerializeEprParam(hypervParamPtr p, hypervPrivate *priv, hypervSerializeEprParam(hypervParamPtr p, hypervPrivate *priv,
const char *resourceUri, WsXmlDocH doc, WsXmlNodeH *methodNode) const char *resourceUri, WsXmlNodeH *methodNode)
{ {
int result = -1; int result = -1;
WsXmlNodeH xmlNodeParam = NULL, WsXmlNodeH xmlNodeParam = NULL,
xmlNodeTemp = NULL, xmlNodeTemp = NULL,
xmlNodeAddr = NULL, xmlNodeAddr = NULL,
xmlNodeRef = NULL; xmlNodeRef = NULL;
xmlNodePtr xmlNodeAddrPtr = NULL,
xmlNodeRefPtr = NULL;
WsXmlDocH xmlDocResponse = NULL; WsXmlDocH xmlDocResponse = NULL;
xmlDocPtr docPtr = (xmlDocPtr) doc->parserDoc;
WsXmlNsH ns = NULL; WsXmlNsH ns = NULL;
client_opt_t *options = NULL; client_opt_t *options = NULL;
filter_t *filter = NULL; filter_t *filter = NULL;
...@@ -573,11 +570,6 @@ hypervSerializeEprParam(hypervParamPtr p, hypervPrivate *priv, ...@@ -573,11 +570,6 @@ hypervSerializeEprParam(hypervParamPtr p, hypervPrivate *priv,
goto cleanup; goto cleanup;
} }
if (!(xmlNodeAddrPtr = xmlDocCopyNode((xmlNodePtr) xmlNodeAddr, docPtr, 1))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Could not copy EPR address"));
goto cleanup;
}
if (!(xmlNodeRef = ws_xml_get_child(xmlNodeTemp, 0, XML_NS_ADDRESSING, if (!(xmlNodeRef = ws_xml_get_child(xmlNodeTemp, 0, XML_NS_ADDRESSING,
WSA_REFERENCE_PARAMETERS))) { WSA_REFERENCE_PARAMETERS))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
...@@ -585,17 +577,11 @@ hypervSerializeEprParam(hypervParamPtr p, hypervPrivate *priv, ...@@ -585,17 +577,11 @@ hypervSerializeEprParam(hypervParamPtr p, hypervPrivate *priv,
goto cleanup; goto cleanup;
} }
if (!(xmlNodeRefPtr = xmlDocCopyNode((xmlNodePtr) xmlNodeRef, docPtr, 1))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Could not copy EPR item reference parameters"));
goto cleanup;
}
/* now build a new xml doc with the EPR node children */ /* now build a new xml doc with the EPR node children */
if (!(xmlNodeParam = ws_xml_add_child(*methodNode, resourceUri, if (!(xmlNodeParam = ws_xml_add_child(*methodNode, resourceUri,
p->epr.name, NULL))) { p->epr.name, NULL))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Could not add child node to xmlNodeParam")); _("Could not add child node to methodNode"));
goto cleanup; goto cleanup;
} }
...@@ -613,23 +599,8 @@ hypervSerializeEprParam(hypervParamPtr p, hypervPrivate *priv, ...@@ -613,23 +599,8 @@ hypervSerializeEprParam(hypervParamPtr p, hypervPrivate *priv,
goto cleanup; goto cleanup;
} }
if (xmlAddChild((xmlNodePtr) *methodNode, (xmlNodePtr) xmlNodeParam) == NULL) { ws_xml_duplicate_tree(xmlNodeParam, xmlNodeAddr);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", ws_xml_duplicate_tree(xmlNodeParam, xmlNodeRef);
_("Could not add child to xml parent node"));
goto cleanup;
}
if (xmlAddChild((xmlNodePtr) xmlNodeParam, xmlNodeAddrPtr) == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Could not add child to xml parent node"));
goto cleanup;
}
if (xmlAddChild((xmlNodePtr) xmlNodeParam, xmlNodeRefPtr) == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Could not add child to xml parent node"));
goto cleanup;
}
/* we did it! */ /* we did it! */
result = 0; result = 0;
...@@ -656,8 +627,7 @@ hypervSerializeEmbeddedParam(hypervParamPtr p, const char *resourceUri, ...@@ -656,8 +627,7 @@ hypervSerializeEmbeddedParam(hypervParamPtr p, const char *resourceUri,
xmlNodeArray = NULL; xmlNodeArray = NULL;
WsXmlDocH xmlDocTemp = NULL, WsXmlDocH xmlDocTemp = NULL,
xmlDocCdata = NULL; xmlDocCdata = NULL;
xmlBufferPtr xmlBufferNode = NULL; char *cdataContent = NULL;
const xmlChar *xmlCharCdataContent = NULL;
xmlNodePtr xmlNodeCdata = NULL; xmlNodePtr xmlNodeCdata = NULL;
hypervWmiClassInfoPtr classInfo = p->embedded.info; hypervWmiClassInfoPtr classInfo = p->embedded.info;
virHashKeyValuePairPtr items = NULL; virHashKeyValuePairPtr items = NULL;
...@@ -761,25 +731,22 @@ hypervSerializeEmbeddedParam(hypervParamPtr p, const char *resourceUri, ...@@ -761,25 +731,22 @@ hypervSerializeEmbeddedParam(hypervParamPtr p, const char *resourceUri,
} }
/* create CDATA node */ /* create CDATA node */
xmlBufferNode = xmlBufferCreate(); ws_xml_dump_memory_node_tree(xmlNodeInstance, &cdataContent, &len);
if (xmlNodeDump(xmlBufferNode, (xmlDocPtr) xmlDocTemp->parserDoc,
(xmlNodePtr) xmlNodeInstance, 0, 0) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Could not get root of temp XML doc"));
goto cleanup;
}
len = xmlBufferLength(xmlBufferNode);
xmlCharCdataContent = xmlBufferContent(xmlBufferNode);
if (!(xmlNodeCdata = xmlNewCDataBlock((xmlDocPtr) xmlDocCdata, if (!(xmlNodeCdata = xmlNewCDataBlock((xmlDocPtr) xmlDocCdata,
xmlCharCdataContent, len))) { (xmlChar *)cdataContent, len))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Could not create CDATA element")); _("Could not create CDATA element"));
goto cleanup; goto cleanup;
} }
/* Add CDATA node to the doc root */ /*
if (!(xmlAddChild((xmlNodePtr) xmlNodeParam, xmlNodeCdata))) { * Add CDATA node to the doc root
*
* FIXME: there is no openwsman wrapper for xmlNewCDataBlock, so instead
* silence clang alignment warnings by casting to a void pointer first
*/
if (!(xmlAddChild((xmlNodePtr)(void *)xmlNodeParam, xmlNodeCdata))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Could not add CDATA to doc root")); _("Could not add CDATA to doc root"));
goto cleanup; goto cleanup;
...@@ -792,7 +759,7 @@ hypervSerializeEmbeddedParam(hypervParamPtr p, const char *resourceUri, ...@@ -792,7 +759,7 @@ hypervSerializeEmbeddedParam(hypervParamPtr p, const char *resourceUri,
VIR_FREE(items); VIR_FREE(items);
ws_xml_destroy_doc(xmlDocCdata); ws_xml_destroy_doc(xmlDocCdata);
ws_xml_destroy_doc(xmlDocTemp); ws_xml_destroy_doc(xmlDocTemp);
xmlBufferFree(xmlBufferNode); ws_xml_free_memory(cdataContent);
return result; return result;
} }
...@@ -854,7 +821,7 @@ hypervInvokeMethod(hypervPrivate *priv, hypervInvokeParamsListPtr params, ...@@ -854,7 +821,7 @@ hypervInvokeMethod(hypervPrivate *priv, hypervInvokeParamsListPtr params,
break; break;
case HYPERV_EPR_PARAM: case HYPERV_EPR_PARAM:
if (hypervSerializeEprParam(p, priv, params->resourceUri, if (hypervSerializeEprParam(p, priv, params->resourceUri,
paramsDocRoot, &methodNode) < 0) &methodNode) < 0)
goto cleanup; goto cleanup;
break; break;
case HYPERV_EMBEDDED_PARAM: case HYPERV_EMBEDDED_PARAM:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册