mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Javier Martinez Canillas <javierm@redhat.com>
To: Douglas Anderson <dianders@chromium.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jani Nikula <jani.nikula@linux.intel.com>,
	Andrzej Hajda <andrzej.hajda@intel.com>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] debugfs: Document that debugfs_create functions need not be error checked
Date: Wed, 23 Feb 2022 09:49:15 +0100	[thread overview]
Message-ID: <88d84e26-9b8c-443d-ebe7-7a7c92f2b595@redhat.com> (raw)
In-Reply-To: <20220222154555.1.I26d364db7a007f8995e8f0dac978673bc8e9f5e2@changeid>

Hello Doug,

On 2/23/22 00:46, Douglas Anderson wrote:
> As talked about in commit b792e64021ec ("drm: no need to check return
> value of debugfs_create functions"), in many cases we can get away
> with totally skipping checking the errors of debugfs functions. Let's
> document that so people don't add new code that needlessly checks
> these errors.
> 
> Probably this note could be added to a boatload of functions, but
> that's a lot of duplication.  Let's just add it to the two most
> frequent ones and hope people will get the idea.
> 

Agreed. The first contact point for folks looking for the function's
return values will probably be these two, I second that is enough.

> Suggested-by: Javier Martinez Canillas <javierm@redhat.com>
> Signed-off-by: Douglas Anderson <dianders@chromium.org>
> ---
> 
>  fs/debugfs/inode.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
> index 2f117c57160d..3dcf0b8b4e93 100644
> --- a/fs/debugfs/inode.c
> +++ b/fs/debugfs/inode.c
> @@ -450,6 +450,11 @@ static struct dentry *__debugfs_create_file(const char *name, umode_t mode,
>   *
>   * If debugfs is not enabled in the kernel, the value -%ENODEV will be
>   * returned.
> + *
> + * NOTE: it's expected that most callers should _ignore_ the errors returned
> + * by this function. Other debugfs functions handle the fact that the "dentry"
> + * passed to them could be an error and they don't crash in that case.
> + * Drivers should generally work fine even if debugfs fails to init anyway.
>   */

Thanks a lot for adding this. I was confused why the kernel doc didn't mention
anything like that, yet most drivers didn't check and just ignored the errors.

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

Best regards,
-- 
Javier Martinez Canillas
Linux Engineering
Red Hat


  reply	other threads:[~2022-02-23  8:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-22 23:46 Douglas Anderson
2022-02-23  8:49 ` Javier Martinez Canillas [this message]
2022-02-25 10:53   ` Greg Kroah-Hartman

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=88d84e26-9b8c-443d-ebe7-7a7c92f2b595@redhat.com \
    --to=javierm@redhat.com \
    --cc=andrzej.hajda@intel.com \
    --cc=dianders@chromium.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®