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 <[email protected]> > <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 <[email protected]> - ajax
signature.asc
Description: This is a digitally signed message part
_______________________________________________ xorg-devel mailing list [email protected] http://lists.x.org/mailman/listinfo/xorg-devel
