[PATCH] Fixing sparse warning of variable length array

Greg KH gregkh at linuxfoundation.org
Thu May 18 20:42:39 UTC 2017


On Thu, May 18, 2017 at 11:39:48PM +0300, Lior Pugatch wrote:
> >From c93e5f16090b217d76c0c0b94201a97e0c43c32b Mon Sep 17 00:00:00 2001
> From: Lior Pugatch <buzz5800 at gmail.com>
> Date: Thu, 18 May 2017 22:49:12 +0300
> Subject: [PATCH] Fixing sparse warning of variable length array
> 
> Signed-off-by: Lior Pugatch <buzz5800 at gmail.com>
> ---
>  drivers/staging/lustre/lustre/llite/xattr.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c
> index 6187bff..4e19249 100644
> --- a/drivers/staging/lustre/lustre/llite/xattr.c
> +++ b/drivers/staging/lustre/lustre/llite/xattr.c
> @@ -86,7 +86,9 @@ static int xattr_type_filter(struct ll_sb_info *sbi,
>  		    const char *name, const void *value, size_t size,
>  		    int flags)
>  {
> -	char fullname[strlen(handler->prefix) + strlen(name) + 1];
> +	const unsigned int prefix_len = strlen(handler->prefix);
> +	const unsigned int name_len = strlen(name);
> +	char fullname[prefix_len + name_len + 1];

Wait, no, you aren't changing anything here, why make this patch at all?

confused,

greg k-h


More information about the devel mailing list