From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH v2 4/4] libxenstat: qmp_read fix and cleanup Date: Wed, 8 Apr 2015 17:11:54 +0100 Message-ID: <5525534A.3090803@citrix.com> References: <1428509302-10081-1-git-send-email-wei.liu2@citrix.com> <1428509302-10081-5-git-send-email-wei.liu2@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1428509302-10081-5-git-send-email-wei.liu2@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Wei Liu , xen-devel@lists.xen.org Cc: Charles Arnold , Ian Jackson , Ian Campbell List-Id: xen-devel@lists.xenproject.org On 08/04/15 17:08, Wei Liu wrote: > The second argument of poll(2) is the number of file descriptors. POLLIN > is defined as 1 so it happens to work. Also reduce the size of array to > one as there is only one file descriptor. > > Signed-off-by: Wei Liu > Cc: Ian Campbell > Cc: Ian Jackson > Cc: Charles Arnold Reviewed-by: Andrew Cooper > --- > tools/xenstat/libxenstat/src/xenstat_qmp.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/tools/xenstat/libxenstat/src/xenstat_qmp.c b/tools/xenstat/libxenstat/src/xenstat_qmp.c > index 8d91fef..5e261af 100644 > --- a/tools/xenstat/libxenstat/src/xenstat_qmp.c > +++ b/tools/xenstat/libxenstat/src/xenstat_qmp.c > @@ -289,13 +289,13 @@ static size_t qmp_write(int qfd, char *cmd, size_t cmd_len) > static int qmp_read(int qfd, unsigned char **qstats) > { > unsigned char buf[1024], *ptr; > - struct pollfd pfd[2]; > + struct pollfd pfd[1]; > int n, qsize = 0; > > *qstats = NULL; > pfd[0].fd = qfd; > pfd[0].events = POLLIN; > - while ((n = poll(pfd, POLLIN, 10)) > 0) { > + while ((n = poll(pfd, 1, 10)) > 0) { > if (pfd[0].revents & POLLIN) { > if ((n = read(qfd, buf, sizeof(buf))) < 0) { > free(*qstats);