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


Groups > linux.kernel > #1510566 > unrolled thread

[PATCH] fs: dlm: lockspace: constify kset_uevent_ops structures

Started byBhumika Goyal <bhumirks@gmail.com>
First post2016-10-27 20:30 +0200
Last post2016-10-27 22:10 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] fs: dlm: lockspace: constify kset_uevent_ops structures Bhumika Goyal <bhumirks@gmail.com> - 2016-10-27 20:30 +0200
    Re: [PATCH] fs: dlm: lockspace: constify kset_uevent_ops  structures Julia Lawall <julia.lawall@lip6.fr> - 2016-10-27 22:10 +0200

#1510566 — [PATCH] fs: dlm: lockspace: constify kset_uevent_ops structures

FromBhumika Goyal <bhumirks@gmail.com>
Date2016-10-27 20:30 +0200
Subject[PATCH] fs: dlm: lockspace: constify kset_uevent_ops structures
Message-ID<swXB7-5us-29@gated-at.bofh.it>
Declare kset_uevent_ops structure as const as it is only passed as
the second argument to the function kset_create_and_add. This
argument is of type const struct kset_uevent_ops *, so kset_uevent_ops 
structures having this property can be declared const.
Done using Coccinelle:

@r1 disable optional_qualifier @
identifier i;
position p;
@@
static struct kset_uevent_ops i@p = {...};

@ok1@
identifier r1.i;
position p;
expression e1,e2;
@@
kset_create_and_add(e1,&i@p,e2)

@bad@
position p!={r1.p,ok1.p};
identifier r1.i;
@@
i@p

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
static
+const
struct kset_uevent_ops i={...};

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
+const
struct kset_uevent_ops i;

File size before:
   text	   data	    bss	    dec	    hex	filename
   8034	    528	    484	   9046	   2356	fs/dlm/lockspace.o

File size after:
   text	   data	    bss	    dec	    hex	filename
   8050	    496	    484	   9030	   2346	fs/dlm/lockspace.o

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
---
 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 f3e7278..2ea1b77 100644
--- a/fs/dlm/lockspace.c
+++ b/fs/dlm/lockspace.c
@@ -233,7 +233,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,
 };
 
-- 
1.9.1

[toc] | [next] | [standalone]


#1510619 — Re: [PATCH] fs: dlm: lockspace: constify kset_uevent_ops structures

FromJulia Lawall <julia.lawall@lip6.fr>
Date2016-10-27 22:10 +0200
SubjectRe: [PATCH] fs: dlm: lockspace: constify kset_uevent_ops structures
Message-ID<swZ9U-6wz-15@gated-at.bofh.it>
In reply to#1510566

On Thu, 27 Oct 2016, Bhumika Goyal wrote:

> Declare kset_uevent_ops structure as const as it is only passed as
> the second argument to the function kset_create_and_add. This
> argument is of type const struct kset_uevent_ops *, so kset_uevent_ops
> structures having this property can be declared const.
> Done using Coccinelle:
>
> @r1 disable optional_qualifier @
> identifier i;
> position p;
> @@
> static struct kset_uevent_ops i@p = {...};
>
> @ok1@
> identifier r1.i;
> position p;
> expression e1,e2;
> @@
> kset_create_and_add(e1,&i@p,e2)
>
> @bad@
> position p!={r1.p,ok1.p};
> identifier r1.i;
> @@
> i@p
>
> @depends on !bad disable optional_qualifier@
> identifier r1.i;
> @@
> static
> +const
> struct kset_uevent_ops i={...};
>
> @depends on !bad disable optional_qualifier@
> identifier r1.i;
> @@
> +const
> struct kset_uevent_ops i;
>
> File size before:
>    text	   data	    bss	    dec	    hex	filename
>    8034	    528	    484	   9046	   2356	fs/dlm/lockspace.o
>
> File size after:
>    text	   data	    bss	    dec	    hex	filename
>    8050	    496	    484	   9030	   2346	fs/dlm/lockspace.o
>
> Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>

Acked-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 f3e7278..2ea1b77 100644
> --- a/fs/dlm/lockspace.c
> +++ b/fs/dlm/lockspace.c
> @@ -233,7 +233,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,
>  };
>
> --
> 1.9.1
>
>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web