Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1370100

[PATCH 04/13] fscrypto: return bool instead of int where appropriate

Path csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!gothmog.csi.it!bofh.it!news.nic.it!robomod
From Eric Biggers <ebiggers3@gmail.com>
Newsgroups linux.kernel
Subject [PATCH 04/13] fscrypto: return bool instead of int where appropriate
Date Sun, 03 Apr 2016 07:30:02 +0200
Message-ID <rjILM-748-9@gated-at.bofh.it> (permalink)
References <rjILL-748-3@gated-at.bofh.it>
X-Original-To linux-fsdevel@vger.kernel.org
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dHzeolHgfJIVXZvYiFOfyumekz58U/afLjT9+NFDppM=; b=EH78rPpAfQGzEY7uHQ4VsQGa3nJAUqYoXZUZZViQwU6XVWntVWlxwJM9Nx9rMpl4vL 1II2MHY3D6a/zHWje2spl+41B1bAhOuROkt5ffuIQAa294CDr17bUfy50xc783SMSArq MK+WMOSGAX0Zd14Rl6QtzYTEwFm4PNONdU39tG8f+9DkOqG8Q/QlO1KQj+mcKho2xZta Q7Dr7FSfBQDL0Ogk9tSlZC1GtXy7GpvX1NLygqrplBRkzUrgFfDHal9tncZz4VLvhAyi WdW97XtgSDLwbwEXOLDuuJi0uXc21NqFLgKsAXttLIDYFDzGS0A7q7X+vsoaq8aHjpX8 2s6Q==
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dHzeolHgfJIVXZvYiFOfyumekz58U/afLjT9+NFDppM=; b=eQgdT8nwSjS39eojJgnHuOTIPezbv53QEDmG1b4hPZW5igRiadaBriVsR9BB+L+Wpr +dayjsemfEvZjoo0uFez6fgOBBYtVU5mexDWBRQNh9YvMRG8lo5B83853goF5Ui28FbN 3f22ayiMLifG9N+MmhVtXR8pV/KnHN5BNddzHahN+AAc8rFaZiwnioxS82JhxqD/qCXG hp2cGNC8yKDAUDMnxDMPZTdBJDrYuRrdU1G5KmZIE7ZWdsO8iaePUfFvNsxdrIgFtLOo lBaE5d/W02NY2pu43gJ3gTdUVdgAFzoTp5q6i810tX3rpkDQpcyUaYrsX7EXRzhDXa8p 0lkw==
X-Gm-Message-State AD7BkJIL+XA3vSaT3NlOg1JMgM2uKfVGyj1tiQY56E9At4DR3RYUuSN4MhCz9KMQjovc9Q==
X-Received by 10.50.147.10 with SMTP id tg10mr5821940igb.8.1459661019876; Sat, 02 Apr 2016 22:23:39 -0700 (PDT)
X-Mailer git-send-email 2.7.4
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 135
Organization linux.* mail to news gateway
X-Original-Cc linux-f2fs-devel@lists.sourceforge.net, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, jaegeuk@kernel.org, tytso@mit.edu, mhalcrow@google.com, Eric Biggers <ebiggers3@gmail.com>
X-Original-Date Sun, 3 Apr 2016 00:21:55 -0500
X-Original-Message-ID <1459660924-2960-5-git-send-email-ebiggers3@gmail.com>
X-Original-References <1459660924-2960-1-git-send-email-ebiggers3@gmail.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1370100

Show key headers only | View raw


Signed-off-by: Eric Biggers <ebiggers3@gmail.com>
---
 fs/crypto/policy.c       | 24 ++++++++++++------------
 include/linux/fscrypto.h | 12 ++++++------
 2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c
index 03a2f50..93244b5 100644
--- a/fs/crypto/policy.c
+++ b/fs/crypto/policy.c
@@ -12,10 +12,10 @@
 #include <linux/string.h>
 #include <linux/fscrypto.h>
 
-static int inode_has_encryption_context(struct inode *inode)
+static bool inode_has_encryption_context(struct inode *inode)
 {
 	if (!inode->i_sb->s_cop->get_context)
-		return 0;
+		return false;
 	return (inode->i_sb->s_cop->get_context(inode, NULL, 0L) > 0);
 }
 
@@ -23,18 +23,18 @@ static int inode_has_encryption_context(struct inode *inode)
  * check whether the policy is consistent with the encryption context
  * for the inode
  */
