[Toybox] [PATCH] net.c: add missing static.

Rob Landley rob at landley.net
Sat Jul 13 16:25:13 PDT 2019


On 7/12/19 5:52 PM, enh via Toybox wrote:
> Pointed out during code review of the recent refactor.

Applied, although _mostly_ I don't do static functions in lib, and this is the
only one in lib/net.c.

Commands shouldn't export unnecessary functions, because if anything else uses
them it should go into lib. (There's nowhere to put the function declarations
other than command_main(), and there's nasty "is this command enabled yes/no"
potential link errors if you just reach across toys/*/*.c files like that.)

But the _point_ of lib/*.c is to export shared infrastructure. What does static
really accomplish there? lib/deflate.c is full of them because it started life
as a command. Almost all the rest of the statics in lib/ are variables, not
functions...

I see you're saying "don't use this interface, use the other interface" and
trying to hide implementation details. (Except they're not hidden, are they?
They're right there...?)

Sigh. Somebody checking a bad patch into their own fork of the project isn't
something this sort of thing would actually prevent, but oh well. If you're
doing that lib/args.c parse_optflaglist() should probably have one. (It's more
or less inlined in the function...)

Rob

(I've been squinting at lib/args.c because shells have a "getopts" that I've
never used but apparently it's a thing and I should support it and I'm wondering
if any of the code I've got is reusable for this...)



More information about the Toybox mailing list