Skip to contentSkip to conversation

drm/xen-front: Make structure fb_funcs constant

PATCH In review Nishka Dasgupta 3 participants 4 messages Aug 13, 2019 – Aug 19, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/xen-front: Make structure fb_funcs constant

Static structure fb_funcs, of type drm_framebuffer_funcs, is used only when it is passed to drm_gem_fb_create_with_funcs() as its last argument. drm_gem_fb_create_with_funcs does not modify its lst argument (fb_funcs) and hence fb_funcs is never modified. Therefore make fb_funcs constant to protect it from further modification.
Issue found with Coccinelle.

---
 drivers/gpu/drm/xen/xen_drm_front_kms.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/xen/xen_drm_front_kms.c +1 -1
index c2955d375394..4a984f45555e 100644
@@ -45,7 +45,7 @@ static void fb_destroy(struct drm_framebuffer *fb)
 	drm_gem_fb_destroy(fb);
 }
 
-static struct drm_framebuffer_funcs fb_funcs = {
+static const struct drm_framebuffer_funcs fb_funcs = {
 	.destroy = fb_destroy,
 };
 
Signature · 7 lines
2.19.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Nishka Dasgupta

Static structure fb_funcs, of type drm_framebuffer_funcs, is used only when it is passed to drm_gem_fb_create_with_funcs() as its last argument. drm_gem_fb_create_with_funcs does not modify its lst argument (fb_funcs) and hence fb_funcs is never modified. Therefore make fb_funcs constant to protect it from further modification.
Issue found with Coccinelle.

Quoted 9 lines
---
  drivers/gpu/drm/xen/xen_drm_front_kms.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/xen/xen_drm_front_kms.c +0 -0
index c2955d375394..4a984f45555e 100644

drivers/gpu/drm/xen/xen_drm_front_kms.c static void fb_destroy(struct drm_framebuffer *fb) · line 51

Quoted 8 lines
drivers/gpu/drm/xen/xen_drm_front_kms.c +1 -1
@@ -45,7 +45,7 @@ static void fb_destroy(struct drm_framebuffer *fb)
  	drm_gem_fb_destroy(fb);
  }
 
-static struct drm_framebuffer_funcs fb_funcs = {
+static const struct drm_framebuffer_funcs fb_funcs = {
  	.destroy = fb_destroy,
  };
 

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw
Quoted 11 lines · Oleksandr Andrushchenko
Quoted 8 lines · Nishka Dasgupta

Static structure fb_funcs, of type drm_framebuffer_funcs, is used only when it is passed to drm_gem_fb_create_with_funcs() as its last argument. drm_gem_fb_create_with_funcs does not modify its lst argument (fb_funcs) and hence fb_funcs is never modified. Therefore make fb_funcs constant to protect it from further modification.
Issue found with Coccinelle.

I'm assuming you'll apply this to drm-misc-next too? Good to state that, to avoid confusion and coordination issues.
-Daniel

Quoted 16 lines
Quoted 15 lines
---
  drivers/gpu/drm/xen/xen_drm_front_kms.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/xen/xen_drm_front_kms.c +1 -1
index c2955d375394..4a984f45555e 100644
@@ -45,7 +45,7 @@ static void fb_destroy(struct drm_framebuffer *fb)
  	drm_gem_fb_destroy(fb);
  }
-static struct drm_framebuffer_funcs fb_funcs = {
+static const struct drm_framebuffer_funcs fb_funcs = {
  	.destroy = fb_destroy,
  };
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#3 lore raw
Quoted 9 lines · Daniel Vetter
Quoted 8 lines · Oleksandr Andrushchenko
Quoted 7 lines · Nishka Dasgupta

Static structure fb_funcs, of type drm_framebuffer_funcs, is used only when it is passed to drm_gem_fb_create_with_funcs() as its last argument. drm_gem_fb_create_with_funcs does not modify its lst argument (fb_funcs) and hence fb_funcs is never modified. Therefore make fb_funcs constant to protect it from further modification.
Issue found with Coccinelle.

Quoted 6 lines
Quoted 2 lines
Quoted 1 line

I'm assuming you'll apply this to drm-misc-next too? Good to state that, to avoid confusion and coordination issues.
-Daniel

Sorry for the delay and confusion.
Applied to drm-misc-next

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
---
   drivers/gpu/drm/xen/xen_drm_front_kms.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 11 lines
Quoted 11 lines

drivers/gpu/drm/xen/xen_drm_front_kms.c static void fb_destroy(struct drm_framebuffer *fb) · line 49

Quoted 11 lines
drivers/gpu/drm/xen/xen_drm_front_kms.c +1 -1
index c2955d375394..4a984f45555e 100644
@@ -45,7 +45,7 @@ static void fb_destroy(struct drm_framebuffer *fb)
   	drm_gem_fb_destroy(fb);
   }
-static struct drm_framebuffer_funcs fb_funcs = {
+static const struct drm_framebuffer_funcs fb_funcs = {
   	.destroy = fb_destroy,
   };

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel