Thu Apr 23 00:23:31 2020 UTC ()
Avoid global scope for variables only used locally


(joerg)
diff -r1.17 -r1.18 src/usr.bin/netstat/atalk.c

cvs diff -r1.17 -r1.18 src/usr.bin/netstat/atalk.c (expand / switch to unified diff)

--- src/usr.bin/netstat/atalk.c 2019/08/18 04:14:40 1.17
+++ src/usr.bin/netstat/atalk.c 2020/04/23 00:23:31 1.18
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: atalk.c,v 1.17 2019/08/18 04:14:40 kamil Exp $ */ 1/* $NetBSD: atalk.c,v 1.18 2020/04/23 00:23:31 joerg Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1983, 1988, 1993 4 * Copyright (c) 1983, 1988, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -24,27 +24,27 @@ @@ -24,27 +24,27 @@
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33#ifndef lint 33#ifndef lint
34#if 0 34#if 0
35static char sccsid[] = "from @(#)atalk.c 1.1 (Whistle) 6/6/96"; 35static char sccsid[] = "from @(#)atalk.c 1.1 (Whistle) 6/6/96";
36#else 36#else
37__RCSID("$NetBSD: atalk.c,v 1.17 2019/08/18 04:14:40 kamil Exp $"); 37__RCSID("$NetBSD: atalk.c,v 1.18 2020/04/23 00:23:31 joerg Exp $");
38#endif 38#endif
39#endif /* not lint */ 39#endif /* not lint */
40 40
41#include <sys/param.h> 41#include <sys/param.h>
42#include <sys/queue.h> 42#include <sys/queue.h>
43#include <sys/socket.h> 43#include <sys/socket.h>
44#include <sys/socketvar.h> 44#include <sys/socketvar.h>
45#include <sys/mbuf.h> 45#include <sys/mbuf.h>
46#include <sys/protosw.h> 46#include <sys/protosw.h>
47#include <sys/sysctl.h> 47#include <sys/sysctl.h>
48 48
49#include <net/route.h> 49#include <net/route.h>
50#include <net/if.h> 50#include <net/if.h>
@@ -53,29 +53,26 @@ __RCSID("$NetBSD: atalk.c,v 1.17 2019/08 @@ -53,29 +53,26 @@ __RCSID("$NetBSD: atalk.c,v 1.17 2019/08
53 53
54#include <netatalk/at.h> 54#include <netatalk/at.h>
55#include <netatalk/ddp_var.h> 55#include <netatalk/ddp_var.h>
56 56
57#include <err.h> 57#include <err.h>
58#include <nlist.h> 58#include <nlist.h>
59#include <kvm.h> 59#include <kvm.h>
60#include <errno.h> 60#include <errno.h>
61#include <stdio.h> 61#include <stdio.h>
62#include <string.h> 62#include <string.h>
63#include "netstat.h" 63#include "netstat.h"
64#include "prog_ops.h" 64#include "prog_ops.h"
65 65
66struct ddpcb ddpcb; 
67struct socket sockb; 
68 
69static int first = 1; 66static int first = 1;
70 67
71/* 68/*
72 * Print a summary of connections related to a Network Systems 69 * Print a summary of connections related to a Network Systems
73 * protocol. For XXX, also give state of connection. 70 * protocol. For XXX, also give state of connection.
74 * Listening processes (aflag) are suppressed unless the 71 * Listening processes (aflag) are suppressed unless the
75 * -a (all) flag is specified. 72 * -a (all) flag is specified.
76 */ 73 */
77 74
78static const char * 75static const char *
79at_pr_net(const struct sockaddr_at *sat, int numeric) 76at_pr_net(const struct sockaddr_at *sat, int numeric)
80{ 77{
81 static char mybuf[50]; 78 static char mybuf[50];
@@ -220,26 +217,28 @@ atalk_print2(const struct sockaddr *sa,  @@ -220,26 +217,28 @@ atalk_print2(const struct sockaddr *sa,
220 l = snprintf(buf + n, sizeof(buf) - n, ".%s", 217 l = snprintf(buf + n, sizeof(buf) - n, ".%s",
221 atalk_print(sa, what & (~1))); 218 atalk_print(sa, what & (~1)));
222 if (l >= (int)(sizeof(buf) - n)) 219 if (l >= (int)(sizeof(buf) - n))
223 l = sizeof(buf) - n - 1; 220 l = sizeof(buf) - n - 1;
224 if (l > 0) 221 if (l > 0)
225 n += l; 222 n += l;
226 } 223 }
227 return (buf); 224 return (buf);
228} 225}
229 226
230void 227void
231atalkprotopr(u_long off, const char *name) 228atalkprotopr(u_long off, const char *name)
232{ 229{
 230 struct ddpcb ddpcb;
 231 struct socket sockb;
233 struct ddpcb *next; 232 struct ddpcb *next;
234 struct ddpcb *initial; 233 struct ddpcb *initial;
235 int width = 22; 234 int width = 22;
236 if (off == 0) 235 if (off == 0)
237 return; 236 return;
238 if (kread(off, (char *)&initial, sizeof(struct ddpcb *)) < 0) 237 if (kread(off, (char *)&initial, sizeof(struct ddpcb *)) < 0)
239 return; 238 return;
240 for (next = initial; next != NULL;) { 239 for (next = initial; next != NULL;) {
241 u_long ppcb = (u_long)next; 240 u_long ppcb = (u_long)next;
242 241
243 if (kread((u_long)next, (char *)&ddpcb, sizeof(ddpcb)) < 0) 242 if (kread((u_long)next, (char *)&ddpcb, sizeof(ddpcb)) < 0)
244 return; 243 return;
245 next = ddpcb.ddp_next; 244 next = ddpcb.ddp_next;