linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ceph: remove unnecessary return in switch statement
@ 2020-08-14  9:38 Luis Henriques
  2020-08-14  9:52 ` David Laight
  0 siblings, 1 reply; 4+ messages in thread
From: Luis Henriques @ 2020-08-14  9:38 UTC (permalink / raw)
  To: Jeff Layton, Ilya Dryomov; +Cc: ceph-devel, linux-kernel, Luis Henriques

Since there's a return immediately after the 'break', there's no need for
this extra 'return' in the S_IFDIR case.

Signed-off-by: Luis Henriques <lhenriques@suse.de>
---
 fs/ceph/file.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index d51c3f2fdca0..04ab99c0223a 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -256,8 +256,6 @@ static int ceph_init_file(struct inode *inode, struct file *file, int fmode)
 	case S_IFDIR:
 		ret = ceph_init_file_info(inode, file, fmode,
 						S_ISDIR(inode->i_mode));
-		if (ret)
-			return ret;
 		break;
 
 	case S_IFLNK:


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

* RE: [PATCH] ceph: remove unnecessary return in switch statement
  2020-08-14  9:38 [PATCH] ceph: remove unnecessary return in switch statement Luis Henriques
@ 2020-08-14  9:52 ` David Laight
  2020-08-14 10:03   ` Luis Henriques
  0 siblings, 1 reply; 4+ messages in thread
From: David Laight @ 2020-08-14  9:52 UTC (permalink / raw)
  To: 'Luis Henriques', Jeff Layton, Ilya Dryomov
  Cc: ceph-devel, linux-kernel

From: Luis Henriques
> Sent: 14 August 2020 10:38
> 
> Since there's a return immediately after the 'break', there's no need for
> this extra 'return' in the S_IFDIR case.
> 
> Signed-off-by: Luis Henriques <lhenriques@suse.de>
> ---
>  fs/ceph/file.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/fs/ceph/file.c b/fs/ceph/file.c
> index d51c3f2fdca0..04ab99c0223a 100644
> --- a/fs/ceph/file.c
> +++ b/fs/ceph/file.c
> @@ -256,8 +256,6 @@ static int ceph_init_file(struct inode *inode, struct file *file, int fmode)
>  	case S_IFDIR:
>  		ret = ceph_init_file_info(inode, file, fmode,
>  						S_ISDIR(inode->i_mode));
> -		if (ret)
> -			return ret;
>  		break;
> 
>  	case S_IFLNK:

I'd move the other way and just do:
		return ceph_init_file_info(...);

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)


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

* Re: [PATCH] ceph: remove unnecessary return in switch statement
  2020-08-14  9:52 ` David Laight
@ 2020-08-14 10:03   ` Luis Henriques
  2020-08-16 14:00     ` Jeff Layton
  0 siblings, 1 reply; 4+ messages in thread
From: Luis Henriques @ 2020-08-14 10:03 UTC (permalink / raw)
  To: David Laight; +Cc: Jeff Layton, Ilya Dryomov, ceph-devel, linux-kernel

David Laight <David.Laight@ACULAB.COM> writes:

> From: Luis Henriques
>> Sent: 14 August 2020 10:38
>> 
>> Since there's a return immediately after the 'break', there's no need for
>> this extra 'return' in the S_IFDIR case.
>> 
>> Signed-off-by: Luis Henriques <lhenriques@suse.de>
>> ---
>>  fs/ceph/file.c | 2 --
>>  1 file changed, 2 deletions(-)
>> 
>> diff --git a/fs/ceph/file.c b/fs/ceph/file.c
>> index d51c3f2fdca0..04ab99c0223a 100644
>> --- a/fs/ceph/file.c
>> +++ b/fs/ceph/file.c
>> @@ -256,8 +256,6 @@ static int ceph_init_file(struct inode *inode, struct file *file, int fmode)
>>  	case S_IFDIR:
>>  		ret = ceph_init_file_info(inode, file, fmode,
>>  						S_ISDIR(inode->i_mode));
>> -		if (ret)
>> -			return ret;
>>  		break;
>> 
>>  	case S_IFLNK:
>
> I'd move the other way and just do:
> 		return ceph_init_file_info(...);

Sure, that would work too, although my preference would be to have a
single function exit point.  But I'll leave that decision to Jeff :-)

Cheers,
-- 
Luis

>
> 	David
>
> -
> Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
> Registration No: 1397386 (Wales)
>

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

* Re: [PATCH] ceph: remove unnecessary return in switch statement
  2020-08-14 10:03   ` Luis Henriques
@ 2020-08-16 14:00     ` Jeff Layton
  0 siblings, 0 replies; 4+ messages in thread
From: Jeff Layton @ 2020-08-16 14:00 UTC (permalink / raw)
  To: Luis Henriques, David Laight; +Cc: Ilya Dryomov, ceph-devel, linux-kernel

On Fri, 2020-08-14 at 11:03 +0100, Luis Henriques wrote:
> David Laight <David.Laight@ACULAB.COM> writes:
> 
> > From: Luis Henriques
> > > Sent: 14 August 2020 10:38
> > > 
> > > Since there's a return immediately after the 'break', there's no need for
> > > this extra 'return' in the S_IFDIR case.
> > > 
> > > Signed-off-by: Luis Henriques <lhenriques@suse.de>
> > > ---
> > >  fs/ceph/file.c | 2 --
> > >  1 file changed, 2 deletions(-)
> > > 
> > > diff --git a/fs/ceph/file.c b/fs/ceph/file.c
> > > index d51c3f2fdca0..04ab99c0223a 100644
> > > --- a/fs/ceph/file.c
> > > +++ b/fs/ceph/file.c
> > > @@ -256,8 +256,6 @@ static int ceph_init_file(struct inode *inode, struct file *file, int fmode)
> > >  	case S_IFDIR:
> > >  		ret = ceph_init_file_info(inode, file, fmode,
> > >  						S_ISDIR(inode->i_mode));
> > > -		if (ret)
> > > -			return ret;
> > >  		break;
> > > 
> > >  	case S_IFLNK:
> > 
> > I'd move the other way and just do:
> > 		return ceph_init_file_info(...);
> 
> Sure, that would work too, although my preference would be to have a
> single function exit point.  But I'll leave that decision to Jeff :-)
> 

I think I agree with Luis here (though it's really a bit subjective). I
don't think it'll matter much to the compiled result either way, and
that will probably be better if this function grows in complexity.

I'll plan to merge this patch in the next day or so.

Thanks!
-- 
Jeff Layton <jlayton@kernel.org>


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

end of thread, other threads:[~2020-08-16 14:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-14  9:38 [PATCH] ceph: remove unnecessary return in switch statement Luis Henriques
2020-08-14  9:52 ` David Laight
2020-08-14 10:03   ` Luis Henriques
2020-08-16 14:00     ` Jeff Layton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).