linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] NFS: Adjustments for three function implementations
@ 2019-07-03 15:07 Markus Elfring
  2019-07-03 15:08 ` [PATCH 1/3] NFS: Use seq_putc() in nfs_show_stats() Markus Elfring
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Markus Elfring @ 2019-07-03 15:07 UTC (permalink / raw)
  To: linux-nfs, Anna Schumaker, Trond Myklebust; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 3 Jul 2019 17:02:05 +0200

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (3):
  Use seq_putc() in nfs_show_stats()
  Replace 16 seq_printf() calls by seq_puts()
  Three function calls less

 fs/nfs/nfs4xdr.c |  5 +----
 fs/nfs/super.c   | 53 ++++++++++++++++++++++++------------------------
 2 files changed, 27 insertions(+), 31 deletions(-)

--
2.22.0


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

* [PATCH 1/3] NFS: Use seq_putc() in nfs_show_stats()
  2019-07-03 15:07 [PATCH 0/3] NFS: Adjustments for three function implementations Markus Elfring
@ 2019-07-03 15:08 ` Markus Elfring
  2019-07-03 15:09 ` [PATCH 2/3] NFS: Replace 16 seq_printf() calls by seq_puts() Markus Elfring
  2019-07-03 15:11 ` [PATCH 3/3] NFS: Three function calls less Markus Elfring
  2 siblings, 0 replies; 4+ messages in thread
From: Markus Elfring @ 2019-07-03 15:08 UTC (permalink / raw)
  To: linux-nfs, Anna Schumaker, Trond Myklebust; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 3 Jul 2019 15:33:09 +0200

A single character (line break) should be put into a sequence.
Thus use the corresponding function “seq_putc”.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/nfs/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index f88ddac2dcdf..0c229e877ba6 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -887,7 +887,7 @@ int nfs_show_stats(struct seq_file *m, struct dentry *root)
 			seq_printf(m, "%Lu ", totals.fscache[i]);
 	}
 #endif
-	seq_printf(m, "\n");
+	seq_putc(m, '\n');

 	rpc_clnt_show_stats(m, nfss->client);

--
2.22.0


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

