linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] thermal/drivers/hisi: Remove bogus const from function return type
@ 2017-11-19 11:04 Geert Uytterhoeven
  2018-01-01 18:21 ` Eduardo Valentin
  2018-01-02 11:44 ` [PATCH] " Arnd Bergmann
  0 siblings, 2 replies; 5+ messages in thread
From: Geert Uytterhoeven @ 2017-11-19 11:04 UTC (permalink / raw)
  To: Zhang Rui, Eduardo Valentin, Kevin Wangtao
  Cc: Arnd Bergmann, linux-pm, linux-kernel, Geert Uytterhoeven

With gcc-4.1.2:

    drivers/thermal/hisi_thermal.c: In function ‘hisi_thermal_probe’:
    drivers/thermal/hisi_thermal.c:530: warning: type qualifiers ignored on function return type

Remove the "const" keyword to fix this.

Fixes: a160a465297362c5 ("thermal/drivers/hisi: Prepare to add support for other hisi platforms")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
 drivers/thermal/hisi_thermal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c
index 2d855a96cdd9886c..761d0559c268b606 100644
--- a/drivers/thermal/hisi_thermal.c
+++ b/drivers/thermal/hisi_thermal.c
@@ -527,7 +527,7 @@ static void hisi_thermal_toggle_sensor(struct hisi_thermal_sensor *sensor,
 static int hisi_thermal_probe(struct platform_device *pdev)
 {
 	struct hisi_thermal_data *data;
-	int const (*platform_probe)(struct hisi_thermal_data *);
+	int (*platform_probe)(struct hisi_thermal_data *);
 	struct device *dev = &pdev->dev;
 	int ret;
 
-- 
2.7.4

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

* Re: thermal/drivers/hisi: Remove bogus const from function return type
  2017-11-19 11:04 [PATCH] thermal/drivers/hisi: Remove bogus const from function return type Geert Uytterhoeven
@ 2018-01-01 18:21 ` Eduardo Valentin
  2018-01-02  7:36   ` Geert Uytterhoeven
  2018-01-02 11:44 ` [PATCH] " Arnd Bergmann
  1 sibling, 1 reply; 5+ messages in thread
From: Eduardo Valentin @ 2018-01-01 18:21 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Zhang Rui, Kevin Wangtao, Arnd Bergmann, linux-pm, linux-kernel

Hello Geert,

On Sun, Nov 19, 2017 at 12:04:27PM +0100, Geert Uytterhoeven wrote:
> With gcc-4.1.2:
> 
>     drivers/thermal/hisi_thermal.c: In function ‘hisi_thermal_probe’:
>     drivers/thermal/hisi_thermal.c:530: warning: type qualifiers ignored on function return type
> 
> Remove the "const" keyword to fix this.

Interesting.

I intentionally asked Daniel to include the modifier because sparse
pointed this to me:

This patch adds this issue to hisi driver (sparse)

drivers/thermal/hisi_thermal.c:398:24: warning: incorrect type in assignment (different modifiers)
drivers/thermal/hisi_thermal.c:398:24:    expected int ( *platform_probe )( ... )
drivers/thermal/hisi_thermal.c:398:24:    got void const *

which makes sense to me to be const, given that it is receiving the return 
of a function which returns a const void *. 
nclude/linux/of_device.h:extern const void *of_device_get_match_data(const struct device *dev);

Cheers,

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

* Re: thermal/drivers/hisi: Remove bogus const from function return type
  2018-01-01 18:21 ` Eduardo Valentin
@ 2018-01-02  7:36   ` Geert Uytterhoeven
  0 siblings, 0 replies; 5+ messages in thread
From: Geert Uytterhoeven @ 2018-01-02  7:36 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Zhang Rui, Kevin Wangtao, Arnd Bergmann, Linux PM list,
	Linux Kernel Mailing List

Hi Eduardo,

On Mon, Jan 1, 2018 at 7:21 PM, Eduardo Valentin <edubezval@gmail.com> wrote:
> On Sun, Nov 19, 2017 at 12:04:27PM +0100, Geert Uytterhoeven wrote:
>> With gcc-4.1.2:
>>
>>     drivers/thermal/hisi_thermal.c: In function ‘hisi_thermal_probe’:
>>     drivers/thermal/hisi_thermal.c:530: warning: type qualifiers ignored on function return type
>>
>> Remove the "const" keyword to fix this.
>
> Interesting.
>
> I intentionally asked Daniel to include the modifier because sparse
> pointed this to me:
>
> This patch adds this issue to hisi driver (sparse)
>
> drivers/thermal/hisi_thermal.c:398:24: warning: incorrect type in assignment (different modifiers)
> drivers/thermal/hisi_thermal.c:398:24:    expected int ( *platform_probe )( ... )
> drivers/thermal/hisi_thermal.c:398:24:    got void const *

Sparse doesn't like assigning void pointers to function pointers without a cast.

> which makes sense to me to be const, given that it is receiving the return
> of a function which returns a const void *.
> nclude/linux/of_device.h:extern const void *of_device_get_match_data(const struct device *dev);

That const applies to what is returned by of_device_get_match_data() (a const
void *), not to what is returned by the returned function (an int).

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH] thermal/drivers/hisi: Remove bogus const from function return type
  2017-11-19 11:04 [PATCH] thermal/drivers/hisi: Remove bogus const from function return type Geert Uytterhoeven
  2018-01-01 18:21 ` Eduardo Valentin
@ 2018-01-02 11:44 ` Arnd Bergmann
  2018-01-02 17:50   ` Eduardo Valentin
  1 sibling, 1 reply; 5+ messages in thread
From: Arnd Bergmann @ 2018-01-02 11:44 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Zhang Rui, Eduardo Valentin, Kevin Wangtao, linux-pm,
	Linux Kernel Mailing List

On Sun, Nov 19, 2017 at 12:04 PM, Geert Uytterhoeven
<geert@linux-m68k.org> wrote:
> With gcc-4.1.2:
>
>     drivers/thermal/hisi_thermal.c: In function ‘hisi_thermal_probe’:
>     drivers/thermal/hisi_thermal.c:530: warning: type qualifiers ignored on function return type
>
> Remove the "const" keyword to fix this.
>
> Fixes: a160a465297362c5 ("thermal/drivers/hisi: Prepare to add support for other hisi platforms")
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>

For future reference, this kind of warning shows up with gcc-4.2 as
well, but not with
gcc-4.3 or higher. I think in this case, both gcc and sparse fail to
provide helpful
feedback, but the code is probably better done using either a typedef
for the function
type, or with a structure containing the function pointer.

         Arnd

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

* Re: [PATCH] thermal/drivers/hisi: Remove bogus const from function return type
  2018-01-02 11:44 ` [PATCH] " Arnd Bergmann
@ 2018-01-02 17:50   ` Eduardo Valentin
  0 siblings, 0 replies; 5+ messages in thread
From: Eduardo Valentin @ 2018-01-02 17:50 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Geert Uytterhoeven, Zhang Rui, Kevin Wangtao, linux-pm,
	Linux Kernel Mailing List

On Tue, Jan 02, 2018 at 12:44:29PM +0100, Arnd Bergmann wrote:
> On Sun, Nov 19, 2017 at 12:04 PM, Geert Uytterhoeven
> <geert@linux-m68k.org> wrote:
> > With gcc-4.1.2:
> >
> >     drivers/thermal/hisi_thermal.c: In function ‘hisi_thermal_probe’:
> >     drivers/thermal/hisi_thermal.c:530: warning: type qualifiers ignored on function return type
> >
> > Remove the "const" keyword to fix this.
> >
> > Fixes: a160a465297362c5 ("thermal/drivers/hisi: Prepare to add support for other hisi platforms")
> > Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
> 
> For future reference, this kind of warning shows up with gcc-4.2 as
> well, but not with
> gcc-4.3 or higher. I think in this case, both gcc and sparse fail to

Yeah, this is correct. I do not see the same warn while using gcc-4.8.

> provide helpful
> feedback, but the code is probably better done using either a typedef
> for the function
> type, or with a structure containing the function pointer.

I agree.

> 
>          Arnd

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

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

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-19 11:04 [PATCH] thermal/drivers/hisi: Remove bogus const from function return type Geert Uytterhoeven
2018-01-01 18:21 ` Eduardo Valentin
2018-01-02  7:36   ` Geert Uytterhoeven
2018-01-02 11:44 ` [PATCH] " Arnd Bergmann
2018-01-02 17:50   ` Eduardo Valentin

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).