de-__P().

WARNS=4 cleanup:
  include headers needed.
  don't initialize char * with const char *.
  fix main() declaration.
  fix shadowed variable.
  properly cast tcpcb members for printf(3) output.
  remove 'register'.
  remove unused arg.

Reviewed by: tmm, bde
This commit is contained in:
Alfred Perlstein 2002-07-15 17:44:34 +00:00
parent f0d2d03884
commit 19d02d39c9
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=100114
2 changed files with 32 additions and 36 deletions

View File

@ -2,6 +2,7 @@
# $FreeBSD$ # $FreeBSD$
PROG= trpt PROG= trpt
WARNS?= 4
MAN= trpt.8 MAN= trpt.8
BINGRP= kmem BINGRP= kmem
BINMODE= 2555 BINMODE= 2555

View File

@ -82,34 +82,31 @@ static const char rcsid[] =
#include <paths.h> #include <paths.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <unistd.h> #include <unistd.h>
struct nlist nl[] = { struct nlist nl[3];
#define N_TCP_DEBUG 0 #define N_TCP_DEBUG 0
{ "_tcp_debug" },
#define N_TCP_DEBX 1 #define N_TCP_DEBX 1
{ "_tcp_debx" },
{ "" },
};
static caddr_t tcp_pcbs[TCP_NDEBUG]; static caddr_t tcp_pcbs[TCP_NDEBUG];
static n_time ntime; static n_time ntime;
static int aflag, kflag, memf, follow, sflag, tflag; static int aflag, kflag, memf, follow, sflag, tflag;
void dotrace __P((caddr_t)); void dotrace(caddr_t);
void klseek __P((int, off_t, int)); void klseek(int, off_t, int);
int numeric __P((const void *, const void *)); int numeric(const void *, const void *);
void tcp_trace __P((short, short, struct tcpcb *, struct tcpcb *, void tcp_trace(short, short, struct tcpcb *, int, void *, struct tcphdr *, int);
int, void *, struct tcphdr *, int)); static void usage(void);
static void usage __P((void));
int int
main(argc, argv) main(int argc, char **argv)
int argc;
char **argv;
{ {
int ch, i, jflag, npcbs; int ch, i, jflag, npcbs;
char *system, *core; const char *core, *syst;
nl[0].n_name = strdup("_tcp_debug");
nl[1].n_name = strdup("_tcp_debx");
jflag = npcbs = 0; jflag = npcbs = 0;
while ((ch = getopt(argc, argv, "afjp:st")) != -1) while ((ch = getopt(argc, argv, "afjp:st")) != -1)
@ -144,7 +141,7 @@ main(argc, argv)
core = _PATH_KMEM; core = _PATH_KMEM;
if (argc > 0) { if (argc > 0) {
system = *argv; syst = *argv;
argc--, argv++; argc--, argv++;
if (argc > 0) { if (argc > 0) {
core = *argv; core = *argv;
@ -158,10 +155,10 @@ main(argc, argv)
setgid(getgid()); setgid(getgid());
} }
else else
system = (char *)getbootfile(); syst = getbootfile();
if (nlist(system, nl) < 0 || !nl[0].n_value) if (nlist(syst, nl) < 0 || !nl[0].n_value)
errx(1, "%s: no namelist", system); errx(1, "%s: no namelist", syst);
if ((memf = open(core, O_RDONLY)) < 0) if ((memf = open(core, O_RDONLY)) < 0)
err(2, "%s", core); err(2, "%s", core);
setgid(getgid()); setgid(getgid());
@ -200,7 +197,7 @@ main(argc, argv)
qsort(tcp_pcbs, npcbs, sizeof(caddr_t), numeric); qsort(tcp_pcbs, npcbs, sizeof(caddr_t), numeric);
if (jflag) { if (jflag) {
for (i = 0;;) { for (i = 0;;) {
printf("%x", tcp_pcbs[i]); printf("%p", (void *)tcp_pcbs[i]);
if (++i == npcbs) if (++i == npcbs)
break; break;
fputs(", ", stdout); fputs(", ", stdout);
@ -245,14 +242,12 @@ again: if (--tcp_debx < 0)
switch(family) { switch(family) {
case AF_INET: case AF_INET:
tcp_trace(td->td_act, td->td_ostate, tcp_trace(td->td_act, td->td_ostate,
(struct tcpcb *)td->td_tcb,
&td->td_cb, td->td_family, &td->td_ti.ti_i, &td->td_cb, td->td_family, &td->td_ti.ti_i,
&td->td_ti.ti_t, td->td_req); &td->td_ti.ti_t, td->td_req);
break; break;
#ifdef INET6 #ifdef INET6
case AF_INET6: case AF_INET6:
tcp_trace(td->td_act, td->td_ostate, tcp_trace(td->td_act, td->td_ostate,
(struct tcpcb *)td->td_tcb,
&td->td_cb, td->td_family, &td->td_ti6.ip6, &td->td_cb, td->td_family, &td->td_ti6.ip6,
&td->td_ti6.th, td->td_req); &td->td_ti6.th, td->td_req);
break; break;
@ -274,14 +269,12 @@ again: if (--tcp_debx < 0)
switch(family) { switch(family) {
case AF_INET: case AF_INET:
tcp_trace(td->td_act, td->td_ostate, tcp_trace(td->td_act, td->td_ostate,
(struct tcpcb *)td->td_tcb,
&td->td_cb, td->td_family, &td->td_ti.ti_i, &td->td_cb, td->td_family, &td->td_ti.ti_i,
&td->td_ti.ti_t, td->td_req); &td->td_ti.ti_t, td->td_req);
break; break;
#ifdef INET6 #ifdef INET6
case AF_INET6: case AF_INET6:
tcp_trace(td->td_act, td->td_ostate, tcp_trace(td->td_act, td->td_ostate,
(struct tcpcb *)td->td_tcb,
&td->td_cb, td->td_family, &td->td_ti6.ip6, &td->td_cb, td->td_family, &td->td_ti6.ip6,
&td->td_ti6.th, td->td_req); &td->td_ti6.th, td->td_req);
break; break;
@ -312,9 +305,9 @@ done: if (follow) {
*/ */
/*ARGSUSED*/ /*ARGSUSED*/
void void
tcp_trace(act, ostate, atp, tp, family, ip, th, req) tcp_trace(act, ostate, tp, family, ip, th, req)
short act, ostate; short act, ostate;
struct tcpcb *atp, *tp; struct tcpcb *tp;
int family; int family;
void *ip; void *ip;
struct tcphdr *th; struct tcphdr *th;
@ -347,7 +340,7 @@ tcp_trace(act, ostate, atp, tp, family, ip, th, req)
#else #else
ip4 = (struct ip *)ip; ip4 = (struct ip *)ip;
#endif #endif
printf("%03ld %s:%s ",(ntime/10) % 1000, tcpstates[ostate], printf("%03ld %s:%s ", (long)((ntime/10) % 1000), tcpstates[ostate],
tanames[act]); tanames[act]);
switch (act) { switch (act) {
case TA_INPUT: case TA_INPUT:
@ -394,15 +387,15 @@ tcp_trace(act, ostate, atp, tp, family, ip, th, req)
if (act == TA_OUTPUT) if (act == TA_OUTPUT)
len -= sizeof(struct tcphdr); len -= sizeof(struct tcphdr);
if (len) if (len)
printf("[%lx..%lx)", seq, seq + len); printf("[%lx..%lx)", (u_long)seq, (u_long)(seq + len));
else else
printf("%lx", seq); printf("%lx", (u_long)seq);
printf("@%lx", ack); printf("@%lx", (u_long)ack);
if (win) if (win)
printf("(win=%x)", win); printf("(win=%x)", win);
flags = th->th_flags; flags = th->th_flags;
if (flags) { if (flags) {
register char *cp = "<"; const char *cp = "<";
#define pf(flag, string) { \ #define pf(flag, string) { \
if (th->th_flags&flag) { \ if (th->th_flags&flag) { \
(void)printf("%s%s", cp, string); \ (void)printf("%s%s", cp, string); \
@ -430,11 +423,13 @@ tcp_trace(act, ostate, atp, tp, family, ip, th, req)
/* print out internal state of tp !?! */ /* print out internal state of tp !?! */
printf("\n"); printf("\n");
if (sflag) { if (sflag) {
printf("\trcv_nxt %lx rcv_wnd %x snd_una %lx snd_nxt %lx snd_max %lx\n", printf("\trcv_nxt %lx rcv_wnd %lx snd_una %lx snd_nxt %lx snd_max %lx\n",
tp->rcv_nxt, tp->rcv_wnd, tp->snd_una, tp->snd_nxt, (u_long)tp->rcv_nxt, tp->rcv_wnd,
tp->snd_max); (u_long)tp->snd_una, (u_long)tp->snd_nxt,
printf("\tsnd_wl1 %lx snd_wl2 %lx snd_wnd %x\n", tp->snd_wl1, (u_long)tp->snd_max);
tp->snd_wl2, tp->snd_wnd); printf("\tsnd_wl1 %lx snd_wl2 %lx snd_wnd %lx\n",
(u_long)tp->snd_wl1,
(u_long)tp->snd_wl2, tp->snd_wnd);
} }
/* print out timers? */ /* print out timers? */
#if 0 #if 0