preparatory patch for -Wwrite-strings #2

This commit is contained in:
Denis Vlasenko 2007-01-29 22:51:25 +00:00
parent a41fdf331a
commit b6aae0f381
32 changed files with 110 additions and 109 deletions

View File

@ -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.* */ /* We don't care about data.tar.* or debian-binary, just control.tar.* */
#ifdef CONFIG_FEATURE_DEB_TAR_GZ #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 #endif
#ifdef CONFIG_FEATURE_DEB_TAR_BZ2 #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 #endif
/* Assign the tar handle as a subarchive of the ar handle */ /* 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.* */ /* We don't care about control.tar.* or debian-binary, just data.tar.* */
#ifdef CONFIG_FEATURE_DEB_TAR_GZ #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 #endif
#ifdef CONFIG_FEATURE_DEB_TAR_BZ2 #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 #endif
/* Assign the tar handle as a subarchive of the ar handle */ /* 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); archive_handle = init_archive_deb_ar(deb_file->filename);
init_archive_deb_data(archive_handle); init_archive_deb_data(archive_handle);
archive_handle->sub_archive->action_data = data_extract_all_prefix; 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; archive_handle->sub_archive->flags |= ARCHIVE_EXTRACT_UNCONDITIONAL;
unpack_ar_archive(archive_handle); unpack_ar_archive(archive_handle);
@ -1629,7 +1629,7 @@ int dpkg_main(int argc, char **argv)
llist_t *control_list = NULL; llist_t *control_list = NULL;
/* Extract the control file */ /* 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]); archive_handle = init_archive_deb_ar(argv[0]);
init_archive_deb_control(archive_handle); init_archive_deb_control(archive_handle);
deb_file[deb_count]->control_file = deb_extract_control_file_to_buffer(archive_handle, control_list); deb_file[deb_count]->control_file = deb_extract_control_file_to_buffer(archive_handle, control_list);

View File

@ -19,7 +19,7 @@ int dpkg_deb_main(int argc, char **argv)
archive_handle_t *tar_archive; archive_handle_t *tar_archive;
llist_t *control_tar_llist = NULL; llist_t *control_tar_llist = NULL;
unsigned opt; unsigned opt;
char *extract_dir = NULL; const char *extract_dir = NULL;
short argcount = 1; short argcount = 1;
/* Setup the tar archive handle */ /* Setup the tar archive handle */
@ -31,13 +31,13 @@ int dpkg_deb_main(int argc, char **argv)
ar_archive->filter = filter_accept_list_reassign; ar_archive->filter = filter_accept_list_reassign;
#ifdef CONFIG_FEATURE_DEB_TAR_GZ #ifdef CONFIG_FEATURE_DEB_TAR_GZ
llist_add_to(&(ar_archive->accept), "data.tar.gz"); llist_add_to(&(ar_archive->accept), (char*)"data.tar.gz");
llist_add_to(&control_tar_llist, "control.tar.gz"); llist_add_to(&control_tar_llist, (char*)"control.tar.gz");
#endif #endif
#ifdef CONFIG_FEATURE_DEB_TAR_BZ2 #ifdef CONFIG_FEATURE_DEB_TAR_BZ2
llist_add_to(&(ar_archive->accept), "data.tar.bz2"); llist_add_to(&(ar_archive->accept), (char*)"data.tar.bz2");
llist_add_to(&control_tar_llist, "control.tar.bz2"); llist_add_to(&control_tar_llist, (char*)"control.tar.bz2");
#endif #endif
opt_complementary = "?c--efXx:e--cfXx:f--ceXx:X--cefx:x--cefX"; 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 * it should accept a second argument which specifies a
* specific field to print */ * specific field to print */
ar_archive->accept = control_tar_llist; 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->filter = filter_accept_list;
tar_archive->action_data = data_extract_to_stdout; tar_archive->action_data = data_extract_to_stdout;
} }

View File

