2023-05-23 12:43:22

by Tom Rix

[permalink] [raw]
Subject: [PATCH] watchdog: set variables watchdog_soft,hardlockup_user_enabled storage-class-specifier to static

smatch reports
kernel/watchdog.c:40:19: warning: symbol
'watchdog_hardlockup_user_enabled' was not declared. Should it be static?
kernel/watchdog.c:41:19: warning: symbol
'watchdog_softlockup_user_enabled' was not declared. Should it be static?

These variabled are only used in their defining file, so it should be static.

Signed-off-by: Tom Rix <[email protected]>
---
kernel/watchdog.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/watchdog.c b/kernel/watchdog.c
index 877d8670f26e..237990e8d345 100644
--- a/kernel/watchdog.c
+++ b/kernel/watchdog.c
@@ -37,8 +37,8 @@ static DEFINE_MUTEX(watchdog_mutex);

unsigned long __read_mostly watchdog_enabled;
int __read_mostly watchdog_user_enabled = 1;
-int __read_mostly watchdog_hardlockup_user_enabled = WATCHDOG_HARDLOCKUP_DEFAULT;
-int __read_mostly watchdog_softlockup_user_enabled = 1;
+static int __read_mostly watchdog_hardlockup_user_enabled = WATCHDOG_HARDLOCKUP_DEFAULT;
+static int __read_mostly watchdog_softlockup_user_enabled = 1;
int __read_mostly watchdog_thresh = 10;
static int __read_mostly watchdog_hardlockup_available;

--
2.27.0



2023-05-23 13:11:59

by Mukesh Ojha

[permalink] [raw]
Subject: Re: [PATCH] watchdog: set variables watchdog_soft,hardlockup_user_enabled storage-class-specifier to static



On 5/23/2023 5:53 PM, Tom Rix wrote:
> smatch reports
> kernel/watchdog.c:40:19: warning: symbol
> 'watchdog_hardlockup_user_enabled' was not declared. Should it be static?
> kernel/watchdog.c:41:19: warning: symbol
> 'watchdog_softlockup_user_enabled' was not declared. Should it be static?
>
> These variabled are only used in their defining file, so it should be static.
>
> Signed-off-by: Tom Rix <[email protected]>

Reviewed-by: Mukesh Ojha <[email protected]>

-- Mukesh

> ---
> kernel/watchdog.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/watchdog.c b/kernel/watchdog.c
> index 877d8670f26e..237990e8d345 100644
> --- a/kernel/watchdog.c
> +++ b/kernel/watchdog.c
> @@ -37,8 +37,8 @@ static DEFINE_MUTEX(watchdog_mutex);
>
> unsigned long __read_mostly watchdog_enabled;
> int __read_mostly watchdog_user_enabled = 1;
> -int __read_mostly watchdog_hardlockup_user_enabled = WATCHDOG_HARDLOCKUP_DEFAULT;
> -int __read_mostly watchdog_softlockup_user_enabled = 1;
> +static int __read_mostly watchdog_hardlockup_user_enabled = WATCHDOG_HARDLOCKUP_DEFAULT;
> +static int __read_mostly watchdog_softlockup_user_enabled = 1;
> int __read_mostly watchdog_thresh = 10;
> static int __read_mostly watchdog_hardlockup_available;
>

2023-05-23 14:31:08

by Doug Anderson

[permalink] [raw]
Subject: Re: [PATCH] watchdog: set variables watchdog_soft,hardlockup_user_enabled storage-class-specifier to static

Hi,

On Tue, May 23, 2023 at 5:23 AM Tom Rix <[email protected]> wrote:
>
> smatch reports
> kernel/watchdog.c:40:19: warning: symbol
> 'watchdog_hardlockup_user_enabled' was not declared. Should it be static?
> kernel/watchdog.c:41:19: warning: symbol
> 'watchdog_softlockup_user_enabled' was not declared. Should it be static?
>
> These variabled are only used in their defining file, so it should be static.

s/variabled/variables

>
> Signed-off-by: Tom Rix <[email protected]>
> ---
> kernel/watchdog.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)

While your fix is valid (thanks!), it's only half the fix.

