linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fs: xfs: xfs_icreate_item: constify xfs_item_ops structure
@ 2016-11-19 13:16 Bhumika Goyal
  2016-11-20  3:39 ` Eric Sandeen
  0 siblings, 1 reply; 2+ messages in thread
From: Bhumika Goyal @ 2016-11-19 13:16 UTC (permalink / raw)
  To: julia.lawall, david, linux-xfs, linux-kernel; +Cc: Bhumika Goyal

Declare the structure xfs_item_ops as const as it is only passed as an
argument to the function xfs_log_item_init. As this argument is of type
const struct xfs_item_ops *, so xfs_item_ops structures having this
property can be declared as const.
Done using Coccinelle:

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

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

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

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

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

File size before:
   text	   data	    bss	    dec	    hex	filename
    737	     64	      8	    809	    329	fs/xfs/xfs_icreate_item.o

File size after:
   text	   data	    bss	    dec	    hex	filename
    801	      0	      8	    809	    329	fs/xfs/xfs_icreate_item.o

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

diff --git a/fs/xfs/xfs_icreate_item.c b/fs/xfs/xfs_icreate_item.c
index d45ca72..865ad13 100644
--- a/fs/xfs/xfs_icreate_item.c
+++ b/fs/xfs/xfs_icreate_item.c
@@ -133,7 +133,7 @@ static inline struct xfs_icreate_item *ICR_ITEM(struct xfs_log_item *lip)
 /*
  * This is the ops vector shared by all buf log items.
  */
-static struct xfs_item_ops xfs_icreate_item_ops = {
+static const struct xfs_item_ops xfs_icreate_item_ops = {
 	.iop_size	= xfs_icreate_item_size,
 	.iop_format	= xfs_icreate_item_format,
 	.iop_pin	= xfs_icreate_item_pin,
-- 
1.9.1

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

* Re: [PATCH] fs: xfs: xfs_icreate_item: constify xfs_item_ops structure
  2016-11-19 13:16 [PATCH] fs: xfs: xfs_icreate_item: constify xfs_item_ops structure Bhumika Goyal
@ 2016-11-20  3:39 ` Eric Sandeen
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Sandeen @ 2016-11-20  3:39 UTC (permalink / raw)
  To: Bhumika Goyal, julia.lawall, david, linux-xfs, linux-kernel


On 11/19/16 7:16 AM, Bhumika Goyal wrote:
> Declare the structure xfs_item_ops as const as it is only passed as an
> argument to the function xfs_log_item_init. As this argument is of type
> const struct xfs_item_ops *, so xfs_item_ops structures having this
> property can be declared as const.
> Done using Coccinelle:
> 
> @r1 disable optional_qualifier @
> identifier i;
> position p;
> @@
> static struct xfs_item_ops i@p = {...};
> 
> @ok1@
> identifier r1.i;
> position p;
> expression e1,e2,e3;
> @@
> xfs_log_item_init(e1,e2,e3,&i@p)
> 
> @bad@
> position p!={r1.p,ok1.p};
> identifier r1.i;
> @@
> i@p
> 
> @depends on !bad disable optional_qualifier@
> identifier r1.i;
> @@
> static
> +const
> struct xfs_item_ops i={...};
> 
> @depends on !bad disable optional_qualifier@
> identifier r1.i;
> @@
> +const
> struct xfs_item_ops i;
> 
> File size before:
>    text	   data	    bss	    dec	    hex	filename
>     737	     64	      8	    809	    329	fs/xfs/xfs_icreate_item.o
> 
> File size after:
>    text	   data	    bss	    dec	    hex	filename
>     801	      0	      8	    809	    329	fs/xfs/xfs_icreate_item.o
> 
> Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>

Sure, every other xfs_item_ops structure is a const.

Reviewed-by: Eric Sandeen <sandeen@sandeen.net>

> ---
>  fs/xfs/xfs_icreate_item.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/xfs/xfs_icreate_item.c b/fs/xfs/xfs_icreate_item.c
> index d45ca72..865ad13 100644
> --- a/fs/xfs/xfs_icreate_item.c
> +++ b/fs/xfs/xfs_icreate_item.c
> @@ -133,7 +133,7 @@ static inline struct xfs_icreate_item *ICR_ITEM(struct xfs_log_item *lip)
>  /*
>   * This is the ops vector shared by all buf log items.
>   */
> -static struct xfs_item_ops xfs_icreate_item_ops = {
> +static const struct xfs_item_ops xfs_icreate_item_ops = {
>  	.iop_size	= xfs_icreate_item_size,
>  	.iop_format	= xfs_icreate_item_format,
>  	.iop_pin	= xfs_icreate_item_pin,
> 

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

end of thread, other threads:[~2016-11-20  3:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-19 13:16 [PATCH] fs: xfs: xfs_icreate_item: constify xfs_item_ops structure Bhumika Goyal
2016-11-20  3:39 ` Eric Sandeen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).