Using assertion in the Linux kernel

后端 未结 6 1152
挽巷
挽巷 2021-02-05 03:09

I have a question about assert() in Linux: can I use it in the kernel?

If no, what techniques do you usually use if, for example I don\'t want to enter NULL

6条回答
  •  说谎
    说谎 (楼主)
    2021-02-05 03:43

    BUG_ON() is the appropriate approach to do it. It checks for the condition to be true and calls the macro BUG().

    How BUG() handles the rest is explained very well in the following article:

    http://kernelnewbies.org/FAQ/BUG

提交回复
热议问题