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


Groups > linux.kernel > #1699273

[PATCH] dlm: constify kset_uevent_ops structure

From Julia Lawall <Julia.Lawall@lip6.fr>
Newsgroups linux.kernel
Subject [PATCH] dlm: constify kset_uevent_ops structure
Date 2017-07-29 11:20 +0200
Message-ID <u8w4G-7n-9@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


The kset_uevent_ops structure is only passed as the second argument
to kset_create_and_add, which is declared as const.  Thus the
kset_uevent_ops structure itself can be const.

Done with the help of Coccinelle.

// <smpl>
@r disable optional_qualifier@
identifier i;
position p;
@@
static struct kset_uevent_ops i@p = { ... };

@ok1@
identifier r.i;
expression e;
position p;
@@
 kset_create_and_add(e,&i@p,...)

@bad@
position p != {r.p,ok1.p};
identifier r.i;
struct kset_uevent_ops e;
@@
e@i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
 struct kset_uevent_ops i = { ... };
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 fs/dlm/lockspace.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c
index 9ebfa05..78a7c85 100644
--- a/fs/dlm/lockspace.c
+++ b/fs/dlm/lockspace.c
@@ -235,7 +235,7 @@ static int dlm_uevent(struct kset *kset, struct kobject *kobj,
 	return 0;
 }
 
-static struct kset_uevent_ops dlm_uevent_ops = {
+static const struct kset_uevent_ops dlm_uevent_ops = {
 	.uevent = dlm_uevent,
 };
 

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH] dlm: constify kset_uevent_ops structure Julia Lawall <Julia.Lawall@lip6.fr> - 2017-07-29 11:20 +0200

csiph-web