Cast sizeof() calls to be of type (int) when they appear in a signed

integer expression.  Otherwise the sizeof() call will force the expression
to be evaluated as unsigned, which is not the intended behavior.

Obtained from:  NetBSD   (in a different form)
This commit is contained in:
jlemon 2000-05-17 04:05:07 +00:00
parent 3759da5283
commit 0d658f6508

View File

@ -1126,7 +1126,7 @@ ip_dooptions(m)
break;
}
off--; /* 0 origin */
if (off > optlen - sizeof(struct in_addr)) {
if (off > optlen - (int)sizeof(struct in_addr)) {
/*
* End of source route. Should be for us.
*/
@ -1197,7 +1197,7 @@ ip_dooptions(m)
* If no space remains, ignore.
*/
off--; /* 0 origin */
if (off > optlen - sizeof(struct in_addr))
if (off > optlen - (int)sizeof(struct in_addr))
break;
(void)memcpy(&ipaddr.sin_addr, &ip->ip_dst,
sizeof(ipaddr.sin_addr));
@ -1221,7 +1221,8 @@ ip_dooptions(m)
ipt = (struct ip_timestamp *)cp;
if (ipt->ipt_len < 5)
goto bad;
if (ipt->ipt_ptr > ipt->ipt_len - sizeof(int32_t)) {
if (ipt->ipt_ptr >
ipt->ipt_len - (int)sizeof(int32_t)) {
if (++ipt->ipt_oflw == 0)
goto bad;
break;