Message ID | 20190704163936.12969-1-colin.king@canonical.com |
---|---|
State | Accepted |
Headers | show |
Series | lib: fwts_pipeio: zero pollfds to squish a static analysis warning | expand |
On 2019-07-04 10:39 a.m., Colin King wrote: > From: Colin Ian King <colin.king@canonical.com> > > Static analysis is warning that the revents field on pollfd[0] may > be uninitialized. Although the system call should set this, zero > pollfds to silcence the static analysis warning and also catch any > unforseen poll bugs. > > Addresses-Coverity: ("Uninitialized scalar variable") > Signed-off-by: Colin Ian King <colin.king@canonical.com> > --- > src/lib/src/fwts_pipeio.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/src/lib/src/fwts_pipeio.c b/src/lib/src/fwts_pipeio.c > index 659b125a..afd4b431 100644 > --- a/src/lib/src/fwts_pipeio.c > +++ b/src/lib/src/fwts_pipeio.c > @@ -161,6 +161,8 @@ int fwts_pipe_readwrite( > > *out_len = 0; > > + memset(&pollfds, 0, sizeof(pollfds)); > + > pollfds[0].fd = out_fd; > pollfds[0].events = POLLIN; > pollfds[1].fd = in_fd; > Acked-by: Alex Hung <alex.hung@canonical.com>
On 7/5/19 12:39 AM, Colin King wrote: > From: Colin Ian King <colin.king@canonical.com> > > Static analysis is warning that the revents field on pollfd[0] may > be uninitialized. Although the system call should set this, zero > pollfds to silcence the static analysis warning and also catch any > unforseen poll bugs. > > Addresses-Coverity: ("Uninitialized scalar variable") > Signed-off-by: Colin Ian King <colin.king@canonical.com> > --- > src/lib/src/fwts_pipeio.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/src/lib/src/fwts_pipeio.c b/src/lib/src/fwts_pipeio.c > index 659b125a..afd4b431 100644 > --- a/src/lib/src/fwts_pipeio.c > +++ b/src/lib/src/fwts_pipeio.c > @@ -161,6 +161,8 @@ int fwts_pipe_readwrite( > > *out_len = 0; > > + memset(&pollfds, 0, sizeof(pollfds)); > + > pollfds[0].fd = out_fd; > pollfds[0].events = POLLIN; > pollfds[1].fd = in_fd; > Acked-by: Ivan Hu <ivan.hu@canonical.com>
diff --git a/src/lib/src/fwts_pipeio.c b/src/lib/src/fwts_pipeio.c index 659b125a..afd4b431 100644 --- a/src/lib/src/fwts_pipeio.c +++ b/src/lib/src/fwts_pipeio.c @@ -161,6 +161,8 @@ int fwts_pipe_readwrite( *out_len = 0; + memset(&pollfds, 0, sizeof(pollfds)); + pollfds[0].fd = out_fd; pollfds[0].events = POLLIN; pollfds[1].fd = in_fd;