Skip to contentSkip to conversation

ext2: use get_random_u32() where appropriate

PATCH In review David Carlier 2 participants 2 messages Apr 5 – Apr 7 ext2 file system

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 ext2: use get_random_u32() where appropriate

Use the typed random integer helpers instead of get_random_bytes() when filling a single integer variable. The helpers return the value directly, require no pointer or size argument, and better express intent.

---
 fs/ext2/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext2/super.c +1 -1
index 603f2641fe10..e4136490c883 100644
@@ -1151,7 +1151,7 @@ static int ext2_fill_super(struct super_block *sb, struct fs_context *fc)
 		goto failed_mount2;
 	}
 	sbi->s_gdb_count = db_count;
-	get_random_bytes(&sbi->s_next_generation, sizeof(u32));
+	sbi->s_next_generation = get_random_u32();
 	spin_lock_init(&sbi->s_next_gen_lock);
 
 	/* per filesystem reservation list head & lock */
Signature · 1 line
2.53.0
#1 lore raw
Quoted 6 lines · David Carlier

Use the typed random integer helpers instead of get_random_bytes() when filling a single integer variable. The helpers return the value directly, require no pointer or size argument, and better express intent.

Thanks! I've added the patch to my tree.

Honza

Quoted 20 lines
---
 fs/ext2/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext2/super.c +1 -1
index 603f2641fe10..e4136490c883 100644
@@ -1151,7 +1151,7 @@ static int ext2_fill_super(struct super_block *sb, struct fs_context *fc)
 		goto failed_mount2;
 	}
 	sbi->s_gdb_count = db_count;
-	get_random_bytes(&sbi->s_next_generation, sizeof(u32));
+	sbi->s_next_generation = get_random_u32();
 	spin_lock_init(&sbi->s_next_gen_lock);
 
 	/* per filesystem reservation list head & lock */
Signature · 1 line
2.53.0
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR