diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-01-30 22:28:21 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-01-30 22:28:21 +0000 |
commit | 15d78fb7241e324a823d00654206695a4f250648 (patch) | |
tree | 5e424d105bdb9c368f16e53de345a726fb0ce206 | |
parent | 34c4e5f0b35c6c3878197b01c2d4695e148ec338 (diff) | |
download | busybox-w32-15d78fb7241e324a823d00654206695a4f250648.tar.gz busybox-w32-15d78fb7241e324a823d00654206695a4f250648.tar.bz2 busybox-w32-15d78fb7241e324a823d00654206695a4f250648.zip |
hust: -Wwrite-strings fixes
-rw-r--r-- | shell/hush.c | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/shell/hush.c b/shell/hush.c index dca04b5a6..1540327f1 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -216,8 +216,8 @@ struct close_me { | |||
216 | }; | 216 | }; |
217 | 217 | ||
218 | struct variables { | 218 | struct variables { |
219 | char *name; | 219 | const char *name; |
220 | char *value; | 220 | const char *value; |
221 | int flg_export; | 221 | int flg_export; |
222 | int flg_read_only; | 222 | int flg_read_only; |
223 | struct variables *next; | 223 | struct variables *next; |
@@ -284,7 +284,8 @@ struct built_in_command { | |||
284 | }; | 284 | }; |
285 | 285 | ||
286 | /* belongs in busybox.h */ | 286 | /* belongs in busybox.h */ |
287 | static int max(int a, int b) { | 287 | static int max(int a, int b) |
288 | { | ||
288 | return (a>b)?a:b; | 289 | return (a>b)?a:b; |
289 | } | 290 | } |
290 | 291 | ||
@@ -376,7 +377,7 @@ static int redirect_dup_num(struct in_str *input); | |||
376 | static int redirect_opt_num(o_string *o); | 377 | static int redirect_opt_num(o_string *o); |
377 | static int process_command_subs(o_string *dest, struct p_context *ctx, struct in_str *input, int subst_end); | 378 | static int process_command_subs(o_string *dest, struct p_context *ctx, struct in_str *input, int subst_end); |
378 | static int parse_group(o_string *dest, struct p_context *ctx, struct in_str *input, int ch); | 379 | static int parse_group(o_string *dest, struct p_context *ctx, struct in_str *input, int ch); |
379 | static char *lookup_param(char *src); | 380 | static const char *lookup_param(const char *src); |
380 | static char *make_string(char **inp); | 381 | static char *make_string(char **inp); |
381 | static int handle_dollar(o_string *dest, struct p_context *ctx, struct in_str *input); | 382 | static int handle_dollar(o_string *dest, struct p_context *ctx, struct in_str *input); |
382 | static int parse_string(o_string *dest, struct p_context *ctx, const char *src); | 383 | static int parse_string(o_string *dest, struct p_context *ctx, const char *src); |
@@ -392,7 +393,7 @@ static void remove_bg_job(struct pipe *pi); | |||
392 | /* local variable support */ | 393 | /* local variable support */ |
393 | static char **make_list_in(char **inp, char *name); | 394 | static char **make_list_in(char **inp, char *name); |
394 | static char *insert_var_value(char *inp); | 395 | static char *insert_var_value(char *inp); |
395 | static char *get_local_var(const char *var); | 396 | static const char *get_local_var(const char *var); |
396 | static void unset_local_var(const char *name); | 397 | static void unset_local_var(const char *name); |
397 | static int set_local_var(const char *s, int flg_export); | 398 | static int set_local_var(const char *s, int flg_export); |
398 | 399 | ||
@@ -513,7 +514,7 @@ static int builtin_export(struct child_prog *child) | |||
513 | name = strdup(name); | 514 | name = strdup(name); |
514 | 515 | ||
515 | if(name) { | 516 | if(name) { |
516 | char *value = strchr(name, '='); | 517 | const char *value = strchr(name, '='); |
517 | 518 | ||
518 | if (!value) { | 519 | if (!value) { |
519 | char *tmp; | 520 | char *tmp; |
@@ -1761,7 +1762,7 @@ static int xglob(o_string *dest, int flags, glob_t *pglob) | |||
1761 | } | 1762 | } |
1762 | 1763 | ||
1763 | /* This is used to get/check local shell variables */ | 1764 | /* This is used to get/check local shell variables */ |
1764 | static char *get_local_var(const char *s) | 1765 | static const char *get_local_var(const char *s) |
1765 | { | 1766 | { |
1766 | struct variables *cur; | 1767 | struct variables *cur; |
1767 | 1768 | ||
@@ -1803,7 +1804,7 @@ static int set_local_var(const char *s, int flg_export) | |||
1803 | if(cur) { | 1804 | if(cur) { |
1804 | if(strcmp(cur->value, value)==0) { | 1805 | if(strcmp(cur->value, value)==0) { |
1805 | if(flg_export>0 && cur->flg_export==0) | 1806 | if(flg_export>0 && cur->flg_export==0) |
1806 | cur->flg_export=flg_export; | 1807 | cur->flg_export = flg_export; |
1807 | else | 1808 | else |
1808 | result++; | 1809 | result++; |
1809 | } else { | 1810 | } else { |
@@ -1813,7 +1814,7 @@ static int set_local_var(const char *s, int flg_export) | |||
1813 | } else { | 1814 | } else { |
1814 | if(flg_export>0 || cur->flg_export>1) | 1815 | if(flg_export>0 || cur->flg_export>1) |
1815 | cur->flg_export=1; | 1816 | cur->flg_export=1; |
1816 | free(cur->value); | 1817 | free((char*)cur->value); |
1817 | 1818 | ||
1818 | cur->value = strdup(value); | 1819 | cur->value = strdup(value); |
1819 | } | 1820 | } |
@@ -1867,8 +1868,8 @@ static void unset_local_var(const char *name) | |||
1867 | } else { | 1868 | } else { |
1868 | if(cur->flg_export) | 1869 | if(cur->flg_export) |
1869 | unsetenv(cur->name); | 1870 | unsetenv(cur->name); |
1870 | free(cur->name); | 1871 | free((char*)cur->name); |
1871 | free(cur->value); | 1872 | free((char*)cur->value); |
1872 | while (next->next != cur) | 1873 | while (next->next != cur) |
1873 | next = next->next; | 1874 | next = next->next; |
1874 | next->next = cur->next; | 1875 | next->next = cur->next; |
@@ -2288,9 +2289,9 @@ static int parse_group(o_string *dest, struct p_context *ctx, | |||
2288 | 2289 | ||
2289 | /* basically useful version until someone wants to get fancier, | 2290 | /* basically useful version until someone wants to get fancier, |
2290 | * see the bash man page under "Parameter Expansion" */ | 2291 | * see the bash man page under "Parameter Expansion" */ |
2291 | static char *lookup_param(char *src) | 2292 | static const char *lookup_param(const char *src) |
2292 | { | 2293 | { |
2293 | char *p=NULL; | 2294 | const char *p = NULL; |
2294 | if (src) { | 2295 | if (src) { |
2295 | p = getenv(src); | 2296 | p = getenv(src); |
2296 | if (!p) | 2297 | if (!p) |
@@ -2785,7 +2786,8 @@ static char *insert_var_value(char *inp) | |||
2785 | int res_str_len = 0; | 2786 | int res_str_len = 0; |
2786 | int len; | 2787 | int len; |
2787 | int done = 0; | 2788 | int done = 0; |
2788 | char *p, *p1, *res_str = NULL; | 2789 | char *p, *res_str = NULL; |
2790 | const char *p1; | ||
2789 | 2791 | ||
2790 | while ((p = strchr(inp, SPECIAL_VAR_SYMBOL))) { | 2792 | while ((p = strchr(inp, SPECIAL_VAR_SYMBOL))) { |
2791 | if (p != inp) { | 2793 | if (p != inp) { |
@@ -2797,7 +2799,8 @@ static char *insert_var_value(char *inp) | |||
2797 | inp = ++p; | 2799 | inp = ++p; |
2798 | p = strchr(inp, SPECIAL_VAR_SYMBOL); | 2800 | p = strchr(inp, SPECIAL_VAR_SYMBOL); |
2799 | *p = '\0'; | 2801 | *p = '\0'; |
2800 | if ((p1 = lookup_param(inp))) { | 2802 | p1 = lookup_param(inp); |
2803 | if (p1) { | ||
2801 | len = res_str_len + strlen(p1); | 2804 | len = res_str_len + strlen(p1); |
2802 | res_str = xrealloc(res_str, (1 + len)); | 2805 | res_str = xrealloc(res_str, (1 + len)); |
2803 | strcpy((res_str + res_str_len), p1); | 2806 | strcpy((res_str + res_str_len), p1); |