From f6d289008c5938514430b8d1afd00d3711a33e56 Mon Sep 17 00:00:00 2001 From: jmallett Date: Fri, 17 May 2002 05:27:52 +0000 Subject: Stop this program's abuse of malloc(3). Its return value doesn't need these ugly explicit casts, and its argument doesn't need explicitly cast to u_int, especially if sizeof() is being used. --- usr.sbin/rpcbind/check_bound.c | 2 +- usr.sbin/rpcbind/rpcb_svc_4.c | 3 +-- usr.sbin/rpcbind/rpcb_svc_com.c | 10 ++++------ usr.sbin/rpcbind/rpcbind.c | 16 ++++++++-------- 4 files changed, 14 insertions(+), 17 deletions(-) (limited to 'usr.sbin') diff --git a/usr.sbin/rpcbind/check_bound.c b/usr.sbin/rpcbind/check_bound.c index e5f7081..c955506 100644 --- a/usr.sbin/rpcbind/check_bound.c +++ b/usr.sbin/rpcbind/check_bound.c @@ -117,7 +117,7 @@ add_bndlist(struct netconfig *nconf, struct netbuf *baddr) newnconf = getnetconfigent(nconf->nc_netid); if (newnconf == NULL) return (-1); - fdl = (struct fdlist *)malloc((u_int)sizeof (struct fdlist)); + fdl = malloc(sizeof (struct fdlist)); if (fdl == NULL) { freenetconfigent(newnconf); syslog(LOG_ERR, "no memory!"); diff --git a/usr.sbin/rpcbind/rpcb_svc_4.c b/usr.sbin/rpcbind/rpcb_svc_4.c index f1bae52..0b2d4a8 100644 --- a/usr.sbin/rpcbind/rpcb_svc_4.c +++ b/usr.sbin/rpcbind/rpcb_svc_4.c @@ -389,8 +389,7 @@ rpcbproc_getaddrlist_4_local(void *arg, struct svc_req *rqstp, SVCXPRT *transp, /* * Add it to rlist. */ - rp = (rpcb_entry_list_ptr) - malloc((u_int)sizeof (rpcb_entry_list)); + rp = malloc(sizeof (rpcb_entry_list)); if (rp == NULL) goto fail; a = &rp->rpcb_entry_map; diff --git a/usr.sbin/rpcbind/rpcb_svc_com.c b/usr.sbin/rpcbind/rpcb_svc_com.c index eeded61..ad9275e 100644 --- a/usr.sbin/rpcbind/rpcb_svc_com.c +++ b/usr.sbin/rpcbind/rpcb_svc_com.c @@ -170,10 +170,9 @@ map_set(RPCB *regp, char *owner) /* * add to the end of the list */ - rbl = (rpcblist_ptr) malloc((u_int)sizeof (RPCBLIST)); - if (rbl == (rpcblist_ptr)NULL) { + rbl = malloc(sizeof (RPCBLIST)); + if (rbl == NULL) return (FALSE); - } a = &(rbl->rpcb_map); a->r_prog = reg.r_prog; a->r_vers = reg.r_vers; @@ -506,8 +505,7 @@ create_rmtcall_fd(struct netconfig *nconf) "create_rmtcall_fd: svc_tli_create failed\n"); return (-1); } - rmt = (struct rmtcallfd_list *)malloc((u_int) - sizeof (struct rmtcallfd_list)); + rmt = malloc(sizeof (struct rmtcallfd_list)); if (rmt == NULL) { syslog(LOG_ERR, "create_rmtcall_fd: no memory!"); return (-1); @@ -1400,7 +1398,7 @@ add_pmaplist(RPCB *arg) /* * add to END of list */ - pml = (struct pmaplist *) malloc((u_int)sizeof (struct pmaplist)); + pml = malloc(sizeof (struct pmaplist)); if (pml == NULL) { (void) syslog(LOG_ERR, "rpcbind: no memory!\n"); return (1); diff --git a/usr.sbin/rpcbind/rpcbind.c b/usr.sbin/rpcbind/rpcbind.c index 2ddf2c0..8e93160 100644 --- a/usr.sbin/rpcbind/rpcbind.c +++ b/usr.sbin/rpcbind/rpcbind.c @@ -342,8 +342,8 @@ init_transport(struct netconfig *nconf) nconf->nc_netid); goto error; } - pml = (struct pmaplist *)malloc((u_int)sizeof (struct pmaplist)); - if (pml == (struct pmaplist *)NULL) { + pml = malloc(sizeof (struct pmaplist)); + if (pml == NULL) { syslog(LOG_ERR, "no memory!"); exit(1); } @@ -380,8 +380,8 @@ init_transport(struct netconfig *nconf) list_pml = pml; /* Add version 3 information */ - pml = (struct pmaplist *)malloc((u_int)sizeof (struct pmaplist)); - if (pml == (struct pmaplist *)NULL) { + pml = malloc(sizeof (struct pmaplist)); + if (pml == NULL) { syslog(LOG_ERR, "no memory!"); exit(1); } @@ -391,8 +391,8 @@ init_transport(struct netconfig *nconf) list_pml = pml; /* Add version 4 information */ - pml = (struct pmaplist *)malloc((u_int)sizeof (struct pmaplist)); - if (pml == (struct pmaplist *)NULL) { + pml = malloc (sizeof (struct pmaplist)); + if (pml == NULL) { syslog(LOG_ERR, "no memory!"); exit(1); } @@ -469,8 +469,8 @@ rbllist_add(rpcprog_t prog, rpcvers_t vers, struct netconfig *nconf, { rpcblist_ptr rbl; - rbl = (rpcblist_ptr)malloc((u_int)sizeof (rpcblist)); - if (rbl == (rpcblist_ptr)NULL) { + rbl = malloc(sizeof (rpcblist)); + if (rbl == NULL) { syslog(LOG_ERR, "no memory!"); exit(1); } -- cgit v1.1