Skip to contentSkip to conversation

notify: constify fsnotify_ops structures

PATCH New Bhumika Goyal 1 participant 1 message Jan 10, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 notify: constify fsnotify_ops structures

Declare fsnotify_ops structures as const as they are only passed as an argument to the function fsnotify_alloc_group. This argument is of type const, so fsnotify_ops structures having the same property can be declared const too.
Done using Coccinelle:

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

@ok1@
identifier r1.i;
position p;
@@
fsnotify_alloc_group(&i@p)

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

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

File size before: fs/notify/dnotify/dnotify.o
text data bss dec hex filename
2227 71 0 2298 8fa fs/notify/dnotify/dnotify.o

File size after: fs/notify/dnotify/dnotify.o
text data bss dec hex filename
2259 39 0 2298 8fa fs/notify/dnotify/dnotify.o

---
 fs/notify/dnotify/dnotify.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/notify/dnotify/dnotify.c +1 -1
index 5a4ec30..33aea5d 100644
@@ -136,7 +136,7 @@ static void dnotify_free_mark(struct fsnotify_mark *fsn_mark)
 	kmem_cache_free(dnotify_mark_cache, dn_mark);
 }
 
-static struct fsnotify_ops dnotify_fsnotify_ops = {
+static const struct fsnotify_ops dnotify_fsnotify_ops = {
 	.handle_event = dnotify_handle_event,
 };
 
Signature · 1 line
1.9.1