[Libguestfs] [libguestfs-common PATCH v2 09/12] mltools/tools_utils-c: handle internal type error with abort()

Laszlo Ersek lersek at redhat.com
Thu Jun 30 12:20:25 UTC 2022


If the "default" label is taken in guestfs_int_mllib_inspect_decrypt(),
that means the C code and the OCaml code disagree on the data constructors
of the "key_store_key" OCaml type. Such internal errors are best reported
with abort() -- not entirely unlike a failed assertion.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1809453
Suggested-by: Richard W.M. Jones <rjones at redhat.com>
Signed-off-by: Laszlo Ersek <lersek at redhat.com>
---

Notes:
    v2:
    
    - new patch [Rich]

 mltools/tools_utils-c.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/mltools/tools_utils-c.c b/mltools/tools_utils-c.c
index 081466776666..c703998d4838 100644
--- a/mltools/tools_utils-c.c
+++ b/mltools/tools_utils-c.c
@@ -74,13 +74,11 @@ guestfs_int_mllib_inspect_decrypt (value gv, value gpv, value keysv)
       key.file.name = strdup (String_val (Field (v, 0)));
       if (!key.file.name)
         caml_raise_out_of_memory ();
       break;
     default:
-      error (EXIT_FAILURE, 0,
-             "internal error: unhandled Tag_val (v) = %d",
-             Tag_val (v));
+      abort ();
     }
 
     ks = key_store_import_key (ks, &key);
 
     keysv = Field (keysv, 1);
-- 
2.19.1.3.g30247aa5d201




More information about the Libguestfs mailing list