Bug 98281 - Misleading indentation in drivers/gpu/drm/i915/i915_debugfs.c: In function ‘describe_obj’
Summary: Misleading indentation in drivers/gpu/drm/i915/i915_debugfs.c: In function ‘d...
Status: RESOLVED CODE_FIX
Alias: None
Product: Drivers
Classification: Unclassified
Component: Video(DRI - Intel) (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: intel-gfx-bugs@lists.freedesktop.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-13 18:59 UTC by Dave Malcolm
Modified: 2015-05-15 07:28 UTC (History)
1 user (show)

See Also:
Kernel Version: 4.0.3
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description Dave Malcolm 2015-05-13 18:59:36 UTC
In kernel-4.0.3/drivers/gpu/drm/i915/i915_debugfs.c: In function ‘describe_obj’:

   142          list_for_each_entry(vma, &obj->vma_list, vma_link)
   143                  if (vma->pin_count > 0)
   144                          pin_count++;
   145                  seq_printf(m, " (pinned x %d)", pin_count);

the "seq_printf" at line 145 is indented as if guarded within the "list_for_each_entry" at line 142.

My reading of the code is that it's meant to be after the loop, rather than within it.  The compiler treats it as after, hence I think this indentation snafu is benign, if misleading.

Seen via an experimental new gcc warning I'm working on for gcc 6, -Wmisleading-indentation, using gcc r223098 adding -Werror=misleading-indentation" to KBUILD_CFLAGS in Makefile, where the experimental gcc emits this error:

drivers/gpu/drm/i915/i915_debugfs.c: In function ‘describe_obj’:
drivers/gpu/drm/i915/i915_debugfs.c:145:3: error: statement is indented as if it were guarded by... [-Werror=misleading-indentation]
   seq_printf(m, " (pinned x %d)", pin_count);
   ^
In file included from include/linux/mutex.h:14:0,
                 from include/linux/seq_file.h:7,
                 from drivers/gpu/drm/i915/i915_debugfs.c:29:
include/linux/list.h:447:2: note: ...this ‘for’ clause, but it is not
  for (pos = list_first_entry(head, typeof(*pos), member); \
  ^
drivers/gpu/drm/i915/i915_debugfs.c:142:2: note: in expansion of macro ‘list_for_each_entry’
  list_for_each_entry(vma, &obj->vma_list, vma_link)
  ^

Hope this is constructive
Comment 1 Jani Nikula 2015-05-15 07:28:18 UTC
(In reply to Dave Malcolm from comment #0)
> Seen via an experimental new gcc warning I'm working on for gcc 6,
> -Wmisleading-indentation, using gcc r223098 adding
> -Werror=misleading-indentation" to KBUILD_CFLAGS in Makefile, where the
> experimental gcc emits this error:

Seems useful.

> Hope this is constructive

Yes... except it's been fixed already!

commit ba0635ffb7665d76715b43ae8144e014a90c1e63
Author: Dan Carpenter <dan.carpenter@oracle.com>
Date:   Wed Feb 25 16:17:48 2015 +0300

    drm/i915: cleanup some indenting

Please always check the latest sources first. And when you do, you might as well send a patch fixing the issue if it's still there! ;)

Thanks for the report.

Note You need to log in before you can comment on or make changes to this bug.