[PATCH 1/2] Ensure all resource types created have names registered

Keith Packard keithp at keithp.com
Thu Dec 10 23:10:40 PST 2009


On Thu, 10 Dec 2009 22:53:48 -0800, Alan Coopersmith <alan.coopersmith at sun.com> wrote:

>      MultibufferDrawableResType =
> -	CreateNewResourceType(MultibufferDrawableDelete)|RC_DRAWABLE;
> +	CreateNewResourceType(MultibufferDrawableDelete);
>      MultibufferResType = CreateNewResourceType(MultibufferDelete);
>      MultibuffersResType = CreateNewResourceType(MultibuffersDelete);
>      OtherClientResType = CreateNewResourceType(OtherClientDelete);
> @@ -479,6 +481,12 @@ MultibufferExtensionInit()
>  				 ProcMultibufferDispatch, SProcMultibufferDispatch,
>  				 MultibufferResetProc, StandardMinorOpcode)))
>      {
> +	MultibufferDrawableResType |= RC_DRAWABLE;
> +	RegisterResourceName(MultibufferDrawableResType,
> +			     "MultibufferDrawable");
> +	RegisterResourceName(MultibufferResType, "MultibufferBuffer");
> +	RegisterResourceName(MultibuffersResType, "MultibufferWindow");
> +	RegisterResourceName(OtherClientResType,
> "MultibufferOtherClient");

Where do you want to add RC_DRAWABLE to MultibufferDrawableResType?
Twice is probably not correct.

>  	XRC_DRAWABLE = CreateNewResourceClass();
> -	XRT_WINDOW = CreateNewResourceType(XineramaDeleteResource) | 
> -						XRC_DRAWABLE;
> -	XRT_PIXMAP = CreateNewResourceType(XineramaDeleteResource) | 
> -						XRC_DRAWABLE;
> +	XRT_WINDOW = CreateNewResourceType(XineramaDeleteResource);
> +	XRT_PIXMAP = CreateNewResourceType(XineramaDeleteResource);
>  	XRT_GC = CreateNewResourceType(XineramaDeleteResource);
>  	XRT_COLORMAP = CreateNewResourceType(XineramaDeleteResource);
>  
>  	panoramiXGeneration = serverGeneration;
> -	success = TRUE;
> +	if (XRT_WINDOW && XRT_PIXMAP && XRT_GC && XRT_COLORMAP) {
> +	    RegisterResourceName(XRT_WINDOW, "XineramaWindow");
> +	    RegisterResourceName(XRT_PIXMAP, "XineramaPixmap");
> +	    RegisterResourceName(XRT_GC, "XineramaGC");
> +	    RegisterResourceName(XRT_COLORMAP, "XineramaColormap");
> +
> +	    XRT_WINDOW |= XRC_DRAWABLE;
> +	    XRT_PIXMAP |= XRC_DRAWABLE;
> +	    success = TRUE;
> +	}

Looks like RegisterResourceName should allow the resource type to come
in with a class mask and should strip that off before setting the name,
that way this patch would be much smaller.

>      RTAlarm = CreateNewResourceType(FreeAlarm);
> -    RTAwait = CreateNewResourceType(FreeAwait)|RC_NEVERRETAIN;
> -    RTAlarmClient = CreateNewResourceType(FreeAlarmClient)|RC_NEVERRETAIN;
> +    RTAwait = CreateNewResourceType(FreeAwait);
> +    RTAlarmClient = CreateNewResourceType(FreeAlarmClient);
>  
>      if (RTCounter == 0 || RTAwait == 0 || RTAlarm == 0 ||
>  	RTAlarmClient == 0 ||
> @@ -2129,6 +2131,12 @@ SyncExtensionInit(void)
>  	return;
>      }
>  
> +    RegisterResourceName(RTCounter, "SyncCounter");
> +    RegisterResourceName(RTAlarm, "SyncAlarm");
> +    RegisterResourceName(RTAwait, "SyncAwait");
> +    RegisterResourceName(RTAlarmClient, "SyncAlarmClient");
> +    RTAwait |= RC_NEVERRETAIN;
> +    RTAlarmClient |= RC_NEVERRETAIN;

Same comment here -- let's fix RegisterResourceName to permit a class to
be mixed into the argument.

>  #include <X11/extensions/Xv.h>
> @@ -1865,7 +1866,9 @@ void XineramifyXv(void)
>  
>     XvXRTPort = CreateNewResourceType(XineramaDeleteResource);
>  
> -   if(!xvsp0) return;
> +   if (!xvsp0 || !XvXRTPort) return;

I'd like to see bug fixes separated out from the rest of the resource
name fixing, unless you think that would be even more confusing.

>  	RT_INPUTCLIENT = CreateNewResourceType((DeleteType) InputClientGone);

Looking at this, I can't help but wonder if CreateNewResourceType (which
should only be called at server startup time) shouldn't be using
xnfalloc instead of having every caller check the return and call FatalError.

> +	if (!RT_INPUTCLIENT)
> +	    FatalError("Failed to add resource type for XI.\n");

There are lots of other places that have pure bug fixes (checking for
allocation failure) mixed in with the resource name fixes.

-- 
keith.packard at intel.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.x.org/archives/xorg-devel/attachments/20091210/9e4d0ed0/attachment.pgp 


More information about the xorg-devel mailing list