From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59602) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YijP1-0005sH-SV for qemu-devel@nongnu.org; Thu, 16 Apr 2015 09:00:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YijOw-0004N8-Mj for qemu-devel@nongnu.org; Thu, 16 Apr 2015 09:00:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34985) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YijOw-0004Mn-IV for qemu-devel@nongnu.org; Thu, 16 Apr 2015 09:00:14 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 0EEA18E6F2 for ; Thu, 16 Apr 2015 13:00:14 +0000 (UTC) Date: Thu, 16 Apr 2015 14:00:12 +0100 From: Stefan Hajnoczi Message-ID: <20150416130012.GE27070@stefanha-thinkpad.redhat.com> References: <1429160256-27231-1-git-send-email-famz@redhat.com> <1429160256-27231-8-git-send-email-famz@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="lkTb+7nhmha7W+c3" Content-Disposition: inline In-Reply-To: <1429160256-27231-8-git-send-email-famz@redhat.com> Subject: Re: [Qemu-devel] [PATCH v3 7/7] poll-linux: Add timerfd support List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: Kevin Wolf , Paolo Bonzini , qemu-devel@nongnu.org --lkTb+7nhmha7W+c3 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Apr 16, 2015 at 12:57:36PM +0800, Fam Zheng wrote: > +static int qemu_poll_timerfd(QEMUPoll *qpoll, int64_t timeout_ns) > +{ > + int r; > + struct itimerspec its = { { 0 } }; > + > + if (timeout_ns > 0) { > + its.it_value.tv_sec = timeout_ns / 1000000000LL; > + its.it_value.tv_nsec = timeout_ns % 1000000000LL; > + } > + > + r = timerfd_settime(qpoll->timerfd, 0, &its, NULL); Can't hurt to put a comment here: /* The timer must be set even when there is no timeout so the readable * timerfd is cleared (we never call read(2) on it). */ > + if (r) { > + struct pollfd fd = { > + .fd = qpoll->epollfd, > + .events = POLLIN | POLLOUT | POLLERR | POLLHUP, > + }; > + perror("timerfd_settime"); > + abort(); > + r = ppoll(&fd, 1, &its.it_value, NULL); Please remove the dead code. In fact, there is no reasonable error for timerfd_settime(). It should never fail, I'd be happy with just assert(r == 0). --lkTb+7nhmha7W+c3 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJVL7JcAAoJEJykq7OBq3PIrFwH/ihJ5nBcVewKIKtqdiD7vQG9 /KVDm0/3SlLfkZ0GmxlfKJPohhMPJZS22q9hw67rkQuMQCpfVl9i+TV+Qrd7a5/f tL5GmiOup+Ha0Bswo3N5N4CqpdKg7KUGXWChxywCX2757zj5WcfVt359Q3wLxGwd XlbpaxZbT6yLZx9o2FqI2ZBt3VHgxMheBCOrc2yJrBaG2fUNqBiUeDirHRUqKRnf RHdp8jUppO27c3AADRGTP1hWdwq8VX7up9qntZbqIfQcprqvmygCM1vnEQwBir1E h0dmP1x4V2mkakn8xR81tpsqcuv5dGQRlZ/87E6uv1bT0caRNmzu3/OPtL7u1BU= =1O9V -----END PGP SIGNATURE----- --lkTb+7nhmha7W+c3--