Skip to contentSkip to conversation

apparmor: remove useless static inline function is_deleted

PATCH In review Colin Ian King 2 participants 2 messages Mar 4, 2024 – May 10, 2024

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

PATCH 1/1 apparmor: remove useless static inline function is_deleted

The inlined function is_deleted is redundant, it is not called at all from any function in security/apparmor/file.c and so it can be removed.

Cleans up clang scan build warning:
security/apparmor/file.c:153:20: warning: unused function 'is_deleted' [-Wunused-function]

---
 security/apparmor/file.c | 13 -------------
 1 file changed, 13 deletions(-)
security/apparmor/file.c +0 -13
index c03eb7c19f16..d52a5b14dad4 100644
@@ -144,19 +144,6 @@ int aa_audit_file(const struct cred *subj_cred,
 	return aa_audit(type, profile, &ad, file_audit_cb);
 }
 
-/**
- * is_deleted - test if a file has been completely unlinked
- * @dentry: dentry of file to test for deletion  (NOT NULL)
- *
- * Returns: true if deleted else false
- */
-static inline bool is_deleted(struct dentry *dentry)
-{
-	if (d_unlinked(dentry) && d_backing_inode(dentry)->i_nlink == 0)
-		return true;
-	return false;
-}
-
 static int path_name(const char *op, const struct cred *subj_cred,
 		     struct aa_label *label,
 		     const struct path *path, int flags, char *buffer,
Signature · 1 line
2.39.2
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Colin Ian King

The inlined function is_deleted is redundant, it is not called at all from any function in security/apparmor/file.c and so it can be removed.

Cleans up clang scan build warning:
security/apparmor/file.c:153:20: warning: unused function 'is_deleted' [-Wunused-function]

I have pulled this into my tree

Quoted 28 lines
---
  security/apparmor/file.c | 13 -------------
  1 file changed, 13 deletions(-)
security/apparmor/file.c +0 -13
index c03eb7c19f16..d52a5b14dad4 100644
@@ -144,19 +144,6 @@ int aa_audit_file(const struct cred *subj_cred,
  	return aa_audit(type, profile, &ad, file_audit_cb);
  }
 
-/**
- * is_deleted - test if a file has been completely unlinked
- * @dentry: dentry of file to test for deletion  (NOT NULL)
- *
- * Returns: true if deleted else false
- */
-static inline bool is_deleted(struct dentry *dentry)
-{
-	if (d_unlinked(dentry) && d_backing_inode(dentry)->i_nlink == 0)
-		return true;
-	return false;
-}
-
  static int path_name(const char *op, const struct cred *subj_cred,
  		     struct aa_label *label,
  		     const struct path *path, int flags, char *buffer,