diff mbox

[-next] fb: fix recent breakage in correct_chipset()

Message ID 20130702062821.GC24410@elgon.mountain (mailing list archive)
State New, archived
Headers show

Commit Message

Dan Carpenter July 2, 2013, 6:28 a.m. UTC
The 6e36308a6f "fb: fix atyfb build warning" isn't right.  It makes all
the indexes off by one.  This patch reverts it and casts the
ARRAY_SIZE() to int to silence the build warning.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

--
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Randy Dunlap July 2, 2013, 3:50 p.m. UTC | #1
On 07/01/13 23:28, Dan Carpenter wrote:
> The 6e36308a6f "fb: fix atyfb build warning" isn't right.  It makes all
> the indexes off by one.  This patch reverts it and casts the
> ARRAY_SIZE() to int to silence the build warning.

Argh.  Thanks.

> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
> index a89c15d..9b0f12c 100644
> --- a/drivers/video/aty/atyfb_base.c
> +++ b/drivers/video/aty/atyfb_base.c
> @@ -435,8 +435,8 @@ static int correct_chipset(struct atyfb_par *par)
>  	const char *name;
>  	int i;
>  
> -	for (i = ARRAY_SIZE(aty_chips); i > 0; i--)
> -		if (par->pci_id == aty_chips[i - 1].pci_id)
> +	for (i = (int)ARRAY_SIZE(aty_chips) - 1; i >= 0; i--)
> +		if (par->pci_id == aty_chips[i].pci_id)
>  			break;
>  
>  	if (i < 0)
>
Randy Dunlap July 12, 2013, 8:11 p.m. UTC | #2
On 07/01/13 23:28, Dan Carpenter wrote:
> The 6e36308a6f "fb: fix atyfb build warning" isn't right.  It makes all
> the indexes off by one.  This patch reverts it and casts the
> ARRAY_SIZE() to int to silence the build warning.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Tomi,

My incorrect patch has been merged into mainline.
Please merge Dan's fix for it instead.

Thanks.

> diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
> index a89c15d..9b0f12c 100644
> --- a/drivers/video/aty/atyfb_base.c
> +++ b/drivers/video/aty/atyfb_base.c
> @@ -435,8 +435,8 @@ static int correct_chipset(struct atyfb_par *par)
>  	const char *name;
>  	int i;
>  
> -	for (i = ARRAY_SIZE(aty_chips); i > 0; i--)
> -		if (par->pci_id == aty_chips[i - 1].pci_id)
> +	for (i = (int)ARRAY_SIZE(aty_chips) - 1; i >= 0; i--)
> +		if (par->pci_id == aty_chips[i].pci_id)
>  			break;
>  
>  	if (i < 0)
>
Tomi Valkeinen July 26, 2013, 8:34 a.m. UTC | #3
On 02/07/13 09:28, Dan Carpenter wrote:
> The 6e36308a6f "fb: fix atyfb build warning" isn't right.  It makes all
> the indexes off by one.  This patch reverts it and casts the
> ARRAY_SIZE() to int to silence the build warning.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
> index a89c15d..9b0f12c 100644
> --- a/drivers/video/aty/atyfb_base.c
> +++ b/drivers/video/aty/atyfb_base.c
> @@ -435,8 +435,8 @@ static int correct_chipset(struct atyfb_par *par)
>  	const char *name;
>  	int i;
>  
> -	for (i = ARRAY_SIZE(aty_chips); i > 0; i--)
> -		if (par->pci_id == aty_chips[i - 1].pci_id)
> +	for (i = (int)ARRAY_SIZE(aty_chips) - 1; i >= 0; i--)
> +		if (par->pci_id == aty_chips[i].pci_id)
>  			break;
>  
>  	if (i < 0)
> 

Thanks, I've applied this into my 3.11-fixes/fbdev branch.

 Tomi
Geert Uytterhoeven Aug. 1, 2013, 9:31 a.m. UTC | #4
On Tue, Jul 2, 2013 at 8:28 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> The 6e36308a6f "fb: fix atyfb build warning" isn't right.  It makes all
> the indexes off by one.  This patch reverts it and casts the
> ARRAY_SIZE() to int to silence the build warning.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
> index a89c15d..9b0f12c 100644
> --- a/drivers/video/aty/atyfb_base.c
> +++ b/drivers/video/aty/atyfb_base.c
> @@ -435,8 +435,8 @@ static int correct_chipset(struct atyfb_par *par)
>         const char *name;
>         int i;
>
> -       for (i = ARRAY_SIZE(aty_chips); i > 0; i--)
> -               if (par->pci_id == aty_chips[i - 1].pci_id)
> +       for (i = (int)ARRAY_SIZE(aty_chips) - 1; i >= 0; i--)
> +               if (par->pci_id == aty_chips[i].pci_id)
>                         break;
>
>         if (i < 0)

Sorry for chiming in late, but can't we just revert the order of the loop
iteration and change i from int to size_t instead of adding a cast?

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
--
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Dan Carpenter Aug. 1, 2013, 11:50 a.m. UTC | #5
On Thu, Aug 01, 2013 at 11:31:07AM +0200, Geert Uytterhoeven wrote:
> On Tue, Jul 2, 2013 at 8:28 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> > The 6e36308a6f "fb: fix atyfb build warning" isn't right.  It makes all
> > the indexes off by one.  This patch reverts it and casts the
> > ARRAY_SIZE() to int to silence the build warning.
> >
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> >
> > diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
> > index a89c15d..9b0f12c 100644
> > --- a/drivers/video/aty/atyfb_base.c
> > +++ b/drivers/video/aty/atyfb_base.c
> > @@ -435,8 +435,8 @@ static int correct_chipset(struct atyfb_par *par)
> >         const char *name;
> >         int i;
> >
> > -       for (i = ARRAY_SIZE(aty_chips); i > 0; i--)
> > -               if (par->pci_id == aty_chips[i - 1].pci_id)
> > +       for (i = (int)ARRAY_SIZE(aty_chips) - 1; i >= 0; i--)
> > +               if (par->pci_id == aty_chips[i].pci_id)
> >                         break;
> >
> >         if (i < 0)
> 
> Sorry for chiming in late, but can't we just revert the order of the loop
> iteration and change i from int to size_t instead of adding a cast?
> 

Nope.  That would be a nearly-forever loop.

regards,
dan carpenter
--
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
index a89c15d..9b0f12c 100644
--- a/drivers/video/aty/atyfb_base.c
+++ b/drivers/video/aty/atyfb_base.c
@@ -435,8 +435,8 @@  static int correct_chipset(struct atyfb_par *par)
 	const char *name;
 	int i;
 
-	for (i = ARRAY_SIZE(aty_chips); i > 0; i--)
-		if (par->pci_id == aty_chips[i - 1].pci_id)
+	for (i = (int)ARRAY_SIZE(aty_chips) - 1; i >= 0; i--)
+		if (par->pci_id == aty_chips[i].pci_id)
 			break;
 
 	if (i < 0)