OSDN Git Service

fs: xfs: xfs_icreate_item: constify xfs_item_ops structure
authorBhumika Goyal <bhumirks@gmail.com>
Mon, 28 Nov 2016 03:57:42 +0000 (14:57 +1100)
committerDave Chinner <david@fromorbit.com>
Mon, 28 Nov 2016 03:57:42 +0000 (14:57 +1100)
commitbb6e0ebed7f7474e0e44cf6b778ee2fda759ddd6
tree5e298f288a0c566816f51ce3b84ea1f2c8ec1091
parentfd26a88093bab6529ea2de819114ca92dbd1d71d
fs: xfs: xfs_icreate_item: constify xfs_item_ops structure

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>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
fs/xfs/xfs_icreate_item.c