Skip to contentSkip to conversation

apparmor: hide unused get_loaddata_common_ref() function

PATCH In review Arnd Bergmann 3 participants 3 messages Mar 16 – Mar 18

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

PATCH 1/1 apparmor: hide unused get_loaddata_common_ref() function

From: Arnd Bergmann <[email protected]>

The newly introduced function is only used in an #ifdef block, which causes a harmless warning:

security/apparmor/apparmorfs.c:177:28: error: 'get_loaddata_common_ref' defined but not used [-Werror=unused-function]
177 | static struct aa_loaddata *get_loaddata_common_ref(struct aa_common_ref *ref)

Move the definition next to the user to avoid the warning.

Fixes 8e135b8aee5a ("apparmor: fix race between freeing data and fs accessing it")

---
Alternatively, the #ifdef checks could be replaced with an 'if(IS_ENABLED(CONFIG_SECURITY_APPARMOR_EXPORT_BINARY) return;' check in __aa_fs_create_rawdata(), relying on the compiler's dead code elimination.

---
 security/apparmor/apparmorfs.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
security/apparmor/apparmorfs.c +8 -8
index ededaf46f3ca..f762b101d682 100644
@@ -174,14 +174,6 @@ static struct aa_proxy *get_proxy_common_ref(struct aa_common_ref *ref)
 	return NULL;
 }
 
-static struct aa_loaddata *get_loaddata_common_ref(struct aa_common_ref *ref)
-{
-	if (ref)
-		return aa_get_i_loaddata(container_of(ref, struct aa_loaddata,
-						      count));
-	return NULL;
-}
-
 static void aa_put_common_ref(struct aa_common_ref *ref)
 {
 	if (!ref)
@@ -1318,6 +1310,14 @@ static const struct file_operations seq_rawdata_ ##NAME ##_fops = {	      \
 	.release	= seq_rawdata_release,				      \
 }									      \
 
+static struct aa_loaddata *get_loaddata_common_ref(struct aa_common_ref *ref)
+{
+	if (ref)
+		return aa_get_i_loaddata(container_of(ref, struct aa_loaddata,
+						      count));
+	return NULL;
+}
+
 static int seq_rawdata_open(struct inode *inode, struct file *file,
 			    int (*show)(struct seq_file *, void *))
 {
Signature · 1 line
2.39.5
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The newly introduced function is only used in an #ifdef block, which causes a harmless warning:

Quoted 7 lines

security/apparmor/apparmorfs.c:177:28: error: 'get_loaddata_common_ref' defined but not used [-Werror=unused-function]
177 | static struct aa_loaddata *get_loaddata_common_ref(struct aa_common_ref *ref)

Move the definition next to the user to avoid the warning.

Fixes 8e135b8aee5a ("apparmor: fix race between freeing data and fs accessing it")
Quoted 45 lines

---
Alternatively, the #ifdef checks could be replaced with an 'if(IS_ENABLED(CONFIG_SECURITY_APPARMOR_EXPORT_BINARY) return;' check in __aa_fs_create_rawdata(), relying on the compiler's dead code elimination.

---
 security/apparmor/apparmorfs.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
security/apparmor/apparmorfs.c +8 -8
index ededaf46f3ca..f762b101d682 100644
@@ -174,14 +174,6 @@ static struct aa_proxy *get_proxy_common_ref(struct aa_common_ref *ref)
 	return NULL;
 }
 
-static struct aa_loaddata *get_loaddata_common_ref(struct aa_common_ref *ref)
-{
-	if (ref)
-		return aa_get_i_loaddata(container_of(ref, struct aa_loaddata,
-						      count));
-	return NULL;
-}
-
 static void aa_put_common_ref(struct aa_common_ref *ref)
 {
 	if (!ref)
@@ -1318,6 +1310,14 @@ static const struct file_operations seq_rawdata_ ##NAME ##_fops = {	      \
 	.release	= seq_rawdata_release,				      \
 }									      \
 
+static struct aa_loaddata *get_loaddata_common_ref(struct aa_common_ref *ref)
+{
+	if (ref)
+		return aa_get_i_loaddata(container_of(ref, struct aa_loaddata,
+						      count));
+	return NULL;
+}
+
 static int seq_rawdata_open(struct inode *inode, struct file *file,
 			    int (*show)(struct seq_file *, void *))
 {
Signature · 1 line
2.39.5
maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Arnd Bergmann
Quoted 5 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The newly introduced function is only used in an #ifdef block, which causes a harmless warning:

Quoted 7 lines

security/apparmor/apparmorfs.c:177:28: error: 'get_loaddata_common_ref' defined but not used [-Werror=unused-function]
177 | static struct aa_loaddata *get_loaddata_common_ref(struct aa_common_ref *ref)

Move the definition next to the user to avoid the warning.

Fixes 8e135b8aee5a ("apparmor: fix race between freeing data and fs accessing it")

this has now been pulled into my tree

Quoted 43 lines

---
Alternatively, the #ifdef checks could be replaced with an 'if(IS_ENABLED(CONFIG_SECURITY_APPARMOR_EXPORT_BINARY) return;' check in __aa_fs_create_rawdata(), relying on the compiler's dead code elimination.

---
  security/apparmor/apparmorfs.c | 16 ++++++++--------
  1 file changed, 8 insertions(+), 8 deletions(-)
security/apparmor/apparmorfs.c +8 -8
index ededaf46f3ca..f762b101d682 100644
@@ -174,14 +174,6 @@ static struct aa_proxy *get_proxy_common_ref(struct aa_common_ref *ref)
  	return NULL;
  }
 
-static struct aa_loaddata *get_loaddata_common_ref(struct aa_common_ref *ref)
-{
-	if (ref)
-		return aa_get_i_loaddata(container_of(ref, struct aa_loaddata,
-						      count));
-	return NULL;
-}
-
  static void aa_put_common_ref(struct aa_common_ref *ref)
  {
  	if (!ref)
@@ -1318,6 +1310,14 @@ static const struct file_operations seq_rawdata_ ##NAME ##_fops = {	      \
  	.release	= seq_rawdata_release,				      \
  }									      \
 
+static struct aa_loaddata *get_loaddata_common_ref(struct aa_common_ref *ref)
+{
+	if (ref)
+		return aa_get_i_loaddata(container_of(ref, struct aa_loaddata,
+						      count));
+	return NULL;
+}
+
  static int seq_rawdata_open(struct inode *inode, struct file *file,
  			    int (*show)(struct seq_file *, void *))
  {