lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <1246282076.7698.10.camel@nathan.suse.cz>
Date:	Mon, 29 Jun 2009 15:27:56 +0200
From:	Petr Tesarik <ptesarik@...e.cz>
To:	qingbo yuan <yuanbor.maillist@...il.com>
Cc:	linux-kernel@...r.kernel.org
Subject: Re: surpring results of test_and_set_bit() and
 test_and_clear_bit() functions in Linux-2.6.25 kernel at x86_64 architecture

qingbo yuan píše v St 17. 06. 2009 v 18:42 +0800:
> hi,all
> I recently encountered a strange phenomenon about test_and_set_bit()
> and test_and_clear_bit().
> [...]
> So, if the old bit is '0', these functions return 0;
>       if the old bit is '1', these functions return -1;
> Both of these functions were right if the comments modified as
> "test_and_set_bit - Set a bit and return its opposite old value".
> 
> Can anybody point out what problems exist in my analysis?

None. Just, the intended return type of those functions is actually
bool, I think, so it doesn't matter if they return 1 or -1. Any non-zero
value will do.

OTOH choosing the word "opposite" is probably unfortunate, because most
people would have difficulties understanding what the function really
returns.

And while we're at nitpicking, what makes you think that a single bit
integer must be an unsigned int? If I look at one bit as a signed int,
then it can hold the values 0 and -1. The test_and_*_bit() merely
sign-extend the bit...

Petr Tesarik

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