summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--archival/dpkg.c12
-rw-r--r--archival/dpkg_deb.c12
-rw-r--r--editors/sed.c20
-rw-r--r--findutils/xargs.c2
-rw-r--r--include/libbb.h2
-rw-r--r--init/mesg.c24
-rw-r--r--libbb/dump.c2
-rw-r--r--libbb/get_last_path_component.c2
-rw-r--r--libbb/xfuncs.c4
-rw-r--r--miscutils/eject.c2
-rw-r--r--miscutils/hdparm.c18
-rw-r--r--miscutils/strings.c2
-rw-r--r--modutils/insmod.c2
-rw-r--r--modutils/lsmod.c10
-rw-r--r--networking/arping.c2
-rw-r--r--networking/ftpgetput.c4
-rw-r--r--networking/inetd.c2
-rw-r--r--networking/libiproute/utils.c2
-rw-r--r--networking/libiproute/utils.h5
-rw-r--r--networking/netstat.c14
-rw-r--r--networking/route.c2
-rw-r--r--networking/telnet.c2
-rw-r--r--networking/udhcp/common.h4
-rw-r--r--networking/udhcp/dhcpc.h4
-rw-r--r--networking/udhcp/script.c2
-rw-r--r--networking/udhcp/socket.c4
-rw-r--r--networking/wget.c18
-rw-r--r--shell/hush.c3
-rw-r--r--shell/msh.c28
-rw-r--r--util-linux/fbset.c4
-rw-r--r--util-linux/mdev.c3
-rw-r--r--util-linux/switch_root.c2
32 files changed, 110 insertions, 109 deletions
diff --git a/archival/dpkg.c b/archival/dpkg.c
index 5535c15a1..126138f80 100644
--- a/archival/dpkg.c
+++ b/archival/dpkg.c
@@ -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);
diff --git a/archival/dpkg_deb.c b/archival/dpkg_deb.c
index d11d9df17..c9b8a0429 100644
--- a/archival/dpkg_deb.c
+++ b/archival/dpkg_deb.c
@@ -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;
}
diff --git a/editors/sed.c b/editors/sed.c
index 695e5e974..70b36095f 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -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. */
diff --git a/findutils/xargs.c b/findutils/xargs.c
index 029d4077d..077b8847f 100644
--- a/findutils/xargs.c
+++ b/findutils/xargs.c
@@ -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++;
}
diff --git a/include/libbb.h b/include/libbb.h
index 6f195cf46..99a9422f0 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -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);
diff --git a/init/mesg.c b/init/mesg.c
index 7e47644c3..658c82447 100644
--- a/init/mesg.c
+++ b/init/mesg.c
@@ -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;
}
}
diff --git a/libbb/dump.c b/libbb/dump.c
index 1815ca914..f078afc1c 100644
--- a/libbb/dump.c
+++ b/libbb/dump.c
@@ -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;
diff --git a/libbb/get_last_path_component.c b/libbb/get_last_path_component.c
index 311909726..b7bc0e626 100644
--- a/libbb/get_last_path_component.c
+++ b/libbb/get_last_path_component.c
@@ -26,7 +26,7 @@ char *bb_get_last_path_component(char *path)
if (*first == '/') {
last = first;
}
- last[1] = 0;
+ last[1] = '\0';
return first;
}
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c
index 54d291ab1..601ff3f7e 100644
--- a/libbb/xfuncs.c
+++ b/libbb/xfuncs.c
@@ -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;
diff --git a/miscutils/eject.c b/miscutils/eject.c
index ff23b1666..8e37c84b5 100644
--- a/miscutils/eject.c
+++ b/miscutils/eject.c
@@ -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";
diff --git a/miscutils/hdparm.c b/miscutils/hdparm.c
index e60e642d6..afb4ecc7b 100644
--- a/miscutils/hdparm.c
+++ b/miscutils/hdparm.c
@@ -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);
diff --git a/miscutils/strings.c b/miscutils/strings.c
index 0d5576e9b..691502dab 100644
--- a/miscutils/strings.c
+++ b/miscutils/strings.c
@@ -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 */
diff --git a/modutils/insmod.c b/modutils/insmod.c
index 1ad3c23a4..241db45e8 100644
--- a/modutils/insmod.c
+++ b/modutils/insmod.c
@@ -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);
diff --git a/modutils/lsmod.c b/modutils/lsmod.c
index 987174081..af16f2c61 100644
--- a/modutils/lsmod.c
+++ b/modutils/lsmod.c
@@ -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);
diff --git a/networking/arping.c b/networking/arping.c
index 725b0e4cb..7bab0d048 100644
--- a/networking/arping.c
+++ b/networking/arping.c
@@ -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;
diff --git a/networking/ftpgetput.c b/networking/ftpgetput.c
index ccc0b5e46..590b7ebcd 100644
--- a/networking/ftpgetput.c
+++ b/networking/ftpgetput.c
@@ -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;
diff --git a/networking/inetd.c b/networking/inetd.c
index c1f9918f0..5e7005e9b 100644
--- a/networking/inetd.c
+++ b/networking/inetd.c
@@ -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];
diff --git a/networking/libiproute/utils.c b/networking/libiproute/utils.c
index 7e74e1c4b..5e06656f6 100644
--- a/networking/libiproute/utils.c
+++ b/networking/libiproute/utils.c
@@ -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);
diff --git a/networking/libiproute/utils.h b/networking/libiproute/utils.h
index c8ac63197..5af8ba744 100644
--- a/networking/libiproute/utils.h
+++ b/networking/libiproute/utils.h
@@ -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);
diff --git a/networking/netstat.c b/networking/netstat.c
index 16ee52d9a..a5631c3c0 100644
--- a/networking/netstat.c
+++ b/networking/netstat.c
@@ -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;
diff --git a/networking/route.c b/networking/route.c
index 56c6f46c6..d32011cc4 100644
--- a/networking/route.c
+++ b/networking/route.c
@@ -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
diff --git a/networking/telnet.c b/networking/telnet.c
index fc70cc406..7407fa413 100644
--- a/networking/telnet.c
+++ b/networking/telnet.c
@@ -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();
diff --git a/networking/udhcp/common.h b/networking/udhcp/common.h
index ca05a9c2c..a80691b4a 100644
--- a/networking/udhcp/common.h
+++ b/networking/udhcp/common.h
@@ -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);
diff --git a/networking/udhcp/dhcpc.h b/networking/udhcp/dhcpc.h
index fd17917d0..4ddd12120 100644
--- a/networking/udhcp/dhcpc.h
+++ b/networking/udhcp/dhcpc.h
@@ -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 */
diff --git a/networking/udhcp/script.c b/networking/udhcp/script.c
index 07f68362c..d2b0bb05b 100644
--- a/networking/udhcp/script.c
+++ b/networking/udhcp/script.c
@@ -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]);
}
diff --git a/networking/udhcp/socket.c b/networking/udhcp/socket.c
index 76ae7172d..d294fb259 100644
--- a/networking/udhcp/socket.c
+++ b/networking/udhcp/socket.c
@@ -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;
diff --git a/networking/wget.c b/networking/wget.c
index 224e80dc0..7766bde88 100644
--- a/networking/wget.c
+++ b/networking/wget.c
@@ -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) {
diff --git a/shell/hush.c b/shell/hush.c
index 7e274324e..dca04b5a6 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -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...
diff --git a/shell/msh.c b/shell/msh.c
index 15ce9ffdd..584668607 100644
--- a/shell/msh.c
+++ b/shell/msh.c
@@ -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;
}
diff --git a/util-linux/fbset.c b/util-linux/fbset.c
index 7ae010163..94d04b12a 100644
--- a/util-linux/fbset.c
+++ b/util-linux/fbset.c
@@ -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));
diff --git a/util-linux/mdev.c b/util-linux/mdev.c
index 957316d52..4a0e9f9fd 100644
--- a/util-linux/mdev.c
+++ b/util-linux/mdev.c
@@ -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
diff --git a/util-linux/switch_root.c b/util-linux/switch_root.c
index 4c23f69da..007083bef 100644
--- a/util-linux/switch_root.c
+++ b/util-linux/switch_root.c
@@ -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;