在自己写的内核模块中,尝试使用WARN_ON(),结果发现没有任何警告。
原来是有一个内核选项控制BUG()和WARN()。
它就是CONFIG_BUG。
General setup
Configure standard kernel features (expert users) (EXPERT [=y])
BUG() support (BUG [=y])
Disabling this option eliminates support for BUG and WARN, reducing │
the size of your kernel image and potentially quietly ignoring │
numerous fatal conditions. You should only consider disabling this │
option for embedded systems with no facilities for reporting errors. │
Just say Y.
开启后内核镜像有变大180K。
-rwxr-xr-x 1 yuan yuan 5918728 Mar 18 09:42 Image
-rwxr-xr-x 1 yuan yuan 6098952 Mar 24 09:57 Image