On Mon, 17 Apr 2023 14:15:40 -0500 Eric Blake <[email protected]> wrote:
> Exploit the value of the flag for -n to reduce the size of > readlink_main() (shown here with CONFIG_FEATURE_READLINK_FOLLOW off) > on x86_64. > > function old new delta > readlink_main 121 118 -3 > > Signed-off-by: Eric Blake <[email protected]> > > --- > > v2: Add 'make bloatcheck' details > --- > coreutils/readlink.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/coreutils/readlink.c b/coreutils/readlink.c > index 0a9aa957e..83c417e66 100644 > --- a/coreutils/readlink.c > +++ b/coreutils/readlink.c > @@ -88,7 +88,7 @@ int readlink_main(int argc UNUSED_PARAM, char **argv) > > if (!buf) > return EXIT_FAILURE; > - printf((opt & 1) ? "%s" : "%s\n", buf); > + printf("%s%s", buf, "\n"[opt & 1]); > free(buf); > > fflush_stdout_and_exit_SUCCESS(); > > base-commit: d2b81b3dc2b31d32e1060d3ea8bd998d30a37d8a Hi, I was just curious as with my limited C skills I didn't understand how "\n"[opt & 1] works, so I applied your patch and compiled it, but it seems to me that something is wrong: Prepare a link for testing: tito@devuan:~/Desktop/SourceCode/busybox_new$ ln -s busybox prova Busybox with your patch applied: $ ./busybox readlink prova Segmentation fault $ ./busybox readlink -n prova busybox(null)$ Real readlink; readlink prova busybox $ readlink -n prova busybox$ Did you intend something like: printf("%s%c", buf, '\n'*!(opt & 1)); I did not test if this reduces size. Ciao, Tito _______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
