[PATCH] Fix xf86DeleteDriver and various places that use it
Mark Kettenis
mark.kettenis at xs4all.nl
Mon Jul 22 02:03:40 PDT 2013
> From: christopher.halse.rogers at canonical.com
> Date: Mon, 22 Jul 2013 13:44:46 +1000
>
> From: Maarten Lankhorst <maarten.lankhorst at canonical.com>
>
> Signed-off-by: Christopher James Halse Rogers <christopher.halse.rogers at canonical.com>
Care to elaborate what's actually broken?
To me this just looks like a somewhat arbitrary change that turns
xf86DriverList from a sparse array into a non-sparse array at the
expense of making the implementation more complex.
> ---
> hw/xfree86/common/xf86Helper.c | 9 ++++++++-
> hw/xfree86/common/xf86Init.c | 8 ++++++--
> 2 files changed, 14 insertions(+), 3 deletions(-)
>
> diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
> index 721159d..d319e0c 100644
> --- a/hw/xfree86/common/xf86Helper.c
> +++ b/hw/xfree86/common/xf86Helper.c
> @@ -100,7 +100,14 @@ xf86DeleteDriver(int drvIndex)
> if (xf86DriverList[drvIndex]->module)
> UnloadModule(xf86DriverList[drvIndex]->module);
> free(xf86DriverList[drvIndex]);
> - xf86DriverList[drvIndex] = NULL;
> +
> + /* Compact xf86DriverList array, update xf86NumDrivers */
> + xf86NumDrivers--;
> + if(drvIndex != xf86NumDrivers)
> + memmove(xf86DriverList + drvIndex,
> + xf86DriverList + drvIndex + 1,
> + sizeof(DriverPtr) * (xf86NumDrivers - drvIndex));
> + xf86DriverList = realloc(xf86DriverList, xf86NumDrivers * sizeof(DriverPtr));
> }
> }
>
> diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
> index 91ec4c8..746168a 100644
> --- a/hw/xfree86/common/xf86Init.c
> +++ b/hw/xfree86/common/xf86Init.c
> @@ -530,7 +530,7 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
> * needed at this early stage.
> */
>
> - for (i = 0; i < xf86NumDrivers; i++) {
> + for (i = 0; i < xf86NumDrivers; ) {
> xorgHWFlags flags = HW_IO;
>
> if (xf86DriverList[i]->Identify != NULL)
> @@ -546,6 +546,8 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
>
> if (!(flags & HW_SKIP_CONSOLE))
> xorgHWOpenConsole = TRUE;
> +
> + i++;
> }
>
> if (xorgHWOpenConsole)
> @@ -631,9 +633,11 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
> }
>
> /* Remove (unload) drivers that are not required */
> - for (i = 0; i < xf86NumDrivers; i++)
> + for (i = 0; i < xf86NumDrivers; )
> if (xf86DriverList[i] && xf86DriverList[i]->refCount <= 0)
> xf86DeleteDriver(i);
> + else
> + i++;
>
> /*
> * At this stage we know how many screens there are.
> --
> 1.8.3.2
>
> _______________________________________________
> 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