2007-12-09 21:34:31

by Marcin Ślusarz

[permalink] [raw]
Subject: [PATCH] fbcon: fix sparse warning about shadowing 'p' symbol

fbcon: fix sparse warning about shadowing 'p' symbol

Signed-off-by: Marcin Ślusarz <[email protected]>
---
drivers/video/console/fbcon.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index 0f32f4a..849e114 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -2795,7 +2795,7 @@ static int fbcon_scrolldelta(struct vc_data *vc, int lines)
{
struct fb_info *info = registered_fb[con2fb_map[fg_console]];
struct fbcon_ops *ops = info->fbcon_par;
- struct display *p = &fb_display[fg_console];
+ struct display *disp = &fb_display[fg_console];
int offset, limit, scrollback_old;

if (softback_top) {
@@ -2833,7 +2833,7 @@ static int fbcon_scrolldelta(struct vc_data *vc, int lines)
logo_shown = FBCON_LOGO_CANSHOW;
}
fbcon_cursor(vc, CM_ERASE | CM_SOFTBACK);
- fbcon_redraw_softback(vc, p, lines);
+ fbcon_redraw_softback(vc, disp, lines);
fbcon_cursor(vc, CM_DRAW | CM_SOFTBACK);
return 0;
}
@@ -2855,9 +2855,9 @@ static int fbcon_scrolldelta(struct vc_data *vc, int lines)

fbcon_cursor(vc, CM_ERASE);

