Chris Wilson <chris@xxxxxxxxxxxxxxxxxx> writes: > Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx> > --- > lib/igt_core.h | 14 ++++++++++++++ > lib/ioctl_wrappers.c | 4 ++++ > 2 files changed, 18 insertions(+) > > diff --git a/lib/igt_core.h b/lib/igt_core.h > index f8543d65..f5f65984 100644 > --- a/lib/igt_core.h > +++ b/lib/igt_core.h > @@ -932,4 +932,18 @@ int igt_system_quiet(const char *command); > free(buf); \ > } while (0) > > +/** > + * igt_typecheck: > + * @type: The intended type we expect the variable to be > + * @x: The variable we wish to check > + * > + * Performs a *compile-time* check that a variable is of a particular type. > + */ > +#define igt_typecheck(type, x) ({ \ > + type __dummy; \ > + typeof(x) __dummy2; \ > + (void)(&__dummy == &__dummy2); \ > + 1; \ > +}) > + > #endif /* IGT_CORE_H */ > diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c > index 87511fc6..0b523fac 100644 > --- a/lib/ioctl_wrappers.c > +++ b/lib/ioctl_wrappers.c > @@ -558,6 +558,10 @@ int __gem_create(int fd, uint64_t size, uint32_t *handle) > }; > int err = 0; > > + /* Ensure that our internal interface matches the kernel's */ > + igt_typecheck(typeof(create.size), size); > + igt_typecheck(typeof(create.handle), *handle); Seems to do what it is missing from the tin :) Fill the commit message and sprinkle more on the ioctl_wrappers.c? -Mika > + > if (igt_ioctl(fd, DRM_IOCTL_I915_GEM_CREATE, &create) == 0) > *handle = create.handle; > else > -- > 2.14.2 > > _______________________________________________ > Intel-gfx mailing list > Intel-gfx@xxxxxxxxxxxxxxxxxxxxx > https://lists.freedesktop.org/mailman/listinfo/intel-gfx _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx