Bug 98241 - Suspected bug in fs/hfsplus/catalog.c ‘hfsplus_delete_cat’ (misleading indentation)
Summary: Suspected bug in fs/hfsplus/catalog.c ‘hfsplus_delete_cat’ (misleading indent...
Status: NEW
Alias: None
Product: File System
Classification: Unclassified
Component: HFS/HFSPLUS (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: fs_hfs@kernel-bugs.osdl.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-13 18:03 UTC by Dave Malcolm
Modified: 2016-03-20 10:06 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:03:02 UTC
In linux-4.0.3/fs/hfsplus/catalog.c it looks like the "else" clause at line 353 is missing braces

   335          if (!str) {
   336                  int len;
   337  
   338                  hfsplus_cat_build_key_with_cnid(sb, fd.search_key, cnid);
   339                  err = hfs_brec_find(&fd, hfs_find_rec_by_key);
   340                  if (err)
   341                          goto out;
   342  
   343                  off = fd.entryoffset +
   344                          offsetof(struct hfsplus_cat_thread, nodeName);
   345                  fd.search_key->cat.parent = cpu_to_be32(dir->i_ino);
   346                  hfs_bnode_read(fd.bnode,
   347                          &fd.search_key->cat.name.length, off, 2);
   348                  len = be16_to_cpu(fd.search_key->cat.name.length) * 2;
   349                  hfs_bnode_read(fd.bnode,
   350                          &fd.search_key->cat.name.unicode,
   351                          off + 2, len);
   352                  fd.search_key->key_len = cpu_to_be16(6 + len);
>>>353          } else
   354                  err = hfsplus_cat_build_key(sb, fd.search_key, dir->i_ino, str);
   355                  if (unlikely(err))
   356                          goto out;
   357  

Note that the "if (unlikely(err))" at line 355 is indented as if it were guarded by the "else" clause, but it isn't.

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:

fs/hfsplus/catalog.c: In function ‘hfsplus_delete_cat’:
fs/hfsplus/catalog.c:355:3: error: statement is indented as if it were guarded by... [-Werror=misleading-indentation]
   if (unlikely(err))
   ^
fs/hfsplus/catalog.c:353:4: note: ...this ‘else’ clause, but it is not
  } else
    ^

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