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

Timo Buhrmester <[email protected]> Sat, 12 Mar 2016 00:35:58 +0100
Newsgroups gmane.os.netbsd.devel.general
Message-ID <[email protected]>
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.