All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Intel graphics driver community testing & development
	<intel-gfx@lists.freedesktop.org>
Subject: Re: [PATCH 2/2] drm/i915: Compile time concatenate WARN_ON macro strings
Date: Mon, 21 Dec 2015 14:25:51 +0100	[thread overview]
Message-ID: <20151221132551.GU30437@phenom.ffwll.local> (raw)
In-Reply-To: <1450440684.4143.6.camel@linux.intel.com>

On Fri, Dec 18, 2015 at 02:11:24PM +0200, Joonas Lahtinen wrote:
> On pe, 2015-12-18 at 12:03 +0000, Dave Gordon wrote:
> > On 18/12/15 10:39, Joonas Lahtinen wrote:
> > > Using __stringify(x) instead of #x adds support for macros as
> > > a parameter and reduces runtime overhead.
> > > 
> > > Slightly increases the .text size but should not matter.
> > > 
> > > v2:
> > > - Define I915_STATE_WARN_ON though I915_STATE_WARN
> > >    (Bikeshed inspiration by Chris)
> > > 
> > > Cc: Rob Clark <robdclark@gmail.com>
> > > Cc: Chris Wilson <chris@chris-wilson.co.uk>
> > > Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> > > Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> > > ---
> > >   drivers/gpu/drm/i915/i915_drv.h | 14 ++++----------
> > >   1 file changed, 4 insertions(+), 10 deletions(-)
> > > 
> > > 
> 
> <SNIP>
> 
> > > 					
> > > \
> > > -})
> > > +#define I915_STATE_WARN_ON(x)					
> > > 	\
> > > +	I915_STATE_WARN((x), "WARN_ON(" __stringify(x) ")")
> > > 
> > >   static inline const char *yesno(bool v)
> > >   {
> > 
> > NAK.
> > 
> > This will give compile-time warnings for lines such as:
> > 
> > 	WARN_ON(x%16 != 0);
> > 
> > because the stringified text of the expression (which in this case 
> > contains a "%" character) would appear as part of the format string, 
> > rather than inside an argument. See:
> > 
> > 4eee492 drm/i915: fix driver's versions of WARN_ON & WARN_ON_ONCE
> > 
> 
> Great catch, I'll change it to have preceding "%s". Did not get any
> compile-time warning though, this would be something caught by a
> (rather advanced?) static analysis.

New gcc seems to complain about this. At least since a few weeks I've seen
a few patches for kernel-wide changes to address this float about.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2015-12-21 13:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-18 10:39 [PATCH 0/2] Optimize WARN_ON macros Joonas Lahtinen
2015-12-18 10:39 ` [PATCH 1/2] drm/i915: Simplify _STATE_ debug macros Joonas Lahtinen
2015-12-18 10:39 ` [PATCH 2/2] drm/i915: Compile time concatenate WARN_ON macro strings Joonas Lahtinen
2015-12-18 11:07   ` Chris Wilson
2015-12-18 12:03   ` Dave Gordon
2015-12-18 12:11     ` Joonas Lahtinen
2015-12-21 13:25       ` Daniel Vetter [this message]
2015-12-18 11:20 ` ✗ warning: Fi.CI.BAT Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151221132551.GU30437@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=joonas.lahtinen@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.