Skip to contentSkip to conversation

NFS: Less function calls in show_pnfs()

PATCH In review Markus Elfring 2 participants 3 messages Jul 2, 2019 – Jul 3, 2019

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

PATCH 1/1 NFS: Less function calls in show_pnfs()

From: Markus Elfring <[email protected]>
Date: Tue, 2 Jul 2019 16:30:53 +0200

Reduce function calls for data output into a sequence.

This issue was detected by using the Coccinelle software.

---
 fs/nfs/super.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
fs/nfs/super.c +4 -5
index f88ddac2dcdf..c301cd585b3b 100644
@@ -749,11 +749,10 @@ static void show_sessions(struct seq_file *m, struct nfs_server *server) {}
 #ifdef CONFIG_NFS_V4_1
 static void show_pnfs(struct seq_file *m, struct nfs_server *server)
 {
-	seq_printf(m, ",pnfs=");
-	if (server->pnfs_curr_ld)
-		seq_printf(m, "%s", server->pnfs_curr_ld->name);
-	else
-		seq_printf(m, "not configured");
+	seq_printf(m, ",pnfs=%s",
+		   server->pnfs_curr_ld
+		   ? server->pnfs_curr_ld->name
+		   : "not configured");
 }
 
 static void show_implementation_id(struct seq_file *m, struct nfs_server *nfss)

--
2.22.0

#1 lore raw
Quoted 19 lines · Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 2 Jul 2019 16:30:53 +0200

Reduce function calls for data output into a sequence.

This issue was detected by using the Coccinelle software.

---
 fs/nfs/super.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
fs/nfs/super.c +0 -0
index f88ddac2dcdf..c301cd585b3b 100644
@@ -749,11 +749,10 @@ static void show_sessions(struct seq_file *m, struct nfs_server *server) {}
 #ifdef CONFIG_NFS_V4_1
 static void show_pnfs(struct seq_file *m, struct nfs_server *server)

fs/nfs/super.c static void show_sessions(struct seq_file *m, struct nfs_server *server) {} · line 755

Quoted 10 lines
fs/nfs/super.c +4 -5
 {
-	seq_printf(m, ",pnfs=");
-	if (server->pnfs_curr_ld)
-		seq_printf(m, "%s", server->pnfs_curr_ld->name);
-	else
-		seq_printf(m, "not configured");
+	seq_printf(m, ",pnfs=%s",
+		   server->pnfs_curr_ld
+		   ? server->pnfs_curr_ld->name
+		   : "not configured");

Unreadable.

julia

Quoted 7 lines
fs/nfs/super.c +0 -1
 }
 
 static void show_implementation_id(struct seq_file *m, struct nfs_server *nfss)
--

2.22.0

#2 lore raw
Quoted 8 lines
Quoted 8 lines

+++ b/fs/nfs/super.c

fs/nfs/super.c +0 -3
@@ -749,11 +749,10 @@ static void show_sessions(struct seq_file *m, struct nfs_server *server) {}
 #ifdef CONFIG_NFS_V4_1
 static void show_pnfs(struct seq_file *m, struct nfs_server *server)
 {
-	seq_printf(m, ",pnfs=");
-	if (server->pnfs_curr_ld)
-		seq_printf(m, "%s", server->pnfs_curr_ld->name);
Quoted 8 lines

fs/nfs/super.c static void show_sessions(struct seq_file *m, struct nfs_server *server) {} · line 755

Quoted 6 lines
fs/nfs/super.c +4 -2
-	else
-		seq_printf(m, "not configured");
+	seq_printf(m, ",pnfs=%s",
+		   server->pnfs_curr_ld
+		   ? server->pnfs_curr_ld->name
+		   : "not configured");

Unreadable.

* Do you find any other source code formatting more readable for the usage of the ternary operator?

* How do you think about the general software transformation possibility (at this place)?

Regards,
Markus