From: Chin-Chun Chen <chinchunchen2001@gmail.com>
To: yury.norov@gmail.com
Cc: linux@rasmusvillemoes.dk, linux-kernel@vger.kernel.org,
Chin-Chun Chen <chinchunchen2001@gmail.com>
Subject: [PATCH] include/linux/bitops.h: Fix function fns
Date: Sat, 13 Apr 2024 14:12:04 +0800 [thread overview]
Message-ID: <20240413061204.10382-1-chinchunchen2001@gmail.com> (raw)
Modified the function fns to resolve a calculation error by:
1. Reducing n first.
2. Adding 1 at the end to get the correct index.
This commit improves the accuracy and reliability of the code.
Signed-off-by: Chin-Chun Chen <chinchunchen2001@gmail.com>
---
include/linux/bitops.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index 2ba557e067fe..2457610f74eb 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -258,8 +258,8 @@ static inline unsigned long fns(unsigned long word, unsigned int n)
while (word) {
bit = __ffs(word);
- if (n-- == 0)
- return bit;
+ if (--n == 0)
+ return bit + 1;
__clear_bit(bit, &word);
}
base-commit: 8f2c057754b25075aa3da132cd4fd4478cdab854
--
2.40.1
next reply other threads:[~2024-04-13 6:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-13 6:12 Chin-Chun Chen [this message]
2024-04-13 16:15 ` [PATCH v2] " Chin-Chun Chen
[not found] ` <20240413155635.11486-1-chinchunchen2001@gmail.com>
2024-04-13 17:14 ` Yury Norov
-- strict thread matches above, loose matches on Subject: below --
2024-04-13 5:28 [PATCH] " Chin-Chun Chen
2024-04-13 5:39 ` Randy Dunlap
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=20240413061204.10382-1-chinchunchen2001@gmail.com \
--to=chinchunchen2001@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=yury.norov@gmail.com \
/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®