[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 02/11] xs: Code cleanup



Housekeeping kind of stuff.
---
 src/xen/xs_internal.c | 108 +++++++++++++++++++++-----------------------------
 1 file changed, 45 insertions(+), 63 deletions(-)

diff --git a/src/xen/xs_internal.c b/src/xen/xs_internal.c
index 573c0c6..f823dfc 100644
--- a/src/xen/xs_internal.c
+++ b/src/xen/xs_internal.c
@@ -83,14 +83,10 @@ struct xenUnifiedDriver xenStoreDriver = {
  * Returns a string which must be freed by the caller or NULL in case of error
  */
 static char **
-virConnectDoStoreList(virConnectPtr conn, const char *path,
-                      unsigned int *nb)
+virConnectDoStoreList(virConnectPtr conn, const char *path, unsigned int *nb)
 {
     xenUnifiedPrivatePtr priv = (xenUnifiedPrivatePtr) conn->privateData;
 
-    if (priv->xshandle == NULL || path == NULL || nb == NULL)
-        return NULL;
-
     return xs_directory(priv->xshandle, 0, path, nb);
 }
 
@@ -131,12 +127,10 @@ virDomainDoStoreQuery(virConnectPtr conn, int domid, const char *path)
  * Returns 0 in case of success, -1 in case of failure
  */
 static int
-virDomainDoStoreWrite(virDomainPtr domain, const char *path,
-                      const char *value)
+virDomainDoStoreWrite(virDomainPtr domain, const char *path, const char *value)
 {
     char s[256];
-    xenUnifiedPrivatePtr priv =
-        (xenUnifiedPrivatePtr) domain->conn->privateData;
+    xenUnifiedPrivatePtr priv = (xenUnifiedPrivatePtr)domain->conn->privateData;
     int ret = -1;
 
     if (priv->xshandle == NULL || domain->conn->flags & VIR_CONNECT_RO)
@@ -165,8 +159,7 @@ virDomainGetVM(virDomainPtr domain)
     char *vm;
     char query[200];
     unsigned int len;
-    xenUnifiedPrivatePtr priv =
-        (xenUnifiedPrivatePtr) domain->conn->privateData;
+    xenUnifiedPrivatePtr priv = (xenUnifiedPrivatePtr)domain->conn->privateData;
 
     if (priv->xshandle == NULL)
         return NULL;
@@ -402,9 +395,7 @@ xenStoreGetDomainInfo(virDomainPtr domain, virDomainInfoPtr info)
  * Returns 0 in case of success, -1 in case of error.
  */
 int
-xenStoreDomainGetState(virDomainPtr domain,
-                       int *state,
-                       int *reason,
+xenStoreDomainGetState(virDomainPtr domain, int *state, int *reason,
                        unsigned int flags)
 {
     char *running;
@@ -540,7 +531,8 @@ out:
  * Returns the number of domain found or -1 in case of error
  */
 static int
-xenStoreDoListDomains(virConnectPtr conn, xenUnifiedPrivatePtr priv, int *ids, int maxids)
+xenStoreDoListDomains(virConnectPtr conn, xenUnifiedPrivatePtr priv, int *ids,
+                      int maxids)
 {
     char **idlist = NULL, *endptr;
     unsigned int num, i;
@@ -726,7 +718,8 @@ xenStoreDomainReboot(virDomainPtr domain, unsigned int flags)
  *         freed by the caller.
  */
 static char *
-xenStoreDomainGetOSType(virDomainPtr domain) {
+xenStoreDomainGetOSType(virDomainPtr domain)
+{
     char *vm, *str = NULL;
 
     vm = virDomainGetVM(domain);
@@ -755,7 +748,9 @@ xenStoreDomainGetOSType(virDomainPtr domain) {
  *
  * Returns the port number, -1 in case of error
  */
-int             xenStoreDomainGetVNCPort(virConnectPtr conn, int domid) {
+int
+xenStoreDomainGetVNCPort(virConnectPtr conn, int domid)
+{
     char *tmp;
     int ret = -1;
 
@@ -785,7 +780,9 @@ int             xenStoreDomainGetVNCPort(virConnectPtr conn, int domid) {
  * The caller must hold the lock on the privateData
  * associated with the 'conn' parameter.
  */
-char *          xenStoreDomainGetConsolePath(virConnectPtr conn, int domid) {
+char *
+xenStoreDomainGetConsolePath(virConnectPtr conn, int domid)
+{
   return virDomainDoStoreQuery(conn, domid, "console/tty");
 }
 
@@ -804,7 +801,9 @@ char *          xenStoreDomainGetConsolePath(virConnectPtr conn, int domid) {
  * The caller must hold the lock on the privateData
  * associated with the 'conn' parameter.
  */
-char * xenStoreDomainGetSerialConsolePath(virConnectPtr conn, int domid) {
+char *
+xenStoreDomainGetSerialConsolePath(virConnectPtr conn, int domid)
+{
     return virDomainDoStoreQuery(conn, domid, "serial/0/tty");
 }
 
@@ -825,17 +824,14 @@ char * xenStoreDomainGetSerialConsolePath(virConnectPtr conn, int domid) {
  *         freed by the caller.
  */
 char *
-xenStoreDomainGetNetworkID(virConnectPtr conn, int id, const char *mac) {
+xenStoreDomainGetNetworkID(virConnectPtr conn, int id, const char *mac)
+{
     char dir[80], path[128], **list = NULL, *val = NULL;
     unsigned int len, i, num;
     char *ret = NULL;
     xenUnifiedPrivatePtr priv = (xenUnifiedPrivatePtr) conn->privateData;
 
-    if (id < 0)
-        return NULL;
-    if (priv->xshandle == NULL)
-        return NULL;
-    if (mac == NULL)
+    if (id < 0 || priv->xshandle == NULL || mac == NULL)
         return NULL;
 
     snprintf(dir, sizeof(dir), "/local/domain/0/backend/vif/%d", id);
@@ -881,17 +877,14 @@ xenStoreDomainGetNetworkID(virConnectPtr conn, int id, const char *mac) {
  *         freed by the caller.
  */
 char *
-xenStoreDomainGetDiskID(virConnectPtr conn, int id, const char *dev) {
+xenStoreDomainGetDiskID(virConnectPtr conn, int id, const char *dev)
+{
     char dir[80], path[128], **list = NULL, *val = NULL;
     unsigned int devlen, len, i, num;
     char *ret = NULL;
     xenUnifiedPrivatePtr priv = (xenUnifiedPrivatePtr) conn->privateData;
 
-    if (id < 0)
-        return NULL;
-    if (priv->xshandle == NULL)
-        return NULL;
-    if (dev == NULL)
+    if (id < 0 || priv->xshandle == NULL || dev == NULL)
         return NULL;
     devlen = strlen(dev);
     if (devlen <= 0)
@@ -969,11 +962,7 @@ xenStoreDomainGetPCIID(virConnectPtr conn, int id, const char *bdf)
     char *ret = NULL;
     xenUnifiedPrivatePtr priv = (xenUnifiedPrivatePtr) conn->privateData;
 
-    if (id < 0)
-        return NULL;
-    if (priv->xshandle == NULL)
-        return NULL;
-    if (bdf == NULL)
+    if (id < 0 || priv->xshandle == NULL || bdf == NULL)
         return NULL;
 
     snprintf(dir, sizeof(dir), "/local/domain/0/backend/pci/%d", id);
@@ -1003,8 +992,9 @@ xenStoreDomainGetPCIID(virConnectPtr conn, int id, const char *bdf)
  * The caller must hold the lock on the privateData
  * associated with the 'conn' parameter.
  */
-char *xenStoreDomainGetName(virConnectPtr conn,
-                            int id) {
+char *
+xenStoreDomainGetName(virConnectPtr conn, int id)
+{
     char prop[200];
     xenUnifiedPrivatePtr priv = (xenUnifiedPrivatePtr) conn->privateData;
     unsigned int len;
@@ -1021,9 +1011,9 @@ char *xenStoreDomainGetName(virConnectPtr conn,
  * The caller must hold the lock on the privateData
  * associated with the 'conn' parameter.
  */
-int xenStoreDomainGetUUID(virConnectPtr conn,
-                          int id,
-                          unsigned char *uuid) {
+int
+xenStoreDomainGetUUID(virConnectPtr conn, int id, unsigned char *uuid)
+{
     char prop[200];
     xenUnifiedPrivatePtr priv = (xenUnifiedPrivatePtr) conn->privateData;
     unsigned int len;
@@ -1066,11 +1056,9 @@ xenStoreWatchListFree(xenStoreWatchListPtr list)
  * The caller must hold the lock on the privateData
  * associated with the 'conn' parameter.
  */
-int xenStoreAddWatch(virConnectPtr conn,
-                     const char *path,
-                     const char *token,
-                     xenStoreWatchCallback cb,
-                     void *opaque)
+int
+xenStoreAddWatch(virConnectPtr conn, const char *path, const char *token,
+                 xenStoreWatchCallback cb, void *opaque)
 {
     xenStoreWatchPtr watch = NULL;
     int n;
@@ -1133,9 +1121,8 @@ int xenStoreAddWatch(virConnectPtr conn,
  * The caller must hold the lock on the privateData
  * associated with the 'conn' parameter.
  */
-int xenStoreRemoveWatch(virConnectPtr conn,
-                        const char *path,
-                        const char *token)
+int
+xenStoreRemoveWatch(virConnectPtr conn, const char *path, const char *token)
 {
     int i;
     xenStoreWatchListPtr list;
@@ -1182,8 +1169,7 @@ int xenStoreRemoveWatch(virConnectPtr conn,
 }
 
 static xenStoreWatchPtr
-xenStoreFindWatch(xenStoreWatchListPtr list,
-                  const char *path,
+xenStoreFindWatch(xenStoreWatchListPtr list, const char *path,
                   const char *token)
 {
     int i;
@@ -1196,10 +1182,8 @@ xenStoreFindWatch(xenStoreWatchListPtr list,
 }
 
 static void
-xenStoreWatchEvent(int watch ATTRIBUTE_UNUSED,
-                   int fd ATTRIBUTE_UNUSED,
-                   int events,
-                   void *data)
+xenStoreWatchEvent(int watch ATTRIBUTE_UNUSED, int fd ATTRIBUTE_UNUSED,
+                   int events, void *data)
 {
     char		 **event;
     char		 *path;
@@ -1242,10 +1226,9 @@ cleanup:
  *
  * The lock on 'priv' is held when calling this
  */
-int xenStoreDomainIntroduced(virConnectPtr conn,
-                             const char *path ATTRIBUTE_UNUSED,
-                             const char *token ATTRIBUTE_UNUSED,
-                             void *opaque)
+int
+xenStoreDomainIntroduced(virConnectPtr conn, const char *path ATTRIBUTE_UNUSED,
+                         const char *token ATTRIBUTE_UNUSED, void *opaque)
 {
     int i, j, found, missing = 0, retries = 20;
     int new_domain_cnt;
@@ -1323,10 +1306,9 @@ retry:
  *
  * The lock on 'priv' is held when calling this
  */
-int xenStoreDomainReleased(virConnectPtr conn,
-                            const char *path  ATTRIBUTE_UNUSED,
-                            const char *token ATTRIBUTE_UNUSED,
-                            void *opaque)
+int
+xenStoreDomainReleased(virConnectPtr conn, const char *path  ATTRIBUTE_UNUSED,
+                       const char *token ATTRIBUTE_UNUSED, void *opaque)
 {
     int i, j, found, removed, retries = 20;
     int new_domain_cnt;
-- 
1.7.11.7


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]