[comp.bugs.4bsd] Small mistake in RENO code

march@cs.uiuc.edu (Steve March) (06/22/91)

In the file ..../sys/netinet/in.c, in the routine in_sockmaskof(), the variable
mask is declared u_long (line 102) but is later assigned a negative value in
line 115.  Doesn't look right to me.

-Steve

===============================================================================
Steve March                            (H) (217)328-5176/328-5230  (W) 333-7408
Domain: march@cs.uiuc.edu             Path: {uunet|convex|pur-ee}!uiucdcs!march
"Time and space are modes by which we think and not conditions in which
 we live."  - Albert Einstein

torek@elf.ee.lbl.gov (Chris Torek) (06/24/91)

In article <1991Jun22.080642.27211@m.cs.uiuc.edu> march@cs.uiuc.edu
(Steve March) writes:
>In the file ..../sys/netinet/in.c, in the routine in_sockmaskof(), the
>variable mask is declared u_long (line 102) but is later assigned a
>negative value in line 115.  Doesn't look right to me.

The code in question is:

	register u_long mask;
	...
	mask = -1;

which is intended to set `mask' to all-ones.  Since all the machines on
which 4BSD runs are 2's complement, this is fine; it would, however, be
better in some sense to use

	mask = ~0UL;

so as to guarantee this result in all cases.  Unfortunately, `U'-suffixed
constants are not recognized by the 4.3-reno Vax and Tahoe C compilers.
Perhaps `mask = ~0L' would suffice. :-)
-- 
In-Real-Life: Chris Torek, Lawrence Berkeley Lab CSE/EE (+1 415 486 5427)
Berkeley, CA		Domain:	torek@ee.lbl.gov