[git commit] rpc: constify some more data

Bernhard Reutner-Fischer rep.dot.nop at gmail.com
Fri Jun 15 12:00:27 UTC 2012


commit: http://git.uclibc.org/uClibc/commit/?id=8bb1bab7542944a3ce1b9c92fcb2ec6731806ae4
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/master

Comments in header were used by vda on a similar commit

Signed-off-by: Peter S. Mazinger <ps.m at gmx.net>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop at gmail.com>
---
 include/rpc/auth.h        |    4 ++++
 include/rpc/xdr.h         |    4 ++++
 libc/inet/rpc/auth_unix.c |    4 ++--
 libc/inet/rpc/svc_raw.c   |    2 +-
 libc/inet/rpc/xdr_mem.c   |    4 +---
 libc/inet/rpc/xdr_rec.c   |    4 +---
 libc/inet/rpc/xdr_stdio.c |    4 +---
 7 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/include/rpc/auth.h b/include/rpc/auth.h
index 1d5198c..e2c7987 100644
--- a/include/rpc/auth.h
+++ b/include/rpc/auth.h
@@ -96,6 +96,10 @@ struct AUTH {
   struct opaque_auth ah_cred;
   struct opaque_auth ah_verf;
   union des_block ah_key;
+  /* not sure whether non-const-ness is a part of the spec... if it is,
+   * enclose "const" in #ifdef _LIBC / #endif
+   * to make it effective only for libc compile */
+  const
   struct auth_ops {
     void (*ah_nextverf) (AUTH *);
     int  (*ah_marshal) (AUTH *, XDR *);		/* nextverf & serialize */
diff --git a/include/rpc/xdr.h b/include/rpc/xdr.h
index ec6cd4c..f4756ac 100644
--- a/include/rpc/xdr.h
+++ b/include/rpc/xdr.h
@@ -112,6 +112,10 @@ typedef struct XDR XDR;
 struct XDR
   {
     enum xdr_op x_op;		/* operation; fast additional param */
+    /* not sure whether non-const-ness is a part of the spec... if it is,
+     * enclose "const" in #ifdef _LIBC / #endif
+     * to make it effective only for libc compile */
+    const
     struct xdr_ops
       {
 	bool_t (*x_getlong) (XDR *__xdrs, long *__lp);
diff --git a/libc/inet/rpc/auth_unix.c b/libc/inet/rpc/auth_unix.c
index 3dc2530..72d7a7a 100644
--- a/libc/inet/rpc/auth_unix.c
+++ b/libc/inet/rpc/auth_unix.c
@@ -59,7 +59,7 @@ static bool_t authunix_validate (AUTH *, struct opaque_auth *);
 static bool_t authunix_refresh (AUTH *);
 static void authunix_destroy (AUTH *);
 
-static struct auth_ops auth_unix_ops = {
+static const struct auth_ops auth_unix_ops = {
   authunix_nextverf,
   authunix_marshal,
   authunix_validate,
@@ -314,7 +314,7 @@ marshal_new_auth (AUTH *auth)
   xdrmem_create (xdrs, au->au_marshed, MAX_AUTH_BYTES, XDR_ENCODE);
   if ((!xdr_opaque_auth (xdrs, &(auth->ah_cred))) ||
       (!xdr_opaque_auth (xdrs, &(auth->ah_verf))))
-    perror (_("auth_none.c - Fatal marshalling problem"));
+    perror (_("auth_unix.c - Fatal marshalling problem"));
   else
     au->au_mpos = XDR_GETPOS (xdrs);
 
diff --git a/libc/inet/rpc/svc_raw.c b/libc/inet/rpc/svc_raw.c
index b76663d..8156042 100644
--- a/libc/inet/rpc/svc_raw.c
+++ b/libc/inet/rpc/svc_raw.c
@@ -67,7 +67,7 @@ static bool_t svcraw_reply (SVCXPRT *, struct rpc_msg *);
 static bool_t svcraw_freeargs (SVCXPRT *, xdrproc_t, caddr_t);
 static void svcraw_destroy (SVCXPRT *);
 
-static struct xp_ops server_ops =
+static const struct xp_ops server_ops =
 {
   svcraw_recv,
   svcraw_stat,
diff --git a/libc/inet/rpc/xdr_mem.c b/libc/inet/rpc/xdr_mem.c
index c58fc45..6773b56 100644
--- a/libc/inet/rpc/xdr_mem.c
+++ b/libc/inet/rpc/xdr_mem.c
@@ -77,9 +77,7 @@ void
 xdrmem_create (XDR *xdrs, const caddr_t addr, u_int size, enum xdr_op op)
 {
   xdrs->x_op = op;
-  /* We have to add the const since the `struct xdr_ops' in `struct XDR'
-     is not `const'.  */
-  xdrs->x_ops = (struct xdr_ops *) &xdrmem_ops;
+  xdrs->x_ops = &xdrmem_ops;
   xdrs->x_private = xdrs->x_base = addr;
   xdrs->x_handy = size;
 }
diff --git a/libc/inet/rpc/xdr_rec.c b/libc/inet/rpc/xdr_rec.c
index 87d50ab..3ad7d72 100644
--- a/libc/inet/rpc/xdr_rec.c
+++ b/libc/inet/rpc/xdr_rec.c
@@ -177,9 +177,7 @@ xdrrec_create (XDR *xdrs, u_int sendsize,
   /*
    * now the rest ...
    */
-  /* We have to add the const since the `struct xdr_ops' in `struct XDR'
-     is not `const'.  */
-  xdrs->x_ops = (struct xdr_ops *) &xdrrec_ops;
+  xdrs->x_ops = &xdrrec_ops;
   xdrs->x_private = (caddr_t) rstrm;
   rstrm->tcp_handle = tcp_handle;
   rstrm->readit = readit;
diff --git a/libc/inet/rpc/xdr_stdio.c b/libc/inet/rpc/xdr_stdio.c
index 6a5e06e..6a18fce 100644
--- a/libc/inet/rpc/xdr_stdio.c
+++ b/libc/inet/rpc/xdr_stdio.c
@@ -78,9 +78,7 @@ void
 xdrstdio_create (XDR *xdrs, FILE *file, enum xdr_op op)
 {
   xdrs->x_op = op;
-  /* We have to add the const since the `struct xdr_ops' in `struct XDR'
-     is not `const'.  */
-  xdrs->x_ops = (struct xdr_ops *) &xdrstdio_ops;
+  xdrs->x_ops = &xdrstdio_ops;
   xdrs->x_private = (caddr_t) file;
   xdrs->x_handy = 0;
   xdrs->x_base = 0;


More information about the uClibc-cvs mailing list