Commit de3f186f authored by Denis Efremov's avatar Denis Efremov Committed by Linus Torvalds
Browse files

checkpatch: check for nested (un)?likely() calls

IS_ERR(), IS_ERR_OR_NULL(), IS_ERR_VALUE() and WARN*() already contain
unlikely() optimization internally.  Thus, there is no point in calling
these functions and defines under likely()/unlikely().

This check is based on the coccinelle rule developed by Enrico Weigelt


Signed-off-by: default avatarDenis Efremov <>
Cc: Joe Perches <>
Cc: Alexander Viro <>
Cc: Anton Altaparmakov <>
Cc: Boris Ostrovsky <>
Cc: Boris Pismenny <>
Cc: Darrick J. Wong <>
Cc: "David S. Miller" <>
Cc: Denis Efremov <>
Cc: Dennis Dalessandro <>
Cc: Inaky Perez-Gonzalez <>
Cc: Juergen Gross <>
Cc: Leon Romanovsky <>
Cc: Mike Marciniszyn <>
Cc: Rob Clark <>
Cc: Saeed Mahameed <>
Cc: Sean Paul <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent c7cc8d77
......@@ -6507,6 +6507,12 @@ sub process {
"Using $1 should generally have parentheses around the comparison\n" . $herecurr);
# nested likely/unlikely calls
if ($line =~ /\b(?:(?:un)?likely)\s*\(\s*!?\s*(IS_ERR(?:_OR_NULL|_VALUE)?|WARN)/) {
"nested (un)?likely() calls, $1 already uses unlikely() internally\n" . $herecurr);
# whine mightly about in_atomic
if ($line =~ /\bin_atomic\s*\(/) {
if ($realfile =~ m@^drivers/@) {
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment