public inbox for llvm@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH] udf: initialize newblock to 0
@ 2022-12-30 17:53 Tom Rix
  2023-01-02 12:50 ` Jan Kara
  0 siblings, 1 reply; 2+ messages in thread
From: Tom Rix @ 2022-12-30 17:53 UTC (permalink / raw)
  To: jack, nathan, ndesaulniers; +Cc: linux-kernel, llvm, Tom Rix

The clang build reports this error
fs/udf/inode.c:805:6: error: variable 'newblock' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
        if (*err < 0)
            ^~~~~~~~
newblock is never set before error handling jump.
Initialize newblock to 0 and remove redundant settings.

Fixes: d8b39db5fab8 ("udf: Handle error when adding extent to a file")
Signed-off-by: Tom Rix <trix@redhat.com>
---
 fs/udf/inode.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 4a912e2edcec..31965c3798f2 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -604,7 +604,7 @@ static sector_t inode_getblk(struct inode *inode, sector_t block,
 	struct kernel_lb_addr eloc, tmpeloc;
 	int c = 1;
 	loff_t lbcount = 0, b_off = 0;
-	udf_pblk_t newblocknum, newblock;
+	udf_pblk_t newblocknum, newblock = 0;
 	sector_t offset = 0;
 	int8_t etype;
 	struct udf_inode_info *iinfo = UDF_I(inode);
@@ -710,7 +710,6 @@ static sector_t inode_getblk(struct inode *inode, sector_t block,
 		ret = udf_do_extend_file(inode, &prev_epos, laarr, hole_len);
 		if (ret < 0) {
 			*err = ret;
-			newblock = 0;
 			goto out_free;
 		}
 		c = 0;
@@ -775,7 +774,6 @@ static sector_t inode_getblk(struct inode *inode, sector_t block,
 				goal, err);
 		if (!newblocknum) {
 			*err = -ENOSPC;
-			newblock = 0;
 			goto out_free;
 		}
 		if (isBeyondEOF)
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] udf: initialize newblock to 0
  2022-12-30 17:53 [PATCH] udf: initialize newblock to 0 Tom Rix
@ 2023-01-02 12:50 ` Jan Kara
  0 siblings, 0 replies; 2+ messages in thread
From: Jan Kara @ 2023-01-02 12:50 UTC (permalink / raw)
  To: Tom Rix; +Cc: jack, nathan, ndesaulniers, linux-kernel, llvm

On Fri 30-12-22 12:53:41, Tom Rix wrote:
> The clang build reports this error
> fs/udf/inode.c:805:6: error: variable 'newblock' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
>         if (*err < 0)
>             ^~~~~~~~
> newblock is never set before error handling jump.
> Initialize newblock to 0 and remove redundant settings.
> 
> Fixes: d8b39db5fab8 ("udf: Handle error when adding extent to a file")
> Signed-off-by: Tom Rix <trix@redhat.com>

Thanks! I've added the patch to my tree.

								Honza

> ---
>  fs/udf/inode.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/fs/udf/inode.c b/fs/udf/inode.c
> index 4a912e2edcec..31965c3798f2 100644
> --- a/fs/udf/inode.c
> +++ b/fs/udf/inode.c
> @@ -604,7 +604,7 @@ static sector_t inode_getblk(struct inode *inode, sector_t block,
>  	struct kernel_lb_addr eloc, tmpeloc;
>  	int c = 1;
>  	loff_t lbcount = 0, b_off = 0;
> -	udf_pblk_t newblocknum, newblock;
> +	udf_pblk_t newblocknum, newblock = 0;
>  	sector_t offset = 0;
>  	int8_t etype;
>  	struct udf_inode_info *iinfo = UDF_I(inode);
> @@ -710,7 +710,6 @@ static sector_t inode_getblk(struct inode *inode, sector_t block,
>  		ret = udf_do_extend_file(inode, &prev_epos, laarr, hole_len);
>  		if (ret < 0) {
>  			*err = ret;
> -			newblock = 0;
>  			goto out_free;
>  		}
>  		c = 0;
> @@ -775,7 +774,6 @@ static sector_t inode_getblk(struct inode *inode, sector_t block,
>  				goal, err);
>  		if (!newblocknum) {
>  			*err = -ENOSPC;
> -			newblock = 0;
>  			goto out_free;
>  		}
>  		if (isBeyondEOF)
> -- 
> 2.27.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-01-02 12:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-30 17:53 [PATCH] udf: initialize newblock to 0 Tom Rix
2023-01-02 12:50 ` Jan Kara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox