preparatory patch for -Wwrite-strings #3
This commit is contained in:
parent
b6aae0f381
commit
06c0a71d23
16
init/init.c
16
init/init.c
@ -326,27 +326,26 @@ static void console_init(void)
|
|||||||
/* Force the TERM setting to vt102 for serial console --
|
/* Force the TERM setting to vt102 for serial console --
|
||||||
* if TERM is set to linux (the default) */
|
* if TERM is set to linux (the default) */
|
||||||
if (s == NULL || strcmp(s, "linux") == 0)
|
if (s == NULL || strcmp(s, "linux") == 0)
|
||||||
putenv("TERM=vt102");
|
putenv((char*)"TERM=vt102");
|
||||||
#if !ENABLE_SYSLOGD
|
#if !ENABLE_SYSLOGD
|
||||||
log_console = console;
|
log_console = console;
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
putenv("TERM=linux");
|
putenv((char*)"TERM=linux");
|
||||||
}
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
messageD(LOG, "console=%s", console);
|
messageD(LOG, "console=%s", console);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fixup_argv(int argc, char **argv, char *new_argv0)
|
static void fixup_argv(int argc, char **argv, const char *new_argv0)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
/* Fix up argv[0] to be certain we claim to be init */
|
/* Fix up argv[0] to be certain we claim to be init */
|
||||||
len = strlen(argv[0]);
|
len = strlen(argv[0]);
|
||||||
memset(argv[0], 0, len);
|
strncpy(argv[0], new_argv0, len);
|
||||||
safe_strncpy(argv[0], new_argv0, len + 1);
|
|
||||||
|
|
||||||
/* Wipe argv[1]-argv[N] so they don't clutter the ps listing */
|
/* Wipe argv[1]-argv[N] so they don't clutter the ps listing */
|
||||||
len = 1;
|
len = 1;
|
||||||
@ -381,7 +380,8 @@ static pid_t run(const struct init_action *a)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
char *s, *tmpCmd, *cmd[INIT_BUFFS_SIZE], *cmdpath;
|
char *s, *tmpCmd, *cmdpath;
|
||||||
|
char *cmd[INIT_BUFFS_SIZE];
|
||||||
char buf[INIT_BUFFS_SIZE + 6]; /* INIT_BUFFS_SIZE+strlen("exec ")+1 */
|
char buf[INIT_BUFFS_SIZE + 6]; /* INIT_BUFFS_SIZE+strlen("exec ")+1 */
|
||||||
sigset_t nmask, omask;
|
sigset_t nmask, omask;
|
||||||
static const char press_enter[] =
|
static const char press_enter[] =
|
||||||
@ -389,7 +389,7 @@ static pid_t run(const struct init_action *a)
|
|||||||
#include CUSTOMIZED_BANNER
|
#include CUSTOMIZED_BANNER
|
||||||
#endif
|
#endif
|
||||||
"\nPlease press Enter to activate this console. ";
|
"\nPlease press Enter to activate this console. ";
|
||||||
char *prog;
|
const char *prog;
|
||||||
|
|
||||||
/* Block sigchild while forking. */
|
/* Block sigchild while forking. */
|
||||||
sigemptyset(&nmask);
|
sigemptyset(&nmask);
|
||||||
@ -472,7 +472,7 @@ static pid_t run(const struct init_action *a)
|
|||||||
/* See if any special /bin/sh requiring characters are present */
|
/* See if any special /bin/sh requiring characters are present */
|
||||||
if (strpbrk(a->command, "~`!$^&*()=|\\{}[];\"'<>?") != NULL) {
|
if (strpbrk(a->command, "~`!$^&*()=|\\{}[];\"'<>?") != NULL) {
|
||||||
cmd[0] = (char *)DEFAULT_SHELL;
|
cmd[0] = (char *)DEFAULT_SHELL;
|
||||||
cmd[1] = "-c";
|
cmd[1] = (char*)"-c";
|
||||||
cmd[2] = strcat(strcpy(buf, "exec "), a->command);
|
cmd[2] = strcat(strcpy(buf, "exec "), a->command);
|
||||||
cmd[3] = NULL;
|
cmd[3] = NULL;
|
||||||
} else {
|
} else {
|
||||||
|
@ -169,7 +169,7 @@ int adduser_main(int argc, char **argv)
|
|||||||
bb_error_msg_and_die(bb_msg_perm_denied_are_you_root);
|
bb_error_msg_and_die(bb_msg_perm_denied_are_you_root);
|
||||||
}
|
}
|
||||||
|
|
||||||
pw.pw_gecos = "Linux User,,,";
|
pw.pw_gecos = (char *)"Linux User,,,";
|
||||||
pw.pw_shell = (char *)DEFAULT_SHELL;
|
pw.pw_shell = (char *)DEFAULT_SHELL;
|
||||||
pw.pw_dir = NULL;
|
pw.pw_dir = NULL;
|
||||||
|
|
||||||
@ -185,7 +185,7 @@ int adduser_main(int argc, char **argv)
|
|||||||
|
|
||||||
/* create a passwd struct */
|
/* create a passwd struct */
|
||||||
pw.pw_name = argv[optind];
|
pw.pw_name = argv[optind];
|
||||||
pw.pw_passwd = "x";
|
pw.pw_passwd = (char *)"x";
|
||||||
pw.pw_uid = 0;
|
pw.pw_uid = 0;
|
||||||
pw.pw_gid = usegroup ? xgroup2gid(usegroup) : 0; /* exits on failure */
|
pw.pw_gid = usegroup ? xgroup2gid(usegroup) : 0; /* exits on failure */
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#if ENABLE_FEATURE_WTMP
|
#if ENABLE_FEATURE_WTMP
|
||||||
extern void updwtmp(const char *filename, const struct utmp *ut);
|
extern void updwtmp(const char *filename, const struct utmp *ut);
|
||||||
static void update_utmp(char *line);
|
static void update_utmp(const char *line);
|
||||||
#endif
|
#endif
|
||||||
#endif /* LOGIN_PROCESS */
|
#endif /* LOGIN_PROCESS */
|
||||||
|
|
||||||
@ -85,10 +85,10 @@ static void update_utmp(char *line);
|
|||||||
struct options {
|
struct options {
|
||||||
int flags; /* toggle switches, see below */
|
int flags; /* toggle switches, see below */
|
||||||
unsigned timeout; /* time-out period */
|
unsigned timeout; /* time-out period */
|
||||||
char *login; /* login program */
|
const char *login; /* login program */
|
||||||
char *tty; /* name of tty */
|
const char *tty; /* name of tty */
|
||||||
char *initstring; /* modem init string */
|
const char *initstring; /* modem init string */
|
||||||
char *issue; /* alternative issue file */
|
const char *issue; /* alternative issue file */
|
||||||
int numspeed; /* number of baud rates to try */
|
int numspeed; /* number of baud rates to try */
|
||||||
int speeds[MAX_SPEED]; /* baud rates to be tried */
|
int speeds[MAX_SPEED]; /* baud rates to be tried */
|
||||||
};
|
};
|
||||||
@ -187,7 +187,7 @@ static void parse_args(int argc, char **argv, struct options *op)
|
|||||||
const char *p = op->initstring;
|
const char *p = op->initstring;
|
||||||
char *q;
|
char *q;
|
||||||
|
|
||||||
q = op->initstring = xstrdup(op->initstring);
|
op->initstring = q = xstrdup(op->initstring);
|
||||||
/* copy optarg into op->initstring decoding \ddd
|
/* copy optarg into op->initstring decoding \ddd
|
||||||
octal codes into chars */
|
octal codes into chars */
|
||||||
while (*p) {
|
while (*p) {
|
||||||
@ -233,7 +233,7 @@ static void xdup2(int srcfd, int dstfd, const char *tty)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* open_tty - set up tty as standard { input, output, error } */
|
/* open_tty - set up tty as standard { input, output, error } */
|
||||||
static void open_tty(char *tty, struct termios *tp, int local)
|
static void open_tty(const char *tty, struct termios *tp, int local)
|
||||||
{
|
{
|
||||||
int chdir_to_root = 0;
|
int chdir_to_root = 0;
|
||||||
|
|
||||||
@ -655,7 +655,7 @@ static void termios_final(struct options *op, struct termios *tp, struct chardat
|
|||||||
#ifdef SYSV_STYLE
|
#ifdef SYSV_STYLE
|
||||||
#if ENABLE_FEATURE_UTMP
|
#if ENABLE_FEATURE_UTMP
|
||||||
/* update_utmp - update our utmp entry */
|
/* update_utmp - update our utmp entry */
|
||||||
static void update_utmp(char *line)
|
static void update_utmp(const char *line)
|
||||||
{
|
{
|
||||||
struct utmp ut;
|
struct utmp ut;
|
||||||
struct utmp *utp;
|
struct utmp *utp;
|
||||||
|
@ -53,7 +53,7 @@ static void crypt_make_salt(char *p, int cnt)
|
|||||||
static char* new_password(const struct passwd *pw, uid_t myuid, int algo)
|
static char* new_password(const struct passwd *pw, uid_t myuid, int algo)
|
||||||
{
|
{
|
||||||
char salt[sizeof("$N$XXXXXXXX")]; /* "$N$XXXXXXXX" or "XX" */
|
char salt[sizeof("$N$XXXXXXXX")]; /* "$N$XXXXXXXX" or "XX" */
|
||||||
char *orig = "";
|
char *orig = (char*)"";
|
||||||
char *newp = NULL;
|
char *newp = NULL;
|
||||||
char *cipher = NULL;
|
char *cipher = NULL;
|
||||||
char *cp = NULL;
|
char *cp = NULL;
|
||||||
@ -241,7 +241,7 @@ int passwd_main(int argc, char **argv)
|
|||||||
/*STATE_ALGO_des = 0x20, not needed yet */
|
/*STATE_ALGO_des = 0x20, not needed yet */
|
||||||
};
|
};
|
||||||
unsigned opt;
|
unsigned opt;
|
||||||
char *opt_a = "";
|
const char *opt_a = "";
|
||||||
const char *filename;
|
const char *filename;
|
||||||
char *myname;
|
char *myname;
|
||||||
char *name;
|
char *name;
|
||||||
|
@ -14,9 +14,9 @@
|
|||||||
int su_main(int argc, char **argv)
|
int su_main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
unsigned flags;
|
unsigned flags;
|
||||||
char *opt_shell = 0;
|
char *opt_shell = NULL;
|
||||||
char *opt_command = 0;
|
char *opt_command = NULL;
|
||||||
char *opt_username = "root";
|
const char *opt_username = "root";
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
uid_t cur_uid = getuid();
|
uid_t cur_uid = getuid();
|
||||||
const char *tty;
|
const char *tty;
|
||||||
|
@ -290,8 +290,7 @@ static void EditFile(const char *user, const char *file)
|
|||||||
/*
|
/*
|
||||||
* CHILD - change user and run editor
|
* CHILD - change user and run editor
|
||||||
*/
|
*/
|
||||||
char *ptr;
|
const char *ptr;
|
||||||
char visual[1024];
|
|
||||||
|
|
||||||
if (ChangeUser(user, 1) < 0)
|
if (ChangeUser(user, 1) < 0)
|
||||||
exit(0);
|
exit(0);
|
||||||
@ -299,10 +298,9 @@ static void EditFile(const char *user, const char *file)
|
|||||||
if (ptr == NULL || strlen(ptr) > 256)
|
if (ptr == NULL || strlen(ptr) > 256)
|
||||||
ptr = PATH_VI;
|
ptr = PATH_VI;
|
||||||
|
|
||||||
snprintf(visual, sizeof(visual), "%s %s", ptr, file);
|
ptr = xasprintf("%s %s", ptr, file);
|
||||||
execl(DEFAULT_SHELL, DEFAULT_SHELL, "-c", visual, NULL);
|
execl(DEFAULT_SHELL, DEFAULT_SHELL, "-c", ptr, NULL);
|
||||||
perror("exec");
|
bb_perror_msg_and_die("exec");
|
||||||
exit(0);
|
|
||||||
}
|
}
|
||||||
if (pid < 0) {
|
if (pid < 0) {
|
||||||
/*
|
/*
|
||||||
|
@ -185,7 +185,7 @@ static void reread_partition_table(int leave);
|
|||||||
static void delete_partition(int i);
|
static void delete_partition(int i);
|
||||||
static int get_partition(int warn, int max);
|
static int get_partition(int warn, int max);
|
||||||
static void list_types(const struct systypes *sys);
|
static void list_types(const struct systypes *sys);
|
||||||
static unsigned read_int(unsigned low, unsigned dflt, unsigned high, unsigned base, char *mesg);
|
static unsigned read_int(unsigned low, unsigned dflt, unsigned high, unsigned base, const char *mesg);
|
||||||
#endif
|
#endif
|
||||||
static const char *partition_type(unsigned char type);
|
static const char *partition_type(unsigned char type);
|
||||||
static void fdisk_fatal(enum failure why) ATTRIBUTE_NORETURN;
|
static void fdisk_fatal(enum failure why) ATTRIBUTE_NORETURN;
|
||||||
@ -1410,7 +1410,7 @@ get_boot(enum action what)
|
|||||||
* There is no default if DFLT is not between LOW and HIGH.
|
* There is no default if DFLT is not between LOW and HIGH.
|
||||||
*/
|
*/
|
||||||
static unsigned
|
static unsigned
|
||||||
read_int(unsigned low, unsigned dflt, unsigned high, unsigned base, char *mesg)
|
read_int(unsigned low, unsigned dflt, unsigned high, unsigned base, const char *mesg)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
int default_ok = 1;
|
int default_ok = 1;
|
||||||
|
@ -630,7 +630,7 @@ xbsd_create_disklabel(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
edit_int(int def, char *mesg)
|
edit_int(int def, const char *mesg)
|
||||||
{
|
{
|
||||||
mesg = xasprintf("%s (%d): ", mesg, def);
|
mesg = xasprintf("%s (%d): ", mesg, def);
|
||||||
do {
|
do {
|
||||||
@ -639,7 +639,7 @@ edit_int(int def, char *mesg)
|
|||||||
} while (!isdigit(*line_ptr));
|
} while (!isdigit(*line_ptr));
|
||||||
def = atoi(line_ptr);
|
def = atoi(line_ptr);
|
||||||
ret:
|
ret:
|
||||||
free(mesg);
|
free((char*)mesg);
|
||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -707,9 +707,9 @@ sync_disks(void)
|
|||||||
static void
|
static void
|
||||||
xbsd_write_bootstrap(void)
|
xbsd_write_bootstrap(void)
|
||||||
{
|
{
|
||||||
char *bootdir = BSD_LINUX_BOOTDIR;
|
|
||||||
char path[MAXPATHLEN];
|
char path[MAXPATHLEN];
|
||||||
char *dkbasename;
|
const char *bootdir = BSD_LINUX_BOOTDIR;
|
||||||
|
const char *dkbasename;
|
||||||
struct xbsd_disklabel dl;
|
struct xbsd_disklabel dl;
|
||||||
char *d, *p, *e;
|
char *d, *p, *e;
|
||||||
int sector;
|
int sector;
|
||||||
|
@ -152,8 +152,8 @@ int ipcrm_main(int argc, char **argv)
|
|||||||
(c == 'm') ? shmget(key, 0, 0) : semget(key, 0, 0));
|
(c == 'm') ? shmget(key, 0, 0) : semget(key, 0, 0));
|
||||||
|
|
||||||
if (id < 0) {
|
if (id < 0) {
|
||||||
char *errmsg;
|
const char *errmsg;
|
||||||
const char * const what = "key";
|
const char *const what = "key";
|
||||||
|
|
||||||
error++;
|
error++;
|
||||||
switch (errno) {
|
switch (errno) {
|
||||||
@ -183,8 +183,8 @@ int ipcrm_main(int argc, char **argv)
|
|||||||
semctl(id, 0, IPC_RMID, arg));
|
semctl(id, 0, IPC_RMID, arg));
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
char *errmsg;
|
const char *errmsg;
|
||||||
const char * const what = iskey ? "key" : "id";
|
const char *const what = iskey ? "key" : "id";
|
||||||
|
|
||||||
error++;
|
error++;
|
||||||
switch (errno) {
|
switch (errno) {
|
||||||
|
@ -64,7 +64,7 @@ enum {
|
|||||||
* flags */
|
* flags */
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
char *name;
|
const char *name;
|
||||||
long flags;
|
long flags;
|
||||||
} static mount_options[] = {
|
} static mount_options[] = {
|
||||||
// MS_FLAGS set a bit. ~MS_FLAGS disable that bit. 0 flags are NOPs.
|
// MS_FLAGS set a bit. ~MS_FLAGS disable that bit. 0 flags are NOPs.
|
||||||
@ -122,7 +122,7 @@ struct {
|
|||||||
#define VECTOR_SIZE(v) (sizeof(v) / sizeof((v)[0]))
|
#define VECTOR_SIZE(v) (sizeof(v) / sizeof((v)[0]))
|
||||||
|
|
||||||
/* Append mount options to string */
|
/* Append mount options to string */
|
||||||
static void append_mount_options(char **oldopts, char *newopts)
|
static void append_mount_options(char **oldopts, const char *newopts)
|
||||||
{
|
{
|
||||||
if (*oldopts && **oldopts) {
|
if (*oldopts && **oldopts) {
|
||||||
/* do not insert options which are already there */
|
/* do not insert options which are already there */
|
||||||
@ -303,7 +303,7 @@ static int mount_it_now(struct mntent *mp, int vfsflags, char *filteropts)
|
|||||||
fsname = 0;
|
fsname = 0;
|
||||||
if (!mp->mnt_type || !*mp->mnt_type) { /* bind mount */
|
if (!mp->mnt_type || !*mp->mnt_type) { /* bind mount */
|
||||||
mp->mnt_fsname = fsname = bb_simplify_path(mp->mnt_fsname);
|
mp->mnt_fsname = fsname = bb_simplify_path(mp->mnt_fsname);
|
||||||
mp->mnt_type = "bind";
|
mp->mnt_type = (char*)"bind";
|
||||||
}
|
}
|
||||||
mp->mnt_freq = mp->mnt_passno = 0;
|
mp->mnt_freq = mp->mnt_passno = 0;
|
||||||
|
|
||||||
@ -1342,7 +1342,7 @@ prepare_kernel_data:
|
|||||||
|
|
||||||
do_mount: /* perform actual mount */
|
do_mount: /* perform actual mount */
|
||||||
|
|
||||||
mp->mnt_type = "nfs";
|
mp->mnt_type = (char*)"nfs";
|
||||||
retval = mount_it_now(mp, vfsflags, (char*)&data);
|
retval = mount_it_now(mp, vfsflags, (char*)&data);
|
||||||
goto ret;
|
goto ret;
|
||||||
|
|
||||||
@ -1428,7 +1428,7 @@ static int singlemount(struct mntent *mp, int ignore_busy)
|
|||||||
// lock is required
|
// lock is required
|
||||||
vfsflags |= MS_MANDLOCK;
|
vfsflags |= MS_MANDLOCK;
|
||||||
|
|
||||||
mp->mnt_type = "cifs";
|
mp->mnt_type = (char*)"cifs";
|
||||||
rc = mount_it_now(mp, vfsflags, filteropts);
|
rc = mount_it_now(mp, vfsflags, filteropts);
|
||||||
if (ENABLE_FEATURE_CLEAN_UP) free(mp->mnt_fsname);
|
if (ENABLE_FEATURE_CLEAN_UP) free(mp->mnt_fsname);
|
||||||
goto report_error;
|
goto report_error;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user