Re: [B.A.T.M.A.N.] [PATCH 3/8] batman-adv: randomize initial seqno to avoid collision

Marek Lindner
2012-02-07T11:50:50Z

On Tuesday, February 07, 2012 19:13:27 Martin Hundebøll wrote:
> On 2012-02-07 12:10, Marek Lindner wrote:
> >>> + unsigned long random_seqno;
> >>>
> >>> > > +
> >>> > > + /* randomize initial seqno to avoid collision */
> >>> > > + get_random_bytes(&random_seqno, sizeof(unsigned long));
> >>> > > + atomic_set(&hard_iface->seqno, (uint32_t)random_seqno);
> >> >
> >> > Wouldn't it be better to cast "unsigned long" in the call to
> >> > atomic_set()?
> >
> > Why should it better ?
>
> Maybe not better, but at least it is consistent with the type of
> random_seqno, which is unsigned long. I know the two types are identical,
> but nevertheless, I like to use the same type of type :)

You lost me somewhere. Yes, random_seqno is unsigned long. If we wanted to
store unsigned long we would not need a cast.
However, in my kernel the second argument for atomic_set() is "int" and not
"unsigned long" which why we have a cast there.

Regards,
Marek