vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| On Thu, 19 May 2005, Jack J. Woehr wrote: > I was looking at this warning in "make build": > > /usr/src/lib/libc/net/res_init.c:214: warning: comparison is always true > due to limited range of data type > > And at /usr/src/lib/libc/res_init.c line 214 I find: > > if (sizeof(_res_extp->nsaddr) >= _resp->nsaddr.sin_len) > memcpy(&_res_extp->nsaddr, &_resp->nsaddr, _resp->nsaddr.sin_len); > > and can't make this make sense. Granted, it's almost 05:00 MDT as I > write this, but why the comparison? Or is the comparison meant to be <= > rather than >= ? > > Excuse me if I'm being late-night-coding silly. The test check if the actual length of _resp->nsaddr (_resp->nsaddr.sin_len) is smaller than the available space in _res_extp->nsaddr. If so, it copies the the data. sin_len is an unsigned 8 bits type, and sizeof(_res_extp->nsaddr) is >= 256. So the test is always true and the data will be copied. Until somebody changes the size of _res_extp->nsaddr or the type of sin_len. -Otto |