clang 7 notes that ~0 is signed and that left-shifting into the sign
bit is undefined behvaior. Use a new construction to clear the low
byte of tv_usec with only bitwise operations that are independent of
the width of tv_usec and stay within the realm of C's defined behavior.
Change-Id: I3e4f0fa4a8b8b72df23ef0c8ad7c4a229ac942f3
Reviewed-on: https://gerrit.openafs.org/13474
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
osi_timeval_t t;
osi_GetTime(&t);
/*
- * 0xfffffff0 was changed to (~0 << 4) since it works no matter how many
- * bits are in a tv_usec
+ * Clear the low byte of tv_usec in a size-independent manner before adding
+ * in the rest of the state.
*/
- state = (t.tv_usec & (~0 << 4)) + (rxi_getaddr() & 0xff);
+ state = t.tv_usec;
+ state ^= (state & 0xff);
+ state += rxi_getaddr() & 0xff;
state += (t.tv_sec & 0xff);
for (i = 0; i < 30; i++) {
ranstage(state);