From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:52076) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QpG5N-0006nk-6X for qemu-devel@nongnu.org; Fri, 05 Aug 2011 04:48:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QpG5K-0002LF-0Y for qemu-devel@nongnu.org; Fri, 05 Aug 2011 04:48:53 -0400 Received: from mail-yx0-f173.google.com ([209.85.213.173]:62233) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QpG5J-0002L6-Rh for qemu-devel@nongnu.org; Fri, 05 Aug 2011 04:48:49 -0400 Received: by yxt3 with SMTP id 3so1813746yxt.4 for ; Fri, 05 Aug 2011 01:48:49 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <4E3B9BE4.3020807@redhat.com> References: <4E3B9BE4.3020807@redhat.com> Date: Fri, 5 Aug 2011 09:48:49 +0100 Message-ID: From: Stefan Hajnoczi Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] Build broken List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: qemu-devel@nongnu.org, Stefan Hajnoczi On Fri, Aug 5, 2011 at 8:29 AM, Kevin Wolf wrote: > Am 05.08.2011 08:22, schrieb malc: >> >> /home/malc/x/rcs/git/qemuorg/coroutine-ucontext.c: In function 'coroutin= e_new': >> /home/malc/x/rcs/git/qemuorg/coroutine-ucontext.c:160:16: error: 'arg.i[= 1]' may be used uninitialized in this function >> /home/malc/x/rcs/git/qemuorg/coroutine-ucontext.c:136:18: note: 'arg.i[1= ]' was declared here >> >> diff --git a/coroutine-ucontext.c b/coroutine-ucontext.c >> index 41c2379..42dc3e2 100644 >> --- a/coroutine-ucontext.c >> +++ b/coroutine-ucontext.c >> @@ -133,7 +133,7 @@ static Coroutine *coroutine_new(void) >> =A0 =A0 =A0CoroutineUContext *co; >> =A0 =A0 =A0ucontext_t old_uc, uc; >> =A0 =A0 =A0jmp_buf old_env; >> - =A0 =A0union cc_arg arg; >> + =A0 =A0union cc_arg arg =3D {0}; >> >> =A0 =A0 =A0/* The ucontext functions preserve signal masks which incurs = a system call >> =A0 =A0 =A0 * overhead. =A0setjmp()/longjmp() does not preserve signal m= asks but only >> >> I guess gcc should yell not only here on ppc32 but on any machine where >> pointer size is less than the size of two ints. > > Stefan, why does this code even exist again? I think at some point I had > it changed to just use a static variable in order to avoid doing this > kind of tricks with unions. virtfs are using coroutines in multiple threads at the same time. Introducing a global variable wouldn't be thread-safe. The real problem is that makecontext(3) has a bad function signature. There's no nice fix - whatever we do will be ugly. Using a union is the way it should be done in C. The code doesn't look pretty but it doesn't introduce global state. Stefan