All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chuck Lever <chuck.lever@oracle.com>
To: trond.myklebust@netapp.com
Cc: linux-nfs@vger.kernel.org
Subject: [PATCH 04/17] NFS: Use the "nfs_stat" enum for nfs_stat_to_errno()'s argument
Date: Wed, 17 Nov 2010 12:44:11 -0500	[thread overview]
Message-ID: <20101117174411.29177.27455.stgit@matisse.1015granger.net> (raw)
In-Reply-To: <20101117174112.29177.69734.stgit@matisse.1015granger.net>

Clean up.

To distinguish more clearly between the on-the-wire NFSERR_ value and
our local errno values, use the proper type for the argument of
nfs_stat_to_errno().

Add a documenting comment appropriate for a global function shared
outside this source file.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Tested-by: J. Bruce Fields <bfields@redhat.com>
---

 fs/nfs/internal.h |    2 +-
 fs/nfs/nfs2xdr.c  |   18 ++++++++++--------
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 1ccf4fb..cddf49d 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -185,7 +185,7 @@ extern int __init nfs_init_directcache(void);
 extern void nfs_destroy_directcache(void);
 
 /* nfs2xdr.c */
-extern int nfs_stat_to_errno(int);
+extern int nfs_stat_to_errno(enum nfs_stat);
 extern struct rpc_procinfo nfs_procedures[];
 extern __be32 *nfs_decode_dirent(struct xdr_stream *, struct nfs_entry *, struct nfs_server *, int);
 
diff --git a/fs/nfs/nfs2xdr.c b/fs/nfs/nfs2xdr.c
index 53db70e..1c5a2fa 100644
--- a/fs/nfs/nfs2xdr.c
+++ b/fs/nfs/nfs2xdr.c
@@ -802,7 +802,7 @@ nfs_xdr_statfsres(struct rpc_rqst *req, __be32 *p, struct nfs2_fsstat *res)
  * We need to translate between nfs status return values and
  * the local errno values which may not be the same.
  */
-static struct {
+static const struct {
 	int stat;
 	int errno;
 } nfs_errtbl[] = {
@@ -842,20 +842,22 @@ static struct {
 	{ -1,			-EIO		}
 };
 
-/*
- * Convert an NFS error code to a local one.
- * This one is used jointly by NFSv2 and NFSv3.
+/**
+ * nfs_stat_to_errno - convert an NFS status code to a local errno
+ * @status: NFS status code to convert
+ *
+ * Returns a local errno value, or -EIO if the NFS status code is
+ * not recognized.  This function is used jointly by NFSv2 and NFSv3.
  */
-int
-nfs_stat_to_errno(int stat)
+int nfs_stat_to_errno(enum nfs_stat status)
 {
 	int i;
 
 	for (i = 0; nfs_errtbl[i].stat != -1; i++) {
-		if (nfs_errtbl[i].stat == stat)
+		if (nfs_errtbl[i].stat == (int)status)
 			return nfs_errtbl[i].errno;
 	}
-	dprintk("nfs_stat_to_errno: bad nfs status return value: %d\n", stat);
+	dprintk("NFS: Unrecognized nfs status value: %u\n", status);
 	return nfs_errtbl[i].errno;
 }
 


  parent reply	other threads:[~2010-11-17 17:44 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-17 17:43 [PATCH 00/17] Update XDR functions for legacy NFS versions Chuck Lever
     [not found] ` <20101117174112.29177.69734.stgit-RytpoXr2tKZ9HhUboXbp9zCvJB+x5qRC@public.gmane.org>
2010-11-17 17:43   ` [PATCH 01/17] NFS: Introduce new-style XDR encoding functions for NFSv2 Chuck Lever
2010-11-18 12:50     ` Boaz Harrosh
2010-11-18 15:24       ` Chuck Lever
2010-11-18 15:28         ` Boaz Harrosh
2010-11-17 17:43   ` [PATCH 02/17] NFS: Remove old NFSv2 encoder functions Chuck Lever
2010-11-17 17:44 ` [PATCH 03/17] NFS: Update xdr_encode_foo() functions that we're keeping Chuck Lever
2010-11-17 17:44 ` Chuck Lever [this message]
2010-11-17 17:44 ` [PATCH 05/17] NFS: Introduce new-style XDR decoding functions for NFSv2 Chuck Lever
2010-11-17 17:44 ` [PATCH 06/17] NFS: Replace old NFSv2 decoder functions with xdr_stream-based ones Chuck Lever
2010-11-17 17:44 ` [PATCH 07/17] NFS: Move and update xdr_decode_foo() functions that we're keeping Chuck Lever
2010-11-17 17:44 ` [PATCH 08/17] lockd: Introduce new-style XDR functions for NLMv3 Chuck Lever
2010-11-17 17:45 ` [PATCH 09/17] NFS: Introduce new-style XDR encoding functions for NFSv3 Chuck Lever
2010-11-17 17:45 ` [PATCH 10/17] NFS: Replace old NFSv3 encoder functions with xdr_stream-based ones Chuck Lever
2010-11-17 17:45 ` [PATCH 11/17] NFS: Remove unused old NFSv3 encoder functions Chuck Lever
2010-11-17 17:45 ` [PATCH 12/17] NFS: Update xdr_encode_foo() functions that we're keeping Chuck Lever
2010-11-17 17:45 ` [PATCH 13/17] NFS: Introduce new-style XDR decoding functions for NFSv2 Chuck Lever
2010-11-17 17:45 ` [PATCH 14/17] NFS: Switch in new NFSv3 decoder functions Chuck Lever
2010-11-17 17:46 ` [PATCH 15/17] NFS: Remove unused old " Chuck Lever
2010-11-17 17:46 ` [PATCH 16/17] NFS: Move and update xdr_decode_foo() functions that we're keeping Chuck Lever
2010-11-17 17:46 ` [PATCH 17/17] lockd: Introduce new-style XDR functions for NLMv4 Chuck Lever

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20101117174411.29177.27455.stgit@matisse.1015granger.net \
    --to=chuck.lever@oracle.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=trond.myklebust@netapp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.