rtsock: redundant NULL pointer check

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

rtsock: redundant NULL pointer check

Tobias Heider-2
It seems that there is no way 'rtm' could actually be NULL here, which
means we can get rid of the check.

ok?

Index: net/rtsock.c
===================================================================
RCS file: /mount/openbsd/cvs/src/sys/net/rtsock.c,v
retrieving revision 1.297
diff -u -p -r1.297 rtsock.c
--- net/rtsock.c 24 Nov 2019 07:56:03 -0000 1.297
+++ net/rtsock.c 23 Mar 2020 21:15:51 -0000
@@ -858,14 +858,12 @@ fail:
  return (error);
  }
  }
- if (rtm) {
- if (m_copyback(m, 0, len, rtm, M_NOWAIT)) {
- m_freem(m);
- m = NULL;
- } else if (m->m_pkthdr.len > len)
- m_adj(m, len - m->m_pkthdr.len);
- free(rtm, M_RTABLE, len);
- }
+ if (m_copyback(m, 0, len, rtm, M_NOWAIT)) {
+ m_freem(m);
+ m = NULL;
+ } else if (m->m_pkthdr.len > len)
+ m_adj(m, len - m->m_pkthdr.len);
+ free(rtm, M_RTABLE, len);
  if (m)
  route_input(m, so, info.rti_info[RTAX_DST] ?
     info.rti_info[RTAX_DST]->sa_family : AF_UNSPEC);

Reply | Threaded
Open this post in threaded view
|

Re: rtsock: redundant NULL pointer check

Claudio Jeker
On Mon, Mar 23, 2020 at 10:36:20PM +0100, Tobias Heider wrote:
> It seems that there is no way 'rtm' could actually be NULL here, which
> means we can get rid of the check.
>
> ok?

OK claudio@
 

> Index: net/rtsock.c
> ===================================================================
> RCS file: /mount/openbsd/cvs/src/sys/net/rtsock.c,v
> retrieving revision 1.297
> diff -u -p -r1.297 rtsock.c
> --- net/rtsock.c 24 Nov 2019 07:56:03 -0000 1.297
> +++ net/rtsock.c 23 Mar 2020 21:15:51 -0000
> @@ -858,14 +858,12 @@ fail:
>   return (error);
>   }
>   }
> - if (rtm) {
> - if (m_copyback(m, 0, len, rtm, M_NOWAIT)) {
> - m_freem(m);
> - m = NULL;
> - } else if (m->m_pkthdr.len > len)
> - m_adj(m, len - m->m_pkthdr.len);
> - free(rtm, M_RTABLE, len);
> - }
> + if (m_copyback(m, 0, len, rtm, M_NOWAIT)) {
> + m_freem(m);
> + m = NULL;
> + } else if (m->m_pkthdr.len > len)
> + m_adj(m, len - m->m_pkthdr.len);
> + free(rtm, M_RTABLE, len);
>   if (m)
>   route_input(m, so, info.rti_info[RTAX_DST] ?
>      info.rti_info[RTAX_DST]->sa_family : AF_UNSPEC);
>

--
:wq Claudio