tech-misc archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Bad bitmasking in tests/lib/libc/gen/t_fpsetmask.c?



A floating point testcase in tests/lib/libc/gen/t_fpsetmask.c reads:
	msk = fpgetmask();
 	for (i = 0; i < __arraycount(lst); i++) {
 		fpsetmask(msk | lst[i]);
 		ATF_CHECK((fpgetmask() & lst[i]) != 0);
		fpsetmask(msk & lst[i]);
 		ATF_CHECK((fpgetmask() & lst[i]) == 0);
 	}
 
Shouldn't the part that reads:
	fpsetmask(msk & lst[i]);
 	ATF_CHECK((fpgetmask() & lst[i]) == 0);
rather read:
	fpsetmask(msk & ~lst[i]);
 	ATF_CHECK((fpgetmask() & ~lst[i]) == 0);
?

Otherwise it seems to work only by accident, relying on fpgetmask()
returning zero at the start of the test case, and doesn't really test
whether a bit of the mask can be cleared.



Home | Main Index | Thread Index | Old Index