Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/net Avoid a maybe-uninitialized warning by checking for ...



details:   https://anonhg.NetBSD.org/src/rev/c7a1d7924956
branches:  trunk
changeset: 450305:c7a1d7924956
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Wed Apr 10 04:06:52 2019 +0000

description:
Avoid a maybe-uninitialized warning by checking for an error return
that might indicate that 'len' was not initialized.

diffstat:

 sys/net/rtsock_shared.c |  10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diffs (38 lines):

diff -r 775c8dfb2dfd -r c7a1d7924956 sys/net/rtsock_shared.c
--- a/sys/net/rtsock_shared.c   Wed Apr 10 03:39:34 2019 +0000
+++ b/sys/net/rtsock_shared.c   Wed Apr 10 04:06:52 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rtsock_shared.c,v 1.4 2019/03/01 11:06:57 pgoyette Exp $       */
+/*     $NetBSD: rtsock_shared.c,v 1.5 2019/04/10 04:06:52 thorpej Exp $        */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rtsock_shared.c,v 1.4 2019/03/01 11:06:57 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtsock_shared.c,v 1.5 2019/04/10 04:06:52 thorpej Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -546,7 +546,7 @@
 route_output_report(struct rtentry *rt, struct rt_addrinfo *info,
     struct rt_xmsghdr *rtm, struct rt_xmsghdr **new_rtm)
 {
-       int len;
+       int len, error;
 
        if (rtm->rtm_addrs & (RTA_IFP | RTA_IFA)) {
                const struct ifaddr *rtifa;
@@ -580,7 +580,9 @@
                        info->rti_info[RTAX_BRD] = NULL;
                rtm->rtm_index = ifp->if_index;
        }
-       (void)rt_msg2(rtm->rtm_type, info, NULL, NULL, &len);
+       error = rt_msg2(rtm->rtm_type, info, NULL, NULL, &len);
+       if (error)
+               return error;
        if (len > rtm->rtm_msglen) {
                struct rt_xmsghdr *old_rtm = rtm;
                R_Malloc(*new_rtm, struct rt_xmsghdr *, len);



Home | Main Index | Thread Index | Old Index