[Libguestfs] [PATCH] generator: Passing "" to StringList tests should turn into empty list.

Richard W.M. Jones
2009-11-24T14:29:55Z

This is a simple bug fix.

--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://et.redhat.com/~rjones/virt-top
-------------- next part --------------
>From cc560d9e43520b03e815ff4a7ae40faabd1f0162 Mon Sep 17 00:00:00 2001
From: Richard Jones <rjones at redhat.com>
Date: Tue, 24 Nov 2009 14:04:28 +0000
Subject: [PATCH 1/4] generator: Passing "" to StringList tests should
turn into empty list.

This is a bug in the generator which wasn't being tickled.  If
you had a test which expected a StringList or DeviceList parameter,
and you passed "" to that test, then you'd (probably) expect to be
testing an empty list, but in fact you got a single element list
containing an empty string.  This fixes it so you get an empty list.
---
 src/generator.ml |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/generator.ml b/src/generator.ml
index a7135a7..1206be2 100755
--- a/src/generator.ml
+++ b/src/generator.ml
@@ -6644,6 +6644,8 @@ and generate_test_command_call ?(expect_error = false)
?test test_name cmd          | Int64 _, _
         | Bool _, _
         | FileIn _, _ | FileOut _, _ -> ()
+        | StringList n, "" | DeviceList n, "" ->
+	    pr "    const char *const %s[1] = { NULL };\n" n
         | StringList n, arg | DeviceList n, arg ->
             let strs = string_split " " arg in
             iteri (
--
1.6.5.2