]> git.baikalelectronics.ru Git - kernel.git/commit
Add braces to avoid "ambiguous ‘else’" compiler warnings
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 28 Jul 2016 03:03:31 +0000 (20:03 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 28 Jul 2016 03:03:31 +0000 (20:03 -0700)
commitaa077acda504fac27822f5726e79f1a25ffbbb04
tree776c4bf61bac8d6fe722926317ba9d757c6e054a
parent15730ce6218ff2297f245f207198938e28e2e5d6
Add braces to avoid "ambiguous ‘else’" compiler warnings

Some of our "for_each_xyz()" macro constructs make gcc unhappy about
lack of braces around if-statements inside or outside the loop, because
the loop construct itself has a "if-then-else" statement inside of it.

The resulting warnings look something like this:

  drivers/gpu/drm/i915/i915_debugfs.c: In function ‘i915_dump_lrc’:
  drivers/gpu/drm/i915/i915_debugfs.c:2103:6: warning: suggest explicit braces to avoid ambiguous ‘else’ [-Wparentheses]
     if (ctx != dev_priv->kernel_context)
        ^

even if the code itself is fine.

Since the warning is fairly easy to avoid by adding a braces around the
if-statement near the for_each_xyz() construct, do so, rather than
disabling the otherwise potentially useful warning.

(The if-then-else statements used in the "for_each_xyz()" constructs are
designed to be inherently safe even with no braces, but in this case
it's quite understandable that gcc isn't really able to tell that).

This finally leaves the standard "allmodconfig" build with just a
handful of remaining warnings, so new and valid warnings hopefully will
stand out.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/gpu/drm/i915/i915_debugfs.c
drivers/iommu/dmar.c
drivers/iommu/intel-iommu.c