Re: BUFSIZ vs magic numbers and co.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Alex,

On Mon, 7 Sep 2020 at 23:37, Alejandro Colomar <colomar.6.4.3@xxxxxxxxx> wrote:
>
> Hi Michael,
>
> There are a lot of EXAMPLES where buffers are created.  In those
> examples, usually there is either a magic random number (e.g., 100, 500,
> 1000) or a custom macro such as `#define BUF_SIZE 500`.
>
> Those examples could all use `BUFSIZ` from <stdio.h>, which would reduce
> code (not having to define the macro), and be more consistent (not
> having a random magic number in each example).
>
> However, I see a slightly good point in having magic numbers in the
> examples section:  a novice reader could infer that you are focrced to
> use BUFSIZ if it's written all over the place, while if there is a
> random magic number, the reader probably will deduce that he can use any
> number.

Yes, I think that's a good point. There's nothing magical about
BUFSIZ; it relates just to stdio.

> What do you think about it?  Would it be better to consistently use
> BUFSIZ, or just keep the magic numbers?

Keep the magic numbers, I would say.

Cheers,

Michael


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/



[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux