[PATCH 15/54] extmod: Use ARRAY_SIZE rather than sentinel

Stéphane Marchesin stephane.marchesin at gmail.com
Mon Jul 9 19:19:58 PDT 2012


On Mon, Jul 9, 2012 at 6:02 PM, Daniel Stone <daniel at fooishbar.org> wrote:
> When the array gets down to size zero (which it does in later patches),
> gcc complains that the index is out of bounds.  Avoid this by using
> ARRAY_SIZE on extensionModules instead.
>
> Signed-off-by: Daniel Stone <daniel at fooishbar.org>

Reviewed-by: Stéphane Marchesin <stephane.marchesin at gmail.com>

> ---
>  hw/xfree86/dixmods/extmod/modinit.c |    8 +-------
>  1 file changed, 1 insertion(+), 7 deletions(-)
>
> diff --git a/hw/xfree86/dixmods/extmod/modinit.c b/hw/xfree86/dixmods/extmod/modinit.c
> index afee27a..009852c 100644
> --- a/hw/xfree86/dixmods/extmod/modinit.c
> +++ b/hw/xfree86/dixmods/extmod/modinit.c
> @@ -101,12 +101,6 @@ static ExtensionModule extensionModules[] = {
>       NULL,
>       NULL},
>  #endif
> -    {                           /* DON'T delete this entry ! */
> -     NULL,
> -     NULL,
> -     NULL,
> -     NULL,
> -     NULL}
>  };
>
>  static XF86ModuleVersionInfo VersRec = {
> @@ -134,7 +128,7 @@ extmodSetup(pointer module, pointer opts, int *errmaj, int *errmin)
>
>      /* XXX the option stuff here is largely a sample/test case */
>
> -    for (i = 0; extensionModules[i].name != NULL; i++) {
> +    for (i = 0; i < ARRAY_SIZE(extensionModules); i++) {
>  #ifdef XSELINUX
>          if (!strcmp(SELINUX_EXTENSION_NAME, extensionModules[i].name)) {
>              pointer o;
> --
> 1.7.10.4
>
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel


More information about the xorg-devel mailing list