* [PATCH] s390/pci: Remove unnecessary if condition
@ 2016-07-29 8:31 Amitoj Kaur Chawla
2016-07-29 8:39 ` Sebastian Ott
0 siblings, 1 reply; 5+ messages in thread
From: Amitoj Kaur Chawla @ 2016-07-29 8:31 UTC (permalink / raw)
To: sebott, gerald.schaefer, schwidefsky, heiko.carstens, linux-s390,
linux-kernel
Cc: julia.lawall
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; }
Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
---
arch/s390/pci/pci_debug.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/arch/s390/pci/pci_debug.c b/arch/s390/pci/pci_debug.c
index 4129b0a..8a25b04 100644
--- a/arch/s390/pci/pci_debug.c
+++ b/arch/s390/pci/pci_debug.c
@@ -139,8 +139,6 @@ void zpci_debug_init_device(struct zpci_dev *zdev)
S_IFREG | S_IRUGO | S_IWUSR,
zdev->debugfs_dev, zdev,
&debugfs_pci_perf_fops);
- if (IS_ERR(zdev->debugfs_perf))
- zdev->debugfs_perf = NULL;
}
void zpci_debug_exit_device(struct zpci_dev *zdev)
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] s390/pci: Remove unnecessary if condition 2016-07-29 8:31 [PATCH] s390/pci: Remove unnecessary if condition Amitoj Kaur Chawla @ 2016-07-29 8:39 ` Sebastian Ott 2016-07-29 8:46 ` Julia Lawall 0 siblings, 1 reply; 5+ messages in thread From: Sebastian Ott @ 2016-07-29 8:39 UTC (permalink / raw) To: Amitoj Kaur Chawla Cc: gerald.schaefer, schwidefsky, heiko.carstens, linux-s390, linux-kernel, julia.lawall 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 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] s390/pci: Remove unnecessary if condition 2016-07-29 8:39 ` Sebastian Ott @ 2016-07-29 8:46 ` Julia Lawall 2016-07-29 9:46 ` Sebastian Ott 0 siblings, 1 reply; 5+ messages in thread From: Julia Lawall @ 2016-07-29 8:46 UTC (permalink / raw) To: Sebastian Ott Cc: Amitoj Kaur Chawla, gerald.schaefer, schwidefsky, heiko.carstens, linux-s390, linux-kernel, julia.lawall 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 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] s390/pci: Remove unnecessary if condition 2016-07-29 8:46 ` Julia Lawall @ 2016-07-29 9:46 ` Sebastian Ott 2016-08-01 6:39 ` Julia Lawall 0 siblings, 1 reply; 5+ messages in thread From: Sebastian Ott @ 2016-07-29 9:46 UTC (permalink / raw) To: Julia Lawall Cc: Amitoj Kaur Chawla, Gerald Schaefer, Martin Schwidefsky, Heiko Carstens, linux-s390, linux-kernel 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 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] s390/pci: Remove unnecessary if condition 2016-07-29 9:46 ` Sebastian Ott @ 2016-08-01 6:39 ` Julia Lawall 0 siblings, 0 replies; 5+ messages in thread From: Julia Lawall @ 2016-08-01 6:39 UTC (permalink / raw) To: Sebastian Ott Cc: Julia Lawall, Amitoj Kaur Chawla, Gerald Schaefer, Martin Schwidefsky, Heiko Carstens, linux-s390, linux-kernel 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 ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-08-01 6:39 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-07-29 8:31 [PATCH] s390/pci: Remove unnecessary if condition Amitoj Kaur Chawla 2016-07-29 8:39 ` Sebastian Ott 2016-07-29 8:46 ` Julia Lawall 2016-07-29 9:46 ` Sebastian Ott 2016-08-01 6:39 ` Julia Lawall
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox