Skip to contentSkip to conversation

correctly handle errors in libxc

PATCH New aq 1 participant 1 message Jun 5, 2005

lore
Share & tools
lore

aq

author
#0 lore raw

PATCH 1/1 correctly handle errors in libxc

This patch (against -unstable [email protected]) prints to stderr (instead of stdout) when some functions in xc_evtchn.c and xc_gnttab.c fail.

$ diffstat fix1.patch 
 xc_evtchn.c |   11 ++++++-----
 xc_gnttab.c |   12 +++++-------
 2 files changed, 11 insertions(+), 12 deletions(-)

===== tools/libxc/xc_evtchn.c 1.8 vs edited =====

tools/libxc/xc_evtchn.c +6 -5
@@ -20,14 +20,15 @@
     if ( mlock(op, sizeof(*op)) != 0 )
     {
         PERROR("Could not lock memory for Xen hypercall");
-        goto out1;
+        goto out;
     }
 
-    if ( (ret = do_xen_hypercall(xc_handle, &hypercall)) < 0 )
-        goto out2;
+    if ((ret = do_xen_hypercall(xc_handle, &hypercall)) < 0)
+            fprintf(stderr, "Channel operation failed.\n");
 
- out2: (void)munlock(op, sizeof(*op));
- out1: return ret;
+    (void)munlock(op, sizeof(*op));
+out: 
+    return ret;
 }
 
 

===== tools/libxc/xc_gnttab.c 1.1 vs edited =====

tools/libxc/xc_gnttab.c +5 -7
@@ -27,17 +27,15 @@
     if ( mlock(op, sizeof(*op)) != 0 )
     {
         PERROR("Could not lock memory for Xen hypercall");
-        goto out1;
+        goto out;
     }
 
     if ( (ret = do_xen_hypercall(xc_handle, &hypercall)) < 0 )
-    {
-        printf("do_gnttab_op: hypercall returned error %d\n", ret);
-        goto out2;
-    }
+        fprintf(stderr, "do_gnttab_op: hypercall returned error %d\n", ret);
 
- out2: (void)munlock(op, sizeof(*op));
- out1: return ret;
+    (void)munlock(op, sizeof(*op));
+out: 
+    return ret;
 }
 
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel