Skip to contentSkip to conversation

secretmem: drop unneeded initialization in secretmem_file_create()

PATCH In review Lukas Bulwahn 3 participants 4 messages Jul 4, 2022 – Jul 5, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 secretmem: drop unneeded initialization in secretmem_file_create()

Drop the unneeded initialization of the local variable file in function secretmem_file_create().

No functional change and no change in the resulting object code.

This unneeded initialization was already introduced with the introduction of secretmem in commit 1507f51255c9 ("mm: introduce memfd_secret system call to create "secret" memory areas"). This minor code-stylistic issue was discovered as a dead store with clang-analyzer.

---
Mike, please ack.

Andrew, please pick this minor stylistic clean-up patch. Thanks.

 mm/secretmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/secretmem.c +1 -1
index 7584aab54d20..46b431d62761 100644
@@ -171,7 +171,7 @@ static struct vfsmount *secretmem_mnt;
 
 static struct file *secretmem_file_create(unsigned long flags)
 {
-	struct file *file = ERR_PTR(-ENOMEM);
+	struct file *file;
 	struct inode *inode;
 	const char *anon_name = "[secretmem]";
 	const struct qstr qname = QSTR_INIT(anon_name, strlen(anon_name));
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Lukas Bulwahn

Drop the unneeded initialization of the local variable file in function secretmem_file_create().

No functional change and no change in the resulting object code.

This unneeded initialization was already introduced with the introduction of secretmem in commit 1507f51255c9 ("mm: introduce memfd_secret system call to create "secret" memory areas").

You may need to be more specific about this commit, the whole function, including this initialization was introduced at this time.

Otherwise, change looks fine.

Quoted 25 lines

This minor code-stylistic issue
was discovered as a dead store with clang-analyzer.

---
Mike, please ack.

Andrew, please pick this minor stylistic clean-up patch. Thanks.

  mm/secretmem.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
mm/secretmem.c +1 -1
index 7584aab54d20..46b431d62761 100644
@@ -171,7 +171,7 @@ static struct vfsmount *secretmem_mnt;
 
  static struct file *secretmem_file_create(unsigned long flags)
  {
-	struct file *file = ERR_PTR(-ENOMEM);
+	struct file *file;
  	struct inode *inode;
  	const char *anon_name = "[secretmem]";
  	const struct qstr qname = QSTR_INIT(anon_name, strlen(anon_name));
#2 lore raw
In reply to Lukas Bulwahn

Hi Lukas,

Quoted 9 lines · Lukas Bulwahn

Drop the unneeded initialization of the local variable file in function secretmem_file_create().

No functional change and no change in the resulting object code.

This unneeded initialization was already introduced with the introduction of secretmem in commit 1507f51255c9 ("mm: introduce memfd_secret system call to create "secret" memory areas"). This minor code-stylistic issue was discovered as a dead store with clang-analyzer.

You are right and in the current code the initialization is unneeded, but there's a pending patch that relies of this initialization:

https://lore.kernel.org/all/[email protected]/

Let's wait and see how that fix develops.

Quoted 25 lines

---
Mike, please ack.

Andrew, please pick this minor stylistic clean-up patch. Thanks.

 mm/secretmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/secretmem.c +1 -1
index 7584aab54d20..46b431d62761 100644
@@ -171,7 +171,7 @@ static struct vfsmount *secretmem_mnt;
 
 static struct file *secretmem_file_create(unsigned long flags)
 {
-	struct file *file = ERR_PTR(-ENOMEM);
+	struct file *file;
 	struct inode *inode;
 	const char *anon_name = "[secretmem]";
 	const struct qstr qname = QSTR_INIT(anon_name, strlen(anon_name));
Signature · 1 line
2.17.1
Signature · 2 lines
Sincerely yours,
Mike.
#3 lore raw
Quoted 14 lines · Mike Rapoport

Hi Lukas,

Quoted 9 lines · Lukas Bulwahn

Drop the unneeded initialization of the local variable file in function secretmem_file_create().

No functional change and no change in the resulting object code.

This unneeded initialization was already introduced with the introduction of secretmem in commit 1507f51255c9 ("mm: introduce memfd_secret system call to create "secret" memory areas"). This minor code-stylistic issue was discovered as a dead store with clang-analyzer.

Quoted 7 lines

You are right and in the current code the initialization is unneeded, but there's a pending patch that relies of this initialization:

https://lore.kernel.org/all/[email protected]/

Let's wait and see how that fix develops.

Agree. I will continue tracking the evolution of this function and resend my patch if this patch above does not land in the next six months. For now, this clean-up patch here can be ignored.

Lukas