[PATCH 2/2] Allow for missing or disabled compat_output

Adam Jackson ajax at nwnk.net
Thu Feb 25 12:16:47 PST 2010


On Thu, 2010-02-25 at 11:39 -0800, Keith Packard wrote:
> When the compat output is missing (I don't think this is actually
> possible), or is disabled (and hence has no crtc), we would like to
> avoid dereferencing NULL pointers. This patch creates inline functions
> to extract the current compat output, crtc or associated RandR crtc
> structure, carefully checking for NULL pointers everywhere.
> 
> Signed-off-by: Keith Packard <keithp at keithp.com>
> <snip>
> diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
> index 1fc63c4..7ba09b6 100644
> --- a/hw/xfree86/modes/xf86RandR12.c
> +++ b/hw/xfree86/modes/xf86RandR12.c
> @@ -805,9 +805,10 @@ xf86RandR12CreateScreenResources (ScreenPtr pScreen)
>  	}
>  	else
>  	{
> -	    xf86OutputPtr   output = config->output[config->compat_output];
> +	    xf86OutputPtr   output = xf86CompatOutput(pScrn);
>  
> -	    if (output->conf_monitor &&
> +	    if (output &&
> +		output->conf_monitor &&
>  		(output->conf_monitor->mon_width  > 0 &&
>  		 output->conf_monitor->mon_height > 0))
>  	    {
> @@ -1719,10 +1720,13 @@ xf86RandR12ChangeGamma(int scrnIndex, Gamma gamma)
>  {
>      CARD16 *points, *red, *green, *blue;
>      ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
> -    xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
> -    RRCrtcPtr crtc = config->output[config->compat_output]->crtc->randr_crtc;
> -    int size = max(0, crtc->gammaSize);
> +    RRCrtcPtr crtc = xf86CompatRRCrtc(pScrn);
> +    int size;
>  
> +    if (!crtc)
> +	return Success;
> +
> +    size = max(0, crtc->gammaSize);
>      if (!size)
>  	return Success;
>  

This bit is really lame.  compat_output never changes for the life of
the server; if you've turned off what the server picked for compat at
startup, vidmode gamma won't change anything.  Picking the first crtc
with a connected output in this case is slightly more DWIMmy, I guess.

But on the other hand: stop using vidmode already, dammit.

Reviewed-by: Adam Jackson <ajax at redhat.com>

- ajax
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://lists.x.org/archives/xorg-devel/attachments/20100225/96734647/attachment.pgp>


More information about the xorg-devel mailing list