[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 14/14] ui: add precondition for dpy_get_ui_info()
From: |
marcandre . lureau |
Subject: |
[PULL 14/14] ui: add precondition for dpy_get_ui_info() |
Date: |
Tue, 12 Sep 2023 14:46:48 +0400 |
From: Marc-André Lureau <marcandre.lureau@redhat.com>
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 | 2 +-
ui/console.c | 4 +++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/include/ui/console.h b/include/ui/console.h
index 79e4702912..28882f15a5 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -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);
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;
}
--
2.41.0
- [PULL 08/14] ui/console: remove redundant format field, (continued)
- [PULL 08/14] ui/console: remove redundant format field, marcandre . lureau, 2023/09/12
- [PULL 09/14] ui/vc: preliminary QemuTextConsole changes before split, marcandre . lureau, 2023/09/12
- [PULL 10/14] ui/vc: split off the VC part from console.c, marcandre . lureau, 2023/09/12
- [PULL 11/14] ui/console: move DisplaySurface to its own header, marcandre . lureau, 2023/09/12
- [PULL 12/14] virtio-gpu/win32: set the destroy function on load, marcandre . lureau, 2023/09/12
- [PULL 13/14] ui: fix crash when there are no active_console, marcandre . lureau, 2023/09/12
- [PULL 14/14] ui: add precondition for dpy_get_ui_info(),
marcandre . lureau <=