Linux virtualization list
 help / color / mirror / Atom feed
* [PATCH] virtio_console: correct error message on failure of debugfs_create_dir
       [not found] <1356030701-16284-1-git-send-email-sasha.levin@oracle.com>
@ 2012-12-20 19:11 ` Sasha Levin
       [not found] ` <1356030701-16284-13-git-send-email-sasha.levin@oracle.com>
  1 sibling, 0 replies; 6+ messages in thread
From: Sasha Levin @ 2012-12-20 19:11 UTC (permalink / raw)
  To: Amit Shah, Arnd Bergmann, Greg Kroah-Hartman, virtualization,
	linux-kernel
  Cc: Sasha Levin

debugfs_create_dir() returns NULL if it fails, there's little point in
calling PTR_ERR on it.

Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 drivers/char/virtio_console.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index c594cb1..490b70e 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -2212,10 +2212,9 @@ static int __init init(void)
 	}
 
 	pdrvdata.debugfs_dir = debugfs_create_dir("virtio-ports", NULL);
-	if (!pdrvdata.debugfs_dir) {
-		pr_warning("Error %ld creating debugfs dir for virtio-ports\n",
-			   PTR_ERR(pdrvdata.debugfs_dir));
-	}
+	if (!pdrvdata.debugfs_dir)
+		pr_warn("Error creating debugfs dir for virtio-ports\n");
+
 	INIT_LIST_HEAD(&pdrvdata.consoles);
 	INIT_LIST_HEAD(&pdrvdata.portdevs);
 
-- 
1.8.0

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

* Re: [PATCH] virtio_console: correct error message on failure of debugfs_create_dir
       [not found] ` <1356030701-16284-13-git-send-email-sasha.levin@oracle.com>
@ 2012-12-21  7:59   ` Amit Shah
  2012-12-24 11:55     ` Arnd Bergmann
       [not found]     ` <201212241155.46866.arnd@arndb.de>
  0 siblings, 2 replies; 6+ messages in thread
From: Amit Shah @ 2012-12-21  7:59 UTC (permalink / raw)
  To: Sasha Levin
  Cc: Greg Kroah-Hartman, linux-kernel, Arnd Bergmann, virtualization

On (Thu) 20 Dec 2012 [14:11:21], Sasha Levin wrote:
> debugfs_create_dir() returns NULL if it fails, there's little point in
> calling PTR_ERR on it.
> 
> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
> ---
>  drivers/char/virtio_console.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
> index c594cb1..490b70e 100644
> --- a/drivers/char/virtio_console.c
> +++ b/drivers/char/virtio_console.c
> @@ -2212,10 +2212,9 @@ static int __init init(void)
>  	}
>  
>  	pdrvdata.debugfs_dir = debugfs_create_dir("virtio-ports", NULL);
> -	if (!pdrvdata.debugfs_dir) {
> -		pr_warning("Error %ld creating debugfs dir for virtio-ports\n",
> -			   PTR_ERR(pdrvdata.debugfs_dir));
> -	}
> +	if (!pdrvdata.debugfs_dir)
> +		pr_warn("Error creating debugfs dir for virtio-ports\n");

debugfs_create_dir() does return an error value if debugfs is not
enabled.

This check for !pdrvdata.debugfs_dir should infact use
IS_ERR_OR_NULL().  Care to submit a patch for that?

		Amit

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

* Re: [PATCH] virtio_console: correct error message on failure of debugfs_create_dir
  2012-12-21  7:59   ` Amit Shah
@ 2012-12-24 11:55     ` Arnd Bergmann
       [not found]     ` <201212241155.46866.arnd@arndb.de>
  1 sibling, 0 replies; 6+ messages in thread
From: Arnd Bergmann @ 2012-12-24 11:55 UTC (permalink / raw)
  To: Amit Shah; +Cc: Sasha Levin, virtualization, linux-kernel, Greg Kroah-Hartman

On Friday 21 December 2012, Amit Shah wrote:
> On (Thu) 20 Dec 2012 [14:11:21], Sasha Levin wrote:
> > debugfs_create_dir() returns NULL if it fails, there's little point in
> > calling PTR_ERR on it.
>
> debugfs_create_dir() does return an error value if debugfs is not
> enabled.
> 
> This check for !pdrvdata.debugfs_dir should infact use
> IS_ERR_OR_NULL().  Care to submit a patch for that?

How about we fix the stub instead to return NULL when debugfs is disabled?

	Arnd

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

* Re: [PATCH] virtio_console: correct error message on failure of debugfs_create_dir
       [not found]     ` <201212241155.46866.arnd@arndb.de>
@ 2012-12-24 17:39       ` Greg Kroah-Hartman
  2012-12-24 18:24         ` Sasha Levin
  0 siblings, 1 reply; 6+ messages in thread
From: Greg Kroah-Hartman @ 2012-12-24 17:39 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Amit Shah, Sasha Levin, linux-kernel, virtualization

