From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:50669) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIOg2-000537-Ss for qemu-devel@nongnu.org; Wed, 20 Mar 2013 15:28:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UIOg0-0003lw-0m for qemu-devel@nongnu.org; Wed, 20 Mar 2013 15:27:58 -0400 Received: from mail-ob0-x235.google.com ([2607:f8b0:4003:c01::235]:44078) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIOfz-0003lF-Ra for qemu-devel@nongnu.org; Wed, 20 Mar 2013 15:27:55 -0400 Received: by mail-ob0-f181.google.com with SMTP id ni5so2003744obc.40 for ; Wed, 20 Mar 2013 12:27:55 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <514A0478.3090908@gmail.com> References: <1363772625-9182-1-git-send-email-kraxel@redhat.com> <1363772625-9182-10-git-send-email-kraxel@redhat.com> <514A0478.3090908@gmail.com> Date: Wed, 20 Mar 2013 23:27:55 +0400 Message-ID: From: Igor Mitsyanko Content-Type: multipart/alternative; boundary=e89a8f646a1907ca5604d86038c2 Subject: Re: [Qemu-devel] [PATCH 09/23] console: displaystate init revamp List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann Cc: Anthony Liguori , qemu-devel@nongnu.org --e89a8f646a1907ca5604d86038c2 Content-Type: text/plain; charset=ISO-8859-1 On 03/20/2013 01:43 PM, Gerd Hoffmann wrote: > >> We have only one DisplayState, so there is no need for the "next" >> linking, rip it. Also consolidate all displaystate initialization >> into init_displaystate(). This function is called by vl.c after >> creating the devices (and thus all QemuConsoles) and before >> initializing DisplayChangeListensers (aka gtk/sdl/vnc/spice ui). >> >> Signed-off-by: Gerd Hoffmann >> --- >> include/ui/console.h | 5 +--- >> ui/console.c | 73 +++++++++++++++++++++++-------** >> -------------------- >> vl.c | 6 +---- >> 3 files changed, 36 insertions(+), 48 deletions(-) >> >> diff --git a/include/ui/console.h b/include/ui/console.h >> index a234c72..3725dae 100644 >> --- a/include/ui/console.h >> +++ b/include/ui/console.h >> @@ -189,12 +189,9 @@ struct DisplayState { >> bool have_text; >> - s = &display_state; >> - while (*s != NULL) >> - s = &(*s)->next; >> - ds->next = NULL; >> - *s = ds; >> + if (!display_state) { >> + display_state = g_new0(DisplayState, 1); >> + } >> + return display_state; >> } >> >> [snip] > -DisplayState *get_displaystate(void) >> +/* >> + * Called by main(), after creating QemuConsoles >> + * and before initializing ui (sdl/vnc/...). >> + */ >> +DisplayState *init_displaystate(void) >> { >> + int i; >> + >> if (!display_state) { >> - dumb_display_init (); >> + display_state = g_new0(DisplayState, 1); >> } >> > > Shouldn't get_alloc_displaystate() be used here instead? --e89a8f646a1907ca5604d86038c2 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

On 03/20= /2013 01:43 PM, Gerd Hoffmann wrote:
We have only one DisplayState, so there is no need for the "next"=
linking, rip it. =A0Also consolidate all displaystate initialization
into init_displaystate(). =A0This function is called by vl.c after
creating the devices (and thus all QemuConsoles) and before
initializing DisplayChangeListensers (aka gtk/sdl/vnc/spice ui).

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
=A0 include/ui/console.h | =A0 =A05 +---
=A0 ui/console.c =A0 =A0 =A0 =A0 | =A0 73 +++++++++++++++++++++++-------= --------------------
=A0 vl.c =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 | =A0 =A06 +----
=A0 3 files changed, 36 insertions(+), 48 deletions(-)

diff --git a/include/ui/console.h b/include/ui/console.h
index a234c72..3725dae 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -189,12 +189,9 @@ struct DisplayState {
=A0 =A0 =A0 bool have_text;
- =A0 =A0s =3D &display_state;
- =A0 =A0while (*s !=3D NULL)
- =A0 =A0 =A0 =A0s =3D &(*s)->next;
- =A0 =A0ds->next =3D NULL;
- =A0 =A0*s =3D ds;
+ =A0 =A0if (!display_state) {
+ =A0 =A0 =A0 =A0display_state =3D g_new0(DisplayState, 1);
+ =A0 =A0}
+ =A0 =A0return display_state;
=A0 }


[snip]
=A0
-DisplayState *get_displaystate(void)
+/*
+ * Called by main(), after creating QemuConsoles
+ * and before initializing ui (sdl/vnc/...).
+ */
+DisplayState *init_displaystate(void)
=A0 {
+ =A0 =A0int i;
+
=A0 =A0 =A0 if (!display_state) {
- =A0 =A0 =A0 =A0dumb_display_init ();
+ =A0 =A0 =A0 =A0display_state =3D g_new0(DisplayState, 1);
=A0 =A0 =A0 }

=A0

Shouldn't get_alloc_displaystate() be used= here instead?
=A0


--e89a8f646a1907ca5604d86038c2--