I wondered why smatch would have suddenly noticed this since the
change that touched this variable recently was only a rename. When I
dug deeper, I realized that the old names actually _were_ referenced
outside this file and my rename missed them. The reason I missed them
is that the only reference is an "extern" reference in
`include/linux/nmi.h`. The references in `include/linux/nmi.h`
probably should have been removed in commit dd0693fdf054 ("watchdog:
move watchdog sysctl interface to watchdog.c")

...so a more complete fix would also remove references to the old
names (nmi_watchdog_user_enabled and soft_watchdog_user_enabled) in
`include/linux/nmi.h`.

-Doug

2023-05-24 18:29:20

by Doug Anderson

[permalink] [raw]
Subject: Re: [PATCH] watchdog: set variables watchdog_soft,hardlockup_user_enabled storage-class-specifier to static

Hi,

On Tue, May 23, 2023 at 7:12 AM Doug Anderson <[email protected]> wrote:
>
> Hi,
>
> On Tue, May 23, 2023 at 5:23 AM Tom Rix <[email protected]> wrote:
> >
> > smatch reports
> > kernel/watchdog.c:40:19: warning: symbol
> > 'watchdog_hardlockup_user_enabled' was not declared. Should it be static?
> > kernel/watchdog.c:41:19: warning: symbol
> > 'watchdog_softlockup_user_enabled' was not declared. Should it be static?
> >
> > These variabled are only used in their defining file, so it should be static.
>
> s/variabled/variables
>
> >
> > Signed-off-by: Tom Rix <[email protected]>
> > ---
> > kernel/watchdog.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
>
> While your fix is valid (thanks!), it's only half the fix.
>
> I wondered why smatch would have suddenly noticed this since the
> change that touched this variable recently was only a rename. When I
> dug deeper, I realized that the old names actually _were_ referenced
> outside this file and my rename missed them. The reason I missed them
> is that the only reference is an "extern" reference in
> `include/linux/nmi.h`. The references in `include/linux/nmi.h`
> probably should have been removed in commit dd0693fdf054 ("watchdog:
> move watchdog sysctl interface to watchdog.c")
>
> ...so a more complete fix would also remove references to the old
> names (nmi_watchdog_user_enabled and soft_watchdog_user_enabled) in
> `include/linux/nmi.h`.

FWIW, Petr has the other half of the fix at:

https://lore.kernel.org/r/ZG4TW--j-DdSsUO6@alley

Any chance you could send out a v2 and include that? If I don't see
something by tomorrow morning I'll try to send out a v2 for you that
squashes your and his changes.

-Doug

2023-05-26 00:01:11

by Doug Anderson

[permalink] [raw]
Subject: Re: [PATCH] watchdog: set variables watchdog_soft,hardlockup_user_enabled storage-class-specifier to static

Hi,

On Wed, May 24, 2023 at 11:05 AM Doug Anderson <[email protected]> wrote:
>
> Hi,
>
> On Tue, May 23, 2023 at 7:12 AM Doug Anderson <[email protected]> wrote:
> >
> > Hi,
> >
> > On Tue, May 23, 2023 at 5:23 AM Tom Rix <[email protected]> wrote:
> > >
> > > smatch reports
> > > kernel/watchdog.c:40:19: warning: symbol
> > > 'watchdog_hardlockup_user_enabled' was not declared. Should it be static?
> > > kernel/watchdog.c:41:19: warning: symbol
> > > 'watchdog_softlockup_user_enabled' was not declared. Should it be static?
> > >
> > > These variabled are only used in their defining file, so it should be static.
> >
> > s/variabled/variables
> >
> > >
> > > Signed-off-by: Tom Rix <[email protected]>
> > > ---
> > > kernel/watchdog.c | 4 ++--
> > > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > While your fix is valid (thanks!), it's only half the fix.
> >
> > I wondered why smatch would have suddenly noticed this since the
> > change that touched this variable recently was only a rename. When I
> > dug deeper, I realized that the old names actually _were_ referenced
> > outside this file and my rename missed them. The reason I missed them
> > is that the only reference is an "extern" reference in
> > `include/linux/nmi.h`. The references in `include/linux/nmi.h`
> > probably should have been removed in commit dd0693fdf054 ("watchdog:
> > move watchdog sysctl interface to watchdog.c")
> >
> > ...so a more complete fix would also remove references to the old
> > names (nmi_watchdog_user_enabled and soft_watchdog_user_enabled) in
> > `include/linux/nmi.h`.
>
> FWIW, Petr has the other half of the fix at:
>
> https://lore.kernel.org/r/ZG4TW--j-DdSsUO6@alley
>
> Any chance you could send out a v2 and include that? If I don't see
> something by tomorrow morning I'll try to send out a v2 for you that
> squashes your and his changes.

Maybe it's still morning somewhere. In any case, I squashed and posted:

https://lore.kernel.org/r/20230525162822.1.I0fb41d138d158c9230573eaa37dc56afa2fb14ee@changeid

Assuming that looks OK it should be considered as superseding $SUBJECT patch.