[LTP] [PATCH v2] misc: rewrite crash02 test
Martin Doucha
mdoucha@suse.cz
Tue Jul 1 15:21:03 CEST 2025
On 01. 07. 25 14:53, Andrea Cervesato wrote:
> Why mixing up unsigned and signed?
Because signed bit shifts that end up setting the highest bit or
truncating high bits result in undefined behavior. C99 standard section
6.5.7 paragraph 4.
> Also, as I mentioned in the previous comment, the more we use rand()
> and the higher is the chance we will move some data which is not
> going to be 0 or close to 0 neither, since every call will add a
> sequence of bits which hardly will be something really close to that
> value.
I don't see any problem there. If you want to increase the probability
of returning zero, do something like this before the loop. Adjust the
constant according to your desired probability.
if (rand() <= 0xff)
return 0;
--
Martin Doucha mdoucha@suse.cz
SW Quality Engineer
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic
More information about the ltp
mailing list