"Daniel P. Berrange" <berra...@redhat.com> wrote: > I've been using the GNULIB poll() impl in libvirt on Win32 (well Mingw + > WINE) and found it was producing really wierd results, such ret=-1 + > errno=EAGAIN, or ret=0 even though requested timeout was infinite. > After a little debugging I discovered a missing initialization of > the 'rc' variable in the Win32 impl of poll(). With this patch > applied, it is behaving as desired. > > diff --git a/gnulib/lib/poll.c b/gnulib/lib/poll.c > --- a/gnulib/lib/poll.c > +++ b/gnulib/lib/poll.c > @@ -405,7 +405,7 @@ poll (pfd, nfd, timeout) > BOOL poll_again; > MSG msg; > char sockbuf[256]; > - int rc; > + int rc = 0;
Obviously correct. Thanks! Paolo, ok to push this? [BTW, would you mind if I filtered poll.c through cppi, which indents each cpp directive according to its nesting level? That'd be a separate, white-space-only change. When they're indented properly it's much easier to determine which branch of a cpp conditional any particular line of code is in. ] >From 33716c5cc9bf4155094277ea495901e26f84f0df Mon Sep 17 00:00:00 2001 From: Daniel P. Berrange <berra...@redhat.com> Date: Wed, 7 Jan 2009 20:43:01 +0100 Subject: [PATCH] poll: don't return uninitialized * lib/poll.c (poll) [WIN32_NATIVE]: Initialize "rc". --- lib/poll.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/poll.c b/lib/poll.c index da04844..35a5d53 100644 --- a/lib/poll.c +++ b/lib/poll.c @@ -1,7 +1,7 @@ /* Emulation for poll(2) Contributed by Paolo Bonzini. - Copyright 2001, 2002, 2003, 2006, 2007, 2008 Free Software Foundation, Inc. + Copyright 2001-2003, 2006-2009 Free Software Foundation, Inc. This file is part of gnulib. @@ -405,7 +405,7 @@ poll (pfd, nfd, timeout) BOOL poll_again; MSG msg; char sockbuf[256]; - int rc; + int rc = 0; nfds_t i; if (nfd < 0 || timeout < -1) -- 1.6.1.121.g866a4a