diff options
author | Ron Yorston <rmy@pobox.com> | 2018-12-02 08:50:49 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2018-12-02 08:50:49 +0000 |
commit | f396a37e27230a737a52154057016c9b09c3d683 (patch) | |
tree | ae1dbad0607f8fe5f2c8bb2818713fbcdc24ffe6 | |
parent | 9dbddc7e030355e4151af39ced599cca3fd6ac89 (diff) | |
download | busybox-w32-f396a37e27230a737a52154057016c9b09c3d683.tar.gz busybox-w32-f396a37e27230a737a52154057016c9b09c3d683.tar.bz2 busybox-w32-f396a37e27230a737a52154057016c9b09c3d683.zip |
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.
-rw-r--r-- | shell/ash.c | 12 |
1 files 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 *); | |||
9243 | # define SAVE_PTR(dst) {if (nodeptr) *nodeptr++ = (char *)&(dst);} | 9243 | # define SAVE_PTR(dst) {if (nodeptr) *nodeptr++ = (char *)&(dst);} |
9244 | # define SAVE_PTR2(dst1,dst2) {if (nodeptr) { *nodeptr++ = (char *)&(dst1);*nodeptr++ = (char *)&(dst2);}} | 9244 | # define SAVE_PTR2(dst1,dst2) {if (nodeptr) { *nodeptr++ = (char *)&(dst1);*nodeptr++ = (char *)&(dst2);}} |
9245 | # define SAVE_PTR3(dst1,dst2,dst3) {if (nodeptr) { *nodeptr++ = (char *)&(dst1);*nodeptr++ = (char *)&(dst2);*nodeptr++ = (char *)&(dst3);}} | 9245 | # define SAVE_PTR3(dst1,dst2,dst3) {if (nodeptr) { *nodeptr++ = (char *)&(dst1);*nodeptr++ = (char *)&(dst2);*nodeptr++ = (char *)&(dst3);}} |
9246 | # define SAVE_PTR4(dst1,dst2,dst3,dst4) {if (nodeptr) { *nodeptr++ = (char *)&(dst1);*nodeptr++ = (char *)&(dst2);*nodeptr++ = (char *)&(dst3);*nodeptr++ = (char *)&(dst4);}} | ||
9247 | #else | 9246 | #else |
9248 | # define SAVE_PTR(dst) | 9247 | # define SAVE_PTR(dst) |
9249 | # define SAVE_PTR2(dst,dst2) | 9248 | # define SAVE_PTR2(dst,dst2) |
9250 | # define SAVE_PTR3(dst,dst2,dst3) | 9249 | # define SAVE_PTR3(dst,dst2,dst3) |
9251 | # define SAVE_PTR4(dst,dst2,dst3,dst4) | ||
9252 | #endif | 9250 | #endif |
9253 | 9251 | ||
9254 | static struct nodelist * | 9252 | static struct nodelist * |
@@ -15132,6 +15130,16 @@ spawn_forkshell(struct job *jp, struct forkshell *fs, int mode) | |||
15132 | * | 15130 | * |
15133 | * When this memory is mapped elsewhere, pointer fixup will be needed | 15131 | * When this memory is mapped elsewhere, pointer fixup will be needed |
15134 | */ | 15132 | */ |
15133 | |||
15134 | /* redefine without test that nodeptr is non-NULL */ | ||
15135 | #undef SAVE_PTR | ||
15136 | #undef SAVE_PTR2 | ||
15137 | #undef SAVE_PTR3 | ||
15138 | #define SAVE_PTR(dst) {*nodeptr++ = (char *)&(dst);} | ||
15139 | #define SAVE_PTR2(dst1,dst2) {SAVE_PTR(dst1); SAVE_PTR(dst2);} | ||
15140 | #define SAVE_PTR3(dst1,dst2,dst3) {SAVE_PTR2(dst1,dst2); SAVE_PTR(dst3);} | ||
15141 | #define SAVE_PTR4(dst1,dst2,dst3,dst4) {SAVE_PTR2(dst1,dst2); SAVE_PTR2(dst3,dst4);} | ||
15142 | |||
15135 | static int align_len(const char *s) | 15143 | static int align_len(const char *s) |
15136 | { | 15144 | { |
15137 | return s ? SHELL_ALIGN(strlen(s)+1) : 0; | 15145 | return s ? SHELL_ALIGN(strlen(s)+1) : 0; |