Code cleanup (part two):

1. Added missing function prototypes.
2. Added missing function return types.
3. Added missing function argument types.
4. Added missing headers for system function prototypes.
5. Corrected casts in select() args.
6. Got rid of more "extern int errno" rubbish.
7. Added extra parentheses around assignment used as truth value.
8. Fixed bug in clnt_{tcp, udp}create() where pointers could be free'd
    even if they hadn't been successfully malloc()'d.
This commit is contained in:
jraynard 1996-06-10 00:49:19 +00:00
parent a9d801afa6
commit 27f0bdfba4
7 changed files with 30 additions and 22 deletions

View File

@ -30,7 +30,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)bindresvport.c 1.8 88/02/08 SMI";*/
/*static char *sccsid = "from: @(#)bindresvport.c 2.2 88/07/29 4.0 RPCSRC";*/
static char *rcsid = "$Id: bindresvport.c,v 1.2 1995/05/30 05:41:13 rgrimes Exp $";
static char *rcsid = "$Id: bindresvport.c,v 1.3 1995/10/22 14:51:11 phk Exp $";
#endif
/*
@ -47,14 +47,13 @@ static char *rcsid = "$Id: bindresvport.c,v 1.2 1995/05/30 05:41:13 rgrimes Exp
/*
* Bind a socket to a privileged IP port
*/
bindresvport(sd, sin)
int bindresvport(sd, sin)
int sd;
struct sockaddr_in *sin;
{
int res;
static short port;
struct sockaddr_in myaddr;
extern int errno;
int i;
#define STARTPORT 600

View File

@ -30,7 +30,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)clnt_tcp.c 1.37 87/10/05 Copyr 1984 Sun Micro";*/
/*static char *sccsid = "from: @(#)clnt_tcp.c 2.2 88/08/01 4.0 RPCSRC";*/
static char *rcsid = "$Id: clnt_tcp.c,v 1.4 1995/10/27 16:56:50 adam Exp $";
static char *rcsid = "$Id: clnt_tcp.c,v 1.5 1995/12/07 12:50:53 bde Exp $";
#endif
/*
@ -64,7 +64,9 @@ static char *rcsid = "$Id: clnt_tcp.c,v 1.4 1995/10/27 16:56:50 adam Exp $";
#define MCALL_MSG_SIZE 24
extern int errno;
int bindresvport(int sd, struct sockaddr_in *);
int _rpc_dtablesize(void);
bool_t xdr_opaque_auth(XDR *, struct opaque_auth *);
static int readtcp();
static int writetcp();
@ -121,7 +123,7 @@ clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz)
u_int recvsz;
{
CLIENT *h;
register struct ct_data *ct;
register struct ct_data *ct = NULL;
struct timeval now;
struct rpc_msg call_msg;
@ -219,8 +221,10 @@ clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz)
/*
* Something goofed, free stuff and barf
*/
mem_free((caddr_t)ct, sizeof(struct ct_data));
mem_free((caddr_t)h, sizeof(CLIENT));
if (ct)
mem_free((caddr_t)ct, sizeof(struct ct_data));
if (h)
mem_free((caddr_t)h, sizeof(CLIENT));
return ((CLIENT *)NULL);
}

View File

