summary refs log tree commit diff stats
path: root/ui/console.c
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2023-09-12 10:13:01 +0400
committerMarc-André Lureau <marcandre.lureau@redhat.com>2023-09-12 11:14:09 +0400
commita92e7bb4cad57cc5c8817fb18fb25650507b69f8 (patch)
treefe679976e6c086661aa2142917a03085699d73b9 /ui/console.c
parent48a35e12faf90a896c5aa4755812201e00d60316 (diff)
downloadfocaccia-qemu-a92e7bb4cad57cc5c8817fb18fb25650507b69f8.tar.gz
focaccia-qemu-a92e7bb4cad57cc5c8817fb18fb25650507b69f8.zip
ui: add precondition for dpy_get_ui_info()
Ensure that it only get called when dpy_ui_info_supported(). The
function should always return a result. There should be a non-null
console or active_console.

Modify the argument to be const as well.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Albert Esteve <aesteve@redhat.com>
Diffstat (limited to 'ui/console.c')
-rw-r--r--ui/console.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/ui/console.c b/ui/console.c
index aa1e09462c..4a4f19ed33 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -801,7 +801,7 @@ static void dpy_set_ui_info_timer(void *opaque)
     con->hw_ops->ui_info(con->hw, head, &con->ui_info);
 }
 
-bool dpy_ui_info_supported(QemuConsole *con)
+bool dpy_ui_info_supported(const QemuConsole *con)
 {
     if (con == NULL) {
         con = active_console;
@@ -815,6 +815,8 @@ bool dpy_ui_info_supported(QemuConsole *con)
 
 const QemuUIInfo *dpy_get_ui_info(const QemuConsole *con)
 {
+    assert(dpy_ui_info_supported(con));
+
     if (con == NULL) {
         con = active_console;
     }