* [PATCH 2/3] NFS: Replace 16 seq_printf() calls by seq_puts()
  2019-07-03 15:07 [PATCH 0/3] NFS: Adjustments for three function implementations Markus Elfring
  2019-07-03 15:08 ` [PATCH 1/3] NFS: Use seq_putc() in nfs_show_stats() Markus Elfring
@ 2019-07-03 15:09 ` Markus Elfring
  2019-07-03 15:11 ` [PATCH 3/3] NFS: Three function calls less Markus Elfring
  2 siblings, 0 replies; 4+ messages in thread
From: Markus Elfring @ 2019-07-03 15:09 UTC (permalink / raw)
  To: linux-nfs, Anna Schumaker, Trond Myklebust; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 3 Jul 2019 15:50:37 +0200

Some strings should be put into a sequence.
Thus use the corresponding function “seq_puts”.

This issue was detected by using the Coccinelle software.

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

diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 0c229e877ba6..84dcde7f560b 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -582,7 +582,7 @@ static void nfs_show_mountd_options(struct seq_file *m, struct nfs_server *nfss,
 	}
 	default:
 		if (showdefaults)
-			seq_printf(m, ",mountaddr=unspecified");
+			seq_puts(m, ",mountaddr=unspecified");
 	}

 	if (nfss->mountd_version || showdefaults)
@@ -690,29 +690,29 @@ static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss,
 		nfs_show_nfsv4_options(m, nfss, showdefaults);

 	if (nfss->options & NFS_OPTION_FSCACHE)
-		seq_printf(m, ",fsc");
+		seq_puts(m, ",fsc");

 	if (nfss->options & NFS_OPTION_MIGRATION)
-		seq_printf(m, ",migration");
+		seq_puts(m, ",migration");

 	if (nfss->flags & NFS_MOUNT_LOOKUP_CACHE_NONEG) {
 		if (nfss->flags & NFS_MOUNT_LOOKUP_CACHE_NONE)
-			seq_printf(m, ",lookupcache=none");
+			seq_puts(m, ",lookupcache=none");
 		else
-			seq_printf(m, ",lookupcache=pos");
+			seq_puts(m, ",lookupcache=pos");
 	}

 	local_flock = nfss->flags & NFS_MOUNT_LOCAL_FLOCK;
 	local_fcntl = nfss->flags & NFS_MOUNT_LOCAL_FCNTL;

 	if (!local_flock && !local_fcntl)
-		seq_printf(m, ",local_lock=none");
+		seq_puts(m, ",local_lock=none");
 	else if (local_flock && local_fcntl)
-		seq_printf(m, ",local_lock=all");
+		seq_puts(m, ",local_lock=all");
 	else if (local_flock)
-		seq_printf(m, ",local_lock=flock");
+		seq_puts(m, ",local_lock=flock");
 	else
-		seq_printf(m, ",local_lock=posix");
+		seq_puts(m, ",local_lock=posix");
 }

 /*
@@ -739,7 +739,7 @@ EXPORT_SYMBOL_GPL(nfs_show_options);
 static void show_sessions(struct seq_file *m, struct nfs_server *server)
 {
 	if (nfs4_has_session(server->nfs_client))
-		seq_printf(m, ",sessions");
+		seq_puts(m, ",sessions");
 }
 #else
 static void show_sessions(struct seq_file *m, struct nfs_server *server) {}
@@ -816,7 +816,7 @@ int nfs_show_stats(struct seq_file *m, struct dentry *root)
 	/*
 	 * Display all mount option settings
 	 */
-	seq_printf(m, "\n\topts:\t");
+	seq_puts(m, "\n\topts:\t");
 	seq_puts(m, sb_rdonly(root->d_sb) ? "ro" : "rw");
 	seq_puts(m, root->d_sb->s_flags & SB_SYNCHRONOUS ? ",sync" : "");
 	seq_puts(m, root->d_sb->s_flags & SB_NOATIME ? ",noatime" : "");
@@ -827,7 +827,7 @@ int nfs_show_stats(struct seq_file *m, struct dentry *root)

 	show_implementation_id(m, nfss);

-	seq_printf(m, "\n\tcaps:\t");
+	seq_puts(m, "\n\tcaps:\t");
 	seq_printf(m, "caps=0x%x", nfss->caps);
 	seq_printf(m, ",wtmult=%u", nfss->wtmult);
 	seq_printf(m, ",dtsize=%u", nfss->dtsize);
@@ -836,7 +836,7 @@ int nfs_show_stats(struct seq_file *m, struct dentry *root)

 #if IS_ENABLED(CONFIG_NFS_V4)
 	if (nfss->nfs_client->rpc_ops->version == 4) {
-		seq_printf(m, "\n\tnfsv4:\t");
+		seq_puts(m, "\n\tnfsv4:\t");
 		seq_printf(m, "bm0=0x%x", nfss->attr_bitmask[0]);
 		seq_printf(m, ",bm1=0x%x", nfss->attr_bitmask[1]);
 		seq_printf(m, ",bm2=0x%x", nfss->attr_bitmask[2]);
@@ -874,15 +874,15 @@ int nfs_show_stats(struct seq_file *m, struct dentry *root)
 		preempt_enable();
 	}

-	seq_printf(m, "\n\tevents:\t");
+	seq_puts(m, "\n\tevents:\t");
 	for (i = 0; i < __NFSIOS_COUNTSMAX; i++)
 		seq_printf(m, "%lu ", totals.events[i]);
-	seq_printf(m, "\n\tbytes:\t");
+	seq_puts(m, "\n\tbytes:\t");
 	for (i = 0; i < __NFSIOS_BYTESMAX; i++)
 		seq_printf(m, "%Lu ", totals.bytes[i]);
 #ifdef CONFIG_NFS_FSCACHE
 	if (nfss->options & NFS_OPTION_FSCACHE) {
-		seq_printf(m, "\n\tfsc:\t");
+		seq_puts(m, "\n\tfsc:\t");
 		for (i = 0; i < __NFSIOS_FSCACHEMAX; i++)
 			seq_printf(m, "%Lu ", totals.fscache[i]);
 	}
--
2.22.0


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

* [PATCH 3/3] NFS: Three function calls less
  2019-07-03 15:07 [PATCH 0/3] NFS: Adjustments for three function implementations Markus Elfring
  2019-07-03 15:08 ` [PATCH 1/3] NFS: Use seq_putc() in nfs_show_stats() Markus Elfring
  2019-07-03 15:09 ` [PATCH 2/3] NFS: Replace 16 seq_printf() calls by seq_puts() Markus Elfring
@ 2019-07-03 15:11 ` Markus Elfring
  2 siblings, 0 replies; 4+ messages in thread
