aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitchell Horne <mhorne@FreeBSD.org>2020-09-18 14:01:10 +0000
committerMitchell Horne <mhorne@FreeBSD.org>2020-09-18 14:01:10 +0000
commit374ce2488ae6f84a6b902a0125569bae434fa375 (patch)
tree382dcdbd2324f6b962ac0b81896555bd7332577f
parent085e04945cc3cb3a725a2b0cd992ad0358e49f7e (diff)
downloadsrc-374ce2488ae6f84a6b902a0125569bae434fa375.tar.gz
src-374ce2488ae6f84a6b902a0125569bae434fa375.zip
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
Notes
Notes: svn path=/head/; revision=365881
-rw-r--r--sys/netinet/ip_output.c6
-rw-r--r--sys/netinet/udp_usrreq.c3
2 files changed, 3 insertions, 6 deletions
diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c
index c1dd6bad6c6d..dde8a1389f98 100644
--- a/sys/netinet/ip_output.c
+++ b/sys/netinet/ip_output.c
@@ -323,11 +323,11 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags,
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);
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c
index 0c8578de3dca..e1bb5f07c0d0 100644
--- a/sys/netinet/udp_usrreq.c
+++ b/sys/netinet/udp_usrreq.c
@@ -1151,7 +1151,7 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr,
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 sockaddr *addr,
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)