Skip to contentSkip to conversation

fix debugfs_simple_attr.cocci warnings (fwd)

PATCH New Julia Lawall 1 participant 1 message Aug 3, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix debugfs_simple_attr.cocci warnings (fwd)

I know nothing about the issues behind this, but I'm forwarding it in case it's useful.

julia

---------- Forwarded message ----------
Date: Wed, 3 Aug 2016 13:26:56 +0800
From: kbuild test robot <[email protected]>
To: [email protected]
Cc: Julia Lawall <[email protected]>
Subject: [PATCH] fix debugfs_simple_attr.cocci warnings

CC: [email protected]
In-Reply-To: <[email protected]>
TO: Andi Kleen <[email protected]>
CC: [email protected], [email protected], Andi Kleen <[email protected]>
CC: [email protected], Andi Kleen <[email protected]>

kernel/panic.c:561:0-23: WARNING: clear_warn_once_fops should be defined with DEFINE_DEBUGFS_ATTRIBUTE

Use DEFINE_DEBUGFS_ATTRIBUTE rather than DEFINE_SIMPLE_ATTRIBUTE for debugfs files.

Semantic patch information:
Rationale: DEFINE_SIMPLE_ATTRIBUTE + debugfs_create_file() imposes some significant overhead as compared to DEFINE_DEBUGFS_ATTRIBUTE + debugfs_create_file_unsafe().

Generated by: scripts/coccinelle/api/debugfs/debugfs_simple_attr.cocci

---

Please take the patch only if it's a positive warning. Thanks!

 panic.c |   10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
kernel/panic.c +4 -6
@@ -558,16 +558,14 @@ static int clear_warn_once_set(void *dat
 	return 0;
 }
 
-DEFINE_SIMPLE_ATTRIBUTE(clear_warn_once_fops,
-			NULL,
-                        clear_warn_once_set,
-		        "%lld\n");
+DEFINE_DEBUGFS_ATTRIBUTE(clear_warn_once_fops, NULL, clear_warn_once_set,
+			 "%lld\n");
 
 static __init int register_warn_debugfs(void)
 {
 	/* Don't care about failure */
-	debugfs_create_file("clear_warn_once", 0644, NULL,
-			    NULL, &clear_warn_once_fops);
+	debugfs_create_file_unsafe("clear_warn_once", 0644, NULL, NULL,
+				   &clear_warn_once_fops);
 	return 0;
 }