lkml.org 
[lkml]   [2019]   [Sep]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] staging: exfat: fix uninitialized variable ret
On Fri, Aug 30, 2019 at 07:46:44PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently there are error return paths in ffsReadFile that
> exit via lable err_out that return and uninitialized error
> return in variable ret. Fix this by initializing ret to zero.
>
> Addresses-Coverity: ("Uninitialized scalar variable")
> Fixes: c48c9f7ff32b ("staging: exfat: add exfat filesystem code to staging")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Clang also warns about this:

drivers/staging/exfat/exfat_super.c:885:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
if (p_fs->dev_ejected)
^~~~~~~~~~~~~~~~~
drivers/staging/exfat/exfat_super.c:892:9: note: uninitialized use occurs here
return ret;
^~~
drivers/staging/exfat/exfat_super.c:885:2: note: remove the 'if' if its condition is always true
if (p_fs->dev_ejected)
^~~~~~~~~~~~~~~~~~~~~~
drivers/staging/exfat/exfat_super.c:776:9: note: initialize the variable 'ret' to silence this warning
int ret;
^
= 0
1 warning generated.

Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>

\
 
 \ /
  Last update: 2019-09-03 07:32    [W:0.044 / U:0.696 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site