vl: fix "type is NULL" in -vga help

Don't pass NULL to module_object_class_by_name(), when the interface is
unavailable.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20240715114420.2062870-1-marcandre.lureau@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
This commit is contained in:
Marc-André Lureau 2024-07-15 15:44:20 +04:00 committed by Philippe Mathieu-Daudé
parent 4bba839808
commit a99dc9cd61

View File

@ -1000,9 +1000,16 @@ static bool vga_interface_available(VGAInterfaceType t)
const VGAInterfaceInfo *ti = &vga_interfaces[t];
assert(t < VGA_TYPE_MAX);
return !ti->class_names[0] ||
module_object_class_by_name(ti->class_names[0]) ||
module_object_class_by_name(ti->class_names[1]);
if (!ti->class_names[0] || module_object_class_by_name(ti->class_names[0])) {
return true;
}
if (ti->class_names[1] && module_object_class_by_name(ti->class_names[1])) {
return true;
}
return false;
}
static const char *