* [PATCH] bcachefs: Simplify kzalloc usage
@ 2025-07-31 13:15 Liao Yuanhong
2025-07-31 18:52 ` Markus Elfring
0 siblings, 1 reply; 5+ messages in thread
From: Liao Yuanhong @ 2025-07-31 13:15 UTC (permalink / raw)
To: Kent Overstreet; +Cc: linux-bcachefs, linux-kernel, liaoyuanhong
Use the shorter variants will improves further maintainability.
Convenient for subsequent code updates or refactoring.
In addition, there are some places in the code where variables
are simply named 'i', which can be confused with count variables
in loops and have low readability. Perhaps I can help gradually
standardize variable naming in the future.
Signed-off-by: Liao Yuanhong <liaoyuanhong@vivo.com>
---
fs/bcachefs/async_objs.c | 2 +-
fs/bcachefs/btree_cache.c | 2 +-
fs/bcachefs/debug.c | 4 ++--
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/fs/bcachefs/async_objs.c b/fs/bcachefs/async_objs.c
index a7cd1f0f0964..9fa09ac3f583 100644
--- a/fs/bcachefs/async_objs.c
+++ b/fs/bcachefs/async_objs.c
@@ -45,7 +45,7 @@ static int bch2_async_obj_list_open(struct inode *inode, struct file *file)
struct async_obj_list *list = inode->i_private;
struct dump_iter *i;
- i = kzalloc(sizeof(struct dump_iter), GFP_KERNEL);
+ i = kzalloc(sizeof(*i), GFP_KERNEL);
if (!i)
return -ENOMEM;
diff --git a/fs/bcachefs/btree_cache.c b/fs/bcachefs/btree_cache.c
index 83c9860e6b82..d04ddf3072c1 100644
--- a/fs/bcachefs/btree_cache.c
+++ b/fs/bcachefs/btree_cache.c
@@ -173,7 +173,7 @@ static struct btree *__btree_node_mem_alloc(struct bch_fs *c, gfp_t gfp)
{
struct btree *b;
- b = kzalloc(sizeof(struct btree), gfp);
+ b = kzalloc(sizeof(*b), gfp);
if (!b)
return NULL;
diff --git a/fs/bcachefs/debug.c b/fs/bcachefs/debug.c
index 07c2a0f73cc2..b056a37dbba4 100644
--- a/fs/bcachefs/debug.c
+++ b/fs/bcachefs/debug.c
@@ -335,7 +335,7 @@ static int bch2_dump_open(struct inode *inode, struct file *file)
struct btree_debug *bd = inode->i_private;
struct dump_iter *i;
- i = kzalloc(sizeof(struct dump_iter), GFP_KERNEL);
+ i = kzalloc(sizeof(*i), GFP_KERNEL);
if (!i)
return -ENOMEM;
@@ -721,7 +721,7 @@ static int btree_transaction_stats_open(struct inode *inode, struct file *file)
struct bch_fs *c = inode->i_private;
struct dump_iter *i;
- i = kzalloc(sizeof(struct dump_iter), GFP_KERNEL);
+ i = kzalloc(sizeof(*i), GFP_KERNEL);
if (!i)
return -ENOMEM;
--
2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] bcachefs: Simplify kzalloc usage
2025-07-31 13:15 [PATCH] bcachefs: Simplify kzalloc usage Liao Yuanhong
@ 2025-07-31 18:52 ` Markus Elfring
2025-07-31 19:19 ` Kent Overstreet
0 siblings, 1 reply; 5+ messages in thread
From: Markus Elfring @ 2025-07-31 18:52 UTC (permalink / raw)
To: Liao Yuanhong, linux-bcachefs; +Cc: LKML, Kent Overstreet
> Use the shorter variants will improves further maintainability.
> Convenient for subsequent code updates or refactoring.
Please improve such a change description.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.16#n45
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?h=v6.16#n941
Regards,
Markus
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] bcachefs: Simplify kzalloc usage
2025-07-31 18:52 ` Markus Elfring
@ 2025-07-31 19:19 ` Kent Overstreet
2025-07-31 20:00 ` Markus Elfring
0 siblings, 1 reply; 5+ messages in thread
From: Kent Overstreet @ 2025-07-31 19:19 UTC (permalink / raw)
To: Markus Elfring; +Cc: Liao Yuanhong, linux-bcachefs, LKML
On Thu, Jul 31, 2025 at 08:52:44PM +0200, Markus Elfring wrote:
> > Use the shorter variants will improves further maintainability.
> > Convenient for subsequent code updates or refactoring.
>
> Please improve such a change description.
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.16#n45
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?h=v6.16#n941
The commit message is reasonable, it communicates the intent.
I haven't decided if I want to apply it; the dereference approach is
better in principle but it's very far off into the weeds of "things that
will never, ever cause an actual problem".
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] bcachefs: Simplify kzalloc usage
2025-07-31 19:19 ` Kent Overstreet
@ 2025-07-31 20:00 ` Markus Elfring
2025-08-01 2:28 ` Kent Overstreet
0 siblings, 1 reply; 5+ messages in thread
From: Markus Elfring @ 2025-07-31 20:00 UTC (permalink / raw)
To: Kent Overstreet, linux-bcachefs; +Cc: Liao Yuanhong, LKML
>>> Use the shorter variants will improves further maintainability.
>>> Convenient for subsequent code updates or refactoring.
>>
>> Please improve such a change description.
>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.16#n45
>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?h=v6.16#n941
>
> The commit message is reasonable, it communicates the intent.
* I would wonder about the relevance of a shorter item here.
* Would you like to avoid wording weaknesses?
Another example for previous contributions:
https://lore.kernel.org/all/?q=%22Improve%20size%20determinations%22
> I haven't decided if I want to apply it; the dereference approach is
> better in principle but it's very far off into the weeds of "things that
> will never, ever cause an actual problem".
Have you got development views which might be in contradiction
to the preferred Linux coding style?
Regards,
Markus
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] bcachefs: Simplify kzalloc usage
2025-07-31 20:00 ` Markus Elfring
@ 2025-08-01 2:28 ` Kent Overstreet
0 siblings, 0 replies; 5+ messages in thread
From: Kent Overstreet @ 2025-08-01 2:28 UTC (permalink / raw)
To: Markus Elfring; +Cc: linux-bcachefs, Liao Yuanhong, LKML
On Thu, Jul 31, 2025 at 10:00:31PM +0200, Markus Elfring wrote:
> >>> Use the shorter variants will improves further maintainability.
> >>> Convenient for subsequent code updates or refactoring.
> >>
> >> Please improve such a change description.
> >> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.16#n45
> >> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?h=v6.16#n941
> >
> > The commit message is reasonable, it communicates the intent.
>
> * I would wonder about the relevance of a shorter item here.
>
> * Would you like to avoid wording weaknesses?
>
>
> Another example for previous contributions:
> https://lore.kernel.org/all/?q=%22Improve%20size%20determinations%22
>
>
> > I haven't decided if I want to apply it; the dereference approach is
> > better in principle but it's very far off into the weeds of "things that
> > will never, ever cause an actual problem".
>
> Have you got development views which might be in contradiction
> to the preferred Linux coding style?
Marcus, I believe you've been warned in other subsystems, by other
maintainers - you need to cut this out. I decide what's acceptable for
patches to bcachefs, not you :)
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-08-01 2:28 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-31 13:15 [PATCH] bcachefs: Simplify kzalloc usage Liao Yuanhong
2025-07-31 18:52 ` Markus Elfring
2025-07-31 19:19 ` Kent Overstreet
2025-07-31 20:00 ` Markus Elfring
2025-08-01 2:28 ` Kent Overstreet
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®