Skip to content

Commit

Permalink
ui: add precondition for dpy_get_ui_info()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
elmarco committed Sep 12, 2023
1 parent 48a35e1 commit a92e7bb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion include/ui/console.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 3 additions & 1 deletion ui/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down

0 comments on commit a92e7bb

Please sign in to comment.