On Mon, Jun 24, 2013 at 06:15:44PM +0200, Maxime Villard wrote:
> Hi,
> there are lots of useless assignment of variables in the code. I know this
> kind of things does not really matter, but when I run my code scanner on
> some parts of the source tree it gives me lots of them.
>
> For example, for the net* directories:
>
> == src/sys/net/if_bridge.c - l2017
>
> u_int32_t cnt = 0; <------- Here, we don't need to set cnt to 0
> struct bridge_rtnode *n;
> struct ifbareq bareq;
>
> if (baconf->ifbac_len == 0)
> onlycnt = 1;
>
> for (i = 0, cnt = 0; i < BRIDGE_RTABLE_SIZE; i++) <------- set here
>
> == src/sys/net/if_sppprubr.c - l403
>
> int i = 0, x;
>
> i = 0; <---- Hum, hum, hum
>
> == src/sys/net/if_pppx.c - l238
>
> int rv = 0; <--- ?
>
> rv = rw_enter(&pppx_devs_lk, RW_WRITE | RW_INTR);
>
> == src/sys/netinet/if_output.c - l623
>
> int transportmode = 0; <----- ?
>
> transportmode = (tdb->tdb_dst.sa.sa_family == AF_INET) &&
> (tdb->tdb_dst.sin.sin_addr.s_addr ==
> ip->ip_dst.s_addr);
>
> == src/sys/netinet6/raw_ip6.c - l380
>
> int priv = 0; <----------
> va_list ap;
> int flags;
>
> va_start(ap, m);
> so = va_arg(ap, struct socket *);
> dstsock = va_arg(ap, struct sockaddr_in6 *);
> control = va_arg(ap, struct mbuf *);
> va_end(ap);
>
> in6p = sotoin6pcb(so);
>
> priv = 0; <--------------- ?
>
>
> Same thing in several other places... Here is a patch for these dirs.
>
> Ok/Comments?
Moving to a consistant style (I believe the current feeling is to
eliminate the declaration initialization) would be the best bet.
.... Ken
>
>
> Index: net/if_bridge.c
> ===================================================================
> RCS file: /cvs/src/sys/net/if_bridge.c,v
> retrieving revision 1.210
> diff -u -r1.210 if_bridge.c
> --- net/if_bridge.c 28 Mar 2013 23:10:05 -0000 1.210
> +++ net/if_bridge.c 24 Jun 2013 15:55:08 -0000
> @@ -2014,7 +2014,7 @@
> bridge_rtfind(struct bridge_softc *sc, struct ifbaconf *baconf)
> {
> int i, error = 0, onlycnt = 0;
> - u_int32_t cnt = 0;
> + u_int32_t cnt;
> struct bridge_rtnode *n;
> struct ifbareq bareq;
>
> Index: net/if_pppx.c
> ===================================================================
> RCS file: /cvs/src/sys/net/if_pppx.c,v
> retrieving revision 1.23
> diff -u -r1.23 if_pppx.c
> --- net/if_pppx.c 24 Jun 2013 09:34:59 -0000 1.23
> +++ net/if_pppx.c 24 Jun 2013 15:55:08 -0000
> @@ -235,7 +235,7 @@
> pppxopen(dev_t dev, int flags, int mode, struct proc *p)
> {
> struct pppx_dev *pxd;
> - int rv = 0;
> + int rv;
>
> rv = rw_enter(&pppx_devs_lk, RW_WRITE | RW_INTR);
> if (rv != 0)
> Index: net/if_spppsubr.c
> ===================================================================
> RCS file: /cvs/src/sys/net/if_spppsubr.c,v
> retrieving revision 1.104
> diff -u -r1.104 if_spppsubr.c
> --- net/if_spppsubr.c 20 Jun 2013 12:03:40 -0000 1.104
> +++ net/if_spppsubr.c 24 Jun 2013 15:55:09 -0000
> @@ -4028,7 +4028,6 @@
> STDDCL;
> int i = 0, x;
>
> - i = 0;
> sp->rst_counter[IDX_CHAP] = sp->lcp.max_configure;
>
> /*
> Index: netinet/ip_output.c
> ===================================================================
> RCS file: /cvs/src/sys/netinet/ip_output.c,v
> retrieving revision 1.241
> diff -u -r1.241 ip_output.c
> --- netinet/ip_output.c 11 Jun 2013 18:15:53 -0000 1.241
> +++ netinet/ip_output.c 24 Jun 2013 15:55:10 -0000
> @@ -620,7 +620,7 @@
> tdb->tdb_mtutimeout > time_second) {
> struct rtentry *rt = NULL;
> int rt_mtucloned = 0;
> - int transportmode = 0;
> + int transportmode;
>
> transportmode = (tdb->tdb_dst.sa.sa_family == AF_INET)
> &&
> (tdb->tdb_dst.sin.sin_addr.s_addr ==
> Index: netinet6/raw_ip6.c
> ===================================================================
> RCS file: /cvs/src/sys/netinet6/raw_ip6.c,v
> retrieving revision 1.58
> diff -u -r1.58 raw_ip6.c
> --- netinet6/raw_ip6.c 4 Jun 2013 19:11:52 -0000 1.58
> +++ netinet6/raw_ip6.c 24 Jun 2013 15:55:10 -0000
> @@ -377,7 +377,6 @@
>
> in6p = sotoin6pcb(so);
>
> - priv = 0;
> if ((so->so_state & SS_PRIV) != 0)
> priv = 1;
> dst = &dstsock->sin6_addr;
>