dix: CreateColormap() pass in ClientPtr instead of client index
The function actually operates on ClientRec, so we can pass it in directly, so it doesn't need to fetch it from clients[] array itself. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
		
							parent
							
								
									1c8ef6d44d
								
							
						
					
					
						commit
						38d62bcc08
					
				|  | @ -55,6 +55,7 @@ SOFTWARE. | ||||||
| #include "dix/colormap_priv.h" | #include "dix/colormap_priv.h" | ||||||
| #include "dix/dix_priv.h" | #include "dix/dix_priv.h" | ||||||
| #include "os/osdep.h" | #include "os/osdep.h" | ||||||
|  | #include "os/bug_priv.h" | ||||||
| 
 | 
 | ||||||
| #include "misc.h" | #include "misc.h" | ||||||
| #include "dix.h" | #include "dix.h" | ||||||
|  | @ -240,8 +241,8 @@ typedef struct _colorResource { | ||||||
|  * \param alloc  1 iff all entries are allocated writable |  * \param alloc  1 iff all entries are allocated writable | ||||||
|  */ |  */ | ||||||
| int | int | ||||||
| CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual, | dixCreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual, | ||||||
|                ColormapPtr *ppcmap, int alloc, int client) |                   ColormapPtr *ppcmap, int alloc, ClientPtr pClient) | ||||||
| { | { | ||||||
|     int class, size; |     int class, size; | ||||||
|     unsigned long sizebytes; |     unsigned long sizebytes; | ||||||
|  | @ -250,9 +251,14 @@ CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual, | ||||||
|     int i; |     int i; | ||||||
|     Pixel *ppix, **pptr; |     Pixel *ppix, **pptr; | ||||||
| 
 | 
 | ||||||
|  |     if (!pClient) | ||||||
|  |         return BadMatch; | ||||||
|  | 
 | ||||||
|  |     const int clientIndex = pClient->index; | ||||||
|  | 
 | ||||||
|     class = pVisual->class; |     class = pVisual->class; | ||||||
|     if (!(class & DynamicClass) && (alloc != AllocNone) && |     if (!(class & DynamicClass) && (alloc != AllocNone) && | ||||||
|         (client != SERVER_ID)) |         (pClient != serverClient)) | ||||||
|         return BadMatch; |         return BadMatch; | ||||||
| 
 | 
 | ||||||
|     size = pVisual->ColormapEntries; |     size = pVisual->ColormapEntries; | ||||||
|  | @ -309,10 +315,10 @@ CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual, | ||||||
|             free(pmap); |             free(pmap); | ||||||
|             return BadAlloc; |             return BadAlloc; | ||||||
|         } |         } | ||||||
|         pmap->clientPixelsRed[client] = ppix; |         pmap->clientPixelsRed[clientIndex] = ppix; | ||||||
|         for (i = 0; i < size; i++) |         for (i = 0; i < size; i++) | ||||||
|             ppix[i] = i; |             ppix[i] = i; | ||||||
|         pmap->numPixelsRed[client] = size; |         pmap->numPixelsRed[clientIndex] = size; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if ((class | DynamicClass) == DirectColor) { |     if ((class | DynamicClass) == DirectColor) { | ||||||
|  | @ -347,14 +353,14 @@ CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual, | ||||||
|             pmap->freeGreen = 0; |             pmap->freeGreen = 0; | ||||||
|             ppix = xallocarray(size, sizeof(Pixel)); |             ppix = xallocarray(size, sizeof(Pixel)); | ||||||
|             if (!ppix) { |             if (!ppix) { | ||||||
|                 free(pmap->clientPixelsRed[client]); |                 free(pmap->clientPixelsRed[clientIndex]); | ||||||
|                 free(pmap); |                 free(pmap); | ||||||
|                 return BadAlloc; |                 return BadAlloc; | ||||||
|             } |             } | ||||||
|             pmap->clientPixelsGreen[client] = ppix; |             pmap->clientPixelsGreen[clientIndex] = ppix; | ||||||
|             for (i = 0; i < size; i++) |             for (i = 0; i < size; i++) | ||||||
|                 ppix[i] = i; |                 ppix[i] = i; | ||||||
|             pmap->numPixelsGreen[client] = size; |             pmap->numPixelsGreen[clientIndex] = size; | ||||||
| 
 | 
 | ||||||
|             size = pmap->freeBlue; |             size = pmap->freeBlue; | ||||||
|             for (pent = &pmap->blue[size - 1]; pent >= pmap->blue; pent--) |             for (pent = &pmap->blue[size - 1]; pent >= pmap->blue; pent--) | ||||||
|  | @ -362,15 +368,15 @@ CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual, | ||||||
|             pmap->freeBlue = 0; |             pmap->freeBlue = 0; | ||||||
|             ppix = xallocarray(size, sizeof(Pixel)); |             ppix = xallocarray(size, sizeof(Pixel)); | ||||||
|             if (!ppix) { |             if (!ppix) { | ||||||
|                 free(pmap->clientPixelsGreen[client]); |                 free(pmap->clientPixelsGreen[clientIndex]); | ||||||
|                 free(pmap->clientPixelsRed[client]); |                 free(pmap->clientPixelsRed[clientIndex]); | ||||||
|                 free(pmap); |                 free(pmap); | ||||||
|                 return BadAlloc; |                 return BadAlloc; | ||||||
|             } |             } | ||||||
|             pmap->clientPixelsBlue[client] = ppix; |             pmap->clientPixelsBlue[clientIndex] = ppix; | ||||||
|             for (i = 0; i < size; i++) |             for (i = 0; i < size; i++) | ||||||
|                 ppix[i] = i; |                 ppix[i] = i; | ||||||
|             pmap->numPixelsBlue[client] = size; |             pmap->numPixelsBlue[clientIndex] = size; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     pmap->flags |= CM_BeingCreated; |     pmap->flags |= CM_BeingCreated; | ||||||
|  | @ -381,7 +387,7 @@ CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual, | ||||||
|     /*
 |     /*
 | ||||||
|      * Security creation/labeling check |      * Security creation/labeling check | ||||||
|      */ |      */ | ||||||
|     i = XaceHookResourceAccess(clients[client], mid, X11_RESTYPE_COLORMAP, |     i = XaceHookResourceAccess(pClient, mid, X11_RESTYPE_COLORMAP, | ||||||
|                  pmap, X11_RESTYPE_NONE, NULL, DixCreateAccess); |                  pmap, X11_RESTYPE_NONE, NULL, DixCreateAccess); | ||||||
|     if (i != Success) { |     if (i != Success) { | ||||||
|         FreeResource(mid, X11_RESTYPE_NONE); |         FreeResource(mid, X11_RESTYPE_NONE); | ||||||
|  | @ -547,7 +553,7 @@ CopyColormapAndFree(Colormap mid, ColormapPtr pSrc, int client) | ||||||
|     size = pVisual->ColormapEntries; |     size = pVisual->ColormapEntries; | ||||||
| 
 | 
 | ||||||
|     /* If the create returns non-0, it failed */ |     /* If the create returns non-0, it failed */ | ||||||
|     result = CreateColormap(mid, pScreen, pVisual, &pmap, alloc, client); |     result = dixCreateColormap(mid, pScreen, pVisual, &pmap, alloc, clients[client]); | ||||||
|     if (result != Success) |     if (result != Success) | ||||||
|         return result; |         return result; | ||||||
|     if (alloc == AllocAll) { |     if (alloc == AllocAll) { | ||||||
|  |  | ||||||
|  | @ -21,8 +21,8 @@ | ||||||
| 
 | 
 | ||||||
| typedef struct _CMEntry *EntryPtr; | typedef struct _CMEntry *EntryPtr; | ||||||
| 
 | 
 | ||||||
| int CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual, | int dixCreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual, | ||||||
|                    ColormapPtr *ppcmap, int alloc, int client); |                       ColormapPtr *ppcmap, int alloc, ClientPtr client); | ||||||
| 
 | 
 | ||||||
| /* should only be called via resource type's destructor */ | /* should only be called via resource type's destructor */ | ||||||
| int FreeColormap(void *pmap, XID mid); | int FreeColormap(void *pmap, XID mid); | ||||||
|  |  | ||||||
|  | @ -2446,8 +2446,8 @@ ProcCreateColormap(ClientPtr client) | ||||||
|          i < pScreen->numVisuals; i++, pVisual++) { |          i < pScreen->numVisuals; i++, pVisual++) { | ||||||
|         if (pVisual->vid != stuff->visual) |         if (pVisual->vid != stuff->visual) | ||||||
|             continue; |             continue; | ||||||
|         return CreateColormap(mid, pScreen, pVisual, &pmap, |         return dixCreateColormap(mid, pScreen, pVisual, &pmap, | ||||||
|                               (int) stuff->alloc, client->index); |                                  (int) stuff->alloc, client); | ||||||
|     } |     } | ||||||
|     client->errorValue = stuff->visual; |     client->errorValue = stuff->visual; | ||||||
|     return BadMatch; |     return BadMatch; | ||||||
|  |  | ||||||
|  | @ -709,7 +709,7 @@ DGACreateColormap(int index, ClientPtr client, int id, int mode, int alloc) | ||||||
| 
 | 
 | ||||||
|     LEGAL_NEW_RESOURCE(id, client); |     LEGAL_NEW_RESOURCE(id, client); | ||||||
| 
 | 
 | ||||||
|     return CreateColormap(id, pScreen, pVisual, &pmap, alloc, client->index); |     return dixCreateColormap(id, pScreen, pVisual, &pmap, alloc, client); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /*  Called by the extension to install a colormap on DGA active screens */ | /*  Called by the extension to install a colormap on DGA active screens */ | ||||||
|  |  | ||||||
|  | @ -469,9 +469,9 @@ xnestCreateDefaultColormap(ScreenPtr pScreen) | ||||||
|     for (pVisual = pScreen->visuals; |     for (pVisual = pScreen->visuals; | ||||||
|          pVisual->vid != pScreen->rootVisual; pVisual++); |          pVisual->vid != pScreen->rootVisual; pVisual++); | ||||||
| 
 | 
 | ||||||
|     if (CreateColormap(pScreen->defColormap, pScreen, pVisual, &pCmap, |     if (dixCreateColormap(pScreen->defColormap, pScreen, pVisual, &pCmap, | ||||||
|                        (pVisual->class & DynamicClass) ? AllocNone : AllocAll, |                        (pVisual->class & DynamicClass) ? AllocNone : AllocAll, | ||||||
|                        0) |                        serverClient) | ||||||
|         != Success) |         != Success) | ||||||
|         return FALSE; |         return FALSE; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -520,12 +520,12 @@ winCreateDefColormap(ScreenPtr pScreen) | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|     /* Allocate an X colormap, owned by client 0 */ |     /* Allocate an X colormap, owned by client 0 */ | ||||||
|     if (CreateColormap(pScreen->defColormap, |     if (dixCreateColormap(pScreen->defColormap, | ||||||
|                        pScreen, |                           pScreen, | ||||||
|                        pVisual, |                           pVisual, | ||||||
|                        &pcmap, |                           &pcmap, | ||||||
|                        (pVisual->class & DynamicClass) ? AllocNone : AllocAll, |                           (pVisual->class & DynamicClass) ? AllocNone : AllocAll, | ||||||
|                        0) != Success) { |                           serverClient) != Success) { | ||||||
|         ErrorF("winCreateDefColormap - CreateColormap failed\n"); |         ErrorF("winCreateDefColormap - CreateColormap failed\n"); | ||||||
|         return FALSE; |         return FALSE; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -261,8 +261,8 @@ miCreateDefColormap(ScreenPtr pScreen) | ||||||
|     else |     else | ||||||
|         alloctype = AllocAll; |         alloctype = AllocAll; | ||||||
| 
 | 
 | ||||||
|     if (CreateColormap(pScreen->defColormap, pScreen, pVisual, &cmap, |     if (dixCreateColormap(pScreen->defColormap, pScreen, pVisual, &cmap, | ||||||
|                        alloctype, 0) != Success) |                           alloctype, serverClient) != Success) | ||||||
|         return FALSE; |         return FALSE; | ||||||
| 
 | 
 | ||||||
|     if (pScreen->rootDepth > 1) { |     if (pScreen->rootDepth > 1) { | ||||||
|  |  | ||||||
|  | @ -421,8 +421,8 @@ PictureInitIndexedFormat(ScreenPtr pScreen, PictFormatPtr format) | ||||||
|         if (pVisual == NULL) |         if (pVisual == NULL) | ||||||
|             return FALSE; |             return FALSE; | ||||||
| 
 | 
 | ||||||
|         if (CreateColormap(FakeClientID(0), pScreen, pVisual, |         if (dixCreateColormap(FakeClientID(0), pScreen, pVisual, | ||||||
|                            &format->index.pColormap, AllocNone, 0) |                               &format->index.pColormap, AllocNone, serverClient) | ||||||
|             != Success) |             != Success) | ||||||
|             return FALSE; |             return FALSE; | ||||||
|     } |     } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue