> Date: Mon, 9 Jan 2017 20:12:32 +0100
> From: Martin Pieuchot <m...@openbsd.org>
> 
> m_free(9) handles NULL, no need to check for it beforehand.
> 
> Seems that we missed these because of the (void) cast!
> 
> ok?

ok kettenis@

> Index: netinet/ip_output.c
> ===================================================================
> RCS file: /cvs/src/sys/netinet/ip_output.c,v
> retrieving revision 1.333
> diff -u -p -r1.333 ip_output.c
> --- netinet/ip_output.c       19 Dec 2016 09:22:24 -0000      1.333
> +++ netinet/ip_output.c       9 Jan 2017 17:51:52 -0000
> @@ -1074,8 +1074,7 @@ ip_ctloutput(int op, struct socket *so, 
>                       error = ENOPROTOOPT;
>                       break;
>               }
> -             if (m)
> -                     (void)m_free(m);
> +             m_free(m);
>               break;
>  
>       case PRCO_GETOPT:
> @@ -1242,15 +1241,13 @@ ip_pcbopts(struct mbuf **pcbopt, struct 
>       u_char opt;
>  
>       /* turn off any old options */
> -     if (*pcbopt)
> -             (void)m_free(*pcbopt);
> +     m_free(*pcbopt);
>       *pcbopt = 0;
>       if (m == NULL || m->m_len == 0) {
>               /*
>                * Only turning off any previous options.
>                */
> -             if (m)
> -                     (void)m_free(m);
> +             m_free(m);
>               return (0);
>       }
>  
> Index: netinet/raw_ip.c
> ===================================================================
> RCS file: /cvs/src/sys/netinet/raw_ip.c,v
> retrieving revision 1.90
> diff -u -p -r1.90 raw_ip.c
> --- netinet/raw_ip.c  19 Dec 2016 09:22:24 -0000      1.90
> +++ netinet/raw_ip.c  9 Jan 2017 17:52:13 -0000
> @@ -325,8 +325,7 @@ rip_ctloutput(int op, struct socket *so,
>                               inp->inp_flags |= INP_HDRINCL;
>                       else
>                               inp->inp_flags &= ~INP_HDRINCL;
> -                     if (*mp)
> -                             (void)m_free(*mp);
> +                     m_free(*mp);
>               } else {
>                       *mp = m_get(M_WAIT, M_SOOPTS);
>                       (*mp)->m_len = sizeof(int);
> Index: netinet/tcp_input.c
> ===================================================================
> RCS file: /cvs/src/sys/netinet/tcp_input.c,v
> retrieving revision 1.334
> diff -u -p -r1.334 tcp_input.c
> --- netinet/tcp_input.c       19 Dec 2016 08:36:49 -0000      1.334
> +++ netinet/tcp_input.c       9 Jan 2017 17:53:03 -0000
> @@ -3340,8 +3340,7 @@ syn_cache_rm(struct syn_cache *sc)
>  void
>  syn_cache_put(struct syn_cache *sc)
>  {
> -     if (sc->sc_ipopts)
> -             (void) m_free(sc->sc_ipopts);
> +     m_free(sc->sc_ipopts);
>       if (sc->sc_route4.ro_rt != NULL) {
>               rtfree(sc->sc_route4.ro_rt);
>               sc->sc_route4.ro_rt = NULL;
> @@ -4035,8 +4034,7 @@ syn_cache_add(struct sockaddr *src, stru
>                        * If we were remembering a previous source route,
>                        * forget it and use the new one we've been given.
>                        */
> -                     if (sc->sc_ipopts)
> -                             (void) m_free(sc->sc_ipopts);
> +                     m_free(sc->sc_ipopts);
>                       sc->sc_ipopts = ipopts;
>               }
>               sc->sc_timestamp = tb.ts_recent;
> @@ -4049,8 +4047,7 @@ syn_cache_add(struct sockaddr *src, stru
>  
>       sc = pool_get(&syn_cache_pool, PR_NOWAIT|PR_ZERO);
>       if (sc == NULL) {
> -             if (ipopts)
> -                     (void) m_free(ipopts);
> +             m_free(ipopts);
>               return (-1);
>       }
>  
> Index: netinet/tcp_subr.c
> ===================================================================
> RCS file: /cvs/src/sys/netinet/tcp_subr.c,v
> retrieving revision 1.157
> diff -u -p -r1.157 tcp_subr.c
> --- netinet/tcp_subr.c        20 Dec 2016 09:57:10 -0000      1.157
> +++ netinet/tcp_subr.c        9 Jan 2017 17:52:39 -0000
> @@ -534,8 +534,7 @@ tcp_close(struct tcpcb *tp)
>               p = q;
>       }
>  #endif
> -     if (tp->t_template)
> -             (void) m_free(tp->t_template);
> +     m_free(tp->t_template);
>  
>       tp->t_flags |= TF_DEAD;
>       timeout_add(&tp->t_reap_to, 0);
> Index: netinet/tcp_usrreq.c
> ===================================================================
> RCS file: /cvs/src/sys/netinet/tcp_usrreq.c,v
> retrieving revision 1.141
> diff -u -p -r1.141 tcp_usrreq.c
> --- netinet/tcp_usrreq.c      3 Jan 2017 10:52:21 -0000       1.141
> +++ netinet/tcp_usrreq.c      9 Jan 2017 17:52:28 -0000
> @@ -569,8 +569,7 @@ tcp_ctloutput(int op, struct socket *so,
>                       error = ENOPROTOOPT;
>                       break;
>               }
> -             if (m)
> -                     (void) m_free(m);
> +             m_free(m);
>               break;
>  
>       case PRCO_GETOPT:
> Index: netinet6/ip6_output.c
> ===================================================================
> RCS file: /cvs/src/sys/netinet6/ip6_output.c,v
> retrieving revision 1.218
> diff -u -p -r1.218 ip6_output.c
> --- netinet6/ip6_output.c     18 Nov 2016 02:53:47 -0000      1.218
> +++ netinet6/ip6_output.c     9 Jan 2017 17:53:14 -0000
> @@ -1414,8 +1414,7 @@ do { \
>                               error = ENOPROTOOPT;
>                               break;
>                       }
> -                     if (m)
> -                             (void)m_free(m);
> +                     m_free(m);
>                       break;
>  
>               case PRCO_GETOPT:
> Index: netinet6/raw_ip6.c
> ===================================================================
> RCS file: /cvs/src/sys/netinet6/raw_ip6.c,v
> retrieving revision 1.101
> diff -u -p -r1.101 raw_ip6.c
> --- netinet6/raw_ip6.c        22 Dec 2016 11:04:44 -0000      1.101
> +++ netinet6/raw_ip6.c        9 Jan 2017 17:53:24 -0000
> @@ -530,8 +530,7 @@ rip6_ctloutput(int op, struct socket *so
>               case MRT6_DEL_MFC:
>                       if (op == PRCO_SETOPT) {
>                               error = ip6_mrouter_set(optname, so, *mp);
> -                             if (*mp)
> -                                     (void)m_free(*mp);
> +                             m_free(*mp);
>                       } else if (op == PRCO_GETOPT)
>                               error = ip6_mrouter_get(optname, so, mp);
>                       else
> 
> 

Reply via email to