On Mon, Dec 24, 2012 at 11:55:46AM +0000, Arnd Bergmann wrote:
> On Friday 21 December 2012, Amit Shah wrote:
> > On (Thu) 20 Dec 2012 [14:11:21], Sasha Levin wrote:
> > > debugfs_create_dir() returns NULL if it fails, there's little point in
> > > calling PTR_ERR on it.
> >
> > debugfs_create_dir() does return an error value if debugfs is not
> > enabled.
> > 
> > This check for !pdrvdata.debugfs_dir should infact use
> > IS_ERR_OR_NULL().  Care to submit a patch for that?
> 
> How about we fix the stub instead to return NULL when debugfs is disabled?

No, please read debugfs.h for why I decided to not do this (i.e. we try
to learn from our mistakes...)

thanks,

greg k-h

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

* Re: [PATCH] virtio_console: correct error message on failure of debugfs_create_dir
  2012-12-24 17:39       ` Greg Kroah-Hartman
@ 2012-12-24 18:24         ` Sasha Levin
  2012-12-24 18:43           ` Greg Kroah-Hartman
  0 siblings, 1 reply; 6+ messages in thread
From: Sasha Levin @ 2012-12-24 18:24 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Amit Shah, Sasha Levin, linux-kernel, Arnd Bergmann,
	virtualization

On Mon, Dec 24, 2012 at 12:39 PM, Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
> On Mon, Dec 24, 2012 at 11:55:46AM +0000, Arnd Bergmann wrote:
>> On Friday 21 December 2012, Amit Shah wrote:
>> > On (Thu) 20 Dec 2012 [14:11:21], Sasha Levin wrote:
>> > > debugfs_create_dir() returns NULL if it fails, there's little point in
>> > > calling PTR_ERR on it.
>> >
>> > debugfs_create_dir() does return an error value if debugfs is not
>> > enabled.
>> >
>> > This check for !pdrvdata.debugfs_dir should infact use
>> > IS_ERR_OR_NULL().  Care to submit a patch for that?
>>
>> How about we fix the stub instead to return NULL when debugfs is disabled?
>
> No, please read debugfs.h for why I decided to not do this (i.e. we try
> to learn from our mistakes...)

Why won't we fix it the other way around and return an actual error
code instead of a NULL on failure?


Thanks,
Sasha

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

* Re: [PATCH] virtio_console: correct error message on failure of debugfs_create_dir
  2012-12-24 18:24         ` Sasha Levin
@ 2012-12-24 18:43           ` Greg Kroah-Hartman
  0 siblings, 0 replies; 6+ messages in thread
From: Greg Kroah-Hartman @ 2012-12-24 18:43 UTC (permalink / raw)
  To: Sasha Levin
  Cc: Amit Shah, Sasha Levin, linux-kernel, Arnd Bergmann,
	virtualization

On Mon, Dec 24, 2012 at 01:24:52PM -0500, Sasha Levin wrote:
> On Mon, Dec 24, 2012 at 12:39 PM, Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> wrote:
> > On Mon, Dec 24, 2012 at 11:55:46AM +0000, Arnd Bergmann wrote:
> >> On Friday 21 December 2012, Amit Shah wrote:
> >> > On (Thu) 20 Dec 2012 [14:11:21], Sasha Levin wrote:
> >> > > debugfs_create_dir() returns NULL if it fails, there's little point in
> >> > > calling PTR_ERR on it.
> >> >
> >> > debugfs_create_dir() does return an error value if debugfs is not
> >> > enabled.
> >> >
> >> > This check for !pdrvdata.debugfs_dir should infact use
> >> > IS_ERR_OR_NULL().  Care to submit a patch for that?
> >>
> >> How about we fix the stub instead to return NULL when debugfs is disabled?
> >
> > No, please read debugfs.h for why I decided to not do this (i.e. we try
> > to learn from our mistakes...)
> 
> Why won't we fix it the other way around and return an actual error
> code instead of a NULL on failure?

Again, no, that doesn't make your code simpler/faster.  You really don't
need to check the return value of debugfs, just handle it as if it
always works, and look, the code handles it all properly, no matter if
debugfs is enabled or not.  It's only debugging code, you shouldn't
really care if it is present or not, right?

If you do, perhaps you shouldn't be using debugfs?

greg k-h

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

end of thread, other threads:[~2012-12-24 18:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1356030701-16284-1-git-send-email-sasha.levin@oracle.com>
2012-12-20 19:11 ` [PATCH] virtio_console: correct error message on failure of debugfs_create_dir Sasha Levin
     [not found] ` <1356030701-16284-13-git-send-email-sasha.levin@oracle.com>
2012-12-21  7:59   ` Amit Shah
2012-12-24 11:55     ` Arnd Bergmann
     [not found]     ` <201212241155.46866.arnd@arndb.de>
2012-12-24 17:39       ` Greg Kroah-Hartman
2012-12-24 18:24         ` Sasha Levin
2012-12-24 18:43           ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox