public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC 0/3] Extend type checking macros
@ 2012-04-14 22:14 Sasha Levin
  2012-04-14 21:02 ` Peter Zijlstra
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Sasha Levin @ 2012-04-14 22:14 UTC (permalink / raw)
  To: torvalds, akpm, peterz, mingo, hpa, tglx, srivatsa.bhat
  Cc: linux-kernel, Sasha Levin

Commit e3831ed ("sched: Fix incorrect usage of for_each_cpu_mask() in
select_fallback_rq()") fixes a very non obvious bug in select_fallback_rq()
which was caused by passing 'struct cpumask' instead of 'struct cpumask *'
to a macro in include/linux/cpumask.h

This bug was quite a pain to debug since it doesn't raise any warnings or
erros during compilation, and the assumption of the kernel hackers who try
to fix a bug is that if the compiler didn't complain, they passed the right
types to functions.

This series of patches adds some more type checking macros to the forgotten
include/linux/typecheck.h, it modified for_each_cpu_mask() to use those
macros to trigger a warning when needed (this is a nice demonstration of how
the bug mentioned before would have been visible with these checks), and
modifies min()/max() and friend to use these macros as well to show their
value in reducing duplicate code and improving readability.

Sasha Levin (3):
  typecheck: extend typecheck.h with more useful typechecking macros
  sched: add type checks to for_each_cpu_mask()
  kernel.h: use new typechecking macros in min()/max() and friends

 include/linux/cpumask.h   |    4 ++-
 include/linux/kernel.h    |   47 ++++++++++++++------------------------------
 include/linux/typecheck.h |   42 ++++++++++++++++++++++++++++++++-------
 3 files changed, 52 insertions(+), 41 deletions(-)

-- 
1.7.8.5


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2012-04-20 22:33 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-14 22:14 [RFC 0/3] Extend type checking macros Sasha Levin
2012-04-14 21:02 ` Peter Zijlstra
2012-04-14 21:18 ` Srivatsa S. Bhat
2012-04-14 22:31   ` Srivatsa S. Bhat
2012-04-14 22:14 ` [RFC 1/3] typecheck: extend typecheck.h with more useful typechecking macros Sasha Levin
2012-04-14 21:12   ` Linus Torvalds
2012-04-14 22:14 ` [RFC 2/3] sched: add type checks to for_each_cpu_mask() Sasha Levin
2012-04-14 21:15   ` Linus Torvalds
2012-04-20 22:33   ` Andrew Morton
2012-04-14 22:14 ` [RFC 3/3] kernel.h: use new typechecking macros in min()/max() and friends Sasha Levin
2012-04-14 21:01   ` Peter Zijlstra
2012-04-14 21:17   ` Linus Torvalds

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox