2022-02-24 11:12:20

by Jiapeng Chong

[permalink] [raw]
Subject: [PATCH] vboxsf: Remove redundant assignment to out_len

Clean up the following clang-w1 warning:

fs/vboxsf/utils.c:442:9: warning: variable 'out_len' set but not used
[-Wunused-but-set-variable].

Reported-by: Abaci Robot <[email protected]>
Signed-off-by: Jiapeng Chong <[email protected]>
---
fs/vboxsf/utils.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/vboxsf/utils.c b/fs/vboxsf/utils.c
index e1db0f3f7e5e..865fe5ddc993 100644
--- a/fs/vboxsf/utils.c
+++ b/fs/vboxsf/utils.c
@@ -439,7 +439,7 @@ int vboxsf_nlscpy(struct vboxsf_sbi *sbi, char *name, size_t name_bound_len,
{
const char *in;
char *out;
- size_t out_len;
+ size_t out_len = 0;
size_t out_bound_len;
size_t in_bound_len;

@@ -447,7 +447,6 @@ int vboxsf_nlscpy(struct vboxsf_sbi *sbi, char *name, size_t name_bound_len,
in_bound_len = utf8_len;

out = name;
- out_len = 0;
/* Reserve space for terminating 0 */
out_bound_len = name_bound_len - 1;

--
2.20.1.7.g153144c


2022-02-24 14:38:11

by Hans de Goede

[permalink] [raw]
Subject: Re: [PATCH] vboxsf: Remove redundant assignment to out_len

Hi,

On 2/24/22 11:48, Jiapeng Chong wrote:
> Clean up the following clang-w1 warning:
>
> fs/vboxsf/utils.c:442:9: warning: variable 'out_len' set but not used
> [-Wunused-but-set-variable].
>
> Reported-by: Abaci Robot <[email protected]>
> Signed-off-by: Jiapeng Chong <[email protected]>

This is not the correct fix out_len indeed is never read
anywhere in this function, so the correct fix is to
completely remove the out_len variable .

Regards,

Hans



> ---
> fs/vboxsf/utils.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/fs/vboxsf/utils.c b/fs/vboxsf/utils.c
> index e1db0f3f7e5e..865fe5ddc993 100644
> --- a/fs/vboxsf/utils.c
> +++ b/fs/vboxsf/utils.c
> @@ -439,7 +439,7 @@ int vboxsf_nlscpy(struct vboxsf_sbi *sbi, char *name, size_t name_bound_len,
> {
> const char *in;
> char *out;
> - size_t out_len;
> + size_t out_len = 0;
> size_t out_bound_len;
> size_t in_bound_len;
>
> @@ -447,7 +447,6 @@ int vboxsf_nlscpy(struct vboxsf_sbi *sbi, char *name, size_t name_bound_len,
> in_bound_len = utf8_len;
>
> out = name;
> - out_len = 0;
> /* Reserve space for terminating 0 */
> out_bound_len = name_bound_len - 1;
>