-static int is_encryption_context_consistent_with_policy(struct inode *inode,
+static bool is_encryption_context_consistent_with_policy(struct inode *inode,
 				const struct fscrypt_policy *policy)
 {
 	struct fscrypt_context ctx;
 	int res;
 
 	if (!inode->i_sb->s_cop->get_context)
-		return 0;
+		return false;
 
 	res = inode->i_sb->s_cop->get_context(inode, &ctx, sizeof(ctx));
 	if (res != sizeof(ctx))
-		return 0;
+		return false;
 
 	return (memcmp(ctx.master_key_descriptor, policy->master_key_descriptor,
 			FS_KEY_DESCRIPTOR_SIZE) == 0 &&
@@ -139,7 +139,7 @@ int fscrypt_get_policy(struct inode *inode, struct fscrypt_policy *policy)
 }
 EXPORT_SYMBOL(fscrypt_get_policy);
 
-int fscrypt_has_permitted_context(struct inode *parent, struct inode *child)
+bool fscrypt_has_permitted_context(struct inode *parent, struct inode *child)
 {
 	struct fscrypt_info *parent_ci, *child_ci;
 	int res;
@@ -151,22 +151,22 @@ int fscrypt_has_permitted_context(struct inode *parent, struct inode *child)
 
 	/* no restrictions if the parent directory is not encrypted */
 	if (!parent->i_sb->s_cop->is_encrypted(parent))
-		return 1;
+		return true;
 	/* if the child directory is not encrypted, this is always a problem */
 	if (!parent->i_sb->s_cop->is_encrypted(child))
-		return 0;
+		return false;
 	res = fscrypt_load_encryption_info(parent);
 	if (res)
-		return 0;
+		return false;
 	res = fscrypt_load_encryption_info(child);
 	if (res)
-		return 0;
+		return false;
 	parent_ci = parent->i_crypt_info;
 	child_ci = child->i_crypt_info;
 	if (!parent_ci && !child_ci)
-		return 1;
+		return true;
 	if (!parent_ci || !child_ci)
-		return 0;
+		return false;
 
 	return (memcmp(parent_ci->ci_master_key,
 			child_ci->ci_master_key,
diff --git a/include/linux/fscrypto.h b/include/linux/fscrypto.h
index 1bf00a5..9a32d7e 100644
--- a/include/linux/fscrypto.h
+++ b/include/linux/fscrypto.h
@@ -177,7 +177,7 @@ struct fscrypt_operations {
 	int (*get_context)(struct inode *, void *, size_t);
 	int (*prepare_context)(struct inode *);
 	int (*set_context)(struct inode *, const void *, size_t, void *);
-	int (*dummy_context)(struct inode *);
+	bool (*dummy_context)(struct inode *);
 	bool (*is_encrypted)(struct inode *);
 	bool (*empty_dir)(struct inode *);
 	unsigned (*max_namelen)(struct inode *);
@@ -229,12 +229,12 @@ static inline struct page *fscrypt_control_page(struct page *page)
 #endif
 }
 
-static inline int fscrypt_has_encryption_key(struct inode *inode)
+static inline bool fscrypt_has_encryption_key(struct inode *inode)
 {
 #if IS_ENABLED(CONFIG_FS_ENCRYPTION)
 	return (inode->i_crypt_info != NULL);
 #else
-	return 0;
+	return false;
 #endif
 }
 
@@ -275,7 +275,7 @@ extern int fscrypt_zeroout_range(struct inode *, pgoff_t, sector_t,
 /* policy.c */
 extern int fscrypt_set_policy(struct inode *, const struct fscrypt_policy *);
 extern int fscrypt_get_policy(struct inode *, struct fscrypt_policy *);
-extern int fscrypt_has_permitted_context(struct inode *, struct inode *);
+extern bool fscrypt_has_permitted_context(struct inode *, struct inode *);
 extern int fscrypt_inherit_context(struct inode *, struct inode *,
 					void *, bool);
 /* keyinfo.c */
@@ -355,10 +355,10 @@ static inline int fscrypt_notsupp_get_policy(struct inode *i,
 	return -EOPNOTSUPP;
 }
 
-static inline int fscrypt_notsupp_has_permitted_context(struct inode *p,
+static inline bool fscrypt_notsupp_has_permitted_context(struct inode *p,
 				struct inode *i)
 {
-	return 0;
+	return false;
 }
 
 static inline int fscrypt_notsupp_inherit_context(struct inode *p,
-- 
2.7.4

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 00/13] fscrypto: cleanups and fixes Eric Biggers <ebiggers3@gmail.com> - 2016-04-03 07:30 +0200
  [PATCH 12/13] fscrypto: require write access to mount to set encryption policy Eric Biggers <ebiggers3@gmail.com> - 2016-04-03 07:30 +0200
  [PATCH 04/13] fscrypto: return bool instead of int where appropriate Eric Biggers <ebiggers3@gmail.com> - 2016-04-03 07:30 +0200
  [PATCH 10/13] fscrypto: restrict setting new policy to empty files and directories only Eric Biggers <ebiggers3@gmail.com> - 2016-04-03 07:30 +0200
  [PATCH 05/13] fscrypto: comment improvements and fixes Eric Biggers <ebiggers3@gmail.com> - 2016-04-03 07:30 +0200
  [PATCH 07/13] fscrypto: simplify building key descriptor string Eric Biggers <ebiggers3@gmail.com> - 2016-04-03 07:30 +0200
  [PATCH 02/13] fscrypto: rename some functions for clarity Eric Biggers <ebiggers3@gmail.com> - 2016-04-03 07:30 +0200
    Re: [PATCH 02/13] fscrypto: rename some functions for clarity Theodore Ts'o <tytso@mit.edu> - 2016-04-03 09:50 +0200
  [PATCH 11/13] fscrypto: restrict setting encryption policy to inode owner Eric Biggers <ebiggers3@gmail.com> - 2016-04-03 07:30 +0200
  [PATCH 08/13] fscrypto: use standard macros from kernel.h Eric Biggers <ebiggers3@gmail.com> - 2016-04-03 07:30 +0200
  [PATCH 09/13] fscrypto: make fname_encrypt() actually return length of ciphertext Eric Biggers <ebiggers3@gmail.com> - 2016-04-03 07:30 +0200
  [PATCH 13/13] fscrypto: improve error handling in fscrypt_set_policy() Eric Biggers <ebiggers3@gmail.com> - 2016-04-03 07:30 +0200
  [PATCH 06/13] fscrypto: crypto_alloc_skcipher() always returns an ERR_PTR(), never NULL Eric Biggers <ebiggers3@gmail.com> - 2016-04-03 07:30 +0200
  [PATCH 03/13] fscrypto: rename functions to load and unload inode encryption info Eric Biggers <ebiggers3@gmail.com> - 2016-04-03 07:30 +0200

csiph-web