summaryrefslogtreecommitdiffstats
path: root/rpc/rpc-lib/src/xdr-rpcclnt.c
diff options
context:
space:
mode:
Diffstat (limited to 'rpc/rpc-lib/src/xdr-rpcclnt.c')
-rw-r--r--rpc/rpc-lib/src/xdr-rpcclnt.c50
1 files changed, 18 insertions, 32 deletions
diff --git a/rpc/rpc-lib/src/xdr-rpcclnt.c b/rpc/rpc-lib/src/xdr-rpcclnt.c
index 933887b0b..810d1961b 100644
--- a/rpc/rpc-lib/src/xdr-rpcclnt.c
+++ b/rpc/rpc-lib/src/xdr-rpcclnt.c
@@ -1,20 +1,11 @@
/*
- Copyright (c) 2010 Gluster, Inc. <http://www.gluster.com>
+ Copyright (c) 2008-2012 Red Hat, Inc. <http://www.redhat.com>
This file is part of GlusterFS.
- GlusterFS is free software; you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation; either version 3 of the License,
- or (at your option) any later version.
-
- GlusterFS is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see
- <http://www.gnu.org/licenses/>.
+ This file is licensed to you under your choice of the GNU Lesser
+ General Public License, version 3 or any later version (LGPLv3 or
+ later), or the GNU General Public License, version 2 (GPLv2), in all
+ cases as published by the Free Software Foundation.
*/
#ifndef _CONFIG_H
@@ -34,6 +25,7 @@
#include "xdr-rpc.h"
#include "xdr-common.h"
#include "logging.h"
+#include "common-utils.h"
/* Decodes the XDR format in msgbuf into rpc_msg.
* The remaining payload is returned into payload.
@@ -43,12 +35,10 @@ xdr_to_rpc_reply (char *msgbuf, size_t len, struct rpc_msg *reply,
struct iovec *payload, char *verfbytes)
{
XDR xdr;
- int ret = -1;
+ int ret = -EINVAL;
- if ((!msgbuf) || (!reply)) {
- ret = -EINVAL;
- goto out;
- }
+ GF_VALIDATE_OR_GOTO ("rpc", msgbuf, out);
+ GF_VALIDATE_OR_GOTO ("rpc", reply, out);
memset (reply, 0, sizeof (struct rpc_msg));
@@ -58,6 +48,7 @@ xdr_to_rpc_reply (char *msgbuf, size_t len, struct rpc_msg *reply,
xdrmem_create (&xdr, msgbuf, len, XDR_DECODE);
if (!xdr_replymsg (&xdr, reply)) {
+ gf_log ("rpc", GF_LOG_WARNING, "failed to decode reply msg");
ret = -errno;
goto out;
}
@@ -71,13 +62,6 @@ out:
return ret;
}
-#if 0
-bool_t
-true_func (XDR *s, caddr_t *a)
-{
- return TRUE;
-}
-#endif
int
rpc_request_to_xdr (struct rpc_msg *request, char *dest, size_t len,
@@ -86,12 +70,13 @@ rpc_request_to_xdr (struct rpc_msg *request, char *dest, size_t len,
XDR xdr;
int ret = -1;
- if ((!dest) || (!request) || (!dst)) {
- goto out;
- }
+ GF_VALIDATE_OR_GOTO ("rpc", dest, out);
+ GF_VALIDATE_OR_GOTO ("rpc", request, out);
+ GF_VALIDATE_OR_GOTO ("rpc", dst, out);
xdrmem_create (&xdr, dest, len, XDR_ENCODE);
if (!xdr_callmsg (&xdr, request)) {
+ gf_log ("rpc", GF_LOG_WARNING, "failed to encode call msg");
goto out;
}
@@ -112,13 +97,14 @@ auth_unix_cred_to_xdr (struct authunix_parms *au, char *dest, size_t len,
XDR xdr;
int ret = -1;
- if (!au || !dest || !iov) {
- goto out;
- }
+ GF_VALIDATE_OR_GOTO ("rpc", au, out);
+ GF_VALIDATE_OR_GOTO ("rpc", dest, out);
+ GF_VALIDATE_OR_GOTO ("rpc", iov, out);
xdrmem_create (&xdr, dest, len, XDR_DECODE);
if (!xdr_authunix_parms (&xdr, au)) {
+ gf_log ("rpc", GF_LOG_WARNING, "failed to decode authunix parms");
goto out;
}