Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1452317 > unrolled thread

Re: [PATCH] s390/pci: Remove unnecessary if condition

Started bySebastian Ott <sebott@linux.vnet.ibm.com>
First post2016-07-29 10:40 +0200
Last post2016-08-01 08:40 +0200
Articles 4 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH] s390/pci: Remove unnecessary if condition Sebastian Ott <sebott@linux.vnet.ibm.com> - 2016-07-29 10:40 +0200
    Re: [PATCH] s390/pci: Remove unnecessary if condition Julia Lawall <julia.lawall@lip6.fr> - 2016-07-29 10:50 +0200
      Re: [PATCH] s390/pci: Remove unnecessary if condition Sebastian Ott <sebott@linux.vnet.ibm.com> - 2016-07-29 11:50 +0200
        Re: [PATCH] s390/pci: Remove unnecessary if condition Julia Lawall <julia.lawall@lip6.fr> - 2016-08-01 08:40 +0200

#1452317 — Re: [PATCH] s390/pci: Remove unnecessary if condition

FromSebastian Ott <sebott@linux.vnet.ibm.com>
Date2016-07-29 10:40 +0200
SubjectRe: [PATCH] s390/pci: Remove unnecessary if condition
Message-ID<s0buO-2d6-19@gated-at.bofh.it>
On Fri, 29 Jul 2016, Amitoj Kaur Chawla wrote:
> Remove unnecessary error handling because the only failure value that
> can be returned is NULL and so the test can never be true.
> 
> The Coccinelle semantic patch used to make this change is as follows:
> @@
> expression e;
> @@
> 
>   e = debugfs_create_file(...);
> - if(IS_ERR(e)) { e = NULL; }

Nope. For !CONFIG_DEBUG_FS debugfs_create_file returns an ERR_PTR.

Regards,
Sebastian

[toc] | [next] | [standalone]


#1452326

FromJulia Lawall <julia.lawall@lip6.fr>
Date2016-07-29 10:50 +0200
Message-ID<s0bEt-2gP-5@gated-at.bofh.it>
In reply to#1452317

On Fri, 29 Jul 2016, Sebastian Ott wrote:

> On Fri, 29 Jul 2016, Amitoj Kaur Chawla wrote:
> > Remove unnecessary error handling because the only failure value that
> > can be returned is NULL and so the test can never be true.
> >
> > The Coccinelle semantic patch used to make this change is as follows:
> > @@
> > expression e;
> > @@
> >
> >   e = debugfs_create_file(...);
> > - if(IS_ERR(e)) { e = NULL; }
>
> Nope. For !CONFIG_DEBUG_FS debugfs_create_file returns an ERR_PTR.

Clicking around in lxr doesn't show that, but perhaps an alternative
definition is overlooked?

julia

[toc] | [prev] | [next] | [standalone]


#1452356

FromSebastian Ott <sebott@linux.vnet.ibm.com>
Date2016-07-29 11:50 +0200
Message-ID<s0cAx-2RM-1@gated-at.bofh.it>
In reply to#1452326
On Fri, 29 Jul 2016, Julia Lawall wrote:
> On Fri, 29 Jul 2016, Sebastian Ott wrote:
> > On Fri, 29 Jul 2016, Amitoj Kaur Chawla wrote:
> > > Remove unnecessary error handling because the only failure value that
> > > can be returned is NULL and so the test can never be true.
> > >
> > > The Coccinelle semantic patch used to make this change is as follows:
> > > @@
> > > expression e;
> > > @@
> > >
> > >   e = debugfs_create_file(...);
> > > - if(IS_ERR(e)) { e = NULL; }
> >
> > Nope. For !CONFIG_DEBUG_FS debugfs_create_file returns an ERR_PTR.
> 
> Clicking around in lxr doesn't show that, but perhaps an alternative
> definition is overlooked?

It looks that way.


[sebott@schleppi linux]$ git grep -W "debugfs_create_file(" include/linux/debugfs.h
include/linux/debugfs.h:struct dentry *debugfs_create_file(const char *name, umode_t mode,
include/linux/debugfs.h-                                   struct dentry *parent, void *data,
include/linux/debugfs.h-                                   const struct file_operations *fops);
--
include/linux/debugfs.h:static inline struct dentry *debugfs_create_file(const char *name, umode_t mode,
include/linux/debugfs.h-                                        struct dentry *parent, void *data,
include/linux/debugfs.h-                                        const struct file_operations *fops)
include/linux/debugfs.h-{
include/linux/debugfs.h-        return ERR_PTR(-ENODEV);
include/linux/debugfs.h-}
include/linux/debugfs.h-

Regards,
Sebastian

[toc] | [prev] | [next] | [standalone]


#1453006

FromJulia Lawall <julia.lawall@lip6.fr>
Date2016-08-01 08:40 +0200
Message-ID<s1f3j-2I4-5@gated-at.bofh.it>
In reply to#1452356

On Fri, 29 Jul 2016, Sebastian Ott wrote:

> On Fri, 29 Jul 2016, Julia Lawall wrote:
> > On Fri, 29 Jul 2016, Sebastian Ott wrote:
> > > On Fri, 29 Jul 2016, Amitoj Kaur Chawla wrote:
> > > > Remove unnecessary error handling because the only failure value that
> > > > can be returned is NULL and so the test can never be true.
> > > >
> > > > The Coccinelle semantic patch used to make this change is as follows:
> > > > @@
> > > > expression e;
> > > > @@
> > > >
> > > >   e = debugfs_create_file(...);
> > > > - if(IS_ERR(e)) { e = NULL; }
> > >
> > > Nope. For !CONFIG_DEBUG_FS debugfs_create_file returns an ERR_PTR.
> >
> > Clicking around in lxr doesn't show that, but perhaps an alternative
> > definition is overlooked?
>
> It looks that way.
>
>
> [sebott@schleppi linux]$ git grep -W "debugfs_create_file(" include/linux/debugfs.h
> include/linux/debugfs.h:struct dentry *debugfs_create_file(const char *name, umode_t mode,
> include/linux/debugfs.h-                                   struct dentry *parent, void *data,
> include/linux/debugfs.h-                                   const struct file_operations *fops);
> --
> include/linux/debugfs.h:static inline struct dentry *debugfs_create_file(const char *name, umode_t mode,
> include/linux/debugfs.h-                                        struct dentry *parent, void *data,
> include/linux/debugfs.h-                                        const struct file_operations *fops)
> include/linux/debugfs.h-{
> include/linux/debugfs.h-        return ERR_PTR(-ENODEV);
> include/linux/debugfs.h-}
> include/linux/debugfs.h-

Thanks for the pointer.  I guess that if the result of debugfs_create_file
is actully dereferenced, then both test should be present, eg:

drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c

       ent = debugfs_create_file(name,
                                 S_IFREG | S_IRUGO, root,
                                 ring, &amdgpu_debugfs_ring_fops);
       if (IS_ERR(ent))
		return PTR_ERR(ent);

       i_size_write(ent->d_inode, ring->ring_size + 12);

This problem seems to only occur in this directory.

thanks,
julia

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web