rtadvd/rrenum.c:179
Matthew Luckie
mjl at luckie.org.nz
Mon May 19 08:17:41 UTC 2008
When rtadvd is compiled on 7.0, the following warning is emitted:
/usr/src/usr.sbin/rtadvd/rrenum.c:179: warning: overflow in implicit
constant conversion
I have not determined if the code works correct or not, but I wonder
if it does. the line in question is this:
struct irr_raflagmask {
u_char onlink : 1;
u_char autonomous : 1;
u_char reserved : 6;
} irr_raflagmask;
irr->irr_raf_mask_onlink = (rpu->rpu_ramask & ICMP6_RR_PCOUSE_RAFLAGS_ONLINK);
rpu_ramask is unsigned char, the constant is 0x80, and
irr_raf_mask_onlink is a single bit value. This troubles me, and the
compiler.
I'm only raising this for consideration; if it can be determined that
the code works correctly, maybe a commit can be made to silence the
warnings.
--- rrenum.c.orig 2004-03-10 21:46:39.000000000 +1300
+++ rrenum.c 2008-05-19 19:39:52.000000000 +1200
@@ -176,9 +176,9 @@ do_use_prefix(int len, struct rr_pco_mat
irr->irr_u_uselen = rpu->rpu_uselen;
irr->irr_u_keeplen = rpu->rpu_keeplen;
irr->irr_raf_mask_onlink =
- (rpu->rpu_ramask & ICMP6_RR_PCOUSE_RAFLAGS_ONLINK);
+ (rpu->rpu_ramask & ICMP6_RR_PCOUSE_RAFLAGS_ONLINK) == 0 ? 0 : 1;
irr->irr_raf_mask_auto =
- (rpu->rpu_ramask & ICMP6_RR_PCOUSE_RAFLAGS_AUTO);
+ (rpu->rpu_ramask & ICMP6_RR_PCOUSE_RAFLAGS_AUTO) == 0 ? 0 : 1;
irr->irr_vltime = ntohl(rpu->rpu_vltime);
irr->irr_pltime = ntohl(rpu->rpu_pltime);
irr->irr_raf_onlink =
More information about the freebsd-net
mailing list