Bug 98251 - Suspected bug in drivers/staging/lustre/lustre/llite/llite_lib.c ‘ll_setattr_raw’ (misleading indentation)
Summary: Suspected bug in drivers/staging/lustre/lustre/llite/llite_lib.c ‘ll_setattr_...
Status: NEW
Alias: None
Product: File System
Classification: Unclassified
Component: Other (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: fs_other
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-13 18:11 UTC by Dave Malcolm
Modified: 2016-03-20 10:07 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:11:51 UTC
In linux-4.0.3/drivers/staging/lustre/lustre/llite/llite_lib.c the following "if" clause doesn't have braces, but multiple statements are indented as if guarded by it.

  1433          if (attr->ia_valid & (ATTR_SIZE |
  1434                                ATTR_ATIME | ATTR_ATIME_SET |
  1435                                ATTR_MTIME | ATTR_MTIME_SET))
  1436                  /* For truncate and utimes sending attributes to OSTs, setting
  1437                   * mtime/atime to the past will be performed under PW [0:EOF]
  1438                   * extent lock (new_size:EOF for truncate).  It may seem
  1439                   * excessive to send mtime/atime updates to OSTs when not
  1440                   * setting times to past, but it is necessary due to possible
  1441                   * time de-synchronization between MDT inode and OST objects */
  1442                  if (attr->ia_valid & ATTR_SIZE)
  1443                          down_write(&lli->lli_trunc_sem);
  1444                  rc = ll_setattr_ost(inode, attr);
  1445                  if (attr->ia_valid & ATTR_SIZE)
  1446                          up_write(&lli->lli_trunc_sem);

Only the initial statement at line 1442 is guarded by the "if" at line 1433.  Should the "if" at line 1433 have braces, so that lines 1444-1446 are also covered by it?

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/staging/lustre/lustre/llite/llite_lib.c: In function ‘ll_setattr_raw’:
drivers/staging/lustre/lustre/llite/llite_lib.c:1444:3: error: statement is indented as if it were guarded by... [-Werror=misleading-indentation]
   rc = ll_setattr_ost(inode, attr);
   ^
drivers/staging/lustre/lustre/llite/llite_lib.c:1433:2: note: ...this ‘if’ clause, but it is not
  if (attr->ia_valid & (ATTR_SIZE |
  ^

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