[Toybox] [PATCH] chvt: remove old workarounds.
Rob Landley
rob at landley.net
Sat Sep 25 09:50:20 PDT 2021
On 9/24/21 7:10 PM, enh via Toybox wrote:
> We don't need the fd=fd hack for GCC 3.4 in 2021,
Yeah, but we still needed it in 2018.
*cracks knuckles* The power of grep '[ ,]\([a-zA-Z0-9_][a-zA-Z0-9_]*\) *= *\1'
*.c lib/*.c toys/*/*.c compels you!
Noise, noise, noise...
toys/net/sntp.c: unsigned long long *pktime = (void *)toybuf, now, then, before
= before;
toys/other/chvt.c: int vtnum, fd = fd;
toys/other/switch_root.c: int console = console; // gcc's "may be used"
warnings are broken.
toys/other/watch.c: unsigned width, height, i, cmdlen, len, xx = xx, yy = yy,
active = active;
toys/posix/uudecode.c: int ofd, idx = 0, m = m, n;
I could definitely clean that regex up more...
> and <linux/vt.h> has
> given names to the two magic numbers since at least Linux 2.4.0...
Heh, back when I was trying not to include linux/*.h at all, before I can up
with the "command can include it, headers shouldn't" policy.
(Back in 2008 Steve Jobs wasn't dead yet and smartphones were brand new, so
"mac/darwin might take over the world or at least meat shield us from the
windopoly" was still a viable concept. lib/portability.h showed up in jan 2007
but sticking linux/ headers in there didn't really help, and portability.c
didn't show up until 2012...)
I do note that:
- if (-1 != (fd = open(*cc, O_RDWR))) break;
+ if ((fd = open(*cc, O_RDWR)) != -1) break;
Was alas good advice that never quite soaked in. (If you typo x == 1 as x = 1 it
compiles. If you typo 1 = x it does not. But for constructs like this, "do the
thing, then error check the thing" makes more sense to human programmers...)
Rob
More information about the Toybox
mailing list