[git commit] hush: smaller code to set o_string to ""

Denys Vlasenko vda.linux at googlemail.com
Wed Jul 18 13:50:04 UTC 2018


commit: https://git.busybox.net/busybox/commit/?id=8b08d5a502adec2067e3ebf7f27513f75b0b95e8
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

function                                             old     new   delta
encode_then_expand_vararg                            399     398      -1
parse_stream                                        2753    2748      -5

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 shell/hush.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/shell/hush.c b/shell/hush.c
index 7da8f334c..534fabbd0 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -4997,8 +4997,7 @@ static struct pipe *parse_stream(char **pstring,
 	/* If very first arg is "" or '', ctx.word.data may end up NULL.
 	 * Preventing this:
 	 */
-	o_addchr(&ctx.word, '\0');
-	ctx.word.length = 0;
+	ctx.word.data = xzalloc(1); /* start as "", not as NULL */
 
 	/* We used to separate words on $IFS here. This was wrong.
 	 * $IFS is used only for word splitting when $var is expanded,
@@ -5795,8 +5794,7 @@ static char *encode_then_expand_vararg(const char *str, int handle_squotes, int
 	 */
 
 	setup_string_in_str(&input, str);
-	o_addchr(&dest, '\0');
-	dest.length = 0;
+	dest.data = xzalloc(1); /* start as "", not as NULL */
 	exp_str = NULL;
 
 	for (;;) {


More information about the busybox-cvs mailing list