kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* Return value for "impossible" situations
@ 2021-07-25 18:07 Ian Pilcher
  2021-07-25 18:59 ` Bernd Petrovitsch
  2021-07-25 23:15 ` Valdis Klētnieks
  0 siblings, 2 replies; 7+ messages in thread
From: Ian Pilcher @ 2021-07-25 18:07 UTC (permalink / raw)
  To: kernelnewbies

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!
========================================================================


_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-07-26 11:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-25 18:07 Return value for "impossible" situations Ian Pilcher
2021-07-25 18:59 ` Bernd Petrovitsch
2021-07-25 19:13   ` Ian Pilcher
2021-07-25 23:15 ` Valdis Klētnieks
2021-07-26  4:18   ` Ian Pilcher
2021-07-26 10:42     ` Bernd Petrovitsch
2021-07-26 11:08     ` Bernd Petrovitsch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).