All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Frederic Barrat <fbarrat@linux.ibm.com>,
	linuxppc-dev <linuxppc-dev@lists.ozlabs.org>,
	Andrew Donnellan <ajd@linux.ibm.com>
Subject: Re: [PATCH] cxl: no need to check return value of debugfs_create functions
Date: Wed, 12 Jun 2019 12:02:26 +0200	[thread overview]
Message-ID: <20190612100226.GA18368@kroah.com> (raw)
In-Reply-To: <CAK8P3a1otKxoJUNH=-tZfzFy9qzQQc61i8AZPh-L7e-Ybd8kpg@mail.gmail.com>

On Wed, Jun 12, 2019 at 11:51:21AM +0200, Arnd Bergmann wrote:
> On Tue, Jun 11, 2019 at 8:13 PM Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> wrote:
> 
> > @@ -64,8 +64,6 @@ int cxl_debugfs_adapter_add(struct cxl *adapter)
> >
> >         snprintf(buf, 32, "card%i", adapter->adapter_num);
> >         dir = debugfs_create_dir(buf, cxl_debugfs);
> > -       if (IS_ERR(dir))
> > -               return PTR_ERR(dir);
> >         adapter->debugfs = dir;
> >
> 
> Should the check for 'cxl_debugfs' get removed here as well?

Maybe, I could not determine the logic if those functions could be
called before cxl_debugfs was ever set.

And debugfs_create_dir() will not return a NULL value if an error
happens, so no need to worry about files being created in the wrong
place.

> If that is null, we might put the subdir in the wrong place in the
> tree, but that would otherwise be harmless as well, and the
> same thing happens if 'dir' is NULL above and we add the
> files in the debugfs root later (losing the ability to clean up
> afterwards).
> 
> int cxl_debugfs_adapter_add(struct cxl *adapter)
> {
>         struct dentry *dir;
>         char buf[32];
> 
>         if (!cxl_debugfs)
>                 return -ENODEV;
> 
> It's still a bit odd to return an error, since the caller then just
> ignores the return code anway:

Then let's just return nothing.

>         /* Don't care if this one fails: */
>         cxl_debugfs_adapter_add(adapter);
> 
> It would seem best to change the return type to 'void' here for
> consistency.

I agree, let me go do that.

thanks,

greg k-h

  reply	other threads:[~2019-06-12 10:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-11 18:13 [PATCH] cxl: no need to check return value of debugfs_create functions Greg Kroah-Hartman
2019-06-12  9:51 ` Arnd Bergmann
2019-06-12 10:02   ` Greg Kroah-Hartman [this message]
2019-06-12 14:10     ` Frederic Barrat
2019-06-12 15:54   ` 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=20190612100226.GA18368@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=ajd@linux.ibm.com \
    --cc=arnd@arndb.de \
    --cc=fbarrat@linux.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.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.