ui: add precondition for dpy_get_ui_info()
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Tue, 12 Sep 2023 06:13:01 +0000 (10:13 +0400)
committerMarc-André Lureau <marcandre.lureau@redhat.com>
Tue, 12 Sep 2023 07:14:09 +0000 (11:14 +0400)
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>
include/ui/console.h
ui/console.c

index 79e4702912505a6971810bcee08a7da6adbaf048..28882f15a5319e93d9df9368e135cdd622060eec 100644 (file)
@@ -329,7 +329,7 @@ void update_displaychangelistener(DisplayChangeListener *dcl,
                                   uint64_t interval);
 void unregister_displaychangelistener(DisplayChangeListener *dcl);
 
-bool dpy_ui_info_supported(QemuConsole *con);
+bool dpy_ui_info_supported(const QemuConsole *con);
 const QemuUIInfo *dpy_get_ui_info(const QemuConsole *con);
 int dpy_set_ui_info(QemuConsole *con, QemuUIInfo *info, bool delay);
 
index aa1e09462cc68ed690f234751eaf9c27a7382209..4a4f19ed33e69294ff7177a095f18a92bac3e0a7 100644 (file)
@@ -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;
     }