dix: fix a misused const pointer in cursor.c

`const CursorPtr` actually means `struct _Cursor *const`, a constant pointer, which does not prevent you from accidentally modifying the value it points to, like the cursor refcnt.

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1140>
This commit is contained in:
moozcheng 2023-07-27 15:09:31 +08:00 committed by Marge Bot
parent 080fd7821b
commit 96079f8c68
2 changed files with 7 additions and 2 deletions

View File

@ -145,7 +145,7 @@ UnrefCursor(CursorPtr cursor)
}
int
CursorRefCount(const CursorPtr cursor)
CursorRefCount(ConstCursorPtr cursor)
{
return cursor ? cursor->refcnt : 0;
}

View File

@ -60,6 +60,11 @@ SOFTWARE.
struct _DeviceIntRec;
typedef struct _Cursor *CursorPtr;
// FUN FACT: If you typedef a pointer type, like the `CursorPtr` above
// then `const CursorPtr` or `CursorPtr const` actually means `struct _Cursor *const`, a constant pointer
// which is probably not what you want(a pointer to constant).
// Maybe better just keep the `*` around, or you have to typedef a separate constPtr type.
typedef struct _Cursor const *ConstCursorPtr;
typedef struct _CursorMetric *CursorMetricPtr;
extern _X_EXPORT CursorPtr rootCursor;
@ -69,7 +74,7 @@ extern _X_EXPORT int FreeCursor(void *pCurs,
extern _X_EXPORT CursorPtr RefCursor(CursorPtr /* cursor */);
extern _X_EXPORT CursorPtr UnrefCursor(CursorPtr /* cursor */);
extern _X_EXPORT int CursorRefCount(const CursorPtr /* cursor */);
extern _X_EXPORT int CursorRefCount(ConstCursorPtr /* cursor */);
extern _X_EXPORT int AllocARGBCursor(unsigned char * /*psrcbits */ ,
unsigned char * /*pmaskbits */ ,