lib: fwts_pipeio: zero pollfds to squish a static analysis warning
diff mbox series

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
Related show

Commit Message

Colin Ian King July 4, 2019, 4:39 p.m. UTC
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(+)

Comments

Alex Hung July 4, 2019, 5:42 p.m. UTC | #1
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>
ivanhu July 24, 2019, 6:46 a.m. UTC | #2
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>

Patch
diff mbox series

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;