Skip to contentSkip to conversation

libxl: remove xs_writev function

PATCH Applied Ian Campbell 2 participants 2 messages Oct 12, 2010 – Oct 13, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libxl: remove xs_writev function

# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1286899422 -3600
# Node ID 40f901c62980bf4b37c3a92ee02cea1c8e91697e # Parent 92be1317280b14e63b381285cdf342dfae014e66
libxl: remove xs_writev function

It isn't actually being used to write a vector at the only callsite and can easily be implemented using xs_write.

Furthermore the old implementation used to leak both the key and value strings.

tools/libxl/libxl.c +14 -10
diff -r 92be1317280b -r 40f901c62980 tools/libxl/libxl.c
@@ -1409,22 +1409,26 @@ static void dm_xenstore_record_pid(void 
 static void dm_xenstore_record_pid(void *for_spawn, pid_t innerchild)
 {
     libxl_device_model_starting *starting = for_spawn;
-    char *kvs[3];
-    int rc;
     struct xs_handle *xsh;
+    char *path = NULL, *pid = NULL;
+    int len;
 
+    if (asprintf(&path, "%s/%s", starting->dom_path, "image/device-model-pid") < 0)
+        goto out;
+
+    len = asprintf(&pid, "%d", innerchild);
+    if (len < 0)
+        goto out;
+
+    /* we mustn't use the parent's handle in the child */
     xsh = xs_daemon_open();
-    /* we mustn't use the parent's handle in the child */
 
-    kvs[0] = "image/device-model-pid";
-    if (asprintf(&kvs[1], "%d", innerchild) < 0)
-        return;
-    kvs[2] = NULL;
+    xs_write(xsh, XBT_NULL, path, pid, len);
 
-    rc = xs_writev(xsh, XBT_NULL, starting->dom_path, kvs);
-    if (rc)
-        return;
     xs_daemon_close(xsh);
+out:
+    free(path);
+    free(pid);
 }
 
 static int libxl_vfb_and_vkb_from_device_model_info(libxl_ctx *ctx,
tools/libxl/libxl_internal.h +0 -2
diff -r 92be1317280b -r 40f901c62980 tools/libxl/libxl_internal.h
@@ -108,8 +108,6 @@ typedef struct {
 #define PCI_BAR_IO             0x01
 
 #define PRINTF_ATTRIBUTE(x, y) __attribute__((format(printf, x, y)))
-
-_hidden int xs_writev(struct xs_handle *xsh, xs_transaction_t t, char *dir, char *kvs[]);
 
 typedef struct {
     /* mini-GC */
tools/libxl/libxl_xshelp.c +0 -20
diff -r 92be1317280b -r 40f901c62980 tools/libxl/libxl_xshelp.c
@@ -23,26 +23,6 @@
 
 #include "libxl.h"
 #include "libxl_internal.h"
-
-int xs_writev(struct xs_handle *xsh, xs_transaction_t t, char *dir, char *kvs[])
-{
-    char *path;
-    int i;
-
-    if (!kvs)
-        return 0;
-
-    for (i = 0; kvs[i] != NULL; i += 2) {
-        if (asprintf(&path, "%s/%s", dir, kvs[i]) < 0)
-            return -1;
-        if (path && kvs[i + 1]) {
-            int length = strlen(kvs[i + 1]);
-            xs_write(xsh, t, path, kvs[i + 1], length);
-        }
-        free(path);
-    }
-    return 0;
-}
 
 char **libxl__xs_kvs_of_flexarray(libxl__gc *gc, flexarray_t *array, int length)
 {
#1 lore raw
Quoted 7 lines · Ian Campbell

# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1286899422 -3600
# Node ID 40f901c62980bf4b37c3a92ee02cea1c8e91697e # Parent 92be1317280b14e63b381285cdf342dfae014e66
libxl: remove xs_writev function

Quoted 6 lines

It isn't actually being used to write a vector at the only callsite and can easily be implemented using xs_write.

Furthermore the old implementation used to leak both the key and value strings.

applied, thanks