preparatory patch for -Wwrite-strings #2
No binary (build failed)
—
(log yok)
| @@ -1417,10 +1417,10 @@ static void init_archive_deb_control(archive_handle_t *ar_handle) | |
| /* We don't care about data.tar.* or debian-binary, just control.tar.* */ | |
| #ifdef CONFIG_FEATURE_DEB_TAR_GZ | |
| - | llist_add_to(&(ar_handle->accept), "control.tar.gz"); |
| + | llist_add_to(&(ar_handle->accept), (char*)"control.tar.gz"); |
| #endif | |
| #ifdef CONFIG_FEATURE_DEB_TAR_BZ2 | |
| - | llist_add_to(&(ar_handle->accept), "control.tar.bz2"); |
| + | llist_add_to(&(ar_handle->accept), (char*)"control.tar.bz2"); |
| #endif | |
| /* Assign the tar handle as a subarchive of the ar handle */ | |
| @@ -1439,10 +1439,10 @@ static void init_archive_deb_data(archive_handle_t *ar_handle) | |
| /* We don't care about control.tar.* or debian-binary, just data.tar.* */ | |
| #ifdef CONFIG_FEATURE_DEB_TAR_GZ | |
| - | llist_add_to(&(ar_handle->accept), "data.tar.gz"); |
| + | llist_add_to(&(ar_handle->accept), (char*)"data.tar.gz"); |
| #endif | |
| #ifdef CONFIG_FEATURE_DEB_TAR_BZ2 | |
| - | llist_add_to(&(ar_handle->accept), "data.tar.bz2"); |
| + | llist_add_to(&(ar_handle->accept), (char*)"data.tar.bz2"); |
| #endif | |
| /* Assign the tar handle as a subarchive of the ar handle */ | |
| @@ -1525,7 +1525,7 @@ static void unpack_package(deb_file_t *deb_file) | |
| archive_handle = init_archive_deb_ar(deb_file->filename); | |
| init_archive_deb_data(archive_handle); | |
| archive_handle->sub_archive->action_data = data_extract_all_prefix; | |
| - | archive_handle->sub_archive->buffer = "/"; |
| + | archive_handle->sub_archive->buffer = (char*)"/"; /* huh? */ |
| archive_handle->sub_archive->flags |= ARCHIVE_EXTRACT_UNCONDITIONAL; | |
| unpack_ar_archive(archive_handle); | |
| @@ -1629,7 +1629,7 @@ int dpkg_main(int argc, char **argv) | |
| llist_t *control_list = NULL; | |
| /* Extract the control file */ | |
| - | llist_add_to(&control_list, "./control"); |
| + | llist_add_to(&control_list, (char*)"./control"); |
| archive_handle = init_archive_deb_ar(argv[0]); | |
| init_archive_deb_control(archive_handle); | |
| deb_file[deb_count]->control_file = deb_extract_control_file_to_buffer(archive_handle, control_list); | |
| @@ -19,7 +19,7 @@ int dpkg_deb_main(int argc, char **argv) | |
| archive_handle_t *tar_archive; | |
| llist_t *control_tar_llist = NULL; | |
| unsigned opt; | |
| - | char *extract_dir = NULL; |
| + | const char *extract_dir = NULL; |
| short argcount = 1; | |
| /* Setup the tar archive handle */ | |
| @@ -31,13 +31,13 @@ int dpkg_deb_main(int argc, char **argv) | |
| ar_archive->filter = filter_accept_list_reassign; | |
| #ifdef CONFIG_FEATURE_DEB_TAR_GZ | |
| - | llist_add_to(&(ar_archive->accept), "data.tar.gz"); |
| - | llist_add_to(&control_tar_llist, "control.tar.gz"); |
| + | llist_add_to(&(ar_archive->accept), (char*)"data.tar.gz"); |
| + | llist_add_to(&control_tar_llist, (char*)"control.tar.gz"); |
| #endif | |
| #ifdef CONFIG_FEATURE_DEB_TAR_BZ2 | |
| - | llist_add_to(&(ar_archive->accept), "data.tar.bz2"); |
| - | llist_add_to(&control_tar_llist, "control.tar.bz2"); |
| + | llist_add_to(&(ar_archive->accept), (char*)"data.tar.bz2"); |
| + | llist_add_to(&control_tar_llist, (char*)"control.tar.bz2"); |
| #endif | |
| opt_complementary = "?c--efXx:e--cfXx:f--ceXx:X--cefx:x--cefX"; | |
| @@ -60,7 +60,7 @@ int dpkg_deb_main(int argc, char **argv) | |
| * it should accept a second argument which specifies a | |
| * specific field to print */ | |
| ar_archive->accept = control_tar_llist; | |
| - | llist_add_to(&(tar_archive->accept), "./control"); |
| + | llist_add_to(&(tar_archive->accept), (char*)"./control"); |
| tar_archive->filter = filter_accept_list; | |
| tar_archive->action_data = data_extract_to_stdout; | |
| } | |
| @@ -168,7 +168,7 @@ static void cleanup_outname(void) | |
| /* strdup, replacing "\n" with '\n', and "\delimiter" with 'delimiter' */ | |
| - | static void parse_escapes(char *dest, char *string, int len, char from, char to) |
| + | static void parse_escapes(char *dest, const char *string, int len, char from, char to) |
| { | |
| int i = 0; | |
| @@ -186,7 +186,7 @@ static void parse_escapes(char *dest, char *string, int len, char from, char to) | |
| *dest = 0; | |
| } | |
| - | static char *copy_parsing_escapes(char *string, int len) |
| + | static char *copy_parsing_escapes(const char *string, int len) |
| { | |
| char *dest = xmalloc(len + 1); | |
| @@ -201,7 +201,7 @@ static char *copy_parsing_escapes(char *string, int len) | |
| * expression delimiter (typically a forward * slash ('/')) not preceded by | |
| * a backslash ('\'). A negative delimiter disables square bracket checking. | |
| */ | |
| - | static int index_of_next_unescaped_regexp_delim(int delimiter, char *str) |
| + | static int index_of_next_unescaped_regexp_delim(int delimiter, const char *str) |
| { | |
| int bracket = -1; | |
| int escaped = 0; | |
| @@ -262,12 +262,12 @@ static int parse_regex_delim(char *cmdstr, char **match, char **replace) | |
| /* | |
| * returns the index in the string just past where the address ends. | |
| */ | |
| - | static int get_address(char *my_str, int *linenum, regex_t ** regex) |
| + | static int get_address(const char *my_str, int *linenum, regex_t ** regex) |
| { | |
| - | char *pos = my_str; |
| + | const char *pos = my_str; |
| if (isdigit(*my_str)) { | |
| - | *linenum = strtol(my_str, &pos, 10); |
| + | *linenum = strtol(my_str, (char**)&pos, 10); |
| /* endstr shouldnt ever equal NULL */ | |
| } else if (*my_str == '$') { | |
| *linenum = -1; | |
| @@ -314,7 +314,7 @@ static int parse_subst_cmd(sed_cmd_t *sed_cmd, char *substr) | |
| { | |
| int cflags = bbg.regex_type; | |
| char *match; | |
| - | int idx = 0; |
| + | int idx; |
| /* | |
| * A substitution command should look something like this: | |
| @@ -469,16 +469,16 @@ static char *parse_cmd_args(sed_cmd_t *sed_cmd, char *cmdstr) | |
| /* Parse address+command sets, skipping comment lines. */ | |
| - | static void add_cmd(char *cmdstr) |
| + | static void add_cmd(const char *cmdstr) |
| { | |
| sed_cmd_t *sed_cmd; | |
| int temp; | |
| /* Append this line to any unfinished line from last time. */ | |
| if (bbg.add_cmd_line) { | |
| - | cmdstr = xasprintf("%s\n%s", bbg.add_cmd_line, cmdstr); |
| + | char *tp = xasprintf("%s\n%s", bbg.add_cmd_line, cmdstr); |
| free(bbg.add_cmd_line); | |
| - | bbg.add_cmd_line = cmdstr; |
| + | bbg.add_cmd_line = tp; |
| } | |
| /* If this line ends with backslash, request next line. */ | |
| @@ -416,7 +416,7 @@ int xargs_main(int argc, char **argv) | |
| argv += optind; | |
| if (!argc) { | |
| /* default behavior is to echo all the filenames */ | |
| - | *argv = "echo"; |
| + | *argv = (char*)"echo"; |
| argc++; | |
| } | |
| @@ -248,6 +248,8 @@ extern void bb_copyfd_exact_size(int fd1, int fd2, off_t size); | |
| /* this helper yells "short read!" if param is not -1 */ | |
| extern void complain_copyfd_and_die(off_t sz) ATTRIBUTE_NORETURN; | |
| extern char bb_process_escape_sequence(const char **ptr); | |
| + | /* TODO: sometimes modifies its parameter, which |
| + | * makes it rather inconvenient at times: */ |
| extern char *bb_get_last_path_component(char *path); | |
| extern int ndelay_on(int fd); | |
| extern int ndelay_off(int fd); | |
| @@ -8,8 +8,6 @@ | |
| */ | |
| #include "busybox.h" | |
| - | #include <unistd.h> |
| - | #include <stdlib.h> |
| #ifdef USE_TTY_GROUP | |
| #define S_IWGRP_OR_S_IWOTH S_IWGRP | |
| @@ -20,24 +18,24 @@ | |
| int mesg_main(int argc, char *argv[]) | |
| { | |
| struct stat sb; | |
| - | char *tty; |
| + | const char *tty; |
| char c = 0; | |
| - | if ((--argc == 0) |
| - | || ((argc == 1) && (((c = **++argv) == 'y') || (c == 'n')))) { |
| - | if ((tty = ttyname(STDERR_FILENO)) == NULL) { |
| + | if (--argc == 0 |
| + | || (argc == 1 && ((c = **++argv) == 'y' || c == 'n')) |
| + | ) { |
| + | tty = ttyname(STDERR_FILENO); |
| + | if (tty == NULL) { |
| tty = "ttyname"; | |
| } else if (stat(tty, &sb) == 0) { | |
| + | mode_t m; |
| if (argc == 0) { | |
| - | puts(((sb.st_mode & (S_IWGRP | S_IWOTH)) == |
| - | 0) ? "is n" : "is y"); |
| + | puts((sb.st_mode & (S_IWGRP|S_IWOTH)) ? "is y" : "is n"); |
| return EXIT_SUCCESS; | |
| } | |
| - | if (chmod |
| - | (tty, |
| - | (c == |
| - | 'y') ? sb.st_mode | (S_IWGRP_OR_S_IWOTH) : sb. |
| - | st_mode & ~(S_IWGRP | S_IWOTH)) == 0) { |
| + | m = (c == 'y') ? sb.st_mode | S_IWGRP_OR_S_IWOTH |
| + | : sb.st_mode & ~(S_IWGRP|S_IWOTH); |
| + | if (chmod(tty, m) == 0) { |
| return EXIT_SUCCESS; | |
| } | |
| } | |
| @@ -291,7 +291,7 @@ static void rewrite(FS * fs) | |
| } | |
| } | |
| - | static void do_skip(char *fname, int statok) |
| + | static void do_skip(const char *fname, int statok) |
| { | |
| struct stat sbuf; | |
| @@ -26,7 +26,7 @@ char *bb_get_last_path_component(char *path) | |
| if (*first == '/') { | |
| last = first; | |
| } | |
| - | last[1] = 0; |
| + | last[1] = '\0'; |
| return first; | |
| } | |
| @@ -184,7 +184,7 @@ pid_t spawn(char **argv) | |
| /* Why static? */ | |
| static int failed; | |
| pid_t pid; | |
| - | char *prog; |
| + | const char *prog; |
| // Be nice to nommu machines. | |
| failed = 0; | |
| @@ -240,7 +240,7 @@ void xsetenv(const char *key, const char *value) | |
| // Fifth char is always '\0' | |
| void smart_ulltoa5(unsigned long long ul, char buf[5]) | |
| { | |
| - | char *fmt; |
| + | const char *fmt; |
| char c; | |
| unsigned v,idx = 0; | |
| ul *= 10; | |
| @@ -28,7 +28,7 @@ | |
| int eject_main(int argc, char **argv) | |
| { | |
| unsigned long flags; | |
| - | char *device; |
| + | const char *device; |
| int dev, cmd; | |
| opt_complementary = "?:?1:t--T:T--t"; | |
| @@ -463,9 +463,7 @@ static void on_off(unsigned int value); | |
| static void print_flag_on_off(unsigned long get_arg, const char *s, unsigned long arg) | |
| { | |
| - | |
| - | if (get_arg) |
| - | { |
| + | if (get_arg) { |
| printf(" setting %s to %ld", s, arg); | |
| on_off(arg); | |
| } | |
| @@ -476,8 +474,7 @@ static void bb_ioctl_on_off(int fd, int request, void *argp, const char *string, | |
| { | |
| if (ioctl(fd, request, &argp) != 0) | |
| bb_perror_msg(" %s", string); | |
| - | else |
| - | { |
| + | else { |
| printf(" %s\t= %2ld", str, (unsigned long) argp); | |
| on_off((unsigned long) argp); | |
| } | |
| @@ -486,16 +483,15 @@ static void bb_ioctl_on_off(int fd, int request, void *argp, const char *string, | |
| #ifdef CONFIG_FEATURE_HDPARM_GET_IDENTITY | |
| static void print_ascii(uint16_t *p, uint8_t length); | |
| - | static void xprint_ascii(uint16_t *val ,int i, char * string, int n) |
| + | static void xprint_ascii(uint16_t *val ,int i, const char *string, int n) |
| { | |
| - | if (val[i]) |
| - | { |
| - | printf("\t%-20s",string); |
| + | if (val[i]) { |
| + | printf("\t%-20s", string); |
| print_ascii(&val[i], n); | |
| } | |
| } | |
| #endif | |
| - | /* end of busybox specific stuff */ |
| + | /* end of busybox specific stuff */ |
| #ifdef CONFIG_FEATURE_HDPARM_GET_IDENTITY | |
| static uint8_t mode_loop(uint16_t mode_sup, uint16_t mode_sel, int cc, uint8_t *have_mode) | |
| @@ -1587,7 +1583,7 @@ static void interpret_xfermode(unsigned int xfermode) | |
| } | |
| #endif /* HDIO_DRIVE_CMD */ | |
| - | static void print_flag(unsigned long flag, char *s, unsigned long value) |
| + | static void print_flag(unsigned long flag, const char *s, unsigned long value) |
| { | |
| if (flag) | |
| printf(" setting %s to %ld\n", s, value); | |
| @@ -26,7 +26,7 @@ int strings_main(int argc, char **argv) | |
| FILE *file = stdin; | |
| char *string; | |
| const char *fmt = "%s: "; | |
| - | char *n_arg = "4"; |
| + | const char *n_arg = "4"; |
| opt = getopt32(argc, argv, "afon:", &n_arg); | |
| /* -a is our default behaviour */ | |
| @@ -1782,7 +1782,7 @@ static int arch_single_init(ElfW(RelM) *rel, struct arch_single_entry *single, | |
| #if defined(USE_GOT_ENTRIES) || defined(USE_PLT_ENTRIES) | |
| - | static struct obj_section *arch_xsect_init(struct obj_file *f, char *name, |
| + | static struct obj_section *arch_xsect_init(struct obj_file *f, const char *name, |
| int offset, int size) | |
| { | |
| struct obj_section *myrelsec = obj_find_section(f, name); | |
| @@ -161,7 +161,7 @@ int lsmod_main(int argc, char **argv) | |
| printf(" %s", tok); | |
| tok = strtok(NULL, "\n"); | |
| if (!tok) | |
| - | tok = ""; |
| + | tok = (char*)""; |
| /* New-style has commas, or -. If so, | |
| truncate (other fields might follow). */ | |
| else if (strchr(tok, ',')) { | |
| @@ -170,9 +170,11 @@ int lsmod_main(int argc, char **argv) | |
| if (tok[strlen(tok)-1] == ',') | |
| tok[strlen(tok)-1] = '\0'; | |
| } else if (tok[0] == '-' | |
| - | && (tok[1] == '\0' || isspace(tok[1]))) |
| - | tok = ""; |
| - | printf(" %s", tok); |
| + | && (tok[1] == '\0' || isspace(tok[1])) |
| + | ) { |
| + | tok = (char*)""; |
| + | } |
| + | printf(" %s", tok); |
| } | |
| puts(""); | |
| free(line); | |
| @@ -240,7 +240,7 @@ static int recv_pack(unsigned char *buf, int len, struct sockaddr_ll *FROM) | |
| int arping_main(int argc, char **argv) | |
| { | |
| - | char *device = "eth0"; |
| + | const char *device = "eth0"; |
| int ifindex; | |
| char *source = NULL; | |
| char *target; | |
| @@ -17,8 +17,8 @@ | |
| #include <getopt.h> | |
| typedef struct ftp_host_info_s { | |
| - | char *user; |
| - | char *password; |
| + | const char *user; |
| + | const char *password; |
| struct len_and_sockaddr *lsa; | |
| } ftp_host_info_t; | |
| @@ -327,7 +327,7 @@ static int timingout; | |
| static struct servent *sp; | |
| static uid_t uid; | |
| - | static char *CONFIG = _PATH_INETDCONF; |
| + | static const char *CONFIG = _PATH_INETDCONF; |
| static FILE *fconfig; | |
| static char line[1024]; | |
| @@ -259,7 +259,7 @@ void duparg2(char *key, char *arg) | |
| exit(-1); | |
| } | |
| - | int matches(char *cmd, char *pattern) |
| + | int matches(const char *cmd, const char *pattern) |
| { | |
| int len = strlen(cmd); | |
| @@ -43,8 +43,7 @@ typedef struct | |
| #define AF_DECnet 12 | |
| #endif | |
| - | struct dn_naddr |
| - | { |
| + | struct dn_naddr { |
| unsigned short a_len; | |
| unsigned char a_addr[DN_MAXADDL]; | |
| }; | |
| @@ -79,7 +78,7 @@ extern const char *rt_addr_n2a(int af, int len, void *addr, char *buf, int bufle | |
| void invarg(const char * const, const char * const) ATTRIBUTE_NORETURN; | |
| void duparg(char *, char *) ATTRIBUTE_NORETURN; | |
| void duparg2(char *, char *) ATTRIBUTE_NORETURN; | |
| - | int matches(char *arg, char *pattern); |
| + | int matches(const char *arg, const char *pattern); |
| extern int inet_addr_match(inet_prefix *a, inet_prefix *b, int bits); | |
| const char *dnet_ntop(int af, const void *addr, char *str, size_t len); | |
| @@ -68,9 +68,10 @@ typedef enum { | |
| #define SO_WAITDATA (1<<17) /* wait data to read */ | |
| #define SO_NOSPACE (1<<18) /* no space to write */ | |
| - | static char *get_sname(int port, const char *proto, int num) |
| + | static const char *get_sname(int port, const char *proto, int num) |
| { | |
| - | char *str = itoa(ntohs(port)); |
| + | /* hummm, we return static buffer here!! */ |
| + | const char *str = itoa(ntohs(port)); |
| if (!num) { | |
| struct servent *se = getservbyport(port, proto); | |
| if (se) | |
| @@ -82,9 +83,9 @@ static char *get_sname(int port, const char *proto, int num) | |
| return str; | |
| } | |
| - | static void snprint_ip_port(char *ip_port, int size, struct sockaddr *addr, int port, char *proto, int numeric) |
| + | static void snprint_ip_port(char *ip_port, int size, struct sockaddr *addr, int port, const char *proto, int numeric) |
| { | |
| - | char *port_name; |
| + | const char *port_name; |
| #if ENABLE_FEATURE_IPV6 | |
| if (addr->sa_family == AF_INET6) { | |
| @@ -178,7 +179,8 @@ static void tcp_do_one(int lnr, const char *line) | |
| static void udp_do_one(int lnr, const char *line) | |
| { | |
| char local_addr[64], rem_addr[64]; | |
| - | char *state_str, more[512]; |
| + | const char *state_str; |
| + | char more[512]; |
| int num, local_port, rem_port, d, state, timer_run, uid, timeout; | |
| #if ENABLE_FEATURE_IPV6 | |
| struct sockaddr_in6 localaddr, remaddr; | |
| @@ -356,7 +358,7 @@ static void unix_do_one(int nr, const char *line) | |
| { | |
| static int has = 0; | |
| char path[PATH_MAX], ss_flags[32]; | |
| - | char *ss_proto, *ss_state, *ss_type; |
| + | const char *ss_proto, *ss_state, *ss_type; |
| int num, state, type, inode; | |
| void *d; | |
| unsigned long refcnt, proto, unix_flags; | |
| @@ -296,7 +296,7 @@ static void INET_setroute(int action, char **args) | |
| #ifdef RTF_REJECT | |
| if ((rt.rt_flags & RTF_REJECT) && !rt.rt_dev) { | |
| - | rt.rt_dev = "lo"; |
| + | rt.rt_dev = (char*)"lo"; |
| } | |
| #endif | |
| @@ -322,7 +322,7 @@ static void putiac_subopt(byte c, char *str) | |
| static void putiac_subopt_autologin(void) | |
| { | |
| int len = strlen(autologin) + 6; // (2 + 1 + 1 + strlen + 2) | |
| - | char *user = "USER"; |
| + | const char *user = "USER"; |
| if (G.iaclen + len > IACBUFSIZE) | |
| iacflush(); | |
| @@ -89,8 +89,8 @@ void udhcp_sp_setup(void); | |
| int udhcp_sp_fd_set(fd_set *rfds, int extra_fd); | |
| int udhcp_sp_read(fd_set *rfds); | |
| int raw_socket(int ifindex); | |
| - | int read_interface(char *interface, int *ifindex, uint32_t *addr, uint8_t *arp); |
| - | int listen_socket(uint32_t ip, int port, char *inf); |
| + | int read_interface(const char *interface, int *ifindex, uint32_t *addr, uint8_t *arp); |
| + | int listen_socket(uint32_t ip, int port, const char *inf); |
| int pidfile_acquire(const char *pidfile); | |
| void pidfile_write_release(int pid_fd); | |
| int arpping(uint32_t yiaddr, uint32_t ip, uint8_t *arp, char *interface); | |
| @@ -20,9 +20,9 @@ struct client_config_t { | |
| char release_on_quit; /* perform release on quit */ | |
| char abort_if_no_lease; /* Abort if no lease */ | |
| char background_if_no_lease; /* Fork to background if no lease */ | |
| - | char *interface; /* The name of the interface to use */ |
| + | const char *interface; /* The name of the interface to use */ |
| char *pidfile; /* Optionally store the process ID */ | |
| - | char *script; /* User script to run at dhcp events */ |
| + | const char *script; /* User script to run at dhcp events */ |
| uint8_t *clientid; /* Optional client id to use */ | |
| uint8_t *vendorclass; /* Optional vendor class-id to use */ | |
| uint8_t *hostname; /* Optional hostname to use */ | |
| @@ -35,7 +35,7 @@ static inline int upper_length(int length, int opt_index) | |
| } | |
| - | static int sprintip(char *dest, char *pre, uint8_t *ip) |
| + | static int sprintip(char *dest, const char *pre, const uint8_t *ip) |
| { | |
| return sprintf(dest, "%s%d.%d.%d.%d", pre, ip[0], ip[1], ip[2], ip[3]); | |
| } | |
| @@ -37,7 +37,7 @@ | |
| #include "common.h" | |
| - | int read_interface(char *interface, int *ifindex, uint32_t *addr, uint8_t *arp) |
| + | int read_interface(const char *interface, int *ifindex, uint32_t *addr, uint8_t *arp) |
| { | |
| int fd; | |
| struct ifreq ifr; | |
| @@ -88,7 +88,7 @@ int read_interface(char *interface, int *ifindex, uint32_t *addr, uint8_t *arp) | |
| } | |
| - | int listen_socket(uint32_t ip, int port, char *inf) |
| + | int listen_socket(uint32_t ip, int port, const char *inf) |
| { | |
| struct ifreq interface; | |
| int fd; | |
| @@ -26,7 +26,7 @@ struct host_info { | |
| static void parse_url(char *url, struct host_info *h); | |
| static FILE *open_socket(len_and_sockaddr *lsa); | |
| static char *gethdr(char *buf, size_t bufsiz, FILE *fp, int *istrunc); | |
| - | static int ftpcmd(char *s1, char *s2, FILE *fp, char *buf); |
| + | static int ftpcmd(const char *s1, const char *s2, FILE *fp, char *buf); |
| /* Globals (can be accessed from signal handlers */ | |
| static off_t content_len; /* Content-length of the file */ | |
| @@ -37,7 +37,7 @@ static off_t transferred; /* Number of bytes transferred so far */ | |
| static int chunked; /* chunked transfer encoding */ | |
| #if ENABLE_FEATURE_WGET_STATUSBAR | |
| static void progressmeter(int flag); | |
| - | static char *curfile; /* Name of current file being transferred */ |
| + | static const char *curfile; /* Name of current file being transferred */ |
| static struct timeval start; /* Time a transfer started */ | |
| enum { | |
| STALLTIME = 5 /* Seconds when xfer considered "stalled" */ | |
| @@ -190,18 +190,18 @@ int wget_main(int argc, char **argv) | |
| // Dirty hack. Needed because bb_get_last_path_component | |
| // will destroy trailing / by storing '\0' in last byte! | |
| if (!last_char_is(target.path, '/')) { | |
| - | fname_out = |
| + | fname_out = bb_get_last_path_component(target.path); |
| #if ENABLE_FEATURE_WGET_STATUSBAR | |
| - | curfile = |
| + | curfile = fname_out; |
| #endif | |
| - | bb_get_last_path_component(target.path); |
| } | |
| if (!fname_out || !fname_out[0]) { | |
| - | fname_out = |
| + | /* bb_get_last_path_component writes |
| + | * to last '/' only. We don't have one here... */ |
| + | fname_out = (char*)"index.html"; |
| #if ENABLE_FEATURE_WGET_STATUSBAR | |
| - | curfile = |
| + | curfile = fname_out; |
| #endif | |
| - | "index.html"; |
| } | |
| if (dir_prefix != NULL) | |
| fname_out = concat_path_file(dir_prefix, fname_out); | |
| @@ -624,7 +624,7 @@ static char *gethdr(char *buf, size_t bufsiz, FILE *fp, int *istrunc) | |
| return hdrval; | |
| } | |
| - | static int ftpcmd(char *s1, char *s2, FILE *fp, char *buf) |
| + | static int ftpcmd(const char *s1, const char *s2, FILE *fp, char *buf) |
| { | |
| int result; | |
| if (s1) { | |
| @@ -308,7 +308,8 @@ static char *indenter(int i) | |
| #endif | |
| #define final_printf debug_printf | |
| - | static void __syntax(char *file, int line) { |
| + | static void __syntax(const char *file, int line) |
| + | { |
| bb_error_msg("syntax error %s:%d", file, line); | |
| } | |
| // NB: was __FILE__, but that produces full path sometimess, so... | |
| @@ -280,9 +280,9 @@ static void onintr(int s); /* SIGINT handler */ | |
| static int newenv(int f); | |
| static void quitenv(void); | |
| - | static void err(char *s); |
| - | static int anys(char *s1, char *s2); |
| - | static int any(int c, char *s); |
| + | static void err(const char *s); |
| + | static int anys(const char *s1, const char *s2); |
| + | static int any(int c, const char *s); |
| static void next(int f); | |
| static void setdash(void); | |
| static void onecommand(void); | |
| @@ -295,7 +295,7 @@ static int gmatch(char *s, char *p); | |
| */ | |
| static void leave(void); /* abort shell (or fail in subshell) */ | |
| static void fail(void); /* fail but return to process next command */ | |
| - | static void warn(char *s); |
| + | static void warn(const char *s); |
| static void sig(int i); /* default signal handler */ | |
| @@ -1135,7 +1135,7 @@ static void leave(void) | |
| /* NOTREACHED */ | |
| } | |
| - | static void warn(char *s) |
| + | static void warn(const char *s) |
| { | |
| if (*s) { | |
| prs(s); | |
| @@ -1146,7 +1146,7 @@ static void warn(char *s) | |
| leave(); | |
| } | |
| - | static void err(char *s) |
| + | static void err(const char *s) |
| { | |
| warn(s); | |
| if (flag['n']) | |
| @@ -1202,23 +1202,23 @@ static void quitenv(void) | |
| } | |
| /* | |
| - | * Is any character from s1 in s2? |
| + | * Is character c in s? |
| */ | |
| - | static int anys(char *s1, char *s2) |
| + | static int any(int c, const char *s) |
| { | |
| - | while (*s1) |
| - | if (any(*s1++, s2)) |
| + | while (*s) |
| + | if (*s++ == c) |
| return 1; | |
| return 0; | |
| } | |
| /* | |
| - | * Is character c in s? |
| + | * Is any character from s1 in s2? |
| */ | |
| - | static int any(int c, char *s) |
| + | static int anys(const char *s1, const char *s2) |
| { | |
| - | while (*s) |
| - | if (*s++ == c) |
| + | while (*s1) |
| + | if (any(*s1++, s2)) |
| return 1; | |
| return 0; | |
| } | |
| @@ -314,8 +314,8 @@ int fbset_main(int argc, char **argv) | |
| { | |
| struct fb_var_screeninfo var, varset; | |
| int fh, i; | |
| - | char *fbdev = DEFAULTFBDEV; |
| - | char *modefile = DEFAULTFBMODE; |
| + | const char *fbdev = DEFAULTFBDEV; |
| + | const char *modefile = DEFAULTFBMODE; |
| char *thisarg, *mode = NULL; | |
| memset(&varset, 0xFF, sizeof(varset)); | |
| @@ -141,7 +141,8 @@ static void make_device(char *path, int delete) | |
| } | |
| if (ENABLE_FEATURE_MDEV_EXEC && field == 3) { | |
| // Command to run | |
| - | char *s = "@$*", *s2; |
| + | const char *s = "@$*"; |
| + | const char *s2; |
| s2 = strchr(s, *pos++); | |
| if (!s2) { | |
| // Force error | |
| @@ -28,7 +28,7 @@ dev_t rootdev; | |
| // Recursively delete contents of rootfs. | |
| - | static void delete_contents(char *directory) |
| + | static void delete_contents(const char *directory) |
| { | |
| DIR *dir; | |
| struct dirent *d; | |