All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs: remove redundant initialization of variable error
@ 2021-06-05  8:52 Shaokun Zhang
  2021-06-07 13:13 ` Carlos Maiolino
  2021-06-12  0:53 ` Darrick J. Wong
  0 siblings, 2 replies; 4+ messages in thread
From: Shaokun Zhang @ 2021-06-05  8:52 UTC (permalink / raw)
  To: linux-xfs; +Cc: Shaokun Zhang, Darrick J. Wong

'error' will be initialized, so clean up the redundant initialization.

Cc: "Darrick J. Wong" <djwong@kernel.org>
Signed-off-by: Shaokun Zhang <zhangshaokun@hisilicon.com>
---
 fs/xfs/xfs_buf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index 592800c8852f..59991c8c7127 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -707,7 +707,7 @@ xfs_buf_get_map(
 {
 	struct xfs_buf		*bp;
 	struct xfs_buf		*new_bp;
-	int			error = 0;
+	int			error;
 
 	*bpp = NULL;
 	error = xfs_buf_find(target, map, nmaps, flags, NULL, &bp);
-- 
2.7.4


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

* Re: [PATCH] xfs: remove redundant initialization of variable error
  2021-06-05  8:52 [PATCH] xfs: remove redundant initialization of variable error Shaokun Zhang
@ 2021-06-07 13:13 ` Carlos Maiolino
  2021-06-08  1:50   ` Shaokun Zhang
  2021-06-12  0:53 ` Darrick J. Wong
  1 sibling, 1 reply; 4+ messages in thread
From: Carlos Maiolino @ 2021-06-07 13:13 UTC (permalink / raw)
  To: Shaokun Zhang; +Cc: linux-xfs, Darrick J. Wong

Hi,

On Sat, Jun 05, 2021 at 04:52:50PM +0800, Shaokun Zhang wrote:
> 'error' will be initialized, so clean up the redundant initialization.
> 
> Cc: "Darrick J. Wong" <djwong@kernel.org>
> Signed-off-by: Shaokun Zhang <zhangshaokun@hisilicon.com>


This makes no difference in the resulting code.
Particularly, I'd rather have such variables explicitly initialized. This
function is small, so it's easy to see its initialization later in the code, but
still, IMHO, it's way better to see the 'default error values' explicit at the
beginning of the function. But, it's just my 'visual' preference :)


> ---
>  fs/xfs/xfs_buf.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
> index 592800c8852f..59991c8c7127 100644
> --- a/fs/xfs/xfs_buf.c
> +++ b/fs/xfs/xfs_buf.c
> @@ -707,7 +707,7 @@ xfs_buf_get_map(
>  {
>  	struct xfs_buf		*bp;
>  	struct xfs_buf		*new_bp;
> -	int			error = 0;
> +	int			error;
>  
>  	*bpp = NULL;
>  	error = xfs_buf_find(target, map, nmaps, flags, NULL, &bp);
> -- 
> 2.7.4
> 

-- 
Carlos


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

* Re: [PATCH] xfs: remove redundant initialization of variable error
  2021-06-07 13:13 ` Carlos Maiolino
@ 2021-06-08  1:50   ` Shaokun Zhang
  0 siblings, 0 replies; 4+ messages in thread
From: Shaokun Zhang @ 2021-06-08  1:50 UTC (permalink / raw)
  To: linux-xfs, Darrick J. Wong

Hi Carlos,

On 2021/6/7 21:13, Carlos Maiolino wrote:
> Hi,
> 
> On Sat, Jun 05, 2021 at 04:52:50PM +0800, Shaokun Zhang wrote:
>> 'error' will be initialized, so clean up the redundant initialization.
>>
>> Cc: "Darrick J. Wong" <djwong@kernel.org>
>> Signed-off-by: Shaokun Zhang <zhangshaokun@hisilicon.com>
> 
> 
> This makes no difference in the resulting code.
> Particularly, I'd rather have such variables explicitly initialized. This
> function is small, so it's easy to see its initialization later in the code, but
> still, IMHO, it's way better to see the 'default error values' explicit at the
> beginning of the function. But, it's just my 'visual' preference :)

Thanks your reply, as you also said that it would be assigned later, the
initialization is unnecessary. I'm fine that Darrick will take it or not.

Cheers,
Shaokun

> 
> 
>> ---
>>  fs/xfs/xfs_buf.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
>> index 592800c8852f..59991c8c7127 100644
>> --- a/fs/xfs/xfs_buf.c
>> +++ b/fs/xfs/xfs_buf.c
>> @@ -707,7 +707,7 @@ xfs_buf_get_map(
>>  {
>>  	struct xfs_buf		*bp;
>>  	struct xfs_buf		*new_bp;
>> -	int			error = 0;
>> +	int			error;
>>  
>>  	*bpp = NULL;
>>  	error = xfs_buf_find(target, map, nmaps, flags, NULL, &bp);
>> -- 
>> 2.7.4
>>
> 

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

* Re: [PATCH] xfs: remove redundant initialization of variable error
  2021-06-05  8:52 [PATCH] xfs: remove redundant initialization of variable error Shaokun Zhang
  2021-06-07 13:13 ` Carlos Maiolino
@ 2021-06-12  0:53 ` Darrick J. Wong
  1 sibling, 0 replies; 4+ messages in thread
From: Darrick J. Wong @ 2021-06-12  0:53 UTC (permalink / raw)
  To: Shaokun Zhang; +Cc: linux-xfs

On Sat, Jun 05, 2021 at 04:52:50PM +0800, Shaokun Zhang wrote:
> 'error' will be initialized, so clean up the redundant initialization.
> 
> Cc: "Darrick J. Wong" <djwong@kernel.org>
> Signed-off-by: Shaokun Zhang <zhangshaokun@hisilicon.com>

Looks ok,
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
>  fs/xfs/xfs_buf.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
> index 592800c8852f..59991c8c7127 100644
> --- a/fs/xfs/xfs_buf.c
> +++ b/fs/xfs/xfs_buf.c
> @@ -707,7 +707,7 @@ xfs_buf_get_map(
>  {
>  	struct xfs_buf		*bp;
>  	struct xfs_buf		*new_bp;
> -	int			error = 0;
> +	int			error;
>  
>  	*bpp = NULL;
>  	error = xfs_buf_find(target, map, nmaps, flags, NULL, &bp);
> -- 
> 2.7.4
> 

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

end of thread, other threads:[~2021-06-12  0:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-05  8:52 [PATCH] xfs: remove redundant initialization of variable error Shaokun Zhang
2021-06-07 13:13 ` Carlos Maiolino
2021-06-08  1:50   ` Shaokun Zhang
2021-06-12  0:53 ` Darrick J. Wong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.