From: Markus Elfring @ 2019-07-03 15:11 UTC (permalink / raw)
  To: linux-nfs, Anna Schumaker, Trond Myklebust; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 3 Jul 2019 16:45:25 +0200

Reduce function calls in two function implementations.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/nfs/nfs4xdr.c |  5 +----
 fs/nfs/super.c   | 23 +++++++++++------------
 2 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 602446158bfb..03d58a4e38de 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -1006,10 +1006,7 @@ static size_t mask_bitmap4(const __u32 *bitmap, const __u32 *mask,
 static void encode_nfs4_seqid(struct xdr_stream *xdr,
 		const struct nfs_seqid *seqid)
 {
-	if (seqid != NULL)
-		encode_uint32(xdr, seqid->sequence->counter);
-	else
-		encode_uint32(xdr, 0);
+	encode_uint32(xdr, seqid ? seqid->sequence->counter : 0);
 }

 static void encode_compound_hdr(struct xdr_stream *xdr,
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 84dcde7f560b..88d0be7959b5 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -663,12 +663,12 @@ static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss,
 		seq_printf(m, ",acdirmax=%u", nfss->acdirmax/HZ);
 	if (!(nfss->flags & (NFS_MOUNT_SOFT|NFS_MOUNT_SOFTERR)))
 			seq_puts(m, ",hard");
-	for (nfs_infop = nfs_info; nfs_infop->flag; nfs_infop++) {
-		if (nfss->flags & nfs_infop->flag)
-			seq_puts(m, nfs_infop->str);
-		else
-			seq_puts(m, nfs_infop->nostr);
-	}
+	for (nfs_infop = nfs_info; nfs_infop->flag; nfs_infop++)
+		seq_puts(m,
+			 (nfss->flags & nfs_infop->flag)
+			 ? nfs_infop->str
+			 : nfs_infop->nostr);
+
 	rcu_read_lock();
 	seq_printf(m, ",proto=%s",
 		   rpc_peeraddr2str(nfss->client, RPC_DISPLAY_NETID));
@@ -695,12 +695,11 @@ static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss,
 	if (nfss->options & NFS_OPTION_MIGRATION)
 		seq_puts(m, ",migration");

-	if (nfss->flags & NFS_MOUNT_LOOKUP_CACHE_NONEG) {
-		if (nfss->flags & NFS_MOUNT_LOOKUP_CACHE_NONE)
-			seq_puts(m, ",lookupcache=none");
-		else
-			seq_puts(m, ",lookupcache=pos");
-	}
+	if (nfss->flags & NFS_MOUNT_LOOKUP_CACHE_NONEG)
+		seq_puts(m,
+			 (nfss->flags & NFS_MOUNT_LOOKUP_CACHE_NONE)
+			 ? ",lookupcache=none"
+			 : ",lookupcache=pos");

 	local_flock = nfss->flags & NFS_MOUNT_LOCAL_FLOCK;
 	local_fcntl = nfss->flags & NFS_MOUNT_LOCAL_FCNTL;
--
2.22.0


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

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

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-03 15:07 [PATCH 0/3] NFS: Adjustments for three function implementations Markus Elfring
2019-07-03 15:08 ` [PATCH 1/3] NFS: Use seq_putc() in nfs_show_stats() Markus Elfring
2019-07-03 15:09 ` [PATCH 2/3] NFS: Replace 16 seq_printf() calls by seq_puts() Markus Elfring
2019-07-03 15:11 ` [PATCH 3/3] NFS: Three function calls less 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).