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 PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Thu, 26 Mar 2009 09:42:39 +0530 From: Nikanth Karthikesan <knikanth@...e.de> To: Rusty Russell <rusty@...tcorp.com.au> Cc: nikanth@...il.com, linux-kernel@...r.kernel.org Subject: Re: Strange code in include/linux/cpumask.h On Thursday 26 March 2009 04:14:46 Rusty Russell wrote: > On Wednesday 25 March 2009 17:14:30 Nikanth Karthikesan wrote: > > On Wednesday 25 March 2009 10:41:11 Rusty Russell wrote: > > > Yes, except that this insists that bitmap be an unsigned long * or > > > you'll get a warning. Otherwise the macro could be used on anything. > > > And it needs to be a macro to use it as a static initializer. > > > > Ah, got it. Thanks a lot for the explanation. May be a comment could be > > added to the source. > > Well, it's not that unusual a trick in the kernel, but an explanation might > help. > I _assumed_ that kernel developers are good programmers who do not need type enforcements/warnings. And tricky code for non-performance optimizations wont be allowed. Yes, this is not very tricky once you are aware that such tricks are done in the kernel just for type-safety. Anyway lets document it. Thanks Nikanth Add a comment explaining the purpose of the tricky code in the macro to_cpumask(). The __check_is_bitmap() is used to enforce type-safety. Signed-off-by: Nikanth Karthikesan <knikanth@...e.de> --- diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index 9f31538..32b802b 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h @@ -279,6 +279,7 @@ static inline void __cpus_shift_left(cpumask_t *dstp, * expose the definition of 'struct cpumask'. * * This does the conversion, and can be used as a constant initializer. + * __check_is_bitmap() enforces bitmap to be an 'unsigned long *'. */ #define to_cpumask(bitmap) \ ((struct cpumask *)(1 ? (bitmap) \ -- 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