All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] vhost: scsi: constify target_core_fabric_ops structures
@ 2017-01-09 15:21 Bhumika Goyal
  0 siblings, 0 replies; 10+ messages in thread
From: Bhumika Goyal @ 2017-01-09 15:21 UTC (permalink / raw)
  To: julia.lawall, mst, jasowang, kvm, virtualization, netdev, linux-kernel
  Cc: Bhumika Goyal

Declare target_core_fabric_ops strucrues as const as they are only
passed as an argument to the functions target_register_template and 
target_unregister_template. The arguments are of type const struct 
target_core_fabric_ops *, so target_core_fabric_ops structures having 
this property can be declared const.
Done using Coccinelle:

@r disable optional_qualifier@
identifier i;
position p;
@@
static struct target_core_fabric_ops i@p={...};

@ok@
position p;
identifier r.i;
@@
(
target_register_template(&i@p)
|
target_unregister_template(&i@p)
)
@bad@
position p!={r.p,ok.p};
identifier r.i;
@@
i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
+const
struct target_core_fabric_ops i;

File size before: drivers/vhost/scsi.o
   text	   data	    bss	    dec	    hex	filename
  18063	   2985	     40	  21088	   5260	drivers/vhost/scsi.o

File size after: drivers/vhost/scsi.o
   text	   data	    bss	    dec	    hex	filename
  18479	   2601	     40	  21120	   5280	drivers/vhost/scsi.o

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
---
 drivers/vhost/scsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
index 253310c..620366d 100644
--- a/drivers/vhost/scsi.c
+++ b/drivers/vhost/scsi.c
@@ -2087,7 +2087,7 @@ static void vhost_scsi_drop_tport(struct se_wwn *wwn)
 	NULL,
 };
 
