[PATCH v3 4/5] pcapng: avoid using alloca()
Morten Brørup
mb at smartsharesystems.com
Thu Nov 9 17:25:52 CET 2023
> From: Stephen Hemminger [mailto:stephen at networkplumber.org]
> Sent: Thursday, 9 November 2023 16.45
>
> On Thu, 9 Nov 2023 09:21:22 +0100
> Morten Brørup <mb at smartsharesystems.com> wrote:
>
> > I can't find the definition of BUFSIZ. Please make sure to add a
> comment to the definition of BUFSIZ mentioning - like in your patch
> description - that it will be more than sufficient for the info related
> blocks in the file.
> >
> > More comments inline below, regarding existing bugs found while
> reviewing.
> >
> >
> > Assuming BUFSIZ has a comment describing the reason for its value,
> >
> > Acked-by: Morten Brørup <mb at smartsharesystems.com>
>
> The constant BUFSIZ comes from stdio.h and used lots of places in
> libraries.
> It is 8192 in current glibc and unlikely to be a problem.
OK, didn't know that. So I looked it up, trying to learn more about it.
I found two sources [1], [2] mentioning that BUFSIZ is guaranteed to be at least 256.
[1]: https://www.gnu.org/software/libc/manual/html_node/Controlling-Buffering.html#BUFSIZ
[2]: Page 234 in "The C Standard Library" by P.J. Plauger, ISBN: 0-13-131509-9, from 1992
If 256 suffices, then I am OK with using BUFSIZ.
I hope the authors of the other libraries using BUFSIZ don't assume more than the C standard promises about it.
> Chose it because this a on stack buffer used before writing to a file
> which
> is similar to what stdio does.
>
> The library does not use stdio because most of the I/O is writing
> packets
> which needs to be fast and overhead of extra stdio buffer is harmful.
> Looking into using io_uring in a future version.
More information about the dev
mailing list