RE: [PATCH 09/14] d_path: introduce struct prepend_buffer

From: Justin He
Date: Thu Jun 24 2021 - 20:44:23 EST


Hi Enrico

> -----Original Message-----
> From: Enrico Weigelt, metux IT consult <lkml@xxxxxxxxx>
> Sent: Thursday, June 24, 2021 5:30 PM
> To: Justin He <Justin.He@xxxxxxx>; Al Viro <viro@xxxxxxxxxxxxxxxxxx>; Linus
> Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
> Cc: Petr Mladek <pmladek@xxxxxxxx>; Steven Rostedt <rostedt@xxxxxxxxxxx>;
> Sergey Senozhatsky <senozhatsky@xxxxxxxxxxxx>; Andy Shevchenko
> <andriy.shevchenko@xxxxxxxxxxxxxxx>; Rasmus Villemoes
> <linux@xxxxxxxxxxxxxxxxxx>; Jonathan Corbet <corbet@xxxxxxx>; Heiko
> Carstens <hca@xxxxxxxxxxxxx>; Vasily Gorbik <gor@xxxxxxxxxxxxx>; Christian
> Borntraeger <borntraeger@xxxxxxxxxx>; Eric W . Biederman
> <ebiederm@xxxxxxxxxxxx>; Darrick J. Wong <darrick.wong@xxxxxxxxxx>; Peter
> Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>; Ira Weiny <ira.weiny@xxxxxxxxx>;
> Eric Biggers <ebiggers@xxxxxxxxxx>; Ahmed S. Darwish
> <a.darwish@xxxxxxxxxxxxx>; open list:DOCUMENTATION <linux-
> doc@xxxxxxxxxxxxxxx>; Linux Kernel Mailing List <linux-
> kernel@xxxxxxxxxxxxxxx>; linux-s390 <linux-s390@xxxxxxxxxxxxxxx>; linux-
> fsdevel <linux-fsdevel@xxxxxxxxxxxxxxx>
> Subject: Re: [PATCH 09/14] d_path: introduce struct prepend_buffer
>
> Hi folks,
>
> <snip>
>
> >> We've a lot of places where we have pairs of form (pointer to
> end
> >> of buffer, amount of space left in front of that). These sit in pairs
> of
> >> variables located next to each other and usually passed by reference.
> >> Turn those into instances of new type (struct prepend_buffer) and pass
> >> reference to the pair instead of pairs of references to its fields.
> >>
> >> Declared and initialized by DECLARE_BUFFER(name, buf, buflen).
> >>
> >> extract_string(prepend_buffer) returns the buffer contents if
> >> no overflow has happened, ERR_PTR(ENAMETOOLONG) otherwise.
> >> All places where we used to have that boilerplate converted to use
> >> of that helper.
>
> this smells like a generic enough thing to go into lib, doesn't it ?
>
Maybe, but the struct prepend_buffer also needs to be moved into lib.
Is it necessary? Is there any other user of struct prepend_buffer?

--
Cheers,
Justin (Jia He)