From: Richard W.M. Jones <"Richard W.M. Jones "> Date: Tue, 10 Jun 2008 11:24:22 +0000 (+0100) Subject: List* functions throw exceptions if maxids = 0, so bypass this case. X-Git-Tag: 0.6.1.1~36 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=fdf0429a9b933e666b95713db0ccf3c26b62a4a7;p=ocaml-libvirt.git List* functions throw exceptions if maxids = 0, so bypass this case. --- diff --git a/libvirt/generator.pl b/libvirt/generator.pl index 4fbace6..0995922 100755 --- a/libvirt/generator.pl +++ b/libvirt/generator.pl @@ -620,6 +620,16 @@ sub gen_c_code int i = Int_val (iv); int ids[i], r; + /* Some libvirt List* functions still throw exceptions if i == 0, + * so catch that and return an empty array directly. This changes + * the semantics slightly (masking other failures) but it's + * unlikely anyone will care. RWMJ 2008/06/10 + */ + if (i == 0) { + rv = caml_alloc (0, 0); + CAMLreturn (rv); + } + NONBLOCKING (r = $c_name (conn, ids, i)); CHECK_ERROR (r == -1, conn, \"$c_name\"); @@ -637,6 +647,16 @@ sub gen_c_code char *names[i]; int r; + /* Some libvirt List* functions still throw exceptions if i == 0, + * so catch that and return an empty array directly. This changes + * the semantics slightly (masking other failures) but it's + * unlikely anyone will care. RWMJ 2008/06/10 + */ + if (i == 0) { + rv = caml_alloc (0, 0); + CAMLreturn (rv); + } + NONBLOCKING (r = $c_name ($1, names, i)); CHECK_ERROR (r == -1, conn, \"$c_name\"); diff --git a/libvirt/libvirt_c.c b/libvirt/libvirt_c.c index ca7f303..e8d071d 100644 --- a/libvirt/libvirt_c.c +++ b/libvirt/libvirt_c.c @@ -194,6 +194,16 @@ ocaml_libvirt_connect_list_domains (value connv, value iv) int i = Int_val (iv); int ids[i], r; + /* Some libvirt List* functions still throw exceptions if i == 0, + * so catch that and return an empty array directly. This changes + * the semantics slightly (masking other failures) but it's + * unlikely anyone will care. RWMJ 2008/06/10 + */ + if (i == 0) { + rv = caml_alloc (0, 0); + CAMLreturn (rv); + } + NONBLOCKING (r = virConnectListDomains (conn, ids, i)); CHECK_ERROR (r == -1, conn, "virConnectListDomains"); @@ -237,6 +247,16 @@ ocaml_libvirt_connect_list_defined_domains (value connv, value iv) char *names[i]; int r; + /* Some libvirt List* functions still throw exceptions if i == 0, + * so catch that and return an empty array directly. This changes + * the semantics slightly (masking other failures) but it's + * unlikely anyone will care. RWMJ 2008/06/10 + */ + if (i == 0) { + rv = caml_alloc (0, 0); + CAMLreturn (rv); + } + NONBLOCKING (r = virConnectListDefinedDomains (conn, names, i)); CHECK_ERROR (r == -1, conn, "virConnectListDefinedDomains"); @@ -283,6 +303,16 @@ ocaml_libvirt_connect_list_networks (value connv, value iv) char *names[i]; int r; + /* Some libvirt List* functions still throw exceptions if i == 0, + * so catch that and return an empty array directly. This changes + * the semantics slightly (masking other failures) but it's + * unlikely anyone will care. RWMJ 2008/06/10 + */ + if (i == 0) { + rv = caml_alloc (0, 0); + CAMLreturn (rv); + } + NONBLOCKING (r = virConnectListNetworks (conn, names, i)); CHECK_ERROR (r == -1, conn, "virConnectListNetworks"); @@ -329,6 +359,16 @@ ocaml_libvirt_connect_list_defined_networks (value connv, value iv) char *names[i]; int r; + /* Some libvirt List* functions still throw exceptions if i == 0, + * so catch that and return an empty array directly. This changes + * the semantics slightly (masking other failures) but it's + * unlikely anyone will care. RWMJ 2008/06/10 + */ + if (i == 0) { + rv = caml_alloc (0, 0); + CAMLreturn (rv); + } + NONBLOCKING (r = virConnectListDefinedNetworks (conn, names, i)); CHECK_ERROR (r == -1, conn, "virConnectListDefinedNetworks"); @@ -406,6 +446,16 @@ ocaml_libvirt_connect_list_storage_pools (value connv, value iv) char *names[i]; int r; + /* Some libvirt List* functions still throw exceptions if i == 0, + * so catch that and return an empty array directly. This changes + * the semantics slightly (masking other failures) but it's + * unlikely anyone will care. RWMJ 2008/06/10 + */ + if (i == 0) { + rv = caml_alloc (0, 0); + CAMLreturn (rv); + } + NONBLOCKING (r = virConnectListStoragePools (conn, names, i)); CHECK_ERROR (r == -1, conn, "virConnectListStoragePools"); @@ -484,6 +534,16 @@ ocaml_libvirt_connect_list_defined_storage_pools (value connv, value iv) char *names[i]; int r; + /* Some libvirt List* functions still throw exceptions if i == 0, + * so catch that and return an empty array directly. This changes + * the semantics slightly (masking other failures) but it's + * unlikely anyone will care. RWMJ 2008/06/10 + */ + if (i == 0) { + rv = caml_alloc (0, 0); + CAMLreturn (rv); + } + NONBLOCKING (r = virConnectListDefinedStoragePools (conn, names, i)); CHECK_ERROR (r == -1, conn, "virConnectListDefinedStoragePools"); @@ -2428,6 +2488,16 @@ ocaml_libvirt_storage_pool_list_volumes (value poolv, value iv) char *names[i]; int r; + /* Some libvirt List* functions still throw exceptions if i == 0, + * so catch that and return an empty array directly. This changes + * the semantics slightly (masking other failures) but it's + * unlikely anyone will care. RWMJ 2008/06/10 + */ + if (i == 0) { + rv = caml_alloc (0, 0); + CAMLreturn (rv); + } + NONBLOCKING (r = virStoragePoolListVolumes (pool, names, i)); CHECK_ERROR (r == -1, conn, "virStoragePoolListVolumes");