Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Linux: Kernel

[PATCH] net/sunrpc/svc.c: fix sparse warning

 

 

Linux kernel RSS feed   Index | Next | Previous | View Threaded


hartleys at visionengravers

Apr 15, 2009, 12:46 PM

Post #1 of 10 (1446 views)
Permalink
[PATCH] net/sunrpc/svc.c: fix sparse warning

Fix sparse warning in net/sunrpc/svc.c.

warning: symbol 'node' shadows an earlier one

Signed-off-by: H Hartley Sweeten <hsweeten [at] visionengravers>

---

diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index 8847add..e781135 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -122,7 +122,7 @@ module_param_call(pool_mode, param_set_pool_mode,
param_get_pool_mode,
static int
svc_pool_map_choose_mode(void)
{
- unsigned int node;
+ unsigned int nid;

if (num_online_nodes() > 1) {
/*
@@ -132,8 +132,8 @@ svc_pool_map_choose_mode(void)
return SVC_POOL_PERNODE;
}

- node = any_online_node(node_online_map);
- if (nr_cpus_node(node) > 2) {
+ nid = any_online_node(node_online_map);
+ if (nr_cpus_node(nid) > 2) {
/*
* Non-trivial SMP, or CONFIG_NUMA on
* non-NUMA hardware, e.g. with a generic
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


jj at chaosbits

Apr 15, 2009, 1:49 PM

Post #2 of 10 (1354 views)
Permalink
Re: [PATCH] net/sunrpc/svc.c: fix sparse warning [In reply to]

On Wed, 15 Apr 2009, H Hartley Sweeten wrote:

> Fix sparse warning in net/sunrpc/svc.c.
>
> warning: symbol 'node' shadows an earlier one
>
> Signed-off-by: H Hartley Sweeten <hsweeten [at] visionengravers>
>
> ---
>
> diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
> index 8847add..e781135 100644
> --- a/net/sunrpc/svc.c
> +++ b/net/sunrpc/svc.c
> @@ -122,7 +122,7 @@ module_param_call(pool_mode, param_set_pool_mode,
> param_get_pool_mode,
> static int
> svc_pool_map_choose_mode(void)
> {
> - unsigned int node;
> + unsigned int nid;
>
> if (num_online_nodes() > 1) {
> /*
> @@ -132,8 +132,8 @@ svc_pool_map_choose_mode(void)
> return SVC_POOL_PERNODE;
> }
>
> - node = any_online_node(node_online_map);
> - if (nr_cpus_node(node) > 2) {
> + nid = any_online_node(node_online_map);
> + if (nr_cpus_node(nid) > 2) {
> /*
> * Non-trivial SMP, or CONFIG_NUMA on
> * non-NUMA hardware, e.g. with a generic

Looks sane to me.

Probably doesn't matter much, but feel free to add

Acked-by: Jesper Juhl <jj [at] chaosbits>

if you like...

--
Jesper Juhl <jj [at] chaosbits> http://www.chaosbits.net/
Plain text mails only, please http://www.expita.com/nomime.html
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


hartleys at visionengravers

Apr 15, 2009, 3:27 PM

Post #3 of 10 (1349 views)
Permalink
RE: [PATCH] net/sunrpc/svc.c: fix sparse warning [In reply to]

Fix sparse warning in net/sunrpc/svc.c.

warning: symbol 'node' shadows an earlier one

Signed-off-by: H Hartley Sweeten <hsweeten [at] visionengravers>
Acked-by: Jesper Juhl <jj [at] chaosbits>

---

diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index 8847add..e781135 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -122,7 +122,7 @@ module_param_call(pool_mode, param_set_pool_mode,
param_get_pool_mode,
static int
svc_pool_map_choose_mode(void)
{
- unsigned int node;
+ unsigned int nid;

if (num_online_nodes() > 1) {
/*
@@ -132,8 +132,8 @@ svc_pool_map_choose_mode(void)
return SVC_POOL_PERNODE;
}

- node = any_online_node(node_online_map);
- if (nr_cpus_node(node) > 2) {
+ nid = any_online_node(node_online_map);
+ if (nr_cpus_node(nid) > 2) {
/*
* Non-trivial SMP, or CONFIG_NUMA on
* non-NUMA hardware, e.g. with a generic
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


bfields at fieldses

Apr 16, 2009, 12:06 PM

Post #4 of 10 (1338 views)
Permalink
Re: [PATCH] net/sunrpc/svc.c: fix sparse warning [In reply to]

On Wed, Apr 15, 2009 at 03:46:13PM -0400, H Hartley Sweeten wrote:
> Fix sparse warning in net/sunrpc/svc.c.
>
> warning: symbol 'node' shadows an earlier one

What's the other symbol?

>
> Signed-off-by: H Hartley Sweeten <hsweeten [at] visionengravers>
>
> ---
>
> diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
> index 8847add..e781135 100644
> --- a/net/sunrpc/svc.c
> +++ b/net/sunrpc/svc.c
> @@ -122,7 +122,7 @@ module_param_call(pool_mode, param_set_pool_mode,
> param_get_pool_mode,
> static int
> svc_pool_map_choose_mode(void)
> {
> - unsigned int node;
> + unsigned int nid;
>
> if (num_online_nodes() > 1) {
> /*
> @@ -132,8 +132,8 @@ svc_pool_map_choose_mode(void)
> return SVC_POOL_PERNODE;
> }
>
> - node = any_online_node(node_online_map);
> - if (nr_cpus_node(node) > 2) {
> + nid = any_online_node(node_online_map);
> + if (nr_cpus_node(nid) > 2) {
> /*
> * Non-trivial SMP, or CONFIG_NUMA on
> * non-NUMA hardware, e.g. with a generic
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo [at] vger
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


hartleys at visionengravers

Apr 16, 2009, 12:15 PM

Post #5 of 10 (1337 views)
Permalink
RE: [PATCH] net/sunrpc/svc.c: fix sparse warning [In reply to]

On Thursday, April 16, 2009 12:06 PM, J. Bruce Fields wrote:
> On Wed, Apr 15, 2009 at 03:46:13PM -0400, H Hartley Sweeten wrote:
>> Fix sparse warning in net/sunrpc/svc.c.
>>
>> warning: symbol 'node' shadows an earlier one
>
> What's the other symbol?

Sorry. Left that out...

include/linux/nodemask.h

#define any_online_node(mask) \
({ \
int node; \
for_each_node_mask(node, (mask)) \
if (node_online(node)) \
break; \
node; \
})

arch/powerpc/mm/numa.c is the only other user of that macro. In that
file the local variable is called nid, hence the name change in this
patch.

Regards,
Hartley

>>
>> Signed-off-by: H Hartley Sweeten <hsweeten [at] visionengravers>
>>
>> ---
>>
>> diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
>> index 8847add..e781135 100644
>> --- a/net/sunrpc/svc.c
>> +++ b/net/sunrpc/svc.c
>> @@ -122,7 +122,7 @@ module_param_call(pool_mode, param_set_pool_mode,
>> param_get_pool_mode,
>> static int
>> svc_pool_map_choose_mode(void)
>> {
>> - unsigned int node;
>> + unsigned int nid;
>>
>> if (num_online_nodes() > 1) {
>> /*
>> @@ -132,8 +132,8 @@ svc_pool_map_choose_mode(void)
>> return SVC_POOL_PERNODE;
>> }
>>
>> - node = any_online_node(node_online_map);
>> - if (nr_cpus_node(node) > 2) {
>> + nid = any_online_node(node_online_map);
>> + if (nr_cpus_node(nid) > 2) {
>> /*
>> * Non-trivial SMP, or CONFIG_NUMA on
>> * non-NUMA hardware, e.g. with a generic
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


bfields at fieldses

May 11, 2009, 4:05 PM

Post #6 of 10 (1297 views)
Permalink
Re: [PATCH] net/sunrpc/svc.c: fix sparse warning [In reply to]

On Thu, Apr 16, 2009 at 03:15:17PM -0400, H Hartley Sweeten wrote:
> On Thursday, April 16, 2009 12:06 PM, J. Bruce Fields wrote:
> > On Wed, Apr 15, 2009 at 03:46:13PM -0400, H Hartley Sweeten wrote:
> >> Fix sparse warning in net/sunrpc/svc.c.
> >>
> >> warning: symbol 'node' shadows an earlier one
> >
> > What's the other symbol?
>
> Sorry. Left that out...
>
> include/linux/nodemask.h
>
> #define any_online_node(mask) \
> ({ \
> int node; \
> for_each_node_mask(node, (mask)) \
> if (node_online(node)) \
> break; \
> node; \
> })
>
> arch/powerpc/mm/numa.c is the only other user of that macro. In that
> file the local variable is called nid, hence the name change in this
> patch.

Stupid question (and sorry for the delay): any reason that macro
couldn't just be a static inline function?

I'm sort of resistant to the idea that the caller should have to care
what local variable names the implementation uses.

--b.

>
> Regards,
> Hartley
>
> >>
> >> Signed-off-by: H Hartley Sweeten <hsweeten [at] visionengravers>
> >>
> >> ---
> >>
> >> diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
> >> index 8847add..e781135 100644
> >> --- a/net/sunrpc/svc.c
> >> +++ b/net/sunrpc/svc.c
> >> @@ -122,7 +122,7 @@ module_param_call(pool_mode, param_set_pool_mode,
> >> param_get_pool_mode,
> >> static int
> >> svc_pool_map_choose_mode(void)
> >> {
> >> - unsigned int node;
> >> + unsigned int nid;
> >>
> >> if (num_online_nodes() > 1) {
> >> /*
> >> @@ -132,8 +132,8 @@ svc_pool_map_choose_mode(void)
> >> return SVC_POOL_PERNODE;
> >> }
> >>
> >> - node = any_online_node(node_online_map);
> >> - if (nr_cpus_node(node) > 2) {
> >> + nid = any_online_node(node_online_map);
> >> + if (nr_cpus_node(nid) > 2) {
> >> /*
> >> * Non-trivial SMP, or CONFIG_NUMA on
> >> * non-NUMA hardware, e.g. with a generic
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


hartleys at visionengravers

May 14, 2009, 8:58 AM

Post #7 of 10 (1288 views)
Permalink
RE: [PATCH] net/sunrpc/svc.c: fix sparse warning [In reply to]

On Monday, May 11, 2009 4:06 PM, J. Bruce Fields wrote:
> On Thu, Apr 16, 2009 at 03:15:17PM -0400, H Hartley Sweeten wrote:
>> On Thursday, April 16, 2009 12:06 PM, J. Bruce Fields wrote:
>>> On Wed, Apr 15, 2009 at 03:46:13PM -0400, H Hartley Sweeten wrote:
>>>> Fix sparse warning in net/sunrpc/svc.c.
>>>>
>>>> warning: symbol 'node' shadows an earlier one
>>>
>>> What's the other symbol?
>>
>> Sorry. Left that out...
>>
>> include/linux/nodemask.h
>>
>> #define any_online_node(mask) \
>> ({ \
>> int node; \
>> for_each_node_mask(node, (mask)) \
>> if (node_online(node)) \
>> break; \
>> node; \
>> })
>>
>> arch/powerpc/mm/numa.c is the only other user of that macro. In that
>> file the local variable is called nid, hence the name change in this
>> patch.
>
> Stupid question (and sorry for the delay): any reason that macro
> couldn't just be a static inline function?
>
> I'm sort of resistant to the idea that the caller should have to care
> what local variable names the implementation uses.

That would probably be cleaner and it would prevent the same warning
from possibly occurring in the future. I just assumed it was originally
made a macro for a good reason.

Should I submit an updated patch changing the macro into an static
inline function?

Thanks,
Hartley
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


bfields at fieldses

May 14, 2009, 9:00 AM

Post #8 of 10 (1285 views)
Permalink
Re: [PATCH] net/sunrpc/svc.c: fix sparse warning [In reply to]

On Thu, May 14, 2009 at 11:58:37AM -0400, H Hartley Sweeten wrote:
> On Monday, May 11, 2009 4:06 PM, J. Bruce Fields wrote:
> > On Thu, Apr 16, 2009 at 03:15:17PM -0400, H Hartley Sweeten wrote:
> >> On Thursday, April 16, 2009 12:06 PM, J. Bruce Fields wrote:
> >>> On Wed, Apr 15, 2009 at 03:46:13PM -0400, H Hartley Sweeten wrote:
> >>>> Fix sparse warning in net/sunrpc/svc.c.
> >>>>
> >>>> warning: symbol 'node' shadows an earlier one
> >>>
> >>> What's the other symbol?
> >>
> >> Sorry. Left that out...
> >>
> >> include/linux/nodemask.h
> >>
> >> #define any_online_node(mask) \
> >> ({ \
> >> int node; \
> >> for_each_node_mask(node, (mask)) \
> >> if (node_online(node)) \
> >> break; \
> >> node; \
> >> })
> >>
> >> arch/powerpc/mm/numa.c is the only other user of that macro. In that
> >> file the local variable is called nid, hence the name change in this
> >> patch.
> >
> > Stupid question (and sorry for the delay): any reason that macro
> > couldn't just be a static inline function?
> >
> > I'm sort of resistant to the idea that the caller should have to care
> > what local variable names the implementation uses.
>
> That would probably be cleaner and it would prevent the same warning
> from possibly occurring in the future. I just assumed it was originally
> made a macro for a good reason.
>
> Should I submit an updated patch changing the macro into an static
> inline function?

I'd be for it. If nothing else that'll probably be the fastest way to
find out if there was a good reason!

--b.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


hartleys at visionengravers

May 14, 2009, 10:25 AM

Post #9 of 10 (1285 views)
Permalink
RE: [PATCH] net/sunrpc/svc.c: fix sparse warning [In reply to]

Change any_online_node() from a macro to a static inline function.

any_online_node() uses the symbol 'node', this causes a sparse
warning in net/sunrpc/svc.c. Changing the macro to a static
inline function removes the sparse warning and will prevent the
same warning from possibly occurring in the future.

Signed-off-by: H Hartley Sweeten <hsweeten [at] visionengravers>

---

diff --git a/include/linux/nodemask.h b/include/linux/nodemask.h
index 848025c..16df302 100644
--- a/include/linux/nodemask.h
+++ b/include/linux/nodemask.h
@@ -440,15 +440,6 @@ static inline int num_node_state(enum node_states state)
#define node_online_map node_states[N_ONLINE]
#define node_possible_map node_states[N_POSSIBLE]

-#define any_online_node(mask) \
-({ \
- int node; \
- for_each_node_mask(node, (mask)) \
- if (node_online(node)) \
- break; \
- node; \
-})
-
#define num_online_nodes() num_node_state(N_ONLINE)
#define num_possible_nodes() num_node_state(N_POSSIBLE)
#define node_online(node) node_state((node), N_ONLINE)
@@ -460,4 +451,15 @@ static inline int num_node_state(enum node_states state)
#define for_each_node(node) for_each_node_state(node, N_POSSIBLE)
#define for_each_online_node(node) for_each_node_state(node, N_ONLINE)

+static inline int any_online_node(nodemask_t mask)
+{
+ int node;
+
+ for_each_node_mask(node, mask) {
+ if (node_online(node))
+ break;
+ }
+ return node;
+}
+
#endif /* __LINUX_NODEMASK_H */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


bfields at fieldses

May 14, 2009, 12:02 PM

Post #10 of 10 (1290 views)
Permalink
Re: [PATCH] net/sunrpc/svc.c: fix sparse warning [In reply to]

On Thu, May 14, 2009 at 01:25:45PM -0400, H Hartley Sweeten wrote:
> Change any_online_node() from a macro to a static inline function.
>
> any_online_node() uses the symbol 'node', this causes a sparse
> warning in net/sunrpc/svc.c. Changing the macro to a static
> inline function removes the sparse warning and will prevent the
> same warning from possibly occurring in the future.
>
> Signed-off-by: H Hartley Sweeten <hsweeten [at] visionengravers>

I'm not sure where this goes--so maybe Andrew should take it?

--b.

>
> ---
>
> diff --git a/include/linux/nodemask.h b/include/linux/nodemask.h
> index 848025c..16df302 100644
> --- a/include/linux/nodemask.h
> +++ b/include/linux/nodemask.h
> @@ -440,15 +440,6 @@ static inline int num_node_state(enum node_states state)
> #define node_online_map node_states[N_ONLINE]
> #define node_possible_map node_states[N_POSSIBLE]
>
> -#define any_online_node(mask) \
> -({ \
> - int node; \
> - for_each_node_mask(node, (mask)) \
> - if (node_online(node)) \
> - break; \
> - node; \
> -})
> -
> #define num_online_nodes() num_node_state(N_ONLINE)
> #define num_possible_nodes() num_node_state(N_POSSIBLE)
> #define node_online(node) node_state((node), N_ONLINE)
> @@ -460,4 +451,15 @@ static inline int num_node_state(enum node_states state)
> #define for_each_node(node) for_each_node_state(node, N_POSSIBLE)
> #define for_each_online_node(node) for_each_node_state(node, N_ONLINE)
>
> +static inline int any_online_node(nodemask_t mask)
> +{
> + int node;
> +
> + for_each_node_mask(node, mask) {
> + if (node_online(node))
> + break;
> + }
> + return node;
> +}
> +
> #endif /* __LINUX_NODEMASK_H */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Linux kernel RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.