git: bb3d7c88ee05 - stable/13 - sysctl_dumpentry: move error to inner scope

From: Warner Losh <imp_at_FreeBSD.org>
Date: Sun, 02 Oct 2022 04:30:09 UTC
The branch stable/13 has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=bb3d7c88ee05a47f1a684cd0e3ca82ca8ba1eec2

commit bb3d7c88ee05a47f1a684cd0e3ca82ca8ba1eec2
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2022-07-08 17:53:34 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2022-10-02 04:25:57 +0000

    sysctl_dumpentry: move error to inner scope
    
    Sponsored by:           Netflix
    
    (cherry picked from commit e606e5d1572684b978ca0572da776a597ffe0d94)
---
 sys/net/rtsock.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index 5f386a2142f6..7802c7d8da9e 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -2205,7 +2205,6 @@ sysctl_dumpentry(struct rtentry *rt, void *vw)
 {
 	struct walkarg *w = vw;
 	struct nhop_object *nh;
-	int error = 0;
 
 	NET_EPOCH_ASSERT();
 
@@ -2217,6 +2216,7 @@ sysctl_dumpentry(struct rtentry *rt, void *vw)
 	if (NH_IS_NHGRP(nh)) {
 		struct weightened_nhop *wn;
 		uint32_t num_nhops;
+		int error;
 		wn = nhgrp_get_nhops((struct nhgrp_object *)nh, &num_nhops);
 		for (int i = 0; i < num_nhops; i++) {
 			error = sysctl_dumpnhop(rt, wn[i].nh, wn[i].weight, w);
@@ -2225,7 +2225,7 @@ sysctl_dumpentry(struct rtentry *rt, void *vw)
 		}
 	} else
 #endif
-		error = sysctl_dumpnhop(rt, nh, rt->rt_weight, w);
+		sysctl_dumpnhop(rt, nh, rt->rt_weight, w);
 
 	return (0);
 }