@ -30,7 +30,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)clnt_udp.c 1.39 87/08/11 Copyr 1984 Sun Micro";*/
/*static char *sccsid = "from: @(#)clnt_udp.c 2.2 88/08/01 4.0 RPCSRC";*/
static char *rcsid = "$Id: clnt_udp.c,v 1.5 1995/10/22 14:51:21 phk Exp $";
static char *rcsid = "$Id: clnt_udp.c,v 1.6 1995/12/07 12:50:54 bde Exp $";
#endif
/*
@ -50,7 +50,9 @@ static char *rcsid = "$Id: clnt_udp.c,v 1.5 1995/10/22 14:51:21 phk Exp $";
#include <errno.h>
#include <rpc/pmap_clnt.h>
extern int errno;
int bindresvport(int sd, struct sockaddr_in *);
int _rpc_dtablesize(void);
bool_t xdr_opaque_auth(XDR *, struct opaque_auth *);
/*
* UDP bases client side rpc operations
@ -117,7 +119,7 @@ clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz)
u_int recvsz;
{
CLIENT *cl;
register struct cu_data *cu;
register struct cu_data *cu = NULL;
struct timeval now;
struct rpc_msg call_msg;

View File

@ -30,7 +30,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)pmap_getmaps.c 1.10 87/08/11 Copyr 1984 Sun Micro";*/
/*static char *sccsid = "from: @(#)pmap_getmaps.c 2.2 88/08/01 4.0 RPCSRC";*/
static char *rcsid = "$Id: pmap_getmaps.c,v 1.2 1995/05/30 05:41:23 rgrimes Exp $";
static char *rcsid = "$Id: pmap_getmaps.c,v 1.3 1995/10/22 14:51:29 phk Exp $";
#endif
/*
@ -54,8 +54,6 @@ static char *rcsid = "$Id: pmap_getmaps.c,v 1.2 1995/05/30 05:41:23 rgrimes Exp
#define NAMELEN 255
#define MAX_BROADCAST_SIZE 1400
extern int errno;
/*
* Get a copy of the current port maps.
* Calls the pmap service remotely to do get the maps.

View File

@ -30,7 +30,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)pmap_rmt.c 1.21 87/08/27 Copyr 1984 Sun Micro";*/
/*static char *sccsid = "from: @(#)pmap_rmt.c 2.2 88/08/01 4.0 RPCSRC";*/
static char *rcsid = "$Id: pmap_rmt.c,v 1.4 1995/12/07 12:50:55 bde Exp $";
static char *rcsid = "$Id: pmap_rmt.c,v 1.5 1996/03/17 20:12:53 guido Exp $";
#endif
/*
@ -55,9 +55,9 @@ static char *rcsid = "$Id: pmap_rmt.c,v 1.4 1995/12/07 12:50:55 bde Exp $";
#include <arpa/inet.h>
#define MAX_BROADCAST_SIZE 1400
extern int errno;
static struct timeval timeout = { 3, 0 };
+int _rpc_dtablesize(void);
/*
* pmapper remote-call-service interface.

View File

@ -30,7 +30,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)svc.c 1.44 88/02/08 Copyr 1984 Sun Micro";*/
/*static char *sccsid = "from: @(#)svc.c 2.4 88/08/11 4.0 RPCSRC";*/
static char *rcsid = "$Id: svc.c,v 1.2 1995/05/30 05:41:31 rgrimes Exp $";
static char *rcsid = "$Id: svc.c,v 1.3 1995/10/22 14:51:34 phk Exp $";
#endif
/*
@ -49,8 +49,6 @@ static char *rcsid = "$Id: svc.c,v 1.2 1995/05/30 05:41:31 rgrimes Exp $";
#include <rpc/rpc.h>
#include <rpc/pmap_clnt.h>
extern int errno;
#ifdef FD_SETSIZE
static SVCXPRT **xports;
#else
@ -62,6 +60,8 @@ static SVCXPRT *xports[NOFILE];
#define NULL_SVC ((struct svc_callout *)0)
#define RQCRED_SIZE 400 /* this size is excessive */
int _rpc_dtablesize(void);
/*
* The services list
* Each entry represents a set of procedures (an rpc program).

View File

@ -30,7 +30,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)svc_run.c 1.1 87/10/13 Copyr 1984 Sun Micro";*/
/*static char *sccsid = "from: @(#)svc_run.c 2.1 88/07/29 4.0 RPCSRC";*/
static char *rcsid = "$Id: svc_run.c,v 1.1 1994/08/07 18:36:09 wollman Exp $";
static char *rcsid = "$Id: svc_run.c,v 1.2 1995/05/30 05:41:35 rgrimes Exp $";
#endif
/*
@ -38,7 +38,13 @@ static char *rcsid = "$Id: svc_run.c,v 1.1 1994/08/07 18:36:09 wollman Exp $";
* Wait for input, call server program.
*/
#include <rpc/rpc.h>
#include <stdio.h>
#include <sys/errno.h>
#include <sys/types.h>
#include <sys/time.h>
#include <unistd.h>
int _rpc_dtablesize(void);
void
svc_run()
@ -48,7 +54,6 @@ svc_run()
#else
int readfds;
#endif /* def FD_SETSIZE */
extern int errno;
for (;;) {
#ifdef FD_SETSIZE
@ -56,7 +61,7 @@ svc_run()
#else
readfds = svc_fds;
#endif /* def FD_SETSIZE */
switch (select(_rpc_dtablesize(), &readfds, (int *)0, (int *)0,
switch (select(_rpc_dtablesize(), &readfds, NULL, NULL,
(struct timeval *)0)) {
case -1:
if (errno == EINTR) {