@ -168,7 +168,7 @@ static void cleanup_outname(void)
/* strdup, replacing "\n" with '\n', and "\delimiter" with 'delimiter' */ /* 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; int i = 0;
@ -186,7 +186,7 @@ static void parse_escapes(char *dest, char *string, int len, char from, char to)
*dest = 0; *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); 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 * expression delimiter (typically a forward * slash ('/')) not preceded by
* a backslash ('\'). A negative delimiter disables square bracket checking. * 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 bracket = -1;
int escaped = 0; 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. * 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)) { if (isdigit(*my_str)) {
*linenum = strtol(my_str, &pos, 10); *linenum = strtol(my_str, (char**)&pos, 10);
/* endstr shouldnt ever equal NULL */ /* endstr shouldnt ever equal NULL */
} else if (*my_str == '$') { } else if (*my_str == '$') {
*linenum = -1; *linenum = -1;
@ -314,7 +314,7 @@ static int parse_subst_cmd(sed_cmd_t *sed_cmd, char *substr)
{ {
int cflags = bbg.regex_type; int cflags = bbg.regex_type;
char *match; char *match;
int idx = 0; int idx;
/* /*
* A substitution command should look something like this: * 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. */ /* 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; sed_cmd_t *sed_cmd;
int temp; int temp;
/* Append this line to any unfinished line from last time. */ /* Append this line to any unfinished line from last time. */
if (bbg.add_cmd_line) { 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); free(bbg.add_cmd_line);
bbg.add_cmd_line = cmdstr; bbg.add_cmd_line = tp;
} }
/* If this line ends with backslash, request next line. */ /* If this line ends with backslash, request next line. */

View File

@ -416,7 +416,7 @@ int xargs_main(int argc, char **argv)
argv += optind; argv += optind;
if (!argc) { if (!argc) {
/* default behavior is to echo all the filenames */ /* default behavior is to echo all the filenames */
*argv = "echo"; *argv = (char*)"echo";
argc++; argc++;
} }

View File

@ -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 */ /* this helper yells "short read!" if param is not -1 */
extern void complain_copyfd_and_die(off_t sz) ATTRIBUTE_NORETURN; extern void complain_copyfd_and_die(off_t sz) ATTRIBUTE_NORETURN;
extern char bb_process_escape_sequence(const char **ptr); 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 char *bb_get_last_path_component(char *path);
extern int ndelay_on(int fd); extern int ndelay_on(int fd);
extern int ndelay_off(int fd); extern int ndelay_off(int fd);

View File

@ -8,8 +8,6 @@
*/ */
#include "busybox.h" #include "busybox.h"
#include <unistd.h>
#include <stdlib.h>
#ifdef USE_TTY_GROUP #ifdef USE_TTY_GROUP
#define S_IWGRP_OR_S_IWOTH S_IWGRP #define S_IWGRP_OR_S_IWOTH S_IWGRP
@ -20,24 +18,24 @@
int mesg_main(int argc, char *argv[]) int mesg_main(int argc, char *argv[])
{ {
struct stat sb; struct stat sb;
char *tty; const char *tty;
char c = 0; char c = 0;
if ((--argc == 0) if (--argc == 0
|| ((argc == 1) && (((c = **++argv) == 'y') || (c == 'n')))) { || (argc == 1 && ((c = **++argv) == 'y' || c == 'n'))
if ((tty = ttyname(STDERR_FILENO)) == NULL) { ) {
tty = ttyname(STDERR_FILENO);
if (tty == NULL) {
tty = "ttyname"; tty = "ttyname";
} else if (stat(tty, &sb) == 0) { } else if (stat(tty, &sb) == 0) {
mode_t m;
if (argc == 0) { if (argc == 0) {
puts(((sb.st_mode & (S_IWGRP | S_IWOTH)) == puts((sb.st_mode & (S_IWGRP|S_IWOTH)) ? "is y" : "is n");
0) ? "is n" : "is y");
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
if (chmod m = (c == 'y') ? sb.st_mode | S_IWGRP_OR_S_IWOTH
(tty, : sb.st_mode & ~(S_IWGRP|S_IWOTH);
(c == if (chmod(tty, m) == 0) {
'y') ? sb.st_mode | (S_IWGRP_OR_S_IWOTH) : sb.
st_mode & ~(S_IWGRP | S_IWOTH)) == 0) {
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
} }

View File

@ -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; struct stat sbuf;

View File

@ -26,7 +26,7 @@ char *bb_get_last_path_component(char *path)
if (*first == '/') { if (*first == '/') {
last = first; last = first;
} }
last[1] = 0; last[1] = '\0';
return first; return first;
} }

View File

@ -184,7 +184,7 @@ pid_t spawn(char **argv)
/* Why static? */ /* Why static? */
static int failed; static int failed;
pid_t pid; pid_t pid;
char *prog; const char *prog;
// Be nice to nommu machines. // Be nice to nommu machines.
failed = 0; failed = 0;
@ -240,7 +240,7 @@ void xsetenv(const char *key, const char *value)
// Fifth char is always '\0' // Fifth char is always '\0'
void smart_ulltoa5(unsigned long long ul, char buf[5]) void smart_ulltoa5(unsigned long long ul, char buf[5])
{ {
char *fmt; const char *fmt;
char c; char c;
unsigned v,idx = 0; unsigned v,idx = 0;
ul *= 10; ul *= 10;

View File

@ -28,7 +28,7 @@
int eject_main(int argc, char **argv) int eject_main(int argc, char **argv)
{ {
unsigned long flags; unsigned long flags;
char *device; const char *device;
int dev, cmd; int dev, cmd;
opt_complementary = "?:?1:t--T:T--t"; opt_complementary = "?:?1:t--T:T--t";

View File

@ -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) 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); printf(" setting %s to %ld", s, arg);
on_off(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) if (ioctl(fd, request, &argp) != 0)
bb_perror_msg(" %s", string); bb_perror_msg(" %s", string);
else else {
{
printf(" %s\t= %2ld", str, (unsigned long) argp); printf(" %s\t= %2ld", str, (unsigned long) argp);
on_off((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 #ifdef CONFIG_FEATURE_HDPARM_GET_IDENTITY
static void print_ascii(uint16_t *p, uint8_t length); 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]) if (val[i]) {
{ printf("\t%-20s", string);
printf("\t%-20s",string);
print_ascii(&val[i], n); print_ascii(&val[i], n);
} }
} }
#endif #endif
/* end of busybox specific stuff */ /* end of busybox specific stuff */
#ifdef CONFIG_FEATURE_HDPARM_GET_IDENTITY #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) 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 */ #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) if (flag)
printf(" setting %s to %ld\n", s, value); printf(" setting %s to %ld\n", s, value);

View File

@ -26,7 +26,7 @@ int strings_main(int argc, char **argv)
FILE *file = stdin; FILE *file = stdin;
char *string; char *string;
const char *fmt = "%s: "; const char *fmt = "%s: ";
char *n_arg = "4"; const char *n_arg = "4";
opt = getopt32(argc, argv, "afon:", &n_arg); opt = getopt32(argc, argv, "afon:", &n_arg);
/* -a is our default behaviour */ /* -a is our default behaviour */

View File

@ -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) #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) int offset, int size)
{ {
struct obj_section *myrelsec = obj_find_section(f, name); struct obj_section *myrelsec = obj_find_section(f, name);

View File

@ -161,7 +161,7 @@ int lsmod_main(int argc, char **argv)
printf(" %s", tok); printf(" %s", tok);
tok = strtok(NULL, "\n"); tok = strtok(NULL, "\n");
if (!tok) if (!tok)
tok = ""; tok = (char*)"";
/* New-style has commas, or -. If so, /* New-style has commas, or -. If so,
truncate (other fields might follow). */ truncate (other fields might follow). */
else if (strchr(tok, ',')) { else if (strchr(tok, ',')) {
@ -170,9 +170,11 @@ int lsmod_main(int argc, char **argv)
if (tok[strlen(tok)-1] == ',') if (tok[strlen(tok)-1] == ',')
tok[strlen(tok)-1] = '\0'; tok[strlen(tok)-1] = '\0';
} else if (tok[0] == '-' } else if (tok[0] == '-'
&& (tok[1] == '\0' || isspace(tok[1]))) && (tok[1] == '\0' || isspace(tok[1]))
tok = ""; ) {
printf(" %s", tok); tok = (char*)"";
}
printf(" %s", tok);
} }
puts(""); puts("");
free(line); free(line);

View File

@ -240,7 +240,7 @@ static int recv_pack(unsigned char *buf, int len, struct sockaddr_ll *FROM)
int arping_main(int argc, char **argv) int arping_main(int argc, char **argv)
{ {
char *device = "eth0"; const char *device = "eth0";
int ifindex; int ifindex;
char *source = NULL; char *source = NULL;
char *target; char *target;

View File

@ -17,8 +17,8 @@
#include <getopt.h> #include <getopt.h>
typedef struct ftp_host_info_s { typedef struct ftp_host_info_s {
char *user; const char *user;
char *password; const char *password;
struct len_and_sockaddr *lsa; struct len_and_sockaddr *lsa;
} ftp_host_info_t; } ftp_host_info_t;

View File

@ -327,7 +327,7 @@ static int timingout;
static struct servent *sp; static struct servent *sp;
static uid_t uid; static uid_t uid;
static char *CONFIG = _PATH_INETDCONF; static const char *CONFIG = _PATH_INETDCONF;
static FILE *fconfig; static FILE *fconfig;
static char line[1024]; static char line[1024];

View File

@ -259,7 +259,7 @@ void duparg2(char *key, char *arg)
exit(-1); exit(-1);
} }
int matches(char *cmd, char *pattern) int matches(const char *cmd, const char *pattern)
{ {
int len = strlen(cmd); int len = strlen(cmd);

View File

@ -43,8 +43,7 @@ typedef struct
#define AF_DECnet 12 #define AF_DECnet 12
#endif #endif
struct dn_naddr struct dn_naddr {
{
unsigned short a_len; unsigned short a_len;
unsigned char a_addr[DN_MAXADDL]; 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 invarg(const char * const, const char * const) ATTRIBUTE_NORETURN;
void duparg(char *, char *) ATTRIBUTE_NORETURN; void duparg(char *, char *) ATTRIBUTE_NORETURN;
void duparg2(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); 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); const char *dnet_ntop(int af, const void *addr, char *str, size_t len);

View File

@ -68,9 +68,10 @@ typedef enum {
#define SO_WAITDATA (1<<17) /* wait data to read */ #define SO_WAITDATA (1<<17) /* wait data to read */
#define SO_NOSPACE (1<<18) /* no space to write */ #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) { if (!num) {
struct servent *se = getservbyport(port, proto); struct servent *se = getservbyport(port, proto);
if (se) if (se)
@ -82,9 +83,9 @@ static char *get_sname(int port, const char *proto, int num)
return str; 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 ENABLE_FEATURE_IPV6
if (addr->sa_family == AF_INET6) { 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) static void udp_do_one(int lnr, const char *line)
{ {
char local_addr[64], rem_addr[64]; 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; int num, local_port, rem_port, d, state, timer_run, uid, timeout;
#if ENABLE_FEATURE_IPV6 #if ENABLE_FEATURE_IPV6
struct sockaddr_in6 localaddr, remaddr; struct sockaddr_in6 localaddr, remaddr;
@ -356,7 +358,7 @@ static void unix_do_one(int nr, const char *line)
{ {
static int has = 0; static int has = 0;
char path[PATH_MAX], ss_flags[32]; 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; int num, state, type, inode;
void *d; void *d;
unsigned long refcnt, proto, unix_flags; unsigned long refcnt, proto, unix_flags;

View File

@ -296,7 +296,7 @@ static void INET_setroute(int action, char **args)
#ifdef RTF_REJECT #ifdef RTF_REJECT
if ((rt.rt_flags & RTF_REJECT) && !rt.rt_dev) { if ((rt.rt_flags & RTF_REJECT) && !rt.rt_dev) {
rt.rt_dev = "lo"; rt.rt_dev = (char*)"lo";
} }
#endif #endif

View File

@ -322,7 +322,7 @@ static void putiac_subopt(byte c, char *str)
static void putiac_subopt_autologin(void) static void putiac_subopt_autologin(void)
{ {
int len = strlen(autologin) + 6; // (2 + 1 + 1 + strlen + 2) int len = strlen(autologin) + 6; // (2 + 1 + 1 + strlen + 2)
char *user = "USER"; const char *user = "USER";
if (G.iaclen + len > IACBUFSIZE) if (G.iaclen + len > IACBUFSIZE)
iacflush(); iacflush();

View File

@ -89,8 +89,8 @@ void udhcp_sp_setup(void);
int udhcp_sp_fd_set(fd_set *rfds, int extra_fd); int udhcp_sp_fd_set(fd_set *rfds, int extra_fd);
int udhcp_sp_read(fd_set *rfds); int udhcp_sp_read(fd_set *rfds);
int raw_socket(int ifindex); int raw_socket(int ifindex);
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 listen_socket(uint32_t ip, int port, char *inf); int listen_socket(uint32_t ip, int port, const char *inf);
int pidfile_acquire(const char *pidfile); int pidfile_acquire(const char *pidfile);
void pidfile_write_release(int pid_fd); void pidfile_write_release(int pid_fd);
int arpping(uint32_t yiaddr, uint32_t ip, uint8_t *arp, char *interface); int arpping(uint32_t yiaddr, uint32_t ip, uint8_t *arp, char *interface);

View File

@ -20,9 +20,9 @@ struct client_config_t {
char release_on_quit; /* perform release on quit */ char release_on_quit; /* perform release on quit */
char abort_if_no_lease; /* Abort if no lease */ char abort_if_no_lease; /* Abort if no lease */
char background_if_no_lease; /* Fork to background 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 *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 *clientid; /* Optional client id to use */
uint8_t *vendorclass; /* Optional vendor class-id to use */ uint8_t *vendorclass; /* Optional vendor class-id to use */
uint8_t *hostname; /* Optional hostname to use */ uint8_t *hostname; /* Optional hostname to use */

View File

@ -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]); return sprintf(dest, "%s%d.%d.%d.%d", pre, ip[0], ip[1], ip[2], ip[3]);
} }

View File

@ -37,7 +37,7 @@
#include "common.h" #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; int fd;
struct ifreq ifr; 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; struct ifreq interface;
int fd; int fd;

View File

@ -26,7 +26,7 @@ struct host_info {
static void parse_url(char *url, struct host_info *h); static void parse_url(char *url, struct host_info *h);
static FILE *open_socket(len_and_sockaddr *lsa); static FILE *open_socket(len_and_sockaddr *lsa);
static char *gethdr(char *buf, size_t bufsiz, FILE *fp, int *istrunc); 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 */ /* Globals (can be accessed from signal handlers */
static off_t content_len; /* Content-length of the file */ 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 */ static int chunked; /* chunked transfer encoding */
#if ENABLE_FEATURE_WGET_STATUSBAR #if ENABLE_FEATURE_WGET_STATUSBAR
static void progressmeter(int flag); 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 */ static struct timeval start; /* Time a transfer started */
enum { enum {
STALLTIME = 5 /* Seconds when xfer considered "stalled" */ 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 // Dirty hack. Needed because bb_get_last_path_component
// will destroy trailing / by storing '\0' in last byte! // will destroy trailing / by storing '\0' in last byte!
if (!last_char_is(target.path, '/')) { if (!last_char_is(target.path, '/')) {
fname_out = fname_out = bb_get_last_path_component(target.path);
#if ENABLE_FEATURE_WGET_STATUSBAR #if ENABLE_FEATURE_WGET_STATUSBAR
curfile = curfile = fname_out;
#endif #endif
bb_get_last_path_component(target.path);
} }
if (!fname_out || !fname_out[0]) { 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 #if ENABLE_FEATURE_WGET_STATUSBAR
curfile = curfile = fname_out;
#endif #endif
"index.html";
} }
if (dir_prefix != NULL) if (dir_prefix != NULL)
fname_out = concat_path_file(dir_prefix, fname_out); 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; 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; int result;
if (s1) { if (s1) {

View File

@ -308,7 +308,8 @@ static char *indenter(int i)
#endif #endif
#define final_printf debug_printf #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); bb_error_msg("syntax error %s:%d", file, line);
} }
// NB: was __FILE__, but that produces full path sometimess, so... // NB: was __FILE__, but that produces full path sometimess, so...

View File

@ -280,9 +280,9 @@ static void onintr(int s); /* SIGINT handler */
static int newenv(int f); static int newenv(int f);
static void quitenv(void); static void quitenv(void);
static void err(char *s); static void err(const char *s);
static int anys(char *s1, char *s2); static int anys(const char *s1, const char *s2);
static int any(int c, char *s); static int any(int c, const char *s);
static void next(int f); static void next(int f);
static void setdash(void); static void setdash(void);
static void onecommand(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 leave(void); /* abort shell (or fail in subshell) */
static void fail(void); /* fail but return to process next command */ 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 */ static void sig(int i); /* default signal handler */
@ -1135,7 +1135,7 @@ static void leave(void)
/* NOTREACHED */ /* NOTREACHED */
} }
static void warn(char *s) static void warn(const char *s)
{ {
if (*s) { if (*s) {
prs(s); prs(s);
@ -1146,7 +1146,7 @@ static void warn(char *s)
leave(); leave();
} }
static void err(char *s) static void err(const char *s)
{ {
warn(s); warn(s);
if (flag['n']) 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) while (*s)
if (any(*s1++, s2)) if (*s++ == c)
return 1; return 1;
return 0; 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) while (*s1)
if (*s++ == c) if (any(*s1++, s2))
return 1; return 1;
return 0; return 0;
} }

View File

@ -314,8 +314,8 @@ int fbset_main(int argc, char **argv)
{ {
struct fb_var_screeninfo var, varset; struct fb_var_screeninfo var, varset;
int fh, i; int fh, i;
char *fbdev = DEFAULTFBDEV; const char *fbdev = DEFAULTFBDEV;
char *modefile = DEFAULTFBMODE; const char *modefile = DEFAULTFBMODE;
char *thisarg, *mode = NULL; char *thisarg, *mode = NULL;
memset(&varset, 0xFF, sizeof(varset)); memset(&varset, 0xFF, sizeof(varset));

View File

@ -141,7 +141,8 @@ static void make_device(char *path, int delete)
} }
if (ENABLE_FEATURE_MDEV_EXEC && field == 3) { if (ENABLE_FEATURE_MDEV_EXEC && field == 3) {
// Command to run // Command to run
char *s = "@$*", *s2; const char *s = "@$*";
const char *s2;
s2 = strchr(s, *pos++); s2 = strchr(s, *pos++);
if (!s2) { if (!s2) {
// Force error // Force error

View File

@ -28,7 +28,7 @@ dev_t rootdev;
// Recursively delete contents of rootfs. // Recursively delete contents of rootfs.
static void delete_contents(char *directory) static void delete_contents(const char *directory)
{ {
DIR *dir; DIR *dir;
struct dirent *d; struct dirent *d;