Change check into an assertion, and add detailed comments explaining our assumptions.
Updates: commit d0fbb769286a97728b0d1358e7accc2eb708d795 --- lib/utils.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/utils.c b/lib/utils.c index cc31b00309..93e520d2fb 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -79,11 +79,21 @@ nbd_internal_copy_string_list (string_vector *v, char **in) int nbd_internal_set_argv (struct nbd_handle *h, char **argv) { - /* FIXME: Do we want to assert(argv)? */ - if (argv == NULL || argv[0] == NULL) { + /* This should never be NULL. Normally the generator adds code to + * each StringList call in lib/api.c to check this and return an + * error. + */ + assert (argv); + + /* Because this function is only called from functions that take + * argv-style lists of strings (such as nbd_connect_command) we can + * check here that the command name is present. + */ + if (argv[0] == NULL) { set_error (EINVAL, "missing command name in argv list"); return -1; } + if (nbd_internal_copy_string_list (&h->argv, argv) == -1) { set_error (errno, "realloc"); return -1; -- 2.37.0.rc2 _______________________________________________ Libguestfs mailing list Libguestfs@redhat.com https://listman.redhat.com/mailman/listinfo/libguestfs