Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 18 Sep 2020 14:01:10 +0000 (UTC)
From:      Mitchell Horne <mhorne@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r365881 - head/sys/netinet
Message-ID:  <202009181401.08IE1AJV025622@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mhorne
Date: Fri Sep 18 14:01:10 2020
New Revision: 365881
URL: https://svnweb.freebsd.org/changeset/base/365881

Log:
  Initialize some local variables earlier
  
  Move the initialization of these variables to the beginning of their
  respective functions.
  
  On our end this creates a small amount of unneeded churn, as these
  variables are properly initialized before their first use in all cases.
  However, changing this benefits at least one downstream consumer
  (NetApp) by allowing local and future modifications to these functions
  to be made without worrying about where the initialization occurs.
  
  Reviewed by:	melifaro, rscheff
  Sponsored by:	NetApp, Inc.
  Sponsored by:	Klara, Inc.
  Differential Revision:	https://reviews.freebsd.org/D26454

Modified:
  head/sys/netinet/ip_output.c
  head/sys/netinet/udp_usrreq.c

Modified: head/sys/netinet/ip_output.c
==============================================================================
--- head/sys/netinet/ip_output.c	Fri Sep 18 12:59:27 2020	(r365880)
+++ head/sys/netinet/ip_output.c	Fri Sep 18 14:01:10 2020	(r365881)
@@ -323,11 +323,11 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct rou
 	struct ifnet *ifp = NULL;	/* keep compiler happy */
 	struct mbuf *m0;
 	int hlen = sizeof (struct ip);
-	int mtu;
+	int mtu = 0;
 	int error = 0;
 	struct sockaddr_in *dst, sin;
 	const struct sockaddr_in *gw;
-	struct in_ifaddr *ia;
+	struct in_ifaddr *ia = NULL;
 	struct in_addr src;
 	int isbroadcast;
 	uint16_t ip_len, ip_off;
@@ -485,7 +485,6 @@ again:
 				 * possible that a matching SPD entry exists.
 				 */
 				no_route_but_check_spd = 1;
-				mtu = 0; /* Silence GCC warning. */
 				goto sendit;
 #endif
 				IPSTAT_INC(ips_noroute);
@@ -521,7 +520,6 @@ again:
 			 * possible that a matching SPD entry exists.
 			 */
 			no_route_but_check_spd = 1;
-			mtu = 0; /* Silence GCC warning. */
 			goto sendit;
 #endif
 			IPSTAT_INC(ips_noroute);

Modified: head/sys/netinet/udp_usrreq.c
==============================================================================
--- head/sys/netinet/udp_usrreq.c	Fri Sep 18 12:59:27 2020	(r365880)
+++ head/sys/netinet/udp_usrreq.c	Fri Sep 18 14:01:10 2020	(r365881)
@@ -1151,7 +1151,7 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct s
 	struct epoch_tracker et;
 	int cscov_partial = 0;
 	int error = 0;
-	int ipflags;
+	int ipflags = 0;
 	u_short fport, lport;
 	u_char tos;
 	uint8_t pr;
@@ -1435,7 +1435,6 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct s
 		ip->ip_off |= htons(IP_DF);
 	}
 
-	ipflags = 0;
 	if (inp->inp_socket->so_options & SO_DONTROUTE)
 		ipflags |= IP_ROUTETOIF;
 	if (inp->inp_socket->so_options & SO_BROADCAST)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202009181401.08IE1AJV025622>