[igt-dev] [PATCH i-g-t] lib/ioctl_wrappers: Assert that prime_handle_to_fd returns a valid fd

Daniel Vetter daniel at ffwll.ch
Wed Mar 13 13:18:23 UTC 2019


On Wed, Mar 13, 2019 at 10:59:09AM +0200, Petri Latvala wrote:
> On Tue, Mar 12, 2019 at 04:25:33PM +0100, Daniel Vetter wrote:
> > On Tue, Mar 12, 2019 at 01:21:14PM +0200, Petri Latvala wrote:
> > > If the ioctl is successful, the returned fd should be valid. Check
> > > that it is, thus also helping static analysis in almost 70 call sites.
> > > 
> > > Signed-off-by: Petri Latvala <petri.latvala at intel.com>
> > > ---
> > >  lib/ioctl_wrappers.c | 1 +
> > >  1 file changed, 1 insertion(+)
> > > 
> > > diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
> > > index 39920f87..31969e77 100644
> > > --- a/lib/ioctl_wrappers.c
> > > +++ b/lib/ioctl_wrappers.c
> > > @@ -1332,6 +1332,7 @@ int prime_handle_to_fd(int fd, uint32_t handle)
> > >  	args.fd = -1;
> > >  
> > >  	do_ioctl(fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &args);
> > > +	igt_assert_fd(args.fd);
> > 
> > fd >= 0 if we want this check. I think it's ok to have the assert here, since
> > do_ioctl already checks that the ioctl didn't fail. If we want an
> > unchecked version we can add the usual __prime_hanlde_to_fd.
> 
> fd >= 0 is what igt_assert_fd does?

I'm blind :-/
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


More information about the igt-dev mailing list