Re: [PATCH] drm/i915: Make for_each_intel_* macros typesafe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Mar 16, 2015 at 12:00:35PM +0200, Jani Nikula wrote:
> On Mon, 16 Mar 2015, Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@xxxxxxxxx> wrote:
> > So that the compiler warns if we get something wrong.
> >
> > Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@xxxxxxxxx>
> > ---
> >  drivers/gpu/drm/i915/i915_drv.h | 39 ++++++++++++++++++++++++++-------------
> >  1 file changed, 26 insertions(+), 13 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> > index ae4ba6a..871d77a 100644
> > --- a/drivers/gpu/drm/i915/i915_drv.h
> > +++ b/drivers/gpu/drm/i915/i915_drv.h
> > @@ -232,30 +232,43 @@ enum hpd_pin {
> >  	     (__s) < INTEL_INFO(__dev_priv)->num_sprites[(__p)];	\
> >  	     (__s)++)
> >  
> > -#define for_each_crtc(dev, crtc) \
> > +#define type_check(variable, type)				\
> > +	{							\
> > +		typeof(variable) __dummy_ptr = NULL;		\
> > +		const type *__type_check = __dummy_ptr;		\
> > +		(void) __type_check;				\
> > +	}
> > +
> > +#define for_each_crtc(dev, crtc)				\
> > +	type_check(crtc, struct drm_crtc)			\
> >  	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)

#define __list_for_each_entry_type(pos, head, type, member) \
	for (pos = list_first_entry(head, type, member); \
	     &pos->member != (head); \
	     pos = list_next_entry(pos, member))

#define for_each_crtc(dev, crtc) \
	__list_for_each_entry_type(crtc, \
				   &dev->mode_config.crtc_list, \
				   struct drm_crtc, \
				   head)
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx





[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux