Left shifting the pid by 16 bits can cause a UBSAN warning if the pid
is greater than or equal to 2**16. It doesn't matter since we're just
using the pid to seed for a pseudo-random number generator, but
silence the warning by just swapping the high and low 16 bits of the
pid instead.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
#ifdef CONFIG_MMP
unsigned new_seq;
struct timeval tv;
+ unsigned long pid = getpid();
gettimeofday(&tv, 0);
- srand((getpid() << 16) ^ getuid() ^ tv.tv_sec ^ tv.tv_usec);
+ pid = (pid >> 16) | ((pid & 0xFFFF) << 16);
+ srand(pid ^ getuid() ^ tv.tv_sec ^ tv.tv_usec);
gettimeofday(&tv, 0);
/* Crank the random number generator a few times */