From: wuchi <wuchi.zero@gmail.com>
To: tytso@mit.edu, adilger.kernel@dilger.ca, ojaswin@linux.ibm.com,
ritesh.list@gmail.com
Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] ext4: simplify 32bit calculation of lblk
Date: Mon, 3 Apr 2023 21:53:04 +0800 [thread overview]
Message-ID: <20230403135304.19858-1-wuchi.zero@gmail.com> (raw)
commit <ad4fb9cafe100a> (ext4: fix 32bit overflow in ext4_ext_find_goal())
uses value compare to fix 32bit overflow. Try to simplify that.
Signed-off-by: wuchi <wuchi.zero@gmail.com>
---
fs/ext4/extents.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 3559ea6b0781..324b7d1386e0 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -237,10 +237,7 @@ static ext4_fsblk_t ext4_ext_find_goal(struct inode *inode,
ext4_fsblk_t ext_pblk = ext4_ext_pblock(ex);
ext4_lblk_t ext_block = le32_to_cpu(ex->ee_block);
- if (block > ext_block)
- return ext_pblk + (block - ext_block);
- else
- return ext_pblk - (ext_block - block);
+ return ext_pblk + ((signed long long)block - (signed long long)ext_block);
}
/* it looks like index is empty;
--
2.20.1
next reply other threads:[~2023-04-03 13:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-03 13:53 wuchi [this message]
2023-04-05 5:40 ` Christoph Hellwig
2023-04-05 8:47 ` chi wu
2023-04-05 11:43 ` David Laight
2023-04-05 12:47 ` chi wu
2023-04-05 13:55 ` David Laight
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=20230403135304.19858-1-wuchi.zero@gmail.com \
--to=wuchi.zero@gmail.com \
--cc=adilger.kernel@dilger.ca \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ojaswin@linux.ibm.com \
--cc=ritesh.list@gmail.com \
--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
all inboxes | Powered by JetHome®