Be explicit in order of evaluation in the reiserfs code
authorTony Breeds <tony@bakeyournoodle.com>
Tue, 10 Feb 2009 03:11:23 +0000 (14:11 +1100)
committerTony Breeds <tony@bakeyournoodle.com>
Tue, 18 Oct 2011 04:11:10 +0000 (15:11 +1100)
GCC Has helpfully pointed out that we're doing some strange things:

second/fs_reiserfs.c: In function ‘block_read’:
second/fs_reiserfs.c:219: warning: operation on ‘journal_table’ may be undefined
second/fs_reiserfs.c:219: warning: operation on ‘journal_table’ may be undefined
second/fs_reiserfs.c:219: warning: operation on ‘journal_table’ may be undefined
second/fs_reiserfs.c: In function ‘next_key’:
second/fs_reiserfs.c:619: warning: operation on ‘depth’ may be undefined

Signed-off-by: Tony Breeds <tony@bakeyournoodle.com>
second/fs_reiserfs.c

index b0c3ac0..a312ced 100644 (file)
@@ -218,7 +218,7 @@ block_read( __u32 blockNr, __u32 start, __u32 len, char *buffer )
          if ( *journal_table != 0xffffffff )
          {
               /* Search for the blockNr in cached journal */
-              j_len = le32_to_cpu(*journal_table++);
+              j_len = le32_to_cpu((*journal_table)++);
               while ( i++ < j_len )
               {
                    if ( le32_to_cpu(*journal_table++) == blockNr )
@@ -618,7 +618,10 @@ next_key( void )
               cache = CACHE( depth );
          else
          {
-              cache = read_tree_node( INFO->blocks[depth], --depth );
+              /* Save depth as using it twice as args to read_tree_node()
+               * has undefined behaviour */
+              __u16 d = depth;
+              cache = read_tree_node( INFO->blocks[d], --depth );
               if ( !cache )
                    return 0;
          }