static __init int kcmp_cookie_init(void)
{
int i, j;
for (i = 0; i< KCMP_TYPES; i++) {
for (j = 0; j< 2; j++)
get_random_bytes(&cookies[i][j], sizeof(long));
cookies[i][1] |= (~(~0UL>> 1) | 1);
}
return 0;
}
I thought in first place that sizeof(cookies[i][j]) would allow me
to change type of cookies in one place (ie at declaration) but
if cookies type will be changed -- the code will need careful review
anway, so sizeof(long) will be enough I think.
On the other hands, maybe more clean variant will be
static __init int kcmp_cookie_init(void)
{
const int size = sizeof(cookies[0][0]);
int i, j;
for (i = 0; i< KCMP_TYPES; i++) {
for (j = 0; j< 2; j++)
get_random_bytes(&cookies[i][j], size);
cookies[i][1] |= (~(~0UL>> 1) | 1);
}