Combined size reduction changes by Glenn and myself. Added back in "unknown" for -p to match normal uname behavior (at a cost of 30-40 bytes).
No binary (build failed)
—
$ git checkout -f 6509f92a3b26b2d91b1552376c68b859782b6273
HEAD is now at 6509f92a3 Combined size reduction changes by Glenn and myself. Added back in "unknown" for -p to match normal uname behavior (at a cost of 30-40 bytes).
$ git clean -fdx
Removing .menuconfig.log
Removing MCmenu0
Removing MCmenu1
Removing MCmenu2
Removing MCmenu3
Removing MCmenu4
Removing include/config/
Removing scripts/lxdialog/checklist.o
Removing scripts/lxdialog/inputbox.o
Removing scripts/lxdialog/lxdialog
Removing scripts/lxdialog/lxdialog.o
Removing scripts/lxdialog/menubox.o
Removing scripts/lxdialog/msgbox.o
Removing scripts/lxdialog/textbox.o
Removing scripts/lxdialog/util.o
Removing scripts/lxdialog/yesno.o
$ make SHELL=/bin/bash CC=/root/asi_db/compat/cc-wrapper.sh HOSTCC=/root/asi_db/compat/cc-wrapper.sh defconfig
make: *** No rule to make target 'defconfig'. Stop.
$ make SHELL=/bin/bash CC=/root/asi_db/compat/cc-wrapper.sh HOSTCC=/root/asi_db/compat/cc-wrapper.sh allnoconfig
make: *** No rule to make target 'allnoconfig'. Stop.
$ make SHELL=/bin/bash CC=/root/asi_db/compat/cc-wrapper.sh HOSTCC=/root/asi_db/compat/cc-wrapper.sh include/bb_config.h
make: *** No rule to make target 'include/bb_config.h'. Stop.
$ make SHELL=/bin/bash CC=/root/asi_db/compat/cc-wrapper.sh HOSTCC=/root/asi_db/compat/cc-wrapper.sh -j3 V=1
mkdir -p /root/asi_db/builds/busybox/_worktrees/w0/include/config
make -C scripts/lxdialog all
make[1]: Entering directory '/root/asi_db/builds/busybox/_worktrees/w0/scripts/lxdialog'
/root/asi_db/compat/cc-wrapper.sh -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -DLOCALE -DCURSES_LOC="<ncurses.h>" -c -o checklist.o checklist.c
/root/asi_db/compat/cc-wrapper.sh -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -DLOCALE -DCURSES_LOC="<ncurses.h>" -c -o menubox.o menubox.c
/root/asi_db/compat/cc-wrapper.sh -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -DLOCALE -DCURSES_LOC="<ncurses.h>" -c -o textbox.o textbox.c
/root/asi_db/compat/cc-wrapper.sh -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -DLOCALE -DCURSES_LOC="<ncurses.h>" -c -o yesno.o yesno.c
/root/asi_db/compat/cc-wrapper.sh -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -DLOCALE -DCURSES_LOC="<ncurses.h>" -c -o inputbox.o inputbox.c
/root/asi_db/compat/cc-wrapper.sh -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -DLOCALE -DCURSES_LOC="<ncurses.h>" -c -o util.o util.c
/root/asi_db/compat/cc-wrapper.sh -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -DLOCALE -DCURSES_LOC="<ncurses.h>" -c -o lxdialog.o lxdialog.c
/root/asi_db/compat/cc-wrapper.sh -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -DLOCALE -DCURSES_LOC="<ncurses.h>" -c -o msgbox.o msgbox.c
/root/asi_db/compat/cc-wrapper.sh -o lxdialog checklist.o menubox.o textbox.o yesno.o inputbox.o util.o lxdialog.o msgbox.o -lncurses
make[1]: Leaving directory '/root/asi_db/builds/busybox/_worktrees/w0/scripts/lxdialog'
/bin/bash scripts/Menuconfig sysdeps/linux/config.in
Using defaults found in sysdeps/linux/defconfig
Preparing scripts: functions, parsingAwk died with error code 137. Giving up.
.....done.
Your BusyBox configuration changes were NOT saved.
lxtemp.c:1:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
1 | main() {}
| ^~~~
textbox.c: In function ‘dialog_textbox’:
textbox.c:42:10: warning: variable ‘search_term’ set but not used [-Wunused-but-set-variable]
42 | char search_term[MAX_LEN + 1];
| ^~~~~~~~~~~
textbox.c: In function ‘print_line’:
textbox.c:462:12: warning: variable ‘x’ set but not used [-Wunused-but-set-variable]
462 | int y, x;
| ^
textbox.c:462:9: warning: variable ‘y’ set but not used [-Wunused-but-set-variable]
462 | int y, x;
| ^
inputbox.c: In function ‘dialog_inputbox’:
inputbox.c:107:17: warning: pointer targets in passing argument 1 of ‘strcpy’ differ in signedness [-Wpointer-sign]
107 | strcpy (instr, init);
| ^~~~~
| |
| unsigned char *
In file included from /usr/include/features.h:486,
from /usr/include/x86_64-linux-gnu/sys/sysmacros.h:22,
from /root/asi_db/compat/compat_stime.h:9,
from <command-line>:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:77:1: note: expected ‘char * restrict’ but argument is of type ‘unsigned char *’
77 | __NTH (strcpy (char *__restrict __dest, const char *__restrict __src))
| ^~~~~
inputbox.c:109:23: warning: pointer targets in passing argument 1 of ‘strlen’ differ in signedness [-Wpointer-sign]
109 | input_x = strlen (instr);
| ^~~~~
| |
| unsigned char *
In file included from dialog.h:27,
from inputbox.c:22:
/usr/include/string.h:407:35: note: expected ‘const char *’ but argument is of type ‘unsigned char *’
407 | extern size_t strlen (const char *__s)
| ~~~~~~~~~~~~^~~
In file included from dialog.h:29,
from inputbox.c:22:
inputbox.c:117:26: warning: pointer targets in passing argument 2 of ‘waddnstr’ differ in signedness [-Wpointer-sign]
117 | waddstr (dialog, instr);
| ^~~~~
| |
| unsigned char *
/usr/include/curses.h:830:47: note: expected ‘const char *’ but argument is of type ‘unsigned char *’
830 | extern NCURSES_EXPORT(int) waddnstr (WINDOW *,const char *,int); /* implemented */
| ^~~~~~~~~~~~
inputbox.c:147:43: warning: pointer targets in passing argument 1 of ‘strlen’ differ in signedness [-Wpointer-sign]
147 | input_x = strlen (instr) - scroll;
| ^~~~~
| |
| unsigned char *
In file included from dialog.h:27,
from inputbox.c:22:
/usr/include/string.h:407:35: note: expected ‘const char *’ but argument is of type ‘unsigned char *’
407 | extern size_t strlen (const char *__s)
| ~~~~~~~~~~~~^~~
lxdialog.c: In function ‘j_inputbox’:
lxdialog.c:211:25: warning: pointer targets in passing argument 2 of ‘fprintf’ differ in signedness [-Wpointer-sign]
211 | fprintf(stderr, dialog_input_result);
| ^~~~~~~~~~~~~~~~~~~
| |
| unsigned char *
In file included from /usr/include/stdio.h:894,
from /usr/include/curses.h:232,
from dialog.h:29,
from lxdialog.c:22:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:103:60: note: expected ‘const char * restrict’ but argument is of type ‘unsigned char *’
103 | fprintf (FILE *__restrict __stream, const char *__restrict __fmt, ...)
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
lxdialog.c:211:25: warning: format not a string literal and no format arguments [-Wformat-security]
211 | fprintf(stderr, dialog_input_result);
| ^~~~~~~~~~~~~~~~~~~
scripts/Menuconfig: line 559: 1018095 Killed awk "$1"
Error opening terminal: unknown.
| @@ -31,126 +31,78 @@ | |
| /* Busyboxed by Erik Andersen */ | |
| + | /* Further size reductions by Glenn McGrath and Manuel Novoa III. */ |
| + | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| + | #include <stddef.h> |
| #include <string.h> | |
| #include <sys/types.h> | |
| #include <sys/utsname.h> | |
| - | |
| - | #if defined (HAVE_SYSINFO) && defined (HAVE_SYS_SYSTEMINFO_H) |
| - | # include <sys/systeminfo.h> |
| - | #endif |
| + | #include <getopt.h> |
| #include "busybox.h" | |
| - | static void print_element(unsigned int mask, char *element); |
| - | |
| - | /* Values that are bitwise or'd into `toprint'. */ |
| - | /* Operating system name. */ |
| - | static const int PRINT_SYSNAME = 1; |
| - | |
| - | /* Node name on a communications network. */ |
| - | static const int PRINT_NODENAME = 2; |
| - | |
| - | /* Operating system release. */ |
| - | static const int PRINT_RELEASE = 4; |
| - | |
| - | /* Operating system version. */ |
| - | static const int PRINT_VERSION = 8; |
| - | |
| - | /* Machine hardware name. */ |
| - | static const int PRINT_MACHINE = 16; |
| - | |
| - | /* Host processor type. */ |
| - | static const int PRINT_PROCESSOR = 32; |
| - | |
| - | /* Mask indicating which elements of the name to print. */ |
| - | static unsigned char toprint; |
| - | |
| + | typedef struct { |
| + | struct utsname name; |
| + | char processor[8]; /* for "unknown" */ |
| + | } uname_info_t; |
| + | |
| + | static const char options[] = "snrvmpa"; |
| + | static const char flags[] = "\x01\x02\x04\x08\x10\x20\x3f"; |
| + | static const unsigned short int utsname_offset[] = { |
| + | offsetof(uname_info_t,name.sysname), |
| + | offsetof(uname_info_t,name.nodename), |
| + | offsetof(uname_info_t,name.release), |
| + | offsetof(uname_info_t,name.version), |
| + | offsetof(uname_info_t,name.machine), |
| + | offsetof(uname_info_t,processor) |
| + | }; |
| int uname_main(int argc, char **argv) | |
| { | |
| - | struct utsname name; |
| - | char processor[256]; |
| + | uname_info_t uname_info; |
| #if defined(__sparc__) && defined(__linux__) | |
| char *fake_sparc = getenv("FAKE_SPARC"); | |
| #endif | |
| - | toprint = 0; |
| - | |
| - | /* Parse any options */ |
| - | //fprintf(stderr, "argc=%d, argv=%s\n", argc, *argv); |
| - | while (--argc > 0 && **(++argv) == '-') { |
| - | while (*(++(*argv))) { |
| - | switch (**argv) { |
| - | case 's': |
| - | toprint |= PRINT_SYSNAME; |
| - | break; |
| - | case 'n': |
| - | toprint |= PRINT_NODENAME; |
| - | break; |
| - | case 'r': |
| - | toprint |= PRINT_RELEASE; |
| - | break; |
| - | case 'v': |
| - | toprint |= PRINT_VERSION; |
| - | break; |
| - | case 'm': |
| - | toprint |= PRINT_MACHINE; |
| - | break; |
| - | case 'p': |
| - | toprint |= PRINT_PROCESSOR; |
| - | break; |
| - | case 'a': |
| - | toprint = (PRINT_SYSNAME | PRINT_NODENAME | PRINT_RELEASE | |
| - | PRINT_PROCESSOR | PRINT_VERSION | |
| - | PRINT_MACHINE); |
| - | break; |
| - | default: |
| - | show_usage(); |
| - | } |
| + | const unsigned short int *delta; |
| + | int opt; |
| + | char toprint = 0; |
| + | |
| + | while ((opt = getopt(argc, argv, options)) != -1) { |
| + | const char *p = strchr(options,opt); |
| + | if (p == NULL) { |
| + | show_usage(); |
| } | |
| + | toprint |= flags[(int)(p-options)]; |
| } | |
| - | if (toprint == 0) |
| - | toprint = PRINT_SYSNAME; |
| - | |
| - | if (uname(&name) == -1) |
| - | perror_msg("cannot get system name"); |
| - | |
| - | #if defined (HAVE_SYSINFO) && defined (SI_ARCHITECTURE) |
| - | if (sysinfo(SI_ARCHITECTURE, processor, sizeof(processor)) == -1) |
| - | perror_msg("cannot get processor type"); |
| - | } |
| + | if (toprint == 0) { |
| + | toprint = flags[0]; /* sysname */ |
| + | } |
| - | #else |
| - | strcpy(processor, "unknown"); |
| - | #endif |
| + | if (uname(&uname_info.name) == -1) { |
| + | error_msg_and_die("cannot get system name"); |
| + | } |
| #if defined(__sparc__) && defined(__linux__) | |
| - | if (fake_sparc != NULL |
| - | && (fake_sparc[0] == 'y' |
| - | || fake_sparc[0] == 'Y')) strcpy(name.machine, "sparc"); |
| + | if ((fake_sparc != NULL) |
| + | && ((fake_sparc[0] == 'y') |
| + | || (fake_sparc[0] == 'Y'))) { |
| + | strcpy(uname_info.name.machine, "sparc"); |
| + | } |
| #endif | |
| - | print_element(PRINT_SYSNAME, name.sysname); |
| - | print_element(PRINT_NODENAME, name.nodename); |
| - | print_element(PRINT_RELEASE, name.release); |
| - | print_element(PRINT_VERSION, name.version); |
| - | print_element(PRINT_MACHINE, name.machine); |
| - | print_element(PRINT_PROCESSOR, processor); |
| + | strcpy(uname_info.processor, "unknown"); |
| - | return EXIT_SUCCESS; |
| - | } |
| + | for (delta=utsname_offset ; toprint ; delta++, toprint >>= 1) { |
| + | if (toprint & 1) { |
| + | printf("%s ", ((char *)(&uname_info)) + *delta ); |
| + | } |
| + | } |
| - | /* If the name element set in MASK is selected for printing in `toprint', |
| - | print ELEMENT; then print a space unless it is the last element to |
| - | be printed, in which case print a newline. */ |
| + | putchar('\n'); |
| - | static void print_element(unsigned int mask, char *element) |
| - | { |
| - | if (toprint & mask) { |
| - | toprint &= ~mask; |
| - | printf("%s%c", element, toprint ? ' ' : '\n'); |
| - | } |
| + | return EXIT_SUCCESS; |
| } | |