[PATCH 4/7] xfuncs: Handle missing non-POSIX termios constants

Kang-Che Sung explorer09 at gmail.com
Sun Oct 8 15:01:26 UTC 2017


On Sun, Oct 8, 2017 at 10:34 PM, Ralf Friedl <Ralf.Friedl at online.de> wrote:
>
> Because the way the line is now is one line with 8 values. Changing that to
> use ifdefs for each value would change that one line to 3*8+2=26 lines, that
> makes the code much harder to read and maintain. And there may be other
> places where it is used. It's perfectly legitimate to define the values as
> 0, like you would define O_BINARY as 0 on platforms that don't need/supply
> it.

Okay. I'm partially convinced about this argument. Consider that there are
other places in busybox code that temporarily defines IUCLC to 0 for similar
purpose:

libbb/xfuncs.c
libbb/bb_askpass.c
coreutils/stty.c
loginutils/getty.c

> There is nothing wrong with that. It is possible to use "#if SIGUSR3" to
> test for SIGUSR being defined and nonzero. It has the additional benefit
> that you can use the value in a C statement (as opposed to a C preprocessor
> test) and let the compiler optimize it out. Busybox does that a lot.

My concern is that there're some macros that are defined to 0 for a
purpose, e.g.
#define O_RDONLY 0x0000
so it's not a good idea in general to arbitrarily define a macro to 0 without
knowing what you are doing. But for IUCLC and such, it might be safe.

James (jrtc27), I apologize for my misunderstanding of the issue.


More information about the busybox mailing list