summaryrefslogtreecommitdiff
path: root/src/sna/sna.h
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2017-11-07 20:16:25 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2017-11-09 00:36:49 +0000
commit21008aaa1f9f77ef3509a68dd83c7ad41da4ec81 (patch)
treec760478b2858b916478b7c96e05d9ffe8760f46c /src/sna/sna.h
parent37a682aa8a420a75a920e0fa7cf8659f834ed60f (diff)
sna: Assert idempotent conversions between sna <-> ScreenPtr
Check that the struct sna we retrieve from the ScreenPtr points back to the screen, and vice versa. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/sna/sna.h')
-rw-r--r--src/sna/sna.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/sna/sna.h b/src/sna/sna.h
index 74eae745..5283ce43 100644
--- a/src/sna/sna.h
+++ b/src/sna/sna.h
@@ -495,7 +495,9 @@ extern int sna_page_flip(struct sna *sna,
pure static inline struct sna *
to_sna(ScrnInfoPtr scrn)
{
- return (struct sna *)(scrn->driverPrivate);
+ struct sna *sna = scrn->driverPrivate;
+ assert(sna->scrn == scrn);
+ return sna;
}
pure static inline struct sna *
@@ -506,7 +508,9 @@ to_sna_from_screen(ScreenPtr screen)
pure static inline ScreenPtr to_screen_from_sna(struct sna *sna)
{
- return xf86ScrnToScreen(sna->scrn);
+ ScreenPtr screen = xf86ScrnToScreen(sna->scrn);
+ assert(sna == to_sna_from_screen(screen));
+ return screen;
}
pure static inline struct sna *