+2001-12-07 Ezra Peisach <epeisach@mit.edu>
+
+ * clnt_raw, clnt_tcp.c, clnt_udp.c: Use a union structure to
+ ensure argument alignment.
+
+ * pmap_clnt.c, pmap_clnt.h (pmap_set): Change port argument to int
+ to avoid width warnings.
+
+ * rpc_callmsg.c (xdr_callmsg): Cast argument to XDR_INLINE to
+ avoid signed vs. unsigned warning.
+
+ * svc.c: Cast assignment to avoid signed warning.
+
+ * xdr.c (xdr_u_short, xdr_u_long): cast pointers to long * in
+ invocation of XDR_PUTLONG.
+
+ * xdr_alloc.c (xdralloc_putbytes): Cast argument to DynInsert to
+ avoid signed/unsigned warning.
+
+ * auth_gssapi.c, svc_auth_gssapi, xdr_rec.c: Cast arguments to
+ avoid alignment warnings.
+
+ * svc_tcp.c, xdr_stdio.c: Cast argument to fread/fwrite/read/write.
+
2001-10-09 Ken Raeburn <raeburn@mit.edu>
* auth_gssapi.h, auth_gssapi_misc.c, getrpcent.c,
creds.client_handle.value = NULL;
}
- xdrmem_create(&xdrs, AUTH_PRIVATE(auth)->cred_buf,
+ xdrmem_create(&xdrs, (caddr_t) AUTH_PRIVATE(auth)->cred_buf,
MAX_AUTH_BYTES, XDR_ENCODE);
if (! xdr_authgssapi_creds(&xdrs, &creds)) {
PRINTF(("marshall_new_creds: failed encoding auth_gssapi_creds\n"));
CLIENT client_object;
XDR xdr_stream;
char _raw_buf[UDPMSGSIZE];
- char mashl_callmsg[MCALL_MSG_SIZE];
+ union {
+ struct rpc_msg mashl_rpcmsg;
+ char mashl_callmsg[MCALL_MSG_SIZE];
+ } u;
unsigned int mcnt;
} *clntraw_private;
call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
call_msg.rm_call.cb_prog = prog;
call_msg.rm_call.cb_vers = vers;
- xdrmem_create(xdrs, clp->mashl_callmsg, MCALL_MSG_SIZE, XDR_ENCODE);
+ xdrmem_create(xdrs, clp->u.mashl_callmsg, MCALL_MSG_SIZE, XDR_ENCODE);
if (! xdr_callhdr(xdrs, &call_msg)) {
perror("clnt_raw.c - Fatal header serialization error.");
}
*/
xdrs->x_op = XDR_ENCODE;
XDR_SETPOS(xdrs, 0);
- ((struct rpc_msg *)clp->mashl_callmsg)->rm_xid ++ ;
- if ((! XDR_PUTBYTES(xdrs, clp->mashl_callmsg, clp->mcnt)) ||
+ clp->u.mashl_rpcmsg.rm_xid ++ ;
+ if ((! XDR_PUTBYTES(xdrs, clp->u.mashl_callmsg, clp->mcnt)) ||
(! XDR_PUTLONG(xdrs, &procl)) ||
(! AUTH_MARSHALL(h->cl_auth, xdrs)) ||
(! (*xargs)(xdrs, argsp))) {
bool_t ct_waitset; /* wait set by clnt_control? */
struct sockaddr_in ct_addr;
struct rpc_err ct_error;
- char ct_mcall[MCALL_MSG_SIZE]; /* marshalled callmsg */
+ union {
+ char ct_mcall[MCALL_MSG_SIZE]; /* marshalled callmsg */
+ rpc_u_int32 ct_mcalli;
+ } ct_u;
unsigned int ct_mpos; /* pos after marshal */
XDR ct_xdrs;
};
/*
* pre-serialize the staic part of the call msg and stash it away
*/
- xdrmem_create(&(ct->ct_xdrs), ct->ct_mcall, MCALL_MSG_SIZE,
+ xdrmem_create(&(ct->ct_xdrs), ct->ct_u.ct_mcall, MCALL_MSG_SIZE,
XDR_ENCODE);
if (! xdr_callhdr(&(ct->ct_xdrs), &call_msg)) {
if (ct->ct_closeit) {
register XDR *xdrs = &(ct->ct_xdrs);
struct rpc_msg reply_msg;
rpc_u_int32 x_id;
- rpc_u_int32 *msg_x_id = (rpc_u_int32 *)(ct->ct_mcall); /* yuk */
+ rpc_u_int32 *msg_x_id = &ct->ct_u.ct_mcalli; /* yuk */
register bool_t shipnow;
int refreshes = 2;
long procl = proc;
xdrs->x_op = XDR_ENCODE;
ct->ct_error.re_status = RPC_SUCCESS;
x_id = ntohl(--(*msg_x_id));
- if ((! XDR_PUTBYTES(xdrs, ct->ct_mcall, ct->ct_mpos)) ||
+ if ((! XDR_PUTBYTES(xdrs, ct->ct_u.ct_mcall, ct->ct_mpos)) ||
(! XDR_PUTLONG(xdrs, &procl)) ||
(! AUTH_MARSHALL(h->cl_auth, xdrs)) ||
(! AUTH_WRAP(h->cl_auth, xdrs, xdr_args, args_ptr))) {
}
break;
}
- switch (len = read(ct->ct_sock, buf, len)) {
+ switch (len = read(ct->ct_sock, buf, (size_t) len)) {
case 0:
/* premature eof */
register int i, cnt;
for (cnt = len; cnt > 0; cnt -= i, buf += i) {
- if ((i = write(ct->ct_sock, buf, cnt)) == -1) {
+ if ((i = write(ct->ct_sock, buf, (size_t) cnt)) == -1) {
ct->ct_error.re_errno = errno;
ct->ct_error.re_status = RPC_CANTSEND;
return (-1);
/*
* the transaction is the first thing in the out buffer
*/
- (*(unsigned short *)(cu->cu_outbuf))++;
+ (*(rpc_u_int32 *)(void *)(cu->cu_outbuf))++;
if ((! XDR_PUTLONG(xdrs, &procl)) ||
(! AUTH_MARSHALL(cl->cl_auth, xdrs)) ||
(! AUTH_WRAP(cl->cl_auth, xdrs, xargs, argsp)))
if (inlen < sizeof(rpc_u_int32))
continue;
/* see if reply transaction id matches sent id */
- if (*((rpc_u_int32 *)(cu->cu_inbuf)) != *((rpc_u_int32 *)(cu->cu_outbuf)))
+ if (*((rpc_u_int32 *)(void *)(cu->cu_inbuf)) !=
+ *((rpc_u_int32 *)(void *)(cu->cu_outbuf)))
continue;
/* we now assume we have the proper reply */
break;
rpc_u_int32 program;
rpc_u_int32 version;
int protocol;
- unsigned short port;
+ int port;
{
struct sockaddr_in myaddress;
int socket = -1;
#define pmap_getport gssrpc_pmap_getport
extern bool_t pmap_set(rpc_u_int32, rpc_u_int32, int,
- unsigned short);
+ int);
extern bool_t pmap_unset(rpc_u_int32, rpc_u_int32);
extern struct pmaplist *pmap_getmaps(struct sockaddr_in *);
enum clnt_stat pmap_rmtcall(struct sockaddr_in *, rpc_u_int32,
{
caddr_t port_ptr;
- port_ptr = (caddr_t)crp->port_ptr;
+ port_ptr = (caddr_t)(void *)crp->port_ptr;
if (xdr_reference(xdrs, &port_ptr, sizeof (rpc_u_int32),
xdr_u_int32) && xdr_u_int32(xdrs, &crp->resultslen)) {
- crp->port_ptr = (rpc_u_int32 *)port_ptr;
+ crp->port_ptr = (rpc_u_int32 *)(void *)port_ptr;
return ((*(crp->xdr_results))(xdrs, crp->results_ptr));
}
return (FALSE);
if (cmsg->rm_call.cb_verf.oa_length > MAX_AUTH_BYTES) {
return (FALSE);
}
- buf = (rpc_int32 *) XDR_INLINE(xdrs, 8 * BYTES_PER_XDR_UNIT
+ buf = (rpc_int32 *) XDR_INLINE(xdrs, (int) (
+ 8 * BYTES_PER_XDR_UNIT
+ RNDUP(cmsg->rm_call.cb_cred.oa_length)
+ 2 * BYTES_PER_XDR_UNIT
- + RNDUP(cmsg->rm_call.cb_verf.oa_length));
+ + RNDUP(cmsg->rm_call.cb_verf.oa_length)));
if (buf != NULL) {
IXDR_PUT_LONG(buf, cmsg->rm_xid);
IXDR_PUT_ENUM(buf, cmsg->rm_direction);
mem_alloc(oa->oa_length);
}
buf = (rpc_int32 *)
- XDR_INLINE(xdrs, RNDUP(oa->oa_length));
+ XDR_INLINE(xdrs, (int)RNDUP(oa->oa_length));
if (buf == NULL) {
if (xdr_opaque(xdrs, oa->oa_base,
oa->oa_length) == FALSE) {
mem_alloc(oa->oa_length);
}
buf = (rpc_int32 *)
- XDR_INLINE(xdrs, RNDUP(oa->oa_length));
+ XDR_INLINE(xdrs, (int)RNDUP(oa->oa_length));
if (buf == NULL) {
if (xdr_opaque(xdrs, oa->oa_base,
oa->oa_length) == FALSE) {
/* now match message with a registered service*/
prog_found = FALSE;
- low_vers = 0 - 1;
+ low_vers = (rpc_u_int32) -1L;
high_vers = 0;
for (s = svc_head; s != NULL_SVC; s = s->sc_next) {
if (s->sc_prog == r.rq_prog) {
if (client_data == NULL)
return NULL;
memset((char *) client_data, 0, sizeof(*client_data));
- L_PRINTF(2, ("create_client: new client_data = %p\n", client_data));
+ L_PRINTF(2, ("create_client: new client_data = %p\n",
+ (void *) client_data));
/* set up client data structure */
client_data->established = 0;
client_list *c, *c2;
PRINTF(("destroy_client: destroying client_data\n"));
- L_PRINTF(2, ("destroy_client: client_data = %p\n", client_data));
+ L_PRINTF(2, ("destroy_client: client_data = %p\n", (void *) client_data));
#ifdef DEBUG_GSSAPI
if (svc_debug_gssapi >= 3)
while (c) {
client_data = c->client;
L_PRINTF(3, ("\tclient_data = %p, exp = %d\n",
- client_data, client_data->expiration));
+ (void *) client_data, client_data->expiration));
c = c->next;
}
client_data = c->client;
L_PRINTF(2, ("clean_client: client_data = %p\n",
- client_data));
+ (void *) client_data));
if (client_data->expiration < time(0)) {
PRINTF(("clean_client: client %d expired\n",
if (! client_data->established) {
PRINTF(("svc_gssapi_unwrap: not established, noop\n"));
- return (*xdr_func)(in_xdrs, (auth_gssapi_init_arg *) xdr_ptr);
+ return (*xdr_func)(in_xdrs, (auth_gssapi_init_arg *)(void *) xdr_ptr);
} else if (! auth_gssapi_unwrap_data(&gssstat, &minor_stat,
client_data->context,
client_data->seq_num-1,
#else
} while (readfds != mask);
#endif /* def FD_SETSIZE */
- if ((len = read(sock, buf, len)) > 0) {
+ if ((len = read(sock, buf, (size_t) len)) > 0) {
return (len);
}
fatal_err:
register int i, cnt;
for (cnt = len; cnt > 0; cnt -= i, buf += i) {
- if ((i = write(xprt->xp_sock, buf, cnt)) < 0) {
+ if ((i = write(xprt->xp_sock, buf, (size_t) cnt)) < 0) {
((struct tcp_conn *)(xprt->xp_p1))->strm_stat =
XPRT_DIED;
return (-1);
return (FALSE);
}
}
- return (XDR_PUTLONG(xdrs, ulp));
+ return (XDR_PUTLONG(xdrs, (long *)ulp));
}
if (xdrs->x_op == XDR_DECODE) {
return (XDR_GETLONG(xdrs, (long *)ulp));
case XDR_ENCODE:
l = (unsigned long) *usp;
- return (XDR_PUTLONG(xdrs, &l));
+ return (XDR_PUTLONG(xdrs, (long *) &l));
case XDR_DECODE:
- if (!XDR_GETLONG(xdrs, &l)) {
+ if (!XDR_GETLONG(xdrs, (long *) &l)) {
return (FALSE);
}
*usp = (unsigned short) l;
{
if (DynInsert((DynObject) xdrs->x_private,
DynSize((DynObject) xdrs->x_private),
- addr, len) != DYN_OK)
+ addr, (int) len) != DYN_OK)
return FALSE;
return TRUE;
}
rstrm->readit = readit;
rstrm->writeit = writeit;
rstrm->out_finger = rstrm->out_boundry = rstrm->out_base;
- rstrm->frag_header = (rpc_u_int32 *)rstrm->out_base;
+ rstrm->frag_header = (rpc_u_int32 *)(void *)rstrm->out_base;
rstrm->out_finger += sizeof(rpc_u_int32);
rstrm->out_boundry += sendsize;
rstrm->frag_sent = FALSE;
long *lp;
{
register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private);
- register rpc_int32 *buflp = (rpc_int32 *)(rstrm->in_finger);
+ register rpc_int32 *buflp = (rpc_int32 *)(void *)(rstrm->in_finger);
int mylong;
/* first try the inline, fast case */
long *lp;
{
register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private);
- register rpc_int32 *dest_lp = ((rpc_int32 *)(rstrm->out_finger));
+ register rpc_int32 *dest_lp = ((rpc_int32 *)(void *)(rstrm->out_finger));
if ((rstrm->out_finger += sizeof(rpc_int32)) > rstrm->out_boundry) {
/*
rstrm->frag_sent = TRUE;
if (! flush_out(rstrm, FALSE))
return (FALSE);
- dest_lp = ((rpc_int32 *)(rstrm->out_finger));
+ dest_lp = ((rpc_int32 *)(void *)(rstrm->out_finger));
rstrm->out_finger += sizeof(rpc_int32);
}
*dest_lp = (rpc_int32)htonl((rpc_u_int32)(*lp));
register unsigned int len;
{
register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private);
- register int current;
+ register size_t current;
while (len > 0) {
- current = (int) ((long)rstrm->out_boundry -
+ current = (size_t) ((long)rstrm->out_boundry -
(long)rstrm->out_finger);
current = (len < current) ? len : current;
memmove(rstrm->out_finger, addr, current);
#ifdef __osf__
pos = -1;
#else
- pos = lseek((int)rstrm->tcp_handle, (long) 0, 1);
+ pos = lseek((int)rstrm->tcp_handle, (off_t) 0, 1);
#endif
if (pos != -1)
switch (xdrs->x_op) {
case XDR_ENCODE:
if ((rstrm->out_finger + len) <= rstrm->out_boundry) {
- buf = (rpc_int32 *) rstrm->out_finger;
+ buf = (rpc_int32 *)(void *) rstrm->out_finger;
rstrm->out_finger += len;
}
break;
case XDR_DECODE:
if ((len <= rstrm->fbtbc) &&
((rstrm->in_finger + len) <= rstrm->in_boundry)) {
- buf = (rpc_int32 *) rstrm->in_finger;
+ buf = (rpc_int32 *)(void *) rstrm->in_finger;
rstrm->fbtbc -= len;
rstrm->in_finger += len;
}
len = (long)(rstrm->out_finger) - (long)(rstrm->frag_header) -
sizeof(unsigned int);
*(rstrm->frag_header) = htonl((unsigned int)len | LAST_FRAG);
- rstrm->frag_header = (rpc_u_int32 *)rstrm->out_finger;
+ rstrm->frag_header = (rpc_u_int32 *)(void *)rstrm->out_finger;
rstrm->out_finger += sizeof(unsigned int);
return (TRUE);
}
if ((*(rstrm->writeit))(rstrm->tcp_handle, rstrm->out_base, (int)len)
!= (int)len)
return (FALSE);
- rstrm->frag_header = (rpc_u_int32 *)rstrm->out_base;
+ rstrm->frag_header = (rpc_u_int32 *)(void *)rstrm->out_base;
rstrm->out_finger = (caddr_t)rstrm->out_base + sizeof(rpc_u_int32);
return (TRUE);
}
register caddr_t addr;
register int len;
{
- register int current;
+ register size_t current;
while (len > 0) {
- current = (int)((long)rstrm->in_boundry -
+ current = (size_t)((long)rstrm->in_boundry -
(long)rstrm->in_finger);
if (current == 0) {
if (! fill_input_buf(rstrm))
unsigned int len;
{
- if ((len != 0) && (fread(addr, (int)len, 1, (FILE *)xdrs->x_private) != 1))
+ if ((len != 0) && (fread(addr, (size_t)len, 1,
+ (FILE *)xdrs->x_private) != 1))
return (FALSE);
return (TRUE);
}
unsigned int len;
{
- if ((len != 0) && (fwrite(addr, (int)len, 1, (FILE *)xdrs->x_private) != 1))
+ if ((len != 0) && (fwrite(addr, (size_t)len, 1,
+ (FILE *)xdrs->x_private) != 1))
return (FALSE);
return (TRUE);
}