2020-08-26 20:55:52

by Julia Lawall

[permalink] [raw]
Subject: [PATCH] coccinelle: api: fix kobj_to_dev.cocci warnings

From: kernel test robot <[email protected]>

Use kobj_to_dev() instead of container_of()

Generated by: scripts/coccinelle/api/kobj_to_dev.cocci

Fixes: a2fc3718bc22 ("coccinelle: api: add kobj_to_dev.cocci script")
CC: Denis Efremov <[email protected]>
Signed-off-by: kernel test robot <[email protected]>
Signed-off-by: Julia Lawall <[email protected]>

---

tree: https://git.kernel.org/pub/scm/linux/kernel/git/jlawall/linux.git for-5.10
head: a2fc3718bc22e85378085568ecc5765fb28cabce
commit: a2fc3718bc22e85378085568ecc5765fb28cabce [3/3] coccinelle: api: add kobj_to_dev.cocci script
:::::: branch date: 5 days ago
:::::: commit date: 5 days ago

udlfb.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

--- a/drivers/video/fbdev/udlfb.c
+++ b/drivers/video/fbdev/udlfb.c
@@ -1457,7 +1457,7 @@ static ssize_t edid_show(
struct file *filp,
struct kobject *kobj, struct bin_attribute *a,
char *buf, loff_t off, size_t count) {
- struct device *fbdev = container_of(kobj, struct device, kobj);
+ struct device *fbdev = kobj_to_dev(kobj);
struct fb_info *fb_info = dev_get_drvdata(fbdev);
struct dlfb_data *dlfb = fb_info->par;

@@ -1479,7 +1479,7 @@ static ssize_t edid_store(
struct file *filp,
struct kobject *kobj, struct bin_attribute *a,
char *src, loff_t src_off, size_t src_size) {
- struct device *fbdev = container_of(kobj, struct device, kobj);
+ struct device *fbdev = kobj_to_dev(kobj);
struct fb_info *fb_info = dev_get_drvdata(fbdev);
struct dlfb_data *dlfb = fb_info->par;
int ret;


2020-08-27 20:08:18

by Julia Lawall

[permalink] [raw]
Subject: Re: [PATCH] coccinelle: api: fix kobj_to_dev.cocci warnings



On Thu, 27 Aug 2020, Markus Elfring wrote:

> > Generated by: scripts/coccinelle/api/kobj_to_dev.cocci
> >
> > Fixes: a2fc3718bc22 ("coccinelle: api: add kobj_to_dev.cocci script")
>
> I wonder about such a combination of information.
>
> I find it reasonable that two function implementations should be adjusted
> according to a generated patch.
> Thus I imagine that not the mentioned SmPL script is “fixed”
> but the affected source file “drivers/video/fbdev/udlfb.c” may be improved.
> Will the subject “[PATCH] video: udlfb: Fix kobj_to_dev.cocci warnings”
> (or “[PATCH] video: udlfb: Use kobj_to_dev() instead of container_of()”)
> be more appropriate for the proposed commit message?

It seems that 0-day picks up new semantic patches that are added to trees
in kernel.org, but that it's strategy for generating the patch is not
ideal. I'll just drop these Fixes lines.

julia

Subject: Re: [PATCH] coccinelle: api: fix kobj_to_dev.cocci warnings


On 8/26/20 10:54 PM, Julia Lawall wrote:
> From: kernel test robot <[email protected]>
>
> Use kobj_to_dev() instead of container_of()
>
> Generated by: scripts/coccinelle/api/kobj_to_dev.cocci
>
> Fixes: a2fc3718bc22 ("coccinelle: api: add kobj_to_dev.cocci script")
> CC: Denis Efremov <[email protected]>
> Signed-off-by: kernel test robot <[email protected]>
> Signed-off-by: Julia Lawall <[email protected]>

Applied to drm-misc-next tree, thanks.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

> ---
>
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/jlawall/linux.git for-5.10
> head: a2fc3718bc22e85378085568ecc5765fb28cabce
> commit: a2fc3718bc22e85378085568ecc5765fb28cabce [3/3] coccinelle: api: add kobj_to_dev.cocci script
> :::::: branch date: 5 days ago
> :::::: commit date: 5 days ago
>
> udlfb.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> --- a/drivers/video/fbdev/udlfb.c
> +++ b/drivers/video/fbdev/udlfb.c
> @@ -1457,7 +1457,7 @@ static ssize_t edid_show(
> struct file *filp,
> struct kobject *kobj, struct bin_attribute *a,
> char *buf, loff_t off, size_t count) {
> - struct device *fbdev = container_of(kobj, struct device, kobj);
> + struct device *fbdev = kobj_to_dev(kobj);
> struct fb_info *fb_info = dev_get_drvdata(fbdev);
> struct dlfb_data *dlfb = fb_info->par;
>
> @@ -1479,7 +1479,7 @@ static ssize_t edid_store(
> struct file *filp,
> struct kobject *kobj, struct bin_attribute *a,
> char *src, loff_t src_off, size_t src_size) {
> - struct device *fbdev = container_of(kobj, struct device, kobj);
> + struct device *fbdev = kobj_to_dev(kobj);
> struct fb_info *fb_info = dev_get_drvdata(fbdev);
> struct dlfb_data *dlfb = fb_info->par;
> int ret;
>