From f396a37e27230a737a52154057016c9b09c3d683 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Sun, 2 Dec 2018 08:50:49 +0000 Subject: ash: redefine SAVE_PTR macros to remove test The SAVE_PTR macros are used to identify pointers that need to be fixed after forkshell. They're initially used in contexts where the nodeptr variable may be NULL, so have a test for this condition. Later uses are in places where nodeptr is known to have a non-NULL value so the macros can be redefined to remove the test. Saves over 100 bytes. --- shell/ash.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/shell/ash.c b/shell/ash.c index 5ac118dd0..07ff29c09 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -9243,12 +9243,10 @@ static union node *copynode(union node *); # define SAVE_PTR(dst) {if (nodeptr) *nodeptr++ = (char *)&(dst);} # define SAVE_PTR2(dst1,dst2) {if (nodeptr) { *nodeptr++ = (char *)&(dst1);*nodeptr++ = (char *)&(dst2);}} # define SAVE_PTR3(dst1,dst2,dst3) {if (nodeptr) { *nodeptr++ = (char *)&(dst1);*nodeptr++ = (char *)&(dst2);*nodeptr++ = (char *)&(dst3);}} -# define SAVE_PTR4(dst1,dst2,dst3,dst4) {if (nodeptr) { *nodeptr++ = (char *)&(dst1);*nodeptr++ = (char *)&(dst2);*nodeptr++ = (char *)&(dst3);*nodeptr++ = (char *)&(dst4);}} #else # define SAVE_PTR(dst) # define SAVE_PTR2(dst,dst2) # define SAVE_PTR3(dst,dst2,dst3) -# define SAVE_PTR4(dst,dst2,dst3,dst4) #endif static struct nodelist * @@ -15132,6 +15130,16 @@ spawn_forkshell(struct job *jp, struct forkshell *fs, int mode) * * When this memory is mapped elsewhere, pointer fixup will be needed */ + +/* redefine without test that nodeptr is non-NULL */ +#undef SAVE_PTR +#undef SAVE_PTR2 +#undef SAVE_PTR3 +#define SAVE_PTR(dst) {*nodeptr++ = (char *)&(dst);} +#define SAVE_PTR2(dst1,dst2) {SAVE_PTR(dst1); SAVE_PTR(dst2);} +#define SAVE_PTR3(dst1,dst2,dst3) {SAVE_PTR2(dst1,dst2); SAVE_PTR(dst3);} +#define SAVE_PTR4(dst1,dst2,dst3,dst4) {SAVE_PTR2(dst1,dst2); SAVE_PTR2(dst3,dst4);} + static int align_len(const char *s) { return s ? SHELL_ALIGN(strlen(s)+1) : 0; -- cgit v1.2.3-55-g6feb