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

[PATCH 5/8] mini-os: apply coding style to consfront.c



Make consfront.c coding style compliant.

Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
---
 consfront.c | 97 +++++++++++++++++++++++++++++------------------------
 1 file changed, 53 insertions(+), 44 deletions(-)

diff --git a/consfront.c b/consfront.c
index 73659656..dfe6a3f0 100644
--- a/consfront.c
+++ b/consfront.c
@@ -15,26 +15,30 @@
 
 void free_consfront(struct consfront_dev *dev)
 {
-    char* err = NULL;
+    char *err = NULL;
     XenbusState state;
-
     char path[strlen(dev->backend) + strlen("/state") + 1];
     char nodename[strlen(dev->nodename) + strlen("/state") + 1];
 
     snprintf(path, sizeof(path), "%s/state", dev->backend);
     snprintf(nodename, sizeof(nodename), "%s/state", dev->nodename);
 
-    if ((err = xenbus_switch_state(XBT_NIL, nodename, XenbusStateClosing)) != 
NULL) {
+    if ( (err = xenbus_switch_state(XBT_NIL, nodename, XenbusStateClosing)) !=
+         NULL )
+    {
         printk("free_consfront: error changing state to %d: %s\n",
                 XenbusStateClosing, err);
         goto close;
     }
+
     state = xenbus_read_integer(path);
-    while (err == NULL && state < XenbusStateClosing)
+    while ( err == NULL && state < XenbusStateClosing )
         err = xenbus_wait_for_state_change(path, &state, &dev->events);
     free(err);
 
-    if ((err = xenbus_switch_state(XBT_NIL, nodename, XenbusStateClosed)) != 
NULL) {
+    if ( (err = xenbus_switch_state(XBT_NIL, nodename, XenbusStateClosed)) !=
+         NULL)
+    {
         printk("free_consfront: error changing state to %d: %s\n",
                 XenbusStateClosed, err);
         goto close;
@@ -59,19 +63,22 @@ close:
 struct consfront_dev *init_consfront(char *_nodename)
 {
     xenbus_transaction_t xbt;
-    char* err = NULL;
-    char* message=NULL;
-    int retry=0;
-    char* msg = NULL;
+    char *err = NULL;
+    char *message = NULL;
+    int retry = 0;
+    char *msg = NULL;
     char nodename[256];
     char path[256];
+    XenbusState state;
     static int consfrontends = 3;
     struct consfront_dev *dev;
     int res;
 
-    if (!_nodename)
-        snprintf(nodename, sizeof(nodename), "device/console/%d", 
consfrontends);
-    else {
+    if ( !_nodename )
+        snprintf(nodename, sizeof(nodename), "device/console/%d",
+                 consfrontends);
+    else
+    {
         strncpy(nodename, _nodename, sizeof(nodename) - 1);
         nodename[sizeof(nodename) - 1] = 0;
     }
@@ -87,13 +94,13 @@ struct consfront_dev *init_consfront(char *_nodename)
 #endif
 
     snprintf(path, sizeof(path), "%s/backend-id", nodename);
-    if ((res = xenbus_read_integer(path)) < 0) 
+    if ( (res = xenbus_read_integer(path)) < 0 )
         goto error;
     else
         dev->dom = res;
     evtchn_alloc_unbound(dev->dom, console_handle_input, dev, &dev->evtchn);
 
-    dev->ring = (struct xencons_interface *) alloc_page();
+    dev->ring = (struct xencons_interface *)alloc_page();
     memset(dev->ring, 0, PAGE_SIZE);
     dev->ring_ref = gnttab_grant_access(dev->dom, virt_to_mfn(dev->ring), 0);
 
@@ -101,33 +108,36 @@ struct consfront_dev *init_consfront(char *_nodename)
 
 again:
     err = xenbus_transaction_start(&xbt);
-    if (err) {
+    if ( err )
+    {
         printk("starting transaction\n");
         free(err);
     }
 
-    err = xenbus_printf(xbt, nodename, "ring-ref","%u",
-                dev->ring_ref);
-    if (err) {
+    err = xenbus_printf(xbt, nodename, "ring-ref","%u", dev->ring_ref);
+    if ( err )
+    {
         message = "writing ring-ref";
         goto abort_transaction;
     }
-    err = xenbus_printf(xbt, nodename,
-                "port", "%u", dev->evtchn);
-    if (err) {
+    err = xenbus_printf(xbt, nodename, "port", "%u", dev->evtchn);
+    if ( err )
+    {
         message = "writing event-channel";
         goto abort_transaction;
     }
-    err = xenbus_printf(xbt, nodename,
-                "protocol", "%s", XEN_IO_PROTO_ABI_NATIVE);
-    if (err) {
+    err = xenbus_printf(xbt, nodename, "protocol", "%s",
+                        XEN_IO_PROTO_ABI_NATIVE);
+    if ( err )
+    {
         message = "writing protocol";
         goto abort_transaction;
     }
 
     snprintf(path, sizeof(path), "%s/state", nodename);
     err = xenbus_switch_state(xbt, path, XenbusStateConnected);
-    if (err) {
+    if ( err )
+    {
         message = "switching state";
         goto abort_transaction;
     }
@@ -135,8 +145,9 @@ again:
 
     err = xenbus_transaction_end(xbt, 0, &retry);
     free(err);
-    if (retry) {
-            goto again;
+    if ( retry )
+    {
+        goto again;
         printk("completing transaction\n");
     }
 
@@ -149,31 +160,28 @@ abort_transaction:
     goto error;
 
 done:
-
     snprintf(path, sizeof(path), "%s/backend", nodename);
     msg = xenbus_read(XBT_NIL, path, &dev->backend);
-    if (msg) {
+    if ( msg )
+    {
         printk("Error %s when reading the backend path %s\n", msg, path);
         goto error;
     }
 
     printk("backend at %s\n", dev->backend);
+    snprintf(path, sizeof(path), "%s/state", dev->backend);
+
+    free(xenbus_watch_path_token(XBT_NIL, path, path, &dev->events));
+    msg = NULL;
+    state = xenbus_read_integer(path);
+    while ( msg == NULL && state < XenbusStateConnected )
+        msg = xenbus_wait_for_state_change(path, &state, &dev->events);
 
+    if ( msg != NULL || state != XenbusStateConnected )
     {
-        XenbusState state;
-        char path[strlen(dev->backend) + strlen("/state") + 1];
-        snprintf(path, sizeof(path), "%s/state", dev->backend);
-        
-       free(xenbus_watch_path_token(XBT_NIL, path, path, &dev->events));
-        msg = NULL;
-        state = xenbus_read_integer(path);
-        while (msg == NULL && state < XenbusStateConnected)
-            msg = xenbus_wait_for_state_change(path, &state, &dev->events);
-        if (msg != NULL || state != XenbusStateConnected) {
-            printk("backend not available, state=%d\n", state);
-            err = xenbus_unwatch_path_token(XBT_NIL, path, path);
-            goto error;
-        }
+        printk("backend not available, state=%d\n", state);
+        err = xenbus_unwatch_path_token(XBT_NIL, path, path);
+        goto error;
     }
     unmask_evtchn(dev->evtchn);
 
@@ -190,7 +198,8 @@ error:
 
 void fini_consfront(struct consfront_dev *dev)
 {
-    if (dev) free_consfront(dev);
+    if ( dev )
+        free_consfront(dev);
 }
 
 #ifdef HAVE_LIBC
-- 
2.35.3




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.