summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-07-27 23:03:31 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-07-27 23:03:31 -0400
commit194dc870a5890e855ecffb30f3b80ba7c88f96d6 (patch)
tree776c4bf61bac8d6fe722926317ba9d757c6e054a /drivers
parent124a3d88fa20e1869fc229d7d8c740cc81944264 (diff)
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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/drm/i915/i915_debugfs.c3
-rw-r--r--drivers/iommu/dmar.c3
-rw-r--r--drivers/iommu/intel-iommu.c3
3 files changed, 6 insertions, 3 deletions
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 103546834b60..2a6e12956baf 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -2100,9 +2100,10 @@ static int i915_dump_lrc(struct seq_file *m, void *unused)
2100 return ret; 2100 return ret;
2101 2101
2102 list_for_each_entry(ctx, &dev_priv->context_list, link) 2102 list_for_each_entry(ctx, &dev_priv->context_list, link)
2103 if (ctx != dev_priv->kernel_context) 2103 if (ctx != dev_priv->kernel_context) {
2104 for_each_engine(engine, dev_priv) 2104 for_each_engine(engine, dev_priv)
2105 i915_dump_lrc_obj(m, ctx, engine); 2105 i915_dump_lrc_obj(m, ctx, engine);
2106 }
2106 2107
2107 mutex_unlock(&dev->struct_mutex); 2108 mutex_unlock(&dev->struct_mutex);
2108 2109
diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c
index 6a86b5d1defa..7330a66e2b7e 100644
--- a/drivers/iommu/dmar.c
+++ b/drivers/iommu/dmar.c
@@ -1871,10 +1871,11 @@ static int dmar_hp_remove_drhd(struct acpi_dmar_header *header, void *arg)
1871 /* 1871 /*
1872 * All PCI devices managed by this unit should have been destroyed. 1872 * All PCI devices managed by this unit should have been destroyed.
1873 */ 1873 */
1874 if (!dmaru->include_all && dmaru->devices && dmaru->devices_cnt) 1874 if (!dmaru->include_all && dmaru->devices && dmaru->devices_cnt) {
1875 for_each_active_dev_scope(dmaru->devices, 1875 for_each_active_dev_scope(dmaru->devices,
1876 dmaru->devices_cnt, i, dev) 1876 dmaru->devices_cnt, i, dev)
1877 return -EBUSY; 1877 return -EBUSY;
1878 }
1878 1879
1879 ret = dmar_ir_hotplug(dmaru, false); 1880 ret = dmar_ir_hotplug(dmaru, false);
1880 if (ret == 0) 1881 if (ret == 0)
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 323dac9900ba..4b9040bb2f1c 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -4272,10 +4272,11 @@ int dmar_check_one_atsr(struct acpi_dmar_header *hdr, void *arg)
4272 if (!atsru) 4272 if (!atsru)
4273 return 0; 4273 return 0;
4274 4274
4275 if (!atsru->include_all && atsru->devices && atsru->devices_cnt) 4275 if (!atsru->include_all && atsru->devices && atsru->devices_cnt) {
4276 for_each_active_dev_scope(atsru->devices, atsru->devices_cnt, 4276 for_each_active_dev_scope(atsru->devices, atsru->devices_cnt,
4277 i, dev) 4277 i, dev)
4278 return -EBUSY; 4278 return -EBUSY;
4279 }
4279 4280
4280 return 0; 4281 return 0;
4281} 4282}