On Tue, Mar 17, 2026 at 12:50:54PM +0400, Marc-André Lureau wrote:
> Remove the extra "info" variable and its initialization.
> 
> Signed-off-by: Marc-André Lureau <[email protected]>
> ---
>  ui/sdl2.c | 10 +++++-----
>  ui/vnc.c  |  7 ++-----
>  2 files changed, 7 insertions(+), 10 deletions(-)
> 
> diff --git a/ui/sdl2.c b/ui/sdl2.c
> index aaaede56e0e..3ffb8acaff8 100644
> --- a/ui/sdl2.c
> +++ b/ui/sdl2.c
> @@ -600,11 +600,11 @@ static void handle_windowevent(SDL_Event *ev)
>      switch (ev->window.event) {
>      case SDL_WINDOWEVENT_RESIZED:
>          {
> -            QemuUIInfo info;
> -            memset(&info, 0, sizeof(info));
> -            info.width = ev->window.data1;
> -            info.height = ev->window.data2;
> -            dpy_set_ui_info(scon->dcl.con, &info, true);
> +            dpy_set_ui_info(scon->dcl.con,
> +                &(QemuUIInfo) {
> +                    .width = ev->window.data1,
> +                    .height = ev->window.data2,
> +                }, true);

I find this new code less readable than the original. The compiler
optimizer can remove uneccessary variables in this way.

I would, however, suggest removing the memset and doing

             QemuUIInfo info = { .width = ev->window.data1,
                                 .height = ev->window.data2 };
             dpy_set_ui_info(scon->dcl.con, &info, true);

With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|


Reply via email to