ACK: [PATCH] lib: fwts_tty: memset a ws struct to keep static analyzers happy

ivanhu ivan.hu at canonical.com
Wed Apr 8 06:42:06 UTC 2020



On 4/8/20 12:07 AM, Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
> 
> Coverity throws a warning of a potential use of unitialized fields
> in the ws struct, so memset it to zero before calling the ioctl.
> 
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
>  src/lib/src/fwts_tty.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/src/lib/src/fwts_tty.c b/src/lib/src/fwts_tty.c
> index 1ed881dc..15c911e7 100644
> --- a/src/lib/src/fwts_tty.c
> +++ b/src/lib/src/fwts_tty.c
> @@ -18,6 +18,7 @@
>   */
>  #include <sys/ioctl.h>
>  #include <unistd.h>
> +#include <string.h>
>  
>  /*
>   *  fwts_tty_width()
> @@ -29,6 +30,8 @@ int fwts_tty_width(const int fd, const int default_width)
>  #ifdef TIOCGWINSZ
>  	struct winsize ws;
>  
> +	/* Zero'ing ws keeps static analyzers happy */
> +	(void)memset(&ws, 0, sizeof(ws));
>  	/* if tty and we can get a sane width, return it */
>  	if (isatty(fd) &&
>  	    (ioctl(fd, TIOCGWINSZ, &ws) != -1) &&
> 


Acked-by: Ivan Hu <ivan.hu at canonical.com>



More information about the fwts-devel mailing list