Return value for "impossible" situations
Bernd Petrovitsch
bernd at petrovitsch.priv.at
Mon Jul 26 07:08:21 EDT 2021
On 26/07/2021 06:18, Ian Pilcher wrote:
> On 7/25/21 6:15 PM, Valdis Klētnieks wrote:
>> The *proper* thing to do is, instead of deciding to return
>> -EHIT_A_BUG, do a
>> WARN(), or BUG(), so that the dmesg has something that's at least
>> potentially
>> useful. Then use that information to fix the issue.
>
> The question is, after the WARN_ON, what code does one return to user-
> space? What is the "kernel bug; go look at dmesg" return value?
You handle the bug gracefully in the kernel and be done. Or return some
"good" errno value.
There is no "go look into dmesg output" error or even the need for it.
> (Obviously, there isn't an obvious one for this situation. Thus my
> original question about whether there was any convention. Sadly, it
There is no convention as these errors do not exist for userspace
applications - the typical person in front or the application can't do
anything about it.
> seems that there really isn't one, which means that I'm basically forced
> to return a garbage error code that is likely to confuse a system
> administrator or cause them to waste time chasing the wrong issue.)
The error in userspace is usually seen by mere users and not some
admin/root/kernel hacker so it makes no sense to bug them with it -
let alone look into dmesg output and try to learn something from it.
MfG,
Bernd
--
Bernd Petrovitsch Email : bernd at petrovitsch.priv.at
There is NO CLOUD, just other people's computers. - FSFE
LUGA : http://www.luga.at
More information about the Kernelnewbies
mailing list