[Toybox] ifconfig: simplify exit with help

Isaac Dunham idunham at lavabit.com
Sat Apr 13 23:03:51 PDT 2013


This patch simplifies exiting with help in ifconfig.
Has no change on binary size, but loses 37 lines.

Also means that ifconfig --help exits cleanly with help disabled.

On Sat, 13 Apr 2013 17:56:34 -0700
Isaac Dunham <idunham at lavabit.com> wrote:
> I took a look at ifconfig to see about show_help vs toys.exithelp, and I saw this repeated 16 times ("string" is the only thing that changes):
> } else if (!strcmp(*argv, "string")) {
>   if(*++argv == NULL) {
>     errno = EINVAL;
>     show_help();
>   }
>   set_string(...)
> 
> This looks like a pretty obvious candidate for a helper function that does more than show help and exit.

Patch attached.
-- 
Isaac Dunham <idunham at lavabit.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ifconfig-help.diff
Type: text/x-diff
Size: 5541 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20130413/5bbe8402/attachment-0002.diff>


More information about the Toybox mailing list