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] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 12 Feb 2008 19:28:36 -0600
From:	Paul Jackson <pj@....com>
To:	Christoph Lameter <clameter@....com>
Cc:	Lee.Schermerhorn@...com, rientjes@...gle.com,
	akpm@...ux-foundation.org, ak@...e.de, linux-kernel@...r.kernel.org
Subject: Re: [patch 1/4] mempolicy: convert MPOL constants to enum

Christoph wrote:
> We usually do that with unsigned XXX and constants. You may want to check 
> multiple flags at once or do other fancy things.

Both are common in the kernel.  I see 241 ":1" bit fields in include/linux/*.h.

One can do Boolean expressions with either form, bitfields or defines.

For example:

	struct {
		int foo:1;
		int goo:1;
	} x;

	if (x.foo && ! x.goo)
		blah blah ...;

Doing (x.flags & FLAG_FOO) is simple enough, but it is still
not as simple as (x.foo).  Where possible, I encourage keeping
extraneous detail out of mainline code.

Sometimes, such as in task struct flags, one has to do such Boolean
combinations in performance critical code paths, and then one must do
what one must do, with the defined constants.

Sometimes, such as with the GFP_* flags, one has to name various
combinations, and then one needs again to use defined constants.

I see no evidence that either of those situations applies here.

-- 
                  I won't rest till it's the best ...
                  Programmer, Linux Scalability
                  Paul Jackson <pj@....com> 1.940.382.4214
--
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