[Intel-gfx] [PATCH 4/4] xf86drm: Unconditionally clear ioctl structs

Daniel Vetter daniel at ffwll.ch
Wed Feb 11 08:21:54 PST 2015


On Wed, Feb 11, 2015 at 10:57:08AM -0500, Jan Vesely wrote:
> On Wed, 2015-02-11 at 12:42 +0100, Daniel Vetter wrote:
> > We really have to do this to avoid surprises when extending the ABI
> > later on. Especially when growing the structures.
> > 
> > A bit overkill to update all the old legacy ioctl wrappers, but can't
> > hurt really either.
> > 
> > Signed-off-by: Daniel Vetter <daniel.vetter at intel.com>
> > ---
> >  xf86drm.c | 112 ++++++++++++++++++++++++++++++++++++++++++--------------------
> >  1 file changed, 77 insertions(+), 35 deletions(-)
> > 
> > diff --git a/xf86drm.c b/xf86drm.c
> > index 263d6835c29a..a2e24eb5f76c 100644
> > --- a/xf86drm.c
> > +++ b/xf86drm.c
> > @@ -89,6 +89,8 @@
> >  #define DRM_NODE_PRIMARY 1
> >  #define DRM_NODE_RENDER 2
> >  
> > +#define memclear(s) memset(&s, 0, sizeof(s))
> > +
> >  static drmServerInfoPtr drm_server_info;
> >  
> >  void drmSetServerInfo(drmServerInfoPtr info)
> > @@ -766,12 +768,7 @@ drmVersionPtr drmGetVersion(int fd)
> >      drmVersionPtr retval;
> >      drm_version_t *version = drmMalloc(sizeof(*version));
> >  
> > -    version->name_len    = 0;
> > -    version->name        = NULL;
> > -    version->date_len    = 0;
> > -    version->date        = NULL;
> > -    version->desc_len    = 0;
> > -    version->desc        = NULL;
> > +    memclear(version);
> 
> I think this should be memclear(*version).
> Otherwise it clears the pointer not the structure.

Yeah ... and stupid me already pushed this :( I'll fix it up and have
another look at the patches to make sure I didn't botch another one.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch


More information about the Intel-gfx mailing list