From: Zhang Jianhua <chris.zjh@huawei.com>
To: <ebiggers@kernel.org>, <tytso@mit.edu>
Cc: <linux-fscrypt@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: [PATCH -next v2] fs-verity: Use struct_size() helper in enable_verity()
Date: Thu, 19 May 2022 10:24:50 +0800 [thread overview]
Message-ID: <20220519022450.2434483-1-chris.zjh@huawei.com> (raw)
Make use of the struct_size() helper to calculate the size of struct
fsverity_digest instead of an open-coded version, in order to get rid
of the warning by sparse.
Also, address the following sparse warning:
fs/verity/enable.c:205:28: warning: using sizeof on a flexible structure
Signed-off-by: Zhang Jianhua <chris.zjh@huawei.com>
---
v2:
- change the commit message from bugfix to cleanup
fs/verity/enable.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/verity/enable.c b/fs/verity/enable.c
index f75d2c010f36..075dc0aa5416 100644
--- a/fs/verity/enable.c
+++ b/fs/verity/enable.c
@@ -201,7 +201,7 @@ static int enable_verity(struct file *filp,
const struct fsverity_operations *vops = inode->i_sb->s_vop;
struct merkle_tree_params params = { };
struct fsverity_descriptor *desc;
- size_t desc_size = sizeof(*desc) + arg->sig_size;
+ size_t desc_size = struct_size(desc, signature, arg->sig_size);
struct fsverity_info *vi;
int err;
--
2.31.0
next reply other threads:[~2022-05-19 2:26 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-19 2:24 Zhang Jianhua [this message]
2022-05-19 3:06 ` [PATCH -next v2] fs-verity: Use struct_size() helper in enable_verity() Eric Biggers
2022-05-19 3:17 ` Eric Biggers
[not found] ` <e030eaf6-0b6b-7685-c5b6-fd0b57aea600@huawei.com>
2022-05-19 4:22 ` Eric Biggers
2022-05-19 6:22 ` zhangjianhua (E)
2022-05-19 11:24 ` Johan Hovold
2022-05-19 16:57 ` Eric Biggers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220519022450.2434483-1-chris.zjh@huawei.com \
--to=chris.zjh@huawei.com \
--cc=ebiggers@kernel.org \
--cc=linux-fscrypt@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox