2017-12-20 20:14:29

by Petros Koutoupis

[permalink] [raw]
Subject: [PATCH] ext4.h: Fixed alignment and minor code cleanup.

Minor code cleanup: Fixed alignment and a reduction of lines in header file.

Signed-off-by: Petros Koutoupis <[email protected]>


diff -uNpr linux-4.15-rc4.orig/fs/ext4/ext4.h linux-4.15-rc4/fs/ext4/ext4.h
--- linux-4.15-rc4.orig/fs/ext4/ext4.h 2017-12-18 08:35:04.000000000 -0600
+++ linux-4.15-rc4/fs/ext4/ext4.h 2017-12-18 08:37:02.000000000 -0600
@@ -611,10 +611,10 @@ enum {
 /*
  * Flags used by ext4_free_blocks
  */
-#define EXT4_FREE_BLOCKS_METADATA 0x0001
-#define EXT4_FREE_BLOCKS_FORGET 0x0002
-#define EXT4_FREE_BLOCKS_VALIDATED 0x0004
-#define EXT4_FREE_BLOCKS_NO_QUOT_UPDATE 0x0008
+#define EXT4_FREE_BLOCKS_METADATA 0x0001
+#define EXT4_FREE_BLOCKS_FORGET 0x0002
+#define EXT4_FREE_BLOCKS_VALIDATED 0x0004
+#define EXT4_FREE_BLOCKS_NO_QUOT_UPDATE 0x0008
 #define EXT4_FREE_BLOCKS_NOFREE_FIRST_CLUSTER 0x0010
 #define EXT4_FREE_BLOCKS_NOFREE_LAST_CLUSTER 0x0020
 
@@ -1986,10 +1986,10 @@ static inline __le16 ext4_rec_len_to_dis
 
 /* Legal values for the dx_root hash_version field: */
 
-#define DX_HASH_LEGACY 0
-#define DX_HASH_HALF_MD4 1
-#define DX_HASH_TEA 2
-#define DX_HASH_LEGACY_UNSIGNED 3
+#define DX_HASH_LEGACY 0
+#define DX_HASH_HALF_MD4 1
+#define DX_HASH_TEA 2
+#define DX_HASH_LEGACY_UNSIGNED 3
 #define DX_HASH_HALF_MD4_UNSIGNED 4
 #define DX_HASH_TEA_UNSIGNED 5
 
@@ -2000,7 +2000,6 @@ static inline u32 ext4_chksum(struct ext
  struct shash_desc shash;
  char ctx[4];
  } desc;
- int err;
 
  BUG_ON(crypto_shash_descsize(sbi->s_chksum_driver)!=sizeof(desc.ctx));
 
@@ -2008,8 +2007,7 @@ static inline u32 ext4_chksum(struct ext
  desc.shash.flags = 0;
  *(u32 *)desc.ctx = crc;
 
- err = crypto_shash_update(&desc.shash, address, length);
- BUG_ON(err);
+ BUG_ON(crypto_shash_update(&desc.shash, address, length));
 
  return *(u32 *)desc.ctx;
 }


2018-01-08 04:57:32

by Theodore Ts'o

[permalink] [raw]
Subject: Re: [PATCH] ext4.h: Fixed alignment and minor code cleanup.

On Wed, Dec 20, 2017 at 02:09:18PM -0600, Petros Koutoupis wrote:
> Minor code cleanup: Fixed alignment and a reduction of lines in header file.
>
> Signed-off-by: Petros Koutoupis <[email protected]>

The patch is whitespace damaged, unfortunately.

Also, the cleanup actually isn't the best cleanup. We should really
be changing ext4_chksum() to take a struct super instead of a struct
ext4_sb_info, so we can call ext4_std_error() so we can properly log
an error without immediately crashing the kernel. The chksum
shouldn't really ever fail, but if it does, calling ext4_error() is
better than bringing down the whole system with a BUG_ON.

Cheers,
- Ted