-static struct target_core_fabric_ops vhost_scsi_ops = {
+static const struct target_core_fabric_ops vhost_scsi_ops = {
 	.module				= THIS_MODULE,
 	.name				= "vhost",
 	.get_fabric_name		= vhost_scsi_get_fabric_name,
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] vhost: scsi: constify target_core_fabric_ops structures
  2017-01-10 12:41   ` Bhumika Goyal
@ 2017-01-10 15:13       ` Michael S. Tsirkin
  0 siblings, 0 replies; 10+ messages in thread
From: Michael S. Tsirkin @ 2017-01-10 15:13 UTC (permalink / raw)
  To: Bhumika Goyal
  Cc: Julia Lawall, jasowang, kvm, virtualization, netdev, linux-kernel

On Tue, Jan 10, 2017 at 06:11:25PM +0530, Bhumika Goyal wrote:
> On Tue, Jan 10, 2017 at 10:41 AM, Michael S. Tsirkin <mst@redhat.com> wrote:
> > On Mon, Jan 09, 2017 at 08:51:02PM +0530, Bhumika Goyal wrote:
> >> Declare target_core_fabric_ops strucrues as const as they are only
> >> passed as an argument to the functions target_register_template and
> >> target_unregister_template. The arguments are of type const struct
> >> target_core_fabric_ops *, so target_core_fabric_ops structures having
> >> this property can be declared const.
> >> Done using Coccinelle:
> >>
> >> @r disable optional_qualifier@
> >> identifier i;
> >> position p;
> >> @@
> >> static struct target_core_fabric_ops i@p={...};
> >>
> >> @ok@
> >> position p;
> >> identifier r.i;
> >> @@
> >> (
> >> target_register_template(&i@p)
> >> |
> >> target_unregister_template(&i@p)
> >> )
> >> @bad@
> >> position p!={r.p,ok.p};
> >> identifier r.i;
> >> @@
> >> i@p
> >>
> >> @depends on !bad disable optional_qualifier@
> >> identifier r.i;
> >> @@
> >> +const
> >> struct target_core_fabric_ops i;
> >>
> >> File size before: drivers/vhost/scsi.o
> >>    text          data     bss     dec     hex filename
> >>   18063          2985      40   21088    5260 drivers/vhost/scsi.o
> >>
> >> File size after: drivers/vhost/scsi.o
> >>    text          data     bss     dec     hex filename
> >>   18479          2601      40   21120    5280 drivers/vhost/scsi.o
> >
> > What are these numbers trying to prove?
> >
> 
> These numbers show that adding const has decreased the size of the
> data segment and increased the size of the text segment, suggesting
> that the changed code has been compiled and the const annotation has
> had an effect.
> 
> Thanks,
> Bhumika

I wonder why there's a net increase in memory consumption though.


> >
> >> Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
> >> ---
> >>  drivers/vhost/scsi.c | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
> >> index 253310c..620366d 100644
> >> --- a/drivers/vhost/scsi.c
> >> +++ b/drivers/vhost/scsi.c
> >> @@ -2087,7 +2087,7 @@ static void vhost_scsi_drop_tport(struct se_wwn *wwn)
> >>       NULL,
> >>  };
> >>
> >> -static struct target_core_fabric_ops vhost_scsi_ops = {
> >> +static const struct target_core_fabric_ops vhost_scsi_ops = {
> >>       .module                         = THIS_MODULE,
> >>       .name                           = "vhost",
> >>       .get_fabric_name                = vhost_scsi_get_fabric_name,
> >
> > If it can be const it probably should ...
> >
> >> --
> >> 1.9.1

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] vhost: scsi: constify target_core_fabric_ops structures
@ 2017-01-10 15:13       ` Michael S. Tsirkin
  0 siblings, 0 replies; 10+ messages in thread
From: Michael S. Tsirkin @ 2017-01-10 15:13 UTC (permalink / raw)
  To: Bhumika Goyal; +Cc: kvm, netdev, linux-kernel, virtualization, Julia Lawall

On Tue, Jan 10, 2017 at 06:11:25PM +0530, Bhumika Goyal wrote:
> On Tue, Jan 10, 2017 at 10:41 AM, Michael S. Tsirkin <mst@redhat.com> wrote:
> > On Mon, Jan 09, 2017 at 08:51:02PM +0530, Bhumika Goyal wrote:
> >> Declare target_core_fabric_ops strucrues as const as they are only
> >> passed as an argument to the functions target_register_template and
> >> target_unregister_template. The arguments are of type const struct
> >> target_core_fabric_ops *, so target_core_fabric_ops structures having
> >> this property can be declared const.
> >> Done using Coccinelle:
> >>
> >> @r disable optional_qualifier@
> >> identifier i;
> >> position p;
> >> @@
> >> static struct target_core_fabric_ops i@p={...};
> >>
> >> @ok@
> >> position p;
> >> identifier r.i;
> >> @@
> >> (
> >> target_register_template(&i@p)
> >> |
> >> target_unregister_template(&i@p)
> >> )
> >> @bad@
> >> position p!={r.p,ok.p};
> >> identifier r.i;
> >> @@
> >> i@p
> >>
> >> @depends on !bad disable optional_qualifier@
> >> identifier r.i;
> >> @@
> >> +const
> >> struct target_core_fabric_ops i;
> >>
> >> File size before: drivers/vhost/scsi.o
> >>    text          data     bss     dec     hex filename
> >>   18063          2985      40   21088    5260 drivers/vhost/scsi.o
> >>
> >> File size after: drivers/vhost/scsi.o
> >>    text          data     bss     dec     hex filename
> >>   18479          2601      40   21120    5280 drivers/vhost/scsi.o
> >
> > What are these numbers trying to prove?
> >
> 
> These numbers show that adding const has decreased the size of the
> data segment and increased the size of the text segment, suggesting
> that the changed code has been compiled and the const annotation has
> had an effect.
> 
> Thanks,
> Bhumika

I wonder why there's a net increase in memory consumption though.


> >
> >> Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
> >> ---
> >>  drivers/vhost/scsi.c | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
> >> index 253310c..620366d 100644
> >> --- a/drivers/vhost/scsi.c
> >> +++ b/drivers/vhost/scsi.c
> >> @@ -2087,7 +2087,7 @@ static void vhost_scsi_drop_tport(struct se_wwn *wwn)
> >>       NULL,
> >>  };
> >>
> >> -static struct target_core_fabric_ops vhost_scsi_ops = {
> >> +static const struct target_core_fabric_ops vhost_scsi_ops = {
> >>       .module                         = THIS_MODULE,
> >>       .name                           = "vhost",
> >>       .get_fabric_name                = vhost_scsi_get_fabric_name,
> >
> > If it can be const it probably should ...
> >
> >> --
> >> 1.9.1

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] vhost: scsi: constify target_core_fabric_ops structures
  2017-01-10  5:11   ` Michael S. Tsirkin
  (?)
@ 2017-01-10 12:41   ` Bhumika Goyal
  2017-01-10 15:13       ` Michael S. Tsirkin
  -1 siblings, 1 reply; 10+ messages in thread
From: Bhumika Goyal @ 2017-01-10 12:41 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Julia Lawall, jasowang, kvm, virtualization, netdev, linux-kernel

On Tue, Jan 10, 2017 at 10:41 AM, Michael S. Tsirkin <mst@redhat.com> wrote:
> On Mon, Jan 09, 2017 at 08:51:02PM +0530, Bhumika Goyal wrote:
>> Declare target_core_fabric_ops strucrues as const as they are only
>> passed as an argument to the functions target_register_template and
>> target_unregister_template. The arguments are of type const struct
>> target_core_fabric_ops *, so target_core_fabric_ops structures having
>> this property can be declared const.
>> Done using Coccinelle:
>>
>> @r disable optional_qualifier@
>> identifier i;
>> position p;
>> @@
>> static struct target_core_fabric_ops i@p={...};
>>
>> @ok@
>> position p;
>> identifier r.i;
>> @@
>> (
>> target_register_template(&i@p)
>> |
>> target_unregister_template(&i@p)
>> )
>> @bad@
>> position p!={r.p,ok.p};
>> identifier r.i;
>> @@
>> i@p
>>
>> @depends on !bad disable optional_qualifier@
>> identifier r.i;
>> @@
>> +const
>> struct target_core_fabric_ops i;
>>
>> File size before: drivers/vhost/scsi.o
>>    text          data     bss     dec     hex filename
>>   18063          2985      40   21088    5260 drivers/vhost/scsi.o
>>
>> File size after: drivers/vhost/scsi.o
>>    text          data     bss     dec     hex filename
>>   18479          2601      40   21120    5280 drivers/vhost/scsi.o
>
> What are these numbers trying to prove?
>

These numbers show that adding const has decreased the size of the
data segment and increased the size of the text segment, suggesting
that the changed code has been compiled and the const annotation has
had an effect.

Thanks,
Bhumika

>
>> Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
>> ---
>>  drivers/vhost/scsi.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
>> index 253310c..620366d 100644
>> --- a/drivers/vhost/scsi.c
>> +++ b/drivers/vhost/scsi.c
>> @@ -2087,7 +2087,7 @@ static void vhost_scsi_drop_tport(struct se_wwn *wwn)
>>       NULL,
>>  };
>>
>> -static struct target_core_fabric_ops vhost_scsi_ops = {
>> +static const struct target_core_fabric_ops vhost_scsi_ops = {
>>       .module                         = THIS_MODULE,
>>       .name                           = "vhost",
>>       .get_fabric_name                = vhost_scsi_get_fabric_name,
>
> If it can be const it probably should ...
>
>> --
>> 1.9.1

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] vhost: scsi: constify target_core_fabric_ops structures
  2017-01-10  5:11   ` Michael S. Tsirkin
  (?)
  (?)
@ 2017-01-10 12:41   ` Bhumika Goyal
  -1 siblings, 0 replies; 10+ messages in thread
From: Bhumika Goyal @ 2017-01-10 12:41 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: kvm, netdev, linux-kernel, virtualization, Julia Lawall

On Tue, Jan 10, 2017 at 10:41 AM, Michael S. Tsirkin <mst@redhat.com> wrote:
> On Mon, Jan 09, 2017 at 08:51:02PM +0530, Bhumika Goyal wrote:
>> Declare target_core_fabric_ops strucrues as const as they are only
>> passed as an argument to the functions target_register_template and
>> target_unregister_template. The arguments are of type const struct
>> target_core_fabric_ops *, so target_core_fabric_ops structures having
>> this property can be declared const.
>> Done using Coccinelle:
>>
>> @r disable optional_qualifier@
>> identifier i;
>> position p;
>> @@
>> static struct target_core_fabric_ops i@p={...};
>>
>> @ok@
>> position p;
>> identifier r.i;
>> @@
>> (
>> target_register_template(&i@p)
>> |
>> target_unregister_template(&i@p)
>> )
>> @bad@
>> position p!={r.p,ok.p};
>> identifier r.i;
>> @@
>> i@p
>>
>> @depends on !bad disable optional_qualifier@
>> identifier r.i;
>> @@
>> +const
>> struct target_core_fabric_ops i;
>>
>> File size before: drivers/vhost/scsi.o
>>    text          data     bss     dec     hex filename
>>   18063          2985      40   21088    5260 drivers/vhost/scsi.o
>>
>> File size after: drivers/vhost/scsi.o
>>    text          data     bss     dec     hex filename
>>   18479          2601      40   21120    5280 drivers/vhost/scsi.o
>
> What are these numbers trying to prove?
>

These numbers show that adding const has decreased the size of the
data segment and increased the size of the text segment, suggesting
that the changed code has been compiled and the const annotation has
had an effect.

Thanks,
Bhumika

>
>> Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
>> ---
>>  drivers/vhost/scsi.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
>> index 253310c..620366d 100644
>> --- a/drivers/vhost/scsi.c
>> +++ b/drivers/vhost/scsi.c
>> @@ -2087,7 +2087,7 @@ static void vhost_scsi_drop_tport(struct se_wwn *wwn)
>>       NULL,
>>  };
>>
>> -static struct target_core_fabric_ops vhost_scsi_ops = {
>> +static const struct target_core_fabric_ops vhost_scsi_ops = {
>>       .module                         = THIS_MODULE,
>>       .name                           = "vhost",
>>       .get_fabric_name                = vhost_scsi_get_fabric_name,
>
> If it can be const it probably should ...
>
>> --
>> 1.9.1

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] vhost: scsi: constify target_core_fabric_ops structures
  2017-01-09 15:21 Bhumika Goyal
@ 2017-01-10  5:11   ` Michael S. Tsirkin
  2017-01-10  5:11   ` Michael S. Tsirkin
  1 sibling, 0 replies; 10+ messages in thread
From: Michael S. Tsirkin @ 2017-01-10  5:11 UTC (permalink / raw)
  To: Bhumika Goyal
  Cc: julia.lawall, jasowang, kvm, virtualization, netdev, linux-kernel

On Mon, Jan 09, 2017 at 08:51:02PM +0530, Bhumika Goyal wrote:
> Declare target_core_fabric_ops strucrues as const as they are only
> passed as an argument to the functions target_register_template and 
> target_unregister_template. The arguments are of type const struct 
> target_core_fabric_ops *, so target_core_fabric_ops structures having 
> this property can be declared const.
> Done using Coccinelle:
> 
> @r disable optional_qualifier@
> identifier i;
> position p;
> @@
> static struct target_core_fabric_ops i@p={...};
> 
> @ok@
> position p;
> identifier r.i;
> @@
> (
> target_register_template(&i@p)
> |
> target_unregister_template(&i@p)
> )
> @bad@
> position p!={r.p,ok.p};
> identifier r.i;
> @@
> i@p
> 
> @depends on !bad disable optional_qualifier@
> identifier r.i;
> @@
> +const
> struct target_core_fabric_ops i;
> 
> File size before: drivers/vhost/scsi.o
>    text	   data	    bss	    dec	    hex	filename
>   18063	   2985	     40	  21088	   5260	drivers/vhost/scsi.o
> 
> File size after: drivers/vhost/scsi.o
>    text	   data	    bss	    dec	    hex	filename
>   18479	   2601	     40	  21120	   5280	drivers/vhost/scsi.o

What are these numbers trying to prove?


> Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
> ---
>  drivers/vhost/scsi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
> index 253310c..620366d 100644
> --- a/drivers/vhost/scsi.c
> +++ b/drivers/vhost/scsi.c
> @@ -2087,7 +2087,7 @@ static void vhost_scsi_drop_tport(struct se_wwn *wwn)
>  	NULL,
>  };
>  
> -static struct target_core_fabric_ops vhost_scsi_ops = {
> +static const struct target_core_fabric_ops vhost_scsi_ops = {
>  	.module				= THIS_MODULE,
>  	.name				= "vhost",
>  	.get_fabric_name		= vhost_scsi_get_fabric_name,

If it can be const it probably should ...

> -- 
> 1.9.1

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] vhost: scsi: constify target_core_fabric_ops structures
@ 2017-01-10  5:11   ` Michael S. Tsirkin
  0 siblings, 0 replies; 10+ messages in thread
From: Michael S. Tsirkin @ 2017-01-10  5:11 UTC (permalink / raw)
  To: Bhumika Goyal; +Cc: kvm, netdev, linux-kernel, virtualization, julia.lawall

On Mon, Jan 09, 2017 at 08:51:02PM +0530, Bhumika Goyal wrote:
> Declare target_core_fabric_ops strucrues as const as they are only
> passed as an argument to the functions target_register_template and 
> target_unregister_template. The arguments are of type const struct 
> target_core_fabric_ops *, so target_core_fabric_ops structures having 
> this property can be declared const.
> Done using Coccinelle:
> 
> @r disable optional_qualifier@
> identifier i;
> position p;
> @@
> static struct target_core_fabric_ops i@p={...};
> 
> @ok@
> position p;
> identifier r.i;
> @@
> (
> target_register_template(&i@p)
> |
> target_unregister_template(&i@p)
> )
> @bad@
> position p!={r.p,ok.p};
> identifier r.i;
> @@
> i@p
> 
> @depends on !bad disable optional_qualifier@
> identifier r.i;
> @@
> +const
> struct target_core_fabric_ops i;
> 
> File size before: drivers/vhost/scsi.o
>    text	   data	    bss	    dec	    hex	filename
>   18063	   2985	     40	  21088	   5260	drivers/vhost/scsi.o
> 
> File size after: drivers/vhost/scsi.o
>    text	   data	    bss	    dec	    hex	filename
>   18479	   2601	     40	  21120	   5280	drivers/vhost/scsi.o

What are these numbers trying to prove?


> Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
> ---
>  drivers/vhost/scsi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
> index 253310c..620366d 100644
> --- a/drivers/vhost/scsi.c
> +++ b/drivers/vhost/scsi.c
> @@ -2087,7 +2087,7 @@ static void vhost_scsi_drop_tport(struct se_wwn *wwn)
>  	NULL,
>  };
>  
> -static struct target_core_fabric_ops vhost_scsi_ops = {
> +static const struct target_core_fabric_ops vhost_scsi_ops = {
>  	.module				= THIS_MODULE,
>  	.name				= "vhost",
>  	.get_fabric_name		= vhost_scsi_get_fabric_name,

If it can be const it probably should ...

> -- 
> 1.9.1

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] vhost: scsi: constify target_core_fabric_ops structures
  2017-01-09 15:21 Bhumika Goyal
@ 2017-01-10  2:50   ` Jason Wang
  2017-01-10  5:11   ` Michael S. Tsirkin
  1 sibling, 0 replies; 10+ messages in thread
From: Jason Wang @ 2017-01-10  2:50 UTC (permalink / raw)
  To: Bhumika Goyal, julia.lawall, mst, kvm, virtualization, netdev,
	linux-kernel



On 2017年01月09日 23:21, Bhumika Goyal wrote:
> Declare target_core_fabric_ops strucrues as const as they are only
> passed as an argument to the functions target_register_template and
> target_unregister_template. The arguments are of type const struct
> target_core_fabric_ops *, so target_core_fabric_ops structures having
> this property can be declared const.
> Done using Coccinelle:
>
> @r disable optional_qualifier@
> identifier i;
> position p;
> @@
> static struct target_core_fabric_ops i@p={...};
>
> @ok@
> position p;
> identifier r.i;
> @@
> (
> target_register_template(&i@p)
> |
> target_unregister_template(&i@p)
> )
> @bad@
> position p!={r.p,ok.p};
> identifier r.i;
> @@
> i@p
>
> @depends on !bad disable optional_qualifier@
> identifier r.i;
> @@
> +const
> struct target_core_fabric_ops i;
>
> File size before: drivers/vhost/scsi.o
>     text	   data	    bss	    dec	    hex	filename
>    18063	   2985	     40	  21088	   5260	drivers/vhost/scsi.o
>
> File size after: drivers/vhost/scsi.o
>     text	   data	    bss	    dec	    hex	filename
>    18479	   2601	     40	  21120	   5280	drivers/vhost/scsi.o
>
> Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
> ---
>   drivers/vhost/scsi.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
> index 253310c..620366d 100644
> --- a/drivers/vhost/scsi.c
> +++ b/drivers/vhost/scsi.c
> @@ -2087,7 +2087,7 @@ static void vhost_scsi_drop_tport(struct se_wwn *wwn)
>   	NULL,
>   };
>   
> -static struct target_core_fabric_ops vhost_scsi_ops = {
> +static const struct target_core_fabric_ops vhost_scsi_ops = {
>   	.module				= THIS_MODULE,
>   	.name				= "vhost",
>   	.get_fabric_name		= vhost_scsi_get_fabric_name,

Acked-by: Jason Wang <jasowang@redhat.com>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] vhost: scsi: constify target_core_fabric_ops structures
@ 2017-01-10  2:50   ` Jason Wang
  0 siblings, 0 replies; 10+ messages in thread
From: Jason Wang @ 2017-01-10  2:50 UTC (permalink / raw)
  To: Bhumika Goyal, julia.lawall, mst, kvm, virtualization, netdev,
	linux-kernel



On 2017年01月09日 23:21, Bhumika Goyal wrote:
> Declare target_core_fabric_ops strucrues as const as they are only
> passed as an argument to the functions target_register_template and
> target_unregister_template. The arguments are of type const struct
> target_core_fabric_ops *, so target_core_fabric_ops structures having
> this property can be declared const.
> Done using Coccinelle:
>
> @r disable optional_qualifier@
> identifier i;
> position p;
> @@
> static struct target_core_fabric_ops i@p={...};
>
> @ok@
> position p;
> identifier r.i;
> @@
> (
> target_register_template(&i@p)
> |
> target_unregister_template(&i@p)
> )
> @bad@
> position p!={r.p,ok.p};
> identifier r.i;
> @@
> i@p
>
> @depends on !bad disable optional_qualifier@
> identifier r.i;
> @@
> +const
> struct target_core_fabric_ops i;
>
> File size before: drivers/vhost/scsi.o
>     text	   data	    bss	    dec	    hex	filename
>    18063	   2985	     40	  21088	   5260	drivers/vhost/scsi.o
>
> File size after: drivers/vhost/scsi.o
>     text	   data	    bss	    dec	    hex	filename
>    18479	   2601	     40	  21120	   5280	drivers/vhost/scsi.o
>
> Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
> ---
>   drivers/vhost/scsi.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
> index 253310c..620366d 100644
> --- a/drivers/vhost/scsi.c
> +++ b/drivers/vhost/scsi.c
> @@ -2087,7 +2087,7 @@ static void vhost_scsi_drop_tport(struct se_wwn *wwn)
>   	NULL,
>   };
>   
> -static struct target_core_fabric_ops vhost_scsi_ops = {
> +static const struct target_core_fabric_ops vhost_scsi_ops = {
>   	.module				= THIS_MODULE,
>   	.name				= "vhost",
>   	.get_fabric_name		= vhost_scsi_get_fabric_name,

Acked-by: Jason Wang <jasowang@redhat.com>
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH] vhost: scsi: constify target_core_fabric_ops structures
@ 2017-01-09 15:21 Bhumika Goyal
  2017-01-10  2:50   ` Jason Wang
  2017-01-10  5:11   ` Michael S. Tsirkin
  0 siblings, 2 replies; 10+ messages in thread
From: Bhumika Goyal @ 2017-01-09 15:21 UTC (permalink / raw)
  To: julia.lawall, mst, jasowang, kvm, virtualization, netdev, linux-kernel
  Cc: Bhumika Goyal

Declare target_core_fabric_ops strucrues as const as they are only
passed as an argument to the functions target_register_template and 
target_unregister_template. The arguments are of type const struct 
target_core_fabric_ops *, so target_core_fabric_ops structures having 
this property can be declared const.
Done using Coccinelle:

@r disable optional_qualifier@
identifier i;
position p;
@@
static struct target_core_fabric_ops i@p={...};

@ok@
position p;
identifier r.i;
@@
(
target_register_template(&i@p)
|
target_unregister_template(&i@p)
)
@bad@
position p!={r.p,ok.p};
identifier r.i;
@@
i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
+const
struct target_core_fabric_ops i;

File size before: drivers/vhost/scsi.o
   text	   data	    bss	    dec	    hex	filename
  18063	   2985	     40	  21088	   5260	drivers/vhost/scsi.o

File size after: drivers/vhost/scsi.o
   text	   data	    bss	    dec	    hex	filename
  18479	   2601	     40	  21120	   5280	drivers/vhost/scsi.o

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
---
 drivers/vhost/scsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
index 253310c..620366d 100644
--- a/drivers/vhost/scsi.c
+++ b/drivers/vhost/scsi.c
@@ -2087,7 +2087,7 @@ static void vhost_scsi_drop_tport(struct se_wwn *wwn)
 	NULL,
 };
 
-static struct target_core_fabric_ops vhost_scsi_ops = {
+static const struct target_core_fabric_ops vhost_scsi_ops = {
 	.module				= THIS_MODULE,
 	.name				= "vhost",
 	.get_fabric_name		= vhost_scsi_get_fabric_name,
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-01-10 15:13 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-09 15:21 [PATCH] vhost: scsi: constify target_core_fabric_ops structures Bhumika Goyal
  -- strict thread matches above, loose matches on Subject: below --
2017-01-09 15:21 Bhumika Goyal
2017-01-10  2:50 ` Jason Wang
2017-01-10  2:50   ` Jason Wang
2017-01-10  5:11 ` Michael S. Tsirkin
2017-01-10  5:11   ` Michael S. Tsirkin
2017-01-10 12:41   ` Bhumika Goyal
2017-01-10 15:13     ` Michael S. Tsirkin
2017-01-10 15:13       ` Michael S. Tsirkin
2017-01-10 12:41   ` Bhumika Goyal

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.