2011/4/14 Eric Blake <eblake(a)redhat.com>:
Rather than copying and pasting lots of code, factor it into a
single helper function.
* src/phyp/phyp_driver.c (phypExecInt): New function.
(phypGetVIOSPartitionID, phypNumDomainsGeneric, phypGetLparID)
(phypGetLparMem, phypGetLparCPUGeneric, phypGetRemoteSlot)
(phypGetVIOSNextSlotNumber, phypAttachDevice)
(phypGetStoragePoolSize, phypStoragePoolNumOfVolumes)
(phypNumOfStoragePools, phypInterfaceDestroy)
(phypInterfaceDefineXML, phypInterfaceLookupByName)
(phypInterfaceIsActive, phypNumOfInterfaces): Use it.
---
src/phyp/phyp_driver.c | 316 ++++++++++--------------------------------------
1 files changed, 67 insertions(+), 249 deletions(-)
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index bc24b76..98d5cd6 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -228,6 +228,26 @@ phypExecBuffer(LIBSSH2_SESSION *session, virBufferPtr buf, int
*exit_status,
return ret;
}
+/* Convenience wrapper function */
+static int phypExecInt(LIBSSH2_SESSION *, virBufferPtr, virConnectPtr, int *)
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);
+static int
+phypExecInt(LIBSSH2_SESSION *session, virBufferPtr buf, virConnectPtr conn,
+ int *result)
+{
+ char *str;
+ int ret;
+
+ str = phypExecBuffer(session, buf, &ret, conn, true);
+ if (!str || ret) {
+ VIR_FREE(str);
+ return -1;
+ }
+ ret = virStrToLong_i(str, NULL, 10, result);
You made the parsing stricter by passing NULL as second argument to
virStrToLong_i. I don't expect it but this might be possible that this
breaks the behavior of the driver.
+ VIR_FREE(str);
+ return ret;
+}
+
The rest of the patch looks fine.
Matthias