svn commit: r305389 - head/sys/netinet
Dimitry Andric
dim at FreeBSD.org
Sun Sep 4 17:23:11 UTC 2016
Author: dim
Date: Sun Sep 4 17:23:10 2016
New Revision: 305389
URL: https://svnweb.freebsd.org/changeset/base/305389
Log:
With clang 3.9.0, compiling sys/netinet/igmp.c results in the following
warning:
sys/netinet/igmp.c:546:21: error: implicit conversion from 'int' to 'char' changes value from 148 to -108 [-Werror,-Wconstant-conversion]
p->ipopt_list[0] = IPOPT_RA; /* Router Alert Option */
~ ^~~~~~~~
sys/netinet/ip.h:153:19: note: expanded from macro 'IPOPT_RA'
#define IPOPT_RA 148 /* router alert */
^~~
This is because ipopt_list is an array of char, so IPOPT_RA is wrapped
to a negative value. It would be nice to change ipopt_list to an array
of u_char, but it changes the signature of the public struct ipoption,
so add an explicit cast to suppress the warning.
Reviewed by: imp
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D7777
Modified:
head/sys/netinet/igmp.c
Modified: head/sys/netinet/igmp.c
==============================================================================
--- head/sys/netinet/igmp.c Sun Sep 4 16:59:35 2016 (r305388)
+++ head/sys/netinet/igmp.c Sun Sep 4 17:23:10 2016 (r305389)
@@ -543,10 +543,10 @@ igmp_ra_alloc(void)
m = m_get(M_WAITOK, MT_DATA);
p = mtod(m, struct ipoption *);
p->ipopt_dst.s_addr = INADDR_ANY;
- p->ipopt_list[0] = IPOPT_RA; /* Router Alert Option */
- p->ipopt_list[1] = 0x04; /* 4 bytes long */
- p->ipopt_list[2] = IPOPT_EOL; /* End of IP option list */
- p->ipopt_list[3] = 0x00; /* pad byte */
+ p->ipopt_list[0] = (char)IPOPT_RA; /* Router Alert Option */
+ p->ipopt_list[1] = 0x04; /* 4 bytes long */
+ p->ipopt_list[2] = IPOPT_EOL; /* End of IP option list */
+ p->ipopt_list[3] = 0x00; /* pad byte */
m->m_len = sizeof(p->ipopt_dst) + p->ipopt_list[1];
return (m);
More information about the svn-src-all
mailing list