All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Pilcher <arequipeno@gmail.com>
To: kernelnewbies@kernelnewbies.org
Subject: Return value for "impossible" situations
Date: Sun, 25 Jul 2021 13:07:21 -0500	[thread overview]
Message-ID: <sdk98p$tmm$1@ciao.gmane.io> (raw)

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

             reply	other threads:[~2021-07-25 18:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-25 18:07 Ian Pilcher [this message]
2021-07-25 18:59 ` Return value for "impossible" situations 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='sdk98p$tmm$1@ciao.gmane.io' \
    --to=arequipeno@gmail.com \
    --cc=kernelnewbies@kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.