From: xu xin <[email protected]>
BUG_ON would be better.
This issue was detected with the help of Coccinelle.
Reported-by: Zeal robot <[email protected]>
Signed-off-by: xu xin <[email protected]>
---
fs/ext4/ext4.h | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 9cc55bcda6ba..00bc3f67d37f 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -2400,8 +2400,7 @@ ext4_rec_len_from_disk(__le16 dlen, unsigned blocksize)
static inline __le16 ext4_rec_len_to_disk(unsigned len, unsigned blocksize)
{
- if ((len > blocksize) || (blocksize > (1 << 18)) || (len & 3))
- BUG();
+ BUG_ON((len > blocksize) || (blocksize > (1 << 18)) || (len & 3));
#if (PAGE_SIZE >= 65536)
if (len < 65536)
return cpu_to_le16(len);
--
2.25.1
On Sun, Dec 19, 2021 at 01:06:43PM +0000, [email protected] wrote:
> From: xu xin <[email protected]>
>
> BUG_ON would be better.
Indeed. Thanks for the patch.
Reviewed-by: Lukas Czerner <[email protected]>
>
> This issue was detected with the help of Coccinelle.
>
> Reported-by: Zeal robot <[email protected]>
> Signed-off-by: xu xin <[email protected]>
> ---
> fs/ext4/ext4.h | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
> index 9cc55bcda6ba..00bc3f67d37f 100644
> --- a/fs/ext4/ext4.h
> +++ b/fs/ext4/ext4.h
> @@ -2400,8 +2400,7 @@ ext4_rec_len_from_disk(__le16 dlen, unsigned blocksize)
>
> static inline __le16 ext4_rec_len_to_disk(unsigned len, unsigned blocksize)
> {
> - if ((len > blocksize) || (blocksize > (1 << 18)) || (len & 3))
> - BUG();
> + BUG_ON((len > blocksize) || (blocksize > (1 << 18)) || (len & 3));
> #if (PAGE_SIZE >= 65536)
> if (len < 65536)
> return cpu_to_le16(len);
> --
> 2.25.1
>
From: xu xin <[email protected]>
BUG_ON would be better.
This issue was detected with the help of Coccinelle.
Reported-by: Zeal robot <[email protected]>
Reviewed-by: Lukas Czerner <[email protected]>
Signed-off-by: xu xin <[email protected]>
---
fs/ext4/ext4.h | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 9cc55bcda6ba..00bc3f67d37f 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -2400,8 +2400,7 @@ ext4_rec_len_from_disk(__le16 dlen, unsigned blocksize)
static inline __le16 ext4_rec_len_to_disk(unsigned len, unsigned blocksize)
{
- if ((len > blocksize) || (blocksize > (1 << 18)) || (len & 3))
- BUG();
+ BUG_ON((len > blocksize) || (blocksize > (1 << 18)) || (len & 3));
#if (PAGE_SIZE >= 65536)
if (len < 65536)
return cpu_to_le16(len);
--
2.25.1
On 21/12/28 07:32AM, [email protected] wrote:
> From: xu xin <[email protected]>
>
> BUG_ON would be better.
While we are at it, I feel correcting below BUG() in the same patch(es?)
might be useful too.
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index bfd3545f1e5d..5656b4a9007b 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1879,10 +1879,7 @@ static int __ext4_journalled_writepage(struct page *page,
goto out;
} else {
page_bufs = page_buffers(page);
- if (!page_bufs) {
- BUG();
- goto out;
- }
+ BUG_ON(!page_bufs);
ext4_walk_page_buffers(handle, inode, page_bufs, 0, len,
NULL, bget_one);
}
-riteshh
>
> This issue was detected with the help of Coccinelle.
>
> Reported-by: Zeal robot <[email protected]>
> Reviewed-by: Lukas Czerner <[email protected]>
> Signed-off-by: xu xin <[email protected]>
> ---
> fs/ext4/ext4.h | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
> index 9cc55bcda6ba..00bc3f67d37f 100644
> --- a/fs/ext4/ext4.h
> +++ b/fs/ext4/ext4.h
> @@ -2400,8 +2400,7 @@ ext4_rec_len_from_disk(__le16 dlen, unsigned blocksize)
>
> static inline __le16 ext4_rec_len_to_disk(unsigned len, unsigned blocksize)
> {
> - if ((len > blocksize) || (blocksize > (1 << 18)) || (len & 3))
> - BUG();
> + BUG_ON((len > blocksize) || (blocksize > (1 << 18)) || (len & 3));
> #if (PAGE_SIZE >= 65536)
> if (len < 65536)
> return cpu_to_le16(len);
> --
> 2.25.1
>
>While we are at it, I feel correcting below BUG() in the same patch(es?)
>might be useful too.
I agree with it.
Feel free if you're willing to do the integration of patches.
Simplify !page_bufs logic with simple BUG_ON().
Signed-off-by: Ritesh Harjani <[email protected]>
---
Noticed a bug_on() related patch while reviewing, hence felt, this
below trivial change could be included along with it.
fs/ext4/inode.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index bfd3545f1e5d..5656b4a9007b 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1879,10 +1879,7 @@ static int __ext4_journalled_writepage(struct page *page,
goto out;
} else {
page_bufs = page_buffers(page);
- if (!page_bufs) {
- BUG();
- goto out;
- }
+ BUG_ON(!page_bufs);
ext4_walk_page_buffers(handle, inode, page_bufs, 0, len,
NULL, bget_one);
}
--
2.31.1
On Wed, Jan 05, 2022 at 02:06:56PM +0530, Ritesh Harjani wrote:
> Simplify !page_bufs logic with simple BUG_ON().
Looks good, thanks!
Reviewed-by: Lukas Czerner <[email protected]>
>
> Signed-off-by: Ritesh Harjani <[email protected]>
> ---
> Noticed a bug_on() related patch while reviewing, hence felt, this
> below trivial change could be included along with it.
>
> fs/ext4/inode.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index bfd3545f1e5d..5656b4a9007b 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -1879,10 +1879,7 @@ static int __ext4_journalled_writepage(struct page *page,
> goto out;
> } else {
> page_bufs = page_buffers(page);
> - if (!page_bufs) {
> - BUG();
> - goto out;
> - }
> + BUG_ON(!page_bufs);
> ext4_walk_page_buffers(handle, inode, page_bufs, 0, len,
> NULL, bget_one);
> }
> --
> 2.31.1
>
On Wed, Jan 05, 2022 at 02:06:56PM +0530, Ritesh Harjani wrote:
> Simplify !page_bufs logic with simple BUG_ON().
>
> @@ -1879,10 +1879,7 @@ static int __ext4_journalled_writepage(struct page *page,
> goto out;
> } else {
> page_bufs = page_buffers(page);
> - if (!page_bufs) {
> - BUG();
> - goto out;
> - }
> + BUG_ON(!page_bufs);
> ext4_walk_page_buffers(handle, inode, page_bufs, 0, len,
> NULL, bget_one);
> }
This code was removed by:
https://lore.kernel.org/r/[email protected]
... so this patch is no longer needed.
- Ted
On Tue, Dec 28, 2021 at 07:32:52AM +0000, [email protected] wrote:
> From: xu xin <[email protected]>
>
> BUG_ON would be better.
>
> This issue was detected with the help of Coccinelle.
>
> Reported-by: Zeal robot <[email protected]>
> Reviewed-by: Lukas Czerner <[email protected]>
> Signed-off-by: xu xin <[email protected]>
Thanks, applied.
- Ted