kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] NFS: Less function calls in show_pnfs()
@ 2019-07-02 14:38 Markus Elfring
  2019-07-03  8:18 ` Julia Lawall
  0 siblings, 1 reply; 3+ messages in thread
From: Markus Elfring @ 2019-07-02 14:38 UTC (permalink / raw)
  To: linux-nfs, Anna Schumaker, Trond Myklebust; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/nfs/super.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index f88ddac2dcdf..c301cd585b3b 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] NFS: Less function calls in show_pnfs()
  2019-07-02 14:38 [PATCH] NFS: Less function calls in show_pnfs() Markus Elfring
@ 2019-07-03  8:18 ` Julia Lawall
  2019-07-03  8:48   ` Markus Elfring
  0 siblings, 1 reply; 3+ messages in thread
From: Julia Lawall @ 2019-07-03  8:18 UTC (permalink / raw)
  To: Markus Elfring
  Cc: linux-nfs, Anna Schumaker, Trond Myklebust, LKML, kernel-janitors



On Tue, 2 Jul 2019, Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  fs/nfs/super.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/fs/nfs/super.c b/fs/nfs/super.c
> index f88ddac2dcdf..c301cd585b3b 100644
> --- a/fs/nfs/super.c
> +++ b/fs/nfs/super.c
> @@ -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");

Unreadable.

julia

>  }
>
>  static void show_implementation_id(struct seq_file *m, struct nfs_server *nfss)
> --
> 2.22.0
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] NFS: Less function calls in show_pnfs()
  2019-07-03  8:18 ` Julia Lawall
@ 2019-07-03  8:48   ` Markus Elfring
  0 siblings, 0 replies; 3+ messages in thread
From: Markus Elfring @ 2019-07-03  8:48 UTC (permalink / raw)
  To: Julia Lawall, linux-nfs
  Cc: Anna Schumaker, Trond Myklebust, LKML, kernel-janitors

>> +++ b/fs/nfs/super.c
>> @@ -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");
>
> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-07-03  8:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-02 14:38 [PATCH] NFS: Less function calls in show_pnfs() Markus Elfring
2019-07-03  8:18 ` Julia Lawall
2019-07-03  8:48   ` Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).