From patchwork Wed Nov 17 18:01:14 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 333781 X-Patchwork-Delegate: Trond.Myklebust@netapp.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oAHI1BKG000644 for ; Wed, 17 Nov 2010 18:01:18 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935214Ab0KQSBS (ORCPT ); Wed, 17 Nov 2010 13:01:18 -0500 Received: from mail-px0-f174.google.com ([209.85.212.174]:35343 "EHLO mail-px0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933795Ab0KQSBR (ORCPT ); Wed, 17 Nov 2010 13:01:17 -0500 Received: by pxi15 with SMTP id 15so578254pxi.19 for ; Wed, 17 Nov 2010 10:01:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:from:subject:to:cc :date:message-id:in-reply-to:references:user-agent:mime-version :content-type:content-transfer-encoding; bh=gCnuWyrZfxzlPl7QtZGKt8qk4TekLOH+pNsl8bvFuss=; b=eDh7lwVsSdaxp5ToQ1376yruMtDEJtuVZqPIQOQ836SNiMxPrBT0o5OQVbpIltq7JO ndTMBgmBsnEKMu6SOGa/hsgQoFEf+0XD56+IbCO6XlenEvLsW7R1o6Q1WU32N89zrU3A NZUeDWHctvJD3dM4wyTwf93rjI6GZqRioPGHU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:subject:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-type:content-transfer-encoding; b=uGz2OFS5gS8st+pipEmQ/BDtMq0rALWopow9mr9D2UJoU1vq/SL0wnDS94kYkB2JQc J2OoypROclnoYmQBUqSdaTbo4QjTJ+Ycn01OkrSn1mMZqTiIFwL3fuJ+lK7AqepWNXnw uab6yaEO5rpZjXHwQG0YeL34ptOsRxB6T9sTk= Received: by 10.231.11.200 with SMTP id u8mr6735691ibu.123.1290016877005; Wed, 17 Nov 2010 10:01:17 -0800 (PST) Received: from matisse.1015granger.net (adsl-99-26-161-222.dsl.sfldmi.sbcglobal.net [99.26.161.222]) by mx.google.com with ESMTPS id i16sm2437944ibl.0.2010.11.17.10.01.15 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 17 Nov 2010 10:01:16 -0800 (PST) From: Chuck Lever Subject: [PATCH 09/12] NFS: Avoid return code checking in mount XDR encoder functions To: trond.myklebust@netapp.com Cc: linux-nfs@vger.kernel.org Date: Wed, 17 Nov 2010 13:01:14 -0500 Message-ID: <20101117180114.29429.39517.stgit@matisse.1015granger.net> In-Reply-To: <20101117175317.29429.90956.stgit@matisse.1015granger.net> References: <20101117175317.29429.90956.stgit@matisse.1015granger.net> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Wed, 17 Nov 2010 18:01:19 +0000 (UTC) diff --git a/fs/nfs/mount_clnt.c b/fs/nfs/mount_clnt.c index eceafe7..2e238f3 100644 --- a/fs/nfs/mount_clnt.c +++ b/fs/nfs/mount_clnt.c @@ -280,20 +280,14 @@ out_call_err: * XDR encode/decode functions for MOUNT */ -static int encode_mntdirpath(struct xdr_stream *xdr, const char *pathname) +static void encode_mntdirpath(struct xdr_stream *xdr, const char *pathname) { const u32 pathname_len = strlen(pathname); __be32 *p; - if (unlikely(pathname_len > MNTPATHLEN)) - return -EIO; - - p = xdr_reserve_space(xdr, sizeof(u32) + pathname_len); - if (unlikely(p == NULL)) - return -EIO; + BUG_ON(pathname_len > MNTPATHLEN); + p = xdr_reserve_space(xdr, 4 + pathname_len); xdr_encode_opaque(p, pathname, pathname_len); - - return 0; } static int mnt_enc_dirpath(struct rpc_rqst *req, __be32 *p, @@ -302,7 +296,8 @@ static int mnt_enc_dirpath(struct rpc_rqst *req, __be32 *p, struct xdr_stream xdr; xdr_init_encode(&xdr, &req->rq_snd_buf, p); - return encode_mntdirpath(&xdr, dirpath); + encode_mntdirpath(&xdr, dirpath); + return 0; } /* @@ -320,10 +315,10 @@ static int decode_status(struct xdr_stream *xdr, struct mountres *res) u32 status; __be32 *p; - p = xdr_inline_decode(xdr, sizeof(status)); + p = xdr_inline_decode(xdr, 4); if (unlikely(p == NULL)) return -EIO; - status = ntohl(*p); + status = be32_to_cpup(p); for (i = 0; i < ARRAY_SIZE(mnt_errtbl); i++) { if (mnt_errtbl[i].status == status) { @@ -371,10 +366,10 @@ static int decode_fhs_status(struct xdr_stream *xdr, struct mountres *res) u32 status; __be32 *p; - p = xdr_inline_decode(xdr, sizeof(status)); + p = xdr_inline_decode(xdr, 4); if (unlikely(p == NULL)) return -EIO; - status = ntohl(*p); + status = be32_to_cpup(p); for (i = 0; i < ARRAY_SIZE(mnt3_errtbl); i++) { if (mnt3_errtbl[i].status == status) { @@ -394,11 +389,11 @@ static int decode_fhandle3(struct xdr_stream *xdr, struct mountres *res) u32 size; __be32 *p; - p = xdr_inline_decode(xdr, sizeof(size)); + p = xdr_inline_decode(xdr, 4); if (unlikely(p == NULL)) return -EIO; - size = ntohl(*p++); + size = be32_to_cpup(p); if (size > NFS3_FHSIZE || size == 0) return -EIO; @@ -421,15 +416,15 @@ static int decode_auth_flavors(struct xdr_stream *xdr, struct mountres *res) if (*count == 0) return 0; - p = xdr_inline_decode(xdr, sizeof(entries)); + p = xdr_inline_decode(xdr, 4); if (unlikely(p == NULL)) return -EIO; - entries = ntohl(*p); + entries = be32_to_cpup(p); dprintk("NFS: received %u auth flavors\n", entries); if (entries > NFS_MAX_SECFLAVORS) entries = NFS_MAX_SECFLAVORS; - p = xdr_inline_decode(xdr, sizeof(u32) * entries); + p = xdr_inline_decode(xdr, 4 * entries); if (unlikely(p == NULL)) return -EIO; @@ -437,7 +432,7 @@ static int decode_auth_flavors(struct xdr_stream *xdr, struct mountres *res) entries = *count; for (i = 0; i < entries; i++) { - flavors[i] = ntohl(*p++); + flavors[i] = be32_to_cpup(p++); dprintk("NFS: auth flavor[%u]: %d\n", i, flavors[i]); } *count = i;