2022-04-12 23:18:27

by Fabio M. De Francesco

[permalink] [raw]
Subject: Re: [PATCH v2 2/2] staging: greybus: remove unneeded return

On marted? 12 aprile 2022 21:59:15 CEST Jaehee Park wrote:
> An empty function with void return type does not need an explicit
> return. Issue found by checkpatch.
>
> Signed-off-by: Jaehee Park <[email protected]>
> ---
> drivers/staging/greybus/audio_codec.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/drivers/staging/greybus/audio_codec.c b/drivers/staging/
greybus/audio_codec.c
> index 0f50d1e51e2c..3e3a16568def 100644
> --- a/drivers/staging/greybus/audio_codec.c
> +++ b/drivers/staging/greybus/audio_codec.c
> @@ -1032,7 +1032,6 @@ static int gbcodec_probe(struct snd_soc_component
*comp)
> static void gbcodec_remove(struct snd_soc_component *comp)
> {
> /* Empty function for now */
> - return;
> }
>
> static int gbcodec_write(struct snd_soc_component *comp, unsigned int
reg,
> --
> 2.25.1
>
Hi Jaehee,

If I recall it correctly, Dan Carpenter suggested to remove this empty
function.

When developers remove lines of code from a function which becomes empty
after the removals, they also remove the resulting empty function and
delete all the calls (if there are any left) at the same time.

Thanks,

Fabio M. De Francesco




2022-04-13 08:52:20

by Jaehee Park

[permalink] [raw]
Subject: Re: [PATCH v2 2/2] staging: greybus: remove unneeded return

On Tue, Apr 12, 2022 at 10:35:58PM +0200, Fabio M. De Francesco wrote:
> On marted? 12 aprile 2022 21:59:15 CEST Jaehee Park wrote:
> > An empty function with void return type does not need an explicit
> > return. Issue found by checkpatch.
> >
> > Signed-off-by: Jaehee Park <[email protected]>
> > ---
> > drivers/staging/greybus/audio_codec.c | 1 -
> > 1 file changed, 1 deletion(-)
> >
> > diff --git a/drivers/staging/greybus/audio_codec.c b/drivers/staging/
> greybus/audio_codec.c
> > index 0f50d1e51e2c..3e3a16568def 100644
> > --- a/drivers/staging/greybus/audio_codec.c
> > +++ b/drivers/staging/greybus/audio_codec.c
> > @@ -1032,7 +1032,6 @@ static int gbcodec_probe(struct snd_soc_component
> *comp)
> > static void gbcodec_remove(struct snd_soc_component *comp)
> > {
> > /* Empty function for now */
> > - return;
> > }
> >
> > static int gbcodec_write(struct snd_soc_component *comp, unsigned int
> reg,
> > --
> > 2.25.1
> >
> Hi Jaehee,
>
> If I recall it correctly, Dan Carpenter suggested to remove this empty
> function.
>
> When developers remove lines of code from a function which becomes empty
> after the removals, they also remove the resulting empty function and
> delete all the calls (if there are any left) at the same time.
>
> Thanks,
>
> Fabio M. De Francesco
>
>
>

Thanks Fabio for pointing this out!

2022-04-13 13:43:44

by Julia Lawall

[permalink] [raw]
Subject: Re: [PATCH v2 2/2] staging: greybus: remove unneeded return



On Tue, 12 Apr 2022, Fabio M. De Francesco wrote:

> On marted? 12 aprile 2022 21:59:15 CEST Jaehee Park wrote:
> > An empty function with void return type does not need an explicit
> > return. Issue found by checkpatch.
> >
> > Signed-off-by: Jaehee Park <[email protected]>
> > ---
> > drivers/staging/greybus/audio_codec.c | 1 -
> > 1 file changed, 1 deletion(-)
> >
> > diff --git a/drivers/staging/greybus/audio_codec.c b/drivers/staging/
> greybus/audio_codec.c
> > index 0f50d1e51e2c..3e3a16568def 100644
> > --- a/drivers/staging/greybus/audio_codec.c
> > +++ b/drivers/staging/greybus/audio_codec.c
> > @@ -1032,7 +1032,6 @@ static int gbcodec_probe(struct snd_soc_component
> *comp)
> > static void gbcodec_remove(struct snd_soc_component *comp)
> > {
> > /* Empty function for now */
> > - return;
> > }
> >
> > static int gbcodec_write(struct snd_soc_component *comp, unsigned int
> reg,
> > --
> > 2.25.1
> >
> Hi Jaehee,
>
> If I recall it correctly, Dan Carpenter suggested to remove this empty
> function.
>
> When developers remove lines of code from a function which becomes empty
> after the removals, they also remove the resulting empty function and
> delete all the calls (if there are any left) at the same time.

It's probably not relevant in this case, but the function could be needed
if it is a branch of an ifdef. Also if it is stored in a structure field
and the user of the structure does not check for NULL.

julia