diff options
author | Dan Fandrich <dan@coneharvesters.com> | 2010-09-07 23:38:28 -0700 |
---|---|---|
committer | Denys Vlasenko <dvlasenk@redhat.com> | 2010-09-09 11:48:02 +0200 |
commit | 77d48726917e6493a8a077be93bb07b22fd2c209 (patch) | |
tree | 71b1d17d7a8a91192d8d0cd3fe0a3dc1028b4a6a | |
parent | 95d48f259807c408de731f580bd48cf20dec724a (diff) | |
download | busybox-w32-77d48726917e6493a8a077be93bb07b22fd2c209.tar.gz busybox-w32-77d48726917e6493a8a077be93bb07b22fd2c209.tar.bz2 busybox-w32-77d48726917e6493a8a077be93bb07b22fd2c209.zip |
Avoid side effects in putc(), which may be implemented as a macro
Signed-off-by: Dan Fandrich <dan@coneharvesters.com>
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
-rw-r--r-- | coreutils/ls.c | 3 | ||||
-rw-r--r-- | coreutils/tee.c | 8 | ||||
-rw-r--r-- | shell/ash.c | 9 |
3 files changed, 12 insertions, 8 deletions
diff --git a/coreutils/ls.c b/coreutils/ls.c index cbfcfc7a1..e69f1afd9 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c | |||
@@ -573,7 +573,8 @@ static unsigned print_name(const char *name) | |||
573 | putchar('\\'); | 573 | putchar('\\'); |
574 | len++; | 574 | len++; |
575 | } | 575 | } |
576 | putchar(*name++); | 576 | putchar(*name); |
577 | name++; | ||
577 | } | 578 | } |
578 | putchar('"'); | 579 | putchar('"'); |
579 | return len; | 580 | return len; |
diff --git a/coreutils/tee.c b/coreutils/tee.c index 8db9042aa..2e1e367f2 100644 --- a/coreutils/tee.c +++ b/coreutils/tee.c | |||
@@ -70,8 +70,8 @@ int tee_main(int argc, char **argv) | |||
70 | while ((c = safe_read(STDIN_FILENO, buf, sizeof(buf))) > 0) { | 70 | while ((c = safe_read(STDIN_FILENO, buf, sizeof(buf))) > 0) { |
71 | fp = files; | 71 | fp = files; |
72 | do | 72 | do |
73 | fwrite(buf, 1, c, *fp++); | 73 | fwrite(buf, 1, c, *fp); |
74 | while (*fp); | 74 | while (*++fp); |
75 | } | 75 | } |
76 | if (c < 0) { /* Make sure read errors are signaled. */ | 76 | if (c < 0) { /* Make sure read errors are signaled. */ |
77 | retval = EXIT_FAILURE; | 77 | retval = EXIT_FAILURE; |
@@ -81,8 +81,8 @@ int tee_main(int argc, char **argv) | |||
81 | while ((c = getchar()) != EOF) { | 81 | while ((c = getchar()) != EOF) { |
82 | fp = files; | 82 | fp = files; |
83 | do | 83 | do |
84 | putc(c, *fp++); | 84 | putc(c, *fp); |
85 | while (*fp); | 85 | while (*++fp); |
86 | } | 86 | } |
87 | #endif | 87 | #endif |
88 | 88 | ||
diff --git a/shell/ash.c b/shell/ash.c index 70425b324..f262872ea 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -953,7 +953,8 @@ sharg(union node *arg, FILE *fp) | |||
953 | for (p = arg->narg.text; *p; p++) { | 953 | for (p = arg->narg.text; *p; p++) { |
954 | switch ((unsigned char)*p) { | 954 | switch ((unsigned char)*p) { |
955 | case CTLESC: | 955 | case CTLESC: |
956 | putc(*++p, fp); | 956 | p++; |
957 | putc(*p, fp); | ||
957 | break; | 958 | break; |
958 | case CTLVAR: | 959 | case CTLVAR: |
959 | putc('$', fp); | 960 | putc('$', fp); |
@@ -962,8 +963,10 @@ sharg(union node *arg, FILE *fp) | |||
962 | if (subtype == VSLENGTH) | 963 | if (subtype == VSLENGTH) |
963 | putc('#', fp); | 964 | putc('#', fp); |
964 | 965 | ||
965 | while (*p != '=') | 966 | while (*p != '=') { |
966 | putc(*p++, fp); | 967 | putc(*p, fp); |
968 | p++; | ||
969 | } | ||
967 | 970 | ||
968 | if (subtype & VSNUL) | 971 | if (subtype & VSNUL) |
969 | putc(':', fp); | 972 | putc(':', fp); |