Skip to contentSkip to conversation

i915: fix build error with -Werror

PATCH Superseded Jeff Mahoney 3 participants 5 messages Jul 4, 2016 – Jul 19, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i915: fix build error with -Werror

This fixes the following build error with -Werror and gcc 6.1:

drivers/gpu/drm/i915/i915_debugfs.c:2103:6: error: suggest explicit braces to avoid ambiguous 'else' [-Werror=parentheses]

---
 drivers/gpu/drm/i915/i915_debugfs.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_debugfs.c +2 -1
@@ -2101,8 +2101,9 @@ static int i915_dump_lrc(struct seq_file
 
 	list_for_each_entry(ctx, &dev_priv->context_list, link)
 		if (ctx != dev_priv->kernel_context)
-			for_each_engine(engine, dev_priv)
+			for_each_engine(engine, dev_priv) {
 				i915_dump_lrc_obj(m, ctx, engine);
+			}
 
 	mutex_unlock(&dev->struct_mutex);
 
Signature · 6 lines
Jeff Mahoney
SUSE Labs
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw
Quoted 3 lines · Jeff Mahoney

This fixes the following build error with -Werror and gcc 6.1:

drivers/gpu/drm/i915/i915_debugfs.c:2103:6: error: suggest explicit braces to avoid ambiguous 'else' [-Werror=parentheses]

Oops. It turns out my build test wasn't using gcc6. This doesn't fix the error. I'll post v2 shortly.

-Jeff

Quoted 19 lines
---
 drivers/gpu/drm/i915/i915_debugfs.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_debugfs.c +2 -1
@@ -2101,8 +2101,9 @@ static int i915_dump_lrc(struct seq_file
 
 	list_for_each_entry(ctx, &dev_priv->context_list, link)
 		if (ctx != dev_priv->kernel_context)
-			for_each_engine(engine, dev_priv)
+			for_each_engine(engine, dev_priv) {
 				i915_dump_lrc_obj(m, ctx, engine);
+			}
 
 	mutex_unlock(&dev->struct_mutex);
 
Signature · 2 lines
Jeff Mahoney
SUSE Labs

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#2 lore raw

PATCH v2 1/1 i915: fix build error with -Werror

In reply to Jeff Mahoney

This fixes the following build error with -Werror and gcc 6.1:

drivers/gpu/drm/i915/i915_debugfs.c:2103:6: error: suggest explicit braces to avoid ambiguous 'else' [-Werror=parentheses]

---
 drivers/gpu/drm/i915/i915_debugfs.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +2 -1
@@ -2100,9 +2100,10 @@ static int i915_dump_lrc(struct seq_file
 		return ret;
 
 	list_for_each_entry(ctx, &dev_priv->context_list, link)
-		if (ctx != dev_priv->kernel_context)
+		if (ctx != dev_priv->kernel_context) {
 			for_each_engine(engine, dev_priv)
 				i915_dump_lrc_obj(m, ctx, engine);
+		}
 
 	mutex_unlock(&dev->struct_mutex);
 
Signature · 6 lines
Jeff Mahoney
SUSE Labs
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw
Quoted 5 lines · Jeff Mahoney

This fixes the following build error with -Werror and gcc 6.1:

drivers/gpu/drm/i915/i915_debugfs.c:2103:6: error: suggest explicit braces to avoid ambiguous 'else' [-Werror=parentheses]

This doesn't apply on -next any more ... Is this still an issue on latest kernels?
-Daniel

Quoted 27 lines
---
 drivers/gpu/drm/i915/i915_debugfs.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +2 -1
@@ -2100,9 +2100,10 @@ static int i915_dump_lrc(struct seq_file
 		return ret;
 
 	list_for_each_entry(ctx, &dev_priv->context_list, link)
-		if (ctx != dev_priv->kernel_context)
+		if (ctx != dev_priv->kernel_context) {
 			for_each_engine(engine, dev_priv)
 				i915_dump_lrc_obj(m, ctx, engine);
+		}
 
 	mutex_unlock(&dev->struct_mutex);
 
Signature · 7 lines
-- 
Jeff Mahoney
SUSE Labs
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#4 lore raw
Quoted 19 lines · Daniel Vetter
Quoted 5 lines · Jeff Mahoney

This fixes the following build error with -Werror and gcc 6.1:

drivers/gpu/drm/i915/i915_debugfs.c:2103:6: error: suggest explicit braces to avoid ambiguous 'else' [-Werror=parentheses]

This doesn't apply on -next any more ... Is this still an issue on latest kernels?
-Daniel

Quoted 9 lines
---
  drivers/gpu/drm/i915/i915_debugfs.c |    7 ++++---
  1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +0 -0
@@ -2100,9 +2100,10 @@ static int i915_dump_lrc(struct seq_file
  		return ret;
 
Quoted 8 lines

drivers/gpu/drm/i915/i915_debugfs.c static int i915_dump_lrc(struct seq_file · line 2108

Quoted 8 lines
drivers/gpu/drm/i915/i915_debugfs.c +2 -1
  	list_for_each_entry(ctx, &dev_priv->context_list, link)
-		if (ctx != dev_priv->kernel_context)
+		if (ctx != dev_priv->kernel_context) {
  			for_each_engine(engine, dev_priv)
  				i915_dump_lrc_obj(m, ctx, engine);
+		}
 
  	mutex_unlock(&dev->struct_mutex);

That's a curious warning. Ever since

commit 373701b1fc7d7c0013ae4fffd8103615c150751e
drm: fix potential dangling else problems in for_each_ macros
Author: Jani Nikula <[email protected]>
Date: Tue Nov 24 21:21:55 2015 +0200

we've avoided leaving a dangling else; the code should expand as

    for ( /* each entry */ )
        if (ctx != dev_priv->kernel_context)
            for ( /* each engine */ )
                if (!intel_engine_initialized(engine))
                    {}
                else
                    i915_dump_lrc_obj(m, ctx, engine);

... so that the (hidden) else is clearly matched with the (hidden) if() generated by the macro expansion. Surely the compiler can't think that an else inside a for-loop could be mistakenly paired with one outside the loop?

Of course we did *have* a proposal for an alternative iterator strategy that didn't expose any if/else at all, but some people didn't like it :L

Oh well, it just shows that using macros to rewrite C syntax is still an abomination, Stephen Bourne notwithstanding. If you want iterators and blocks, use Ruby ;)

.Dave.
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx