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.
This commit is contained in:
parent
ca9cbcece0
commit
2244ec0163
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=96788
@ -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!");
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user