Return value for "impossible" situations

Ian Pilcher arequipeno at gmail.com
Sun Jul 25 14:07:21 EDT 2021


In user space, I use assertions to check (and document) the assumptions
built in to my code - this value won't ever be negative, this int will
only ever by one of these 3 values, etc.

For kernel code, I can use pr_err, dump_stack, WARN_ON, etc. to report
the issue in the log, but I often also need to return some sort of error
code (negative errno value).

Is there any sort of convention around what to return in the case of an
error in the logic of the code itself, something that will make it as
obvious as possible that the problem is a bug.

TIA!

-- 
========================================================================
                  In Soviet Russia, Google searches you!
========================================================================




More information about the Kernelnewbies mailing list