Skip to contentSkip to conversation

btrfs: remove unneeded NULL initializer for struct fs_path

PATCH In review Alexandru Moise 2 participants 3 messages Sep 26, 2015 – Sep 29, 2015 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: remove unneeded NULL initializer for struct fs_path

fs_path_alloc() either returns an alloc'ed struct fs_path or NULL, no need to initialize the pointer to NULL.

---
 fs/btrfs/send.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/send.c +1 -1
index aa72bfd..0019c90 100644
@@ -2230,7 +2230,7 @@ static int get_cur_path(struct send_ctx *sctx, u64 ino, u64 gen,
 			struct fs_path *dest)
 {
 	int ret = 0;
-	struct fs_path *name = NULL;
+	struct fs_path *name;
 	u64 parent_inode = 0;
 	u64 parent_gen = 0;
 	int stop = 0;
Signature · 1 line
2.5.3
#1 lore raw
Quoted 13 lines · Alexandru Moise

fs_path_alloc() either returns an alloc'ed struct fs_path or NULL, no need to initialize the pointer to NULL.

---
 fs/btrfs/send.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/send.c +0 -0
index aa72bfd..0019c90 100644

fs/btrfs/send.c static int get_cur_path(struct send_ctx *sctx, u64 ino, u64 gen, · line 2233

Quoted 5 lines
fs/btrfs/send.c +1 -1
@@ -2230,7 +2230,7 @@ static int get_cur_path(struct send_ctx *sctx, u64 ino, u64 gen,
 			struct fs_path *dest)
 {
 	int ret = 0;
-	struct fs_path *name = NULL;
+	struct fs_path *name;

I'd rather see all such instances fixed in one patch. Quick grep revealed a few more. OTOH this kind of extra initialization is harmless and sometimes help readability, it's clear that he value is zeroed.

#2 lore raw
Quoted 9 lines · David Sterba
Quoted 8 lines · Alexandru Moise

fs_path_alloc() either returns an alloc'ed struct fs_path or NULL, no need to initialize the pointer to NULL.

---
 fs/btrfs/send.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 14 lines

fs/btrfs/send.c static int get_cur_path(struct send_ctx *sctx, u64 ino, u64 gen, · line 2233

Quoted 10 lines
fs/btrfs/send.c +1 -1
index aa72bfd..0019c90 100644
@@ -2230,7 +2230,7 @@ static int get_cur_path(struct send_ctx *sctx, u64 ino, u64 gen,
 			struct fs_path *dest)
 {
 	int ret = 0;
-	struct fs_path *name = NULL;
+	struct fs_path *name;

I'd rather see all such instances fixed in one patch. Quick grep revealed a few more. OTOH this kind of extra initialization is harmless and sometimes help readability, it's clear that he value is zeroed.

When you put it like that, you are right, it's more important to make things obvious than to fiercely abide by all the subtleties of our coding style. I submit to your point of view and will not insist on this kind of change in the future.