Author: trasz
Date: Tue Mar 29 13:56:59 2016
New Revision: 297391
URL: https://svnweb.freebsd.org/changeset/base/297391

Log:
  Remove some NULL checks for M_WAITOK allocations.
  
  MFC after:    1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/kern/imgact_elf.c
  head/sys/kern/kern_exec.c
  head/sys/kern/kern_linker.c
  head/sys/net/rtsock.c
  head/sys/netinet/tcp_subr.c
  head/sys/rpc/rpc_generic.c
  head/sys/ufs/ufs/ufs_extattr.c

Modified: head/sys/kern/imgact_elf.c
==============================================================================
--- head/sys/kern/imgact_elf.c  Tue Mar 29 13:51:26 2016        (r297390)
+++ head/sys/kern/imgact_elf.c  Tue Mar 29 13:56:59 2016        (r297391)
@@ -1370,10 +1370,6 @@ __elfN(coredump)(struct thread *td, stru
         * and write it out following the notes.
         */
        hdr = malloc(hdrsize, M_TEMP, M_WAITOK);
-       if (hdr == NULL) {
-               error = EINVAL;
-               goto done;
-       }
        error = __elfN(corehdr)(&params, seginfo.count, hdr, hdrsize, &notelst,
            notesz);
 

Modified: head/sys/kern/kern_exec.c
==============================================================================
--- head/sys/kern/kern_exec.c   Tue Mar 29 13:51:26 2016        (r297390)
+++ head/sys/kern/kern_exec.c   Tue Mar 29 13:56:59 2016        (r297391)
@@ -1570,8 +1570,6 @@ exec_register(execsw_arg)
                for (es = execsw; *es; es++)
                        count++;
        newexecsw = malloc(count * sizeof(*es), M_TEMP, M_WAITOK);
-       if (newexecsw == NULL)
-               return (ENOMEM);
        xs = newexecsw;
        if (execsw)
                for (es = execsw; *es; es++)
@@ -1604,8 +1602,6 @@ exec_unregister(execsw_arg)
                if (*es != execsw_arg)
                        count++;
        newexecsw = malloc(count * sizeof(*es), M_TEMP, M_WAITOK);
-       if (newexecsw == NULL)
-               return (ENOMEM);
        xs = newexecsw;
        for (es = execsw; *es; es++)
                if (*es != execsw_arg)

Modified: head/sys/kern/kern_linker.c
==============================================================================
--- head/sys/kern/kern_linker.c Tue Mar 29 13:51:26 2016        (r297390)
+++ head/sys/kern/kern_linker.c Tue Mar 29 13:56:59 2016        (r297391)
@@ -1763,8 +1763,6 @@ linker_hints_lookup(const char *path, in
                goto bad;
        }
        hints = malloc(vattr.va_size, M_TEMP, M_WAITOK);
-       if (hints == NULL)
-               goto bad;
        error = vn_rdwr(UIO_READ, nd.ni_vp, (caddr_t)hints, vattr.va_size, 0,
            UIO_SYSSPACE, IO_NODELOCKED, cred, NOCRED, &reclen, td);
        if (error)

Modified: head/sys/net/rtsock.c
==============================================================================
--- head/sys/net/rtsock.c       Tue Mar 29 13:51:26 2016        (r297390)
+++ head/sys/net/rtsock.c       Tue Mar 29 13:56:59 2016        (r297391)
@@ -275,8 +275,6 @@ rts_attach(struct socket *so, int proto,
 
        /* XXX */
        rp = malloc(sizeof *rp, M_PCB, M_WAITOK | M_ZERO);
-       if (rp == NULL)
-               return ENOBUFS;
 
        so->so_pcb = (caddr_t)rp;
        so->so_fibnum = td->td_proc->p_fibnum;

Modified: head/sys/netinet/tcp_subr.c
==============================================================================
--- head/sys/netinet/tcp_subr.c Tue Mar 29 13:51:26 2016        (r297390)
+++ head/sys/netinet/tcp_subr.c Tue Mar 29 13:56:59 2016        (r297391)
@@ -1706,8 +1706,6 @@ tcp_pcblist(SYSCTL_HANDLER_ARGS)
                return (error);
 
        inp_list = malloc(n * sizeof *inp_list, M_TEMP, M_WAITOK);
-       if (inp_list == NULL)
-               return (ENOMEM);
 
        INP_INFO_WLOCK(&V_tcbinfo);
        for (inp = LIST_FIRST(V_tcbinfo.ipi_listhead), i = 0;

Modified: head/sys/rpc/rpc_generic.c
==============================================================================
--- head/sys/rpc/rpc_generic.c  Tue Mar 29 13:51:26 2016        (r297390)
+++ head/sys/rpc/rpc_generic.c  Tue Mar 29 13:56:59 2016        (r297391)
@@ -390,15 +390,11 @@ __rpc_uaddr2taddr_af(int af, const char 
        }
 
        ret = (struct netbuf *)malloc(sizeof *ret, M_RPC, M_WAITOK);
-       if (ret == NULL)
-               goto out;
        
        switch (af) {
        case AF_INET:
                sin = (struct sockaddr_in *)malloc(sizeof *sin, M_RPC,
                    M_WAITOK);
-               if (sin == NULL)
-                       goto out;
                memset(sin, 0, sizeof *sin);
                sin->sin_family = AF_INET;
                sin->sin_port = htons(port);
@@ -415,8 +411,6 @@ __rpc_uaddr2taddr_af(int af, const char 
        case AF_INET6:
                sin6 = (struct sockaddr_in6 *)malloc(sizeof *sin6, M_RPC,
                    M_WAITOK);
-               if (sin6 == NULL)
-                       goto out;
                memset(sin6, 0, sizeof *sin6);
                sin6->sin6_family = AF_INET6;
                sin6->sin6_port = htons(port);
@@ -433,8 +427,6 @@ __rpc_uaddr2taddr_af(int af, const char 
        case AF_LOCAL:
                sun = (struct sockaddr_un *)malloc(sizeof *sun, M_RPC,
                    M_WAITOK);
-               if (sun == NULL)
-                       goto out;
                memset(sun, 0, sizeof *sun);
                sun->sun_family = AF_LOCAL;
                strncpy(sun->sun_path, addrstr, sizeof(sun->sun_path) - 1);

Modified: head/sys/ufs/ufs/ufs_extattr.c
==============================================================================
--- head/sys/ufs/ufs/ufs_extattr.c      Tue Mar 29 13:51:26 2016        
(r297390)
+++ head/sys/ufs/ufs/ufs_extattr.c      Tue Mar 29 13:56:59 2016        
(r297391)
@@ -597,8 +597,6 @@ ufs_extattr_enable(struct ufsmount *ump,
 
        attribute = malloc(sizeof(struct ufs_extattr_list_entry),
            M_UFS_EXTATTR, M_WAITOK);
-       if (attribute == NULL)
-               return (ENOMEM);
 
        if (!(ump->um_extattr.uepm_flags & UFS_EXTATTR_UEPM_STARTED)) {
                error = EOPNOTSUPP;
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to