- offset = p->yscroll - scrollback_current;
- limit = p->vrows;
- switch (p->scrollmode) {
+ offset = disp->yscroll - scrollback_current;
+ limit = disp->vrows;
+ switch (disp->scrollmode) {
case SCROLL_WRAP_MOVE:
info->var.vmode |= FB_VMODE_YWRAP;
break;


2007-12-12 00:57:17

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH] fbcon: fix sparse warning about shadowing 'p' symbol

On Sun, 9 Dec 2007 22:34:33 +0100
Marcin __lusarz <[email protected]> wrote:

> fbcon: fix sparse warning about shadowing 'p' symbol
>

Please always quote error messages and warnings in the changelog when
fixing them, thanks.

> ---
> drivers/video/console/fbcon.c | 10 +++++-----
> 1 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
> index 0f32f4a..849e114 100644
> --- a/drivers/video/console/fbcon.c
> +++ b/drivers/video/console/fbcon.c
> @@ -2795,7 +2795,7 @@ static int fbcon_scrolldelta(struct vc_data *vc, int lines)
> {
> struct fb_info *info = registered_fb[con2fb_map[fg_console]];
> struct fbcon_ops *ops = info->fbcon_par;
> - struct display *p = &fb_display[fg_console];
> + struct display *disp = &fb_display[fg_console];

We have a global symbol called "p"? That would be bad. Where is it?

(The patch is good anwyay - "p" is a poorly chosen identifier here).

2007-12-12 02:50:49

by Dave Jones

[permalink] [raw]
Subject: Re: [PATCH] fbcon: fix sparse warning about shadowing 'p' symbol

On Tue, Dec 11, 2007 at 04:57:00PM -0800, Andrew Morton wrote:

> > --- a/drivers/video/console/fbcon.c
> > +++ b/drivers/video/console/fbcon.c
> > @@ -2795,7 +2795,7 @@ static int fbcon_scrolldelta(struct vc_data *vc, int lines)
> > {
> > struct fb_info *info = registered_fb[con2fb_map[fg_console]];
> > struct fbcon_ops *ops = info->fbcon_par;
> > - struct display *p = &fb_display[fg_console];
> > + struct display *disp = &fb_display[fg_console];
>
> We have a global symbol called "p"? That would be bad. Where is it?

in the same function.
We have quite a few shadow warnings in that file.

drivers/video/console/fbcon.c:337:25: warning: symbol '_x' shadows an earlier one
drivers/video/console/fbcon.c:337:25: originally declared here
drivers/video/console/fbcon.c:337:25: warning: symbol '_x' shadows an earlier one
drivers/video/console/fbcon.c:337:25: originally declared here
drivers/video/console/fbcon.c:337:25: warning: symbol '_y' shadows an earlier one
drivers/video/console/fbcon.c:337:25: originally declared here
drivers/video/console/fbcon.c:2813:19: warning: symbol 'p' shadows an earlier one
drivers/video/console/fbcon.c:2798:17: originally declared here
drivers/video/console/fbcon.c:3336:6: warning: symbol 'rotate' shadows an earlier one
drivers/video/console/fbcon.c:150:12: originally declared here
drivers/video/console/fbcon.c:3361:6: warning: symbol 'rotate' shadows an earlier one
drivers/video/console/fbcon.c:150:12: originally declared here
drivers/video/console/fbcon.c:3385:6: warning: symbol 'rotate' shadows an earlier one
drivers/video/console/fbcon.c:150:12: originally declared here

Dave


--
http://www.codemonkey.org.uk

2007-12-12 19:23:29

by David Miller

[permalink] [raw]
Subject: Re: [PATCH] fbcon: fix sparse warning about shadowing 'p' symbol

From: Andrew Morton <[email protected]>
Date: Tue, 11 Dec 2007 16:57:00 -0800

> On Sun, 9 Dec 2007 22:34:33 +0100
> Marcin __lusarz <[email protected]> wrote:
>
> > fbcon: fix sparse warning about shadowing 'p' symbol
> >
>
> Please always quote error messages and warnings in the changelog when
> fixing them, thanks.
>
> > ---
> > drivers/video/console/fbcon.c | 10 +++++-----
> > 1 files changed, 5 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
> > index 0f32f4a..849e114 100644
> > --- a/drivers/video/console/fbcon.c
> > +++ b/drivers/video/console/fbcon.c
> > @@ -2795,7 +2795,7 @@ static int fbcon_scrolldelta(struct vc_data *vc, int lines)
> > {
> > struct fb_info *info = registered_fb[con2fb_map[fg_console]];
> > struct fbcon_ops *ops = info->fbcon_par;
> > - struct display *p = &fb_display[fg_console];
> > + struct display *disp = &fb_display[fg_console];
>
> We have a global symbol called "p"? That would be bad. Where is it?

I'm curious about this too.

Ahh, I see, look down a few lines in fbcon_scrolldelta(), we have:

if (logo_shown == vc->vc_num) {
unsigned long p, q;
int i;

and that's where the warning is coming from.

2007-12-12 19:36:19

by Marcin Ślusarz

[permalink] [raw]
Subject: Re: [PATCH] fbcon: fix sparse warning about shadowing 'p' symbol

On Tue, Dec 11, 2007 at 09:50:32PM -0500, Dave Jones wrote:
> On Tue, Dec 11, 2007 at 04:57:00PM -0800, Andrew Morton wrote:
>
> > > --- a/drivers/video/console/fbcon.c
> > > +++ b/drivers/video/console/fbcon.c
> > > @@ -2795,7 +2795,7 @@ static int fbcon_scrolldelta(struct vc_data *vc, int lines)
> > > {
> > > struct fb_info *info = registered_fb[con2fb_map[fg_console]];
> > > struct fbcon_ops *ops = info->fbcon_par;
> > > - struct display *p = &fb_display[fg_console];
> > > + struct display *disp = &fb_display[fg_console];
> >
> > We have a global symbol called "p"? That would be bad. Where is it?
>
> in the same function.
> We have quite a few shadow warnings in that file.
>
> drivers/video/console/fbcon.c:337:25: warning: symbol '_x' shadows an earlier one
> drivers/video/console/fbcon.c:337:25: originally declared here
> drivers/video/console/fbcon.c:337:25: warning: symbol '_x' shadows an earlier one
> drivers/video/console/fbcon.c:337:25: originally declared here
> drivers/video/console/fbcon.c:337:25: warning: symbol '_y' shadows an earlier one
> drivers/video/console/fbcon.c:337:25: originally declared here
That's from max(A, max(B, C)) and max is defined as:
#define max(x,y) ({ \
typeof(x) _x = (x); \
typeof(y) _y = (y); \
(void) (&_x == &_y); \
_x > _y ? _x : _y; })

Don't know how to fix it without making the code look uglier...

> drivers/video/console/fbcon.c:3336:6: warning: symbol 'rotate' shadows an earlier one
> drivers/video/console/fbcon.c:150:12: originally declared here
> drivers/video/console/fbcon.c:3361:6: warning: symbol 'rotate' shadows an earlier one
> drivers/video/console/fbcon.c:150:12: originally declared here
> drivers/video/console/fbcon.c:3385:6: warning: symbol 'rotate' shadows an earlier one
> drivers/video/console/fbcon.c:150:12: originally declared here
That's fixed in another patch.

Marcin