libxenstat: qmp_read fix and cleanup
authorWei Liu <wei.liu2@citrix.com>
Wed, 8 Apr 2015 16:08:22 +0000 (17:08 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Wed, 15 Apr 2015 16:10:58 +0000 (17:10 +0100)
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 <wei.liu2@citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Charles Arnold <carnold@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
tools/xenstat/libxenstat/src/xenstat_qmp.c

index 8d91feffa107da945cb5e2b4cdd9126653721ba8..5e261afe1c5b8a43fdd5327517320fba33917b49 100644 (file)
@@ -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);