Ver código fonte

rpc: constify some more data

Comments in header were used by vda on a similar commit

Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Peter S. Mazinger 13 anos atrás
pai
commit
8bb1bab754

+ 4 - 0
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 */

+ 4 - 0
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);

+ 2 - 2
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);
 

+ 1 - 1
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,

+ 1 - 3
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;
 }

+ 1 - 3
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;

+ 1 - 3
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;