Subject: bin/12517: netstat/iso.c uses paddr_t casts on pointer arithmetic
To: None <gnats-bugs@gnats.netbsd.org>
From: None <tsutsui@ceres.dti.ne.jp>
List: netbsd-bugs
Date: 04/01/2001 04:21:51
>Number:         12517
>Category:       bin
>Synopsis:       netstat/iso.c uses paddr_t casts on pointer arithmetic
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Mar 31 11:22:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Izumi Tsutsui
>Release:        NetBSD-current 1.5S
>Organization:
Izumi Tsutsui	Himeji City, Japan
>Environment:
NetBSD/arc 1.5S

>Description:

usr.bin/netstat/iso.c uses paddr_t casts on pointer arithmetic,
but they do not compile on hosts sizeof(u_long *) != sizeof(paddr_t).

---
  static void
  tprintstat(s, indent)
          struct tp_stat *s;
          int indent;
  {
    :
  #define pgroup(group, header) \
  for (j = 0, tpfirst=1; group[j].text; j++) \
          if (*(u_long*)((paddr_t)s + group[j].off) || \
---

>How-To-Repeat:
make netstat on arc (or _MIPS_PADDR_T_64BIT arch):

cc -O2  -Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wno-uninitialized -Werror   -DINET6 -DIPSEC -DKAME_SCOPEID -c /usr/src/usr.bin/netstat/iso.c
cc1: warnings being treated as errors
/usr/src/usr.bin/netstat/iso.c: In function `tprintstat':
/usr/src/usr.bin/netstat/iso.c:685: warning: cast from pointer to integer of different size
/usr/src/usr.bin/netstat/iso.c:685: warning: cast to pointer from integer of different size
/usr/src/usr.bin/netstat/iso.c:685: warning: cast from pointer to integer of different size
/usr/src/usr.bin/netstat/iso.c:685: warning: cast to pointer from integer of different size
/usr/src/usr.bin/netstat/iso.c:685: warning: cast from pointer to integer of different size
/usr/src/usr.bin/netstat/iso.c:685: warning: cast to pointer from integer of different size
/usr/src/usr.bin/netstat/iso.c:686: warning: cast from pointer to integer of different size
/usr/src/usr.bin/netstat/iso.c:686: warning: cast to pointer from integer of different size
/usr/src/usr.bin/netstat/iso.c:686: warning: cast from pointer to integer of different size
/usr/src/usr.bin/netstat/iso.c:686: warning: cast to pointer from integer of different size
/usr/src/usr.bin/netstat/iso.c:686: warning: cast from pointer to integer of different size
/usr/src/usr.bin/netstat/iso.c:686: warning: cast to pointer from integer of different size
/usr/src/usr.bin/netstat/iso.c:688: warning: cast from pointer to integer of different size
/usr/src/usr.bin/netstat/iso.c:688: warning: cast to pointer from integer of different size
/usr/src/usr.bin/netstat/iso.c:688: warning: cast from pointer to integer of different size
/usr/src/usr.bin/netstat/iso.c:688: warning: cast to pointer from integer of different size
/usr/src/usr.bin/netstat/iso.c:688: warning: cast from pointer to integer of different size
/usr/src/usr.bin/netstat/iso.c:688: warning: cast to pointer from integer of different size
/usr/src/usr.bin/netstat/iso.c:716: warning: cast from pointer to integer of different size
/usr/src/usr.bin/netstat/iso.c:716: warning: cast to pointer from integer of different size
/usr/src/usr.bin/netstat/iso.c:716: warning: cast from pointer to integer of different size
/usr/src/usr.bin/netstat/iso.c:716: warning: cast to pointer from integer of different size
/usr/src/usr.bin/netstat/iso.c:716: warning: cast from pointer to integer of different size
/usr/src/usr.bin/netstat/iso.c:716: warning: cast to pointer from integer of different size
/usr/src/usr.bin/netstat/iso.c:830: warning: cast from pointer to integer of different size
/usr/src/usr.bin/netstat/iso.c:830: warning: cast to pointer from integer of different size
/usr/src/usr.bin/netstat/iso.c:830: warning: cast from pointer to integer of different size
/usr/src/usr.bin/netstat/iso.c:830: warning: cast to pointer from integer of different size
/usr/src/usr.bin/netstat/iso.c:830: warning: cast from pointer to integer of different size
/usr/src/usr.bin/netstat/iso.c:830: warning: cast to pointer from integer of different size
/usr/src/usr.bin/netstat/iso.c:832: warning: cast from pointer to integer of different size
/usr/src/usr.bin/netstat/iso.c:832: warning: cast to pointer from integer of different size
/usr/src/usr.bin/netstat/iso.c:832: warning: cast from pointer to integer of different size
/usr/src/usr.bin/netstat/iso.c:832: warning: cast to pointer from integer of different size
/usr/src/usr.bin/netstat/iso.c:832: warning: cast from pointer to integer of different size
/usr/src/usr.bin/netstat/iso.c:832: warning: cast to pointer from integer of different size
*** Error code 1

Stop.

>Fix:

Maybe we should use vaddr_t (or simply u_long) rathar than paddr_t.
>Release-Note:
>Audit-Trail:
>Unformatted: