diff options
author | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2007-01-29 22:51:44 +0000 |
---|---|---|
committer | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2007-01-29 22:51:44 +0000 |
commit | 0c7ca1fafeb5f23776ba7e1624636ad1698b6536 (patch) | |
tree | df385c84041f3fd8328e7a50caef4495ef2734a8 | |
parent | 2f2ce3c4222378da84c9f5f555c32409566579d8 (diff) | |
download | busybox-w32-0c7ca1fafeb5f23776ba7e1624636ad1698b6536.tar.gz busybox-w32-0c7ca1fafeb5f23776ba7e1624636ad1698b6536.tar.bz2 busybox-w32-0c7ca1fafeb5f23776ba7e1624636ad1698b6536.zip |
preparatory patch for -Wwrite-strings #3
git-svn-id: svn://busybox.net/trunk/busybox@17655 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r-- | init/init.c | 16 | ||||
-rw-r--r-- | loginutils/adduser.c | 4 | ||||
-rw-r--r-- | loginutils/getty.c | 16 | ||||
-rw-r--r-- | loginutils/passwd.c | 4 | ||||
-rw-r--r-- | loginutils/su.c | 6 | ||||
-rw-r--r-- | miscutils/crontab.c | 10 | ||||
-rw-r--r-- | util-linux/fdisk.c | 4 | ||||
-rw-r--r-- | util-linux/fdisk_osf.c | 8 | ||||
-rw-r--r-- | util-linux/ipcrm.c | 8 | ||||
-rw-r--r-- | util-linux/mount.c | 10 |
10 files changed, 42 insertions, 44 deletions
diff --git a/init/init.c b/init/init.c index 7694b4448..cb314003e 100644 --- a/init/init.c +++ b/init/init.c | |||
@@ -326,27 +326,26 @@ static void console_init(void) | |||
326 | /* Force the TERM setting to vt102 for serial console -- | 326 | /* Force the TERM setting to vt102 for serial console -- |
327 | * if TERM is set to linux (the default) */ | 327 | * if TERM is set to linux (the default) */ |
328 | if (s == NULL || strcmp(s, "linux") == 0) | 328 | if (s == NULL || strcmp(s, "linux") == 0) |
329 | putenv("TERM=vt102"); | 329 | putenv((char*)"TERM=vt102"); |
330 | #if !ENABLE_SYSLOGD | 330 | #if !ENABLE_SYSLOGD |
331 | log_console = console; | 331 | log_console = console; |
332 | #endif | 332 | #endif |
333 | } else { | 333 | } else { |
334 | if (s == NULL) | 334 | if (s == NULL) |
335 | putenv("TERM=linux"); | 335 | putenv((char*)"TERM=linux"); |
336 | } | 336 | } |
337 | close(fd); | 337 | close(fd); |
338 | } | 338 | } |
339 | messageD(LOG, "console=%s", console); | 339 | messageD(LOG, "console=%s", console); |
340 | } | 340 | } |
341 | 341 | ||
342 | static void fixup_argv(int argc, char **argv, char *new_argv0) | 342 | static void fixup_argv(int argc, char **argv, const char *new_argv0) |
343 | { | 343 | { |
344 | int len; | 344 | int len; |
345 | 345 | ||
346 | /* Fix up argv[0] to be certain we claim to be init */ | 346 | /* Fix up argv[0] to be certain we claim to be init */ |
347 | len = strlen(argv[0]); | 347 | len = strlen(argv[0]); |
348 | memset(argv[0], 0, len); | 348 | strncpy(argv[0], new_argv0, len); |
349 | safe_strncpy(argv[0], new_argv0, len + 1); | ||
350 | 349 | ||
351 | /* Wipe argv[1]-argv[N] so they don't clutter the ps listing */ | 350 | /* Wipe argv[1]-argv[N] so they don't clutter the ps listing */ |
352 | len = 1; | 351 | len = 1; |
@@ -381,7 +380,8 @@ static pid_t run(const struct init_action *a) | |||
381 | { | 380 | { |
382 | int i; | 381 | int i; |
383 | pid_t pid; | 382 | pid_t pid; |
384 | char *s, *tmpCmd, *cmd[INIT_BUFFS_SIZE], *cmdpath; | 383 | char *s, *tmpCmd, *cmdpath; |
384 | char *cmd[INIT_BUFFS_SIZE]; | ||
385 | char buf[INIT_BUFFS_SIZE + 6]; /* INIT_BUFFS_SIZE+strlen("exec ")+1 */ | 385 | char buf[INIT_BUFFS_SIZE + 6]; /* INIT_BUFFS_SIZE+strlen("exec ")+1 */ |
386 | sigset_t nmask, omask; | 386 | sigset_t nmask, omask; |
387 | static const char press_enter[] = | 387 | static const char press_enter[] = |
@@ -389,7 +389,7 @@ static pid_t run(const struct init_action *a) | |||
389 | #include CUSTOMIZED_BANNER | 389 | #include CUSTOMIZED_BANNER |
390 | #endif | 390 | #endif |
391 | "\nPlease press Enter to activate this console. "; | 391 | "\nPlease press Enter to activate this console. "; |
392 | char *prog; | 392 | const char *prog; |
393 | 393 | ||
394 | /* Block sigchild while forking. */ | 394 | /* Block sigchild while forking. */ |
395 | sigemptyset(&nmask); | 395 | sigemptyset(&nmask); |
@@ -472,7 +472,7 @@ static pid_t run(const struct init_action *a) | |||
472 | /* See if any special /bin/sh requiring characters are present */ | 472 | /* See if any special /bin/sh requiring characters are present */ |
473 | if (strpbrk(a->command, "~`!$^&*()=|\\{}[];\"'<>?") != NULL) { | 473 | if (strpbrk(a->command, "~`!$^&*()=|\\{}[];\"'<>?") != NULL) { |
474 | cmd[0] = (char *)DEFAULT_SHELL; | 474 | cmd[0] = (char *)DEFAULT_SHELL; |
475 | cmd[1] = "-c"; | 475 | cmd[1] = (char*)"-c"; |
476 | cmd[2] = strcat(strcpy(buf, "exec "), a->command); | 476 | cmd[2] = strcat(strcpy(buf, "exec "), a->command); |
477 | cmd[3] = NULL; | 477 | cmd[3] = NULL; |
478 | } else { | 478 | } else { |
diff --git a/loginutils/adduser.c b/loginutils/adduser.c index ea0b89a9b..5a48e9cbb 100644 --- a/loginutils/adduser.c +++ b/loginutils/adduser.c | |||
@@ -169,7 +169,7 @@ int adduser_main(int argc, char **argv) | |||
169 | bb_error_msg_and_die(bb_msg_perm_denied_are_you_root); | 169 | bb_error_msg_and_die(bb_msg_perm_denied_are_you_root); |
170 | } | 170 | } |
171 | 171 | ||
172 | pw.pw_gecos = "Linux User,,,"; | 172 | pw.pw_gecos = (char *)"Linux User,,,"; |
173 | pw.pw_shell = (char *)DEFAULT_SHELL; | 173 | pw.pw_shell = (char *)DEFAULT_SHELL; |
174 | pw.pw_dir = NULL; | 174 | pw.pw_dir = NULL; |
175 | 175 | ||
@@ -185,7 +185,7 @@ int adduser_main(int argc, char **argv) | |||
185 | 185 | ||
186 | /* create a passwd struct */ | 186 | /* create a passwd struct */ |
187 | pw.pw_name = argv[optind]; | 187 | pw.pw_name = argv[optind]; |
188 | pw.pw_passwd = "x"; | 188 | pw.pw_passwd = (char *)"x"; |
189 | pw.pw_uid = 0; | 189 | pw.pw_uid = 0; |
190 | pw.pw_gid = usegroup ? xgroup2gid(usegroup) : 0; /* exits on failure */ | 190 | pw.pw_gid = usegroup ? xgroup2gid(usegroup) : 0; /* exits on failure */ |
191 | 191 | ||
diff --git a/loginutils/getty.c b/loginutils/getty.c index f2c2b4afb..8f81cafcc 100644 --- a/loginutils/getty.c +++ b/loginutils/getty.c | |||
@@ -33,7 +33,7 @@ | |||
33 | #include <time.h> | 33 | #include <time.h> |
34 | #if ENABLE_FEATURE_WTMP | 34 | #if ENABLE_FEATURE_WTMP |
35 | extern void updwtmp(const char *filename, const struct utmp *ut); | 35 | extern void updwtmp(const char *filename, const struct utmp *ut); |
36 | static void update_utmp(char *line); | 36 | static void update_utmp(const char *line); |
37 | #endif | 37 | #endif |
38 | #endif /* LOGIN_PROCESS */ | 38 | #endif /* LOGIN_PROCESS */ |
39 | 39 | ||
@@ -85,10 +85,10 @@ static void update_utmp(char *line); | |||
85 | struct options { | 85 | struct options { |
86 | int flags; /* toggle switches, see below */ | 86 | int flags; /* toggle switches, see below */ |
87 | unsigned timeout; /* time-out period */ | 87 | unsigned timeout; /* time-out period */ |
88 | char *login; /* login program */ | 88 | const char *login; /* login program */ |
89 | char *tty; /* name of tty */ | 89 | const char *tty; /* name of tty */ |
90 | char *initstring; /* modem init string */ | 90 | const char *initstring; /* modem init string */ |
91 | char *issue; /* alternative issue file */ | 91 | const char *issue; /* alternative issue file */ |
92 | int numspeed; /* number of baud rates to try */ | 92 | int numspeed; /* number of baud rates to try */ |
93 | int speeds[MAX_SPEED]; /* baud rates to be tried */ | 93 | int speeds[MAX_SPEED]; /* baud rates to be tried */ |
94 | }; | 94 | }; |
@@ -187,7 +187,7 @@ static void parse_args(int argc, char **argv, struct options *op) | |||
187 | const char *p = op->initstring; | 187 | const char *p = op->initstring; |
188 | char *q; | 188 | char *q; |
189 | 189 | ||
190 | q = op->initstring = xstrdup(op->initstring); | 190 | op->initstring = q = xstrdup(op->initstring); |
191 | /* copy optarg into op->initstring decoding \ddd | 191 | /* copy optarg into op->initstring decoding \ddd |
192 | octal codes into chars */ | 192 | octal codes into chars */ |
193 | while (*p) { | 193 | while (*p) { |
@@ -233,7 +233,7 @@ static void xdup2(int srcfd, int dstfd, const char *tty) | |||
233 | } | 233 | } |
234 | 234 | ||
235 | /* open_tty - set up tty as standard { input, output, error } */ | 235 | /* open_tty - set up tty as standard { input, output, error } */ |
236 | static void open_tty(char *tty, struct termios *tp, int local) | 236 | static void open_tty(const char *tty, struct termios *tp, int local) |
237 | { | 237 | { |
238 | int chdir_to_root = 0; | 238 | int chdir_to_root = 0; |
239 | 239 | ||
@@ -655,7 +655,7 @@ static void termios_final(struct options *op, struct termios *tp, struct chardat | |||
655 | #ifdef SYSV_STYLE | 655 | #ifdef SYSV_STYLE |
656 | #if ENABLE_FEATURE_UTMP | 656 | #if ENABLE_FEATURE_UTMP |
657 | /* update_utmp - update our utmp entry */ | 657 | /* update_utmp - update our utmp entry */ |
658 | static void update_utmp(char *line) | 658 | static void update_utmp(const char *line) |
659 | { | 659 | { |
660 | struct utmp ut; | 660 | struct utmp ut; |
661 | struct utmp *utp; | 661 | struct utmp *utp; |
diff --git a/loginutils/passwd.c b/loginutils/passwd.c index 5c822b190..ab20f2807 100644 --- a/loginutils/passwd.c +++ b/loginutils/passwd.c | |||
@@ -53,7 +53,7 @@ static void crypt_make_salt(char *p, int cnt) | |||
53 | static char* new_password(const struct passwd *pw, uid_t myuid, int algo) | 53 | static char* new_password(const struct passwd *pw, uid_t myuid, int algo) |
54 | { | 54 | { |
55 | char salt[sizeof("$N$XXXXXXXX")]; /* "$N$XXXXXXXX" or "XX" */ | 55 | char salt[sizeof("$N$XXXXXXXX")]; /* "$N$XXXXXXXX" or "XX" */ |
56 | char *orig = ""; | 56 | char *orig = (char*)""; |
57 | char *newp = NULL; | 57 | char *newp = NULL; |
58 | char *cipher = NULL; | 58 | char *cipher = NULL; |
59 | char *cp = NULL; | 59 | char *cp = NULL; |
@@ -241,7 +241,7 @@ int passwd_main(int argc, char **argv) | |||
241 | /*STATE_ALGO_des = 0x20, not needed yet */ | 241 | /*STATE_ALGO_des = 0x20, not needed yet */ |
242 | }; | 242 | }; |
243 | unsigned opt; | 243 | unsigned opt; |
244 | char *opt_a = ""; | 244 | const char *opt_a = ""; |
245 | const char *filename; | 245 | const char *filename; |
246 | char *myname; | 246 | char *myname; |
247 | char *name; | 247 | char *name; |
diff --git a/loginutils/su.c b/loginutils/su.c index e1c1591aa..9a134dd88 100644 --- a/loginutils/su.c +++ b/loginutils/su.c | |||
@@ -14,9 +14,9 @@ | |||
14 | int su_main(int argc, char **argv) | 14 | int su_main(int argc, char **argv) |
15 | { | 15 | { |
16 | unsigned flags; | 16 | unsigned flags; |
17 | char *opt_shell = 0; | 17 | char *opt_shell = NULL; |
18 | char *opt_command = 0; | 18 | char *opt_command = NULL; |
19 | char *opt_username = "root"; | 19 | const char *opt_username = "root"; |
20 | struct passwd *pw; | 20 | struct passwd *pw; |
21 | uid_t cur_uid = getuid(); | 21 | uid_t cur_uid = getuid(); |
22 | const char *tty; | 22 | const char *tty; |
diff --git a/miscutils/crontab.c b/miscutils/crontab.c index d442272f0..eb7c2059c 100644 --- a/miscutils/crontab.c +++ b/miscutils/crontab.c | |||
@@ -290,8 +290,7 @@ static void EditFile(const char *user, const char *file) | |||
290 | /* | 290 | /* |
291 | * CHILD - change user and run editor | 291 | * CHILD - change user and run editor |
292 | */ | 292 | */ |
293 | char *ptr; | 293 | const char *ptr; |
294 | char visual[1024]; | ||
295 | 294 | ||
296 | if (ChangeUser(user, 1) < 0) | 295 | if (ChangeUser(user, 1) < 0) |
297 | exit(0); | 296 | exit(0); |
@@ -299,10 +298,9 @@ static void EditFile(const char *user, const char *file) | |||
299 | if (ptr == NULL || strlen(ptr) > 256) | 298 | if (ptr == NULL || strlen(ptr) > 256) |
300 | ptr = PATH_VI; | 299 | ptr = PATH_VI; |
301 | 300 | ||
302 | snprintf(visual, sizeof(visual), "%s %s", ptr, file); | 301 | ptr = xasprintf("%s %s", ptr, file); |
303 | execl(DEFAULT_SHELL, DEFAULT_SHELL, "-c", visual, NULL); | 302 | execl(DEFAULT_SHELL, DEFAULT_SHELL, "-c", ptr, NULL); |
304 | perror("exec"); | 303 | bb_perror_msg_and_die("exec"); |
305 | exit(0); | ||
306 | } | 304 | } |
307 | if (pid < 0) { | 305 | if (pid < 0) { |
308 | /* | 306 | /* |
diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c index f15b9af91..6d827105e 100644 --- a/util-linux/fdisk.c +++ b/util-linux/fdisk.c | |||
@@ -185,7 +185,7 @@ static void reread_partition_table(int leave); | |||
185 | static void delete_partition(int i); | 185 | static void delete_partition(int i); |
186 | static int get_partition(int warn, int max); | 186 | static int get_partition(int warn, int max); |
187 | static void list_types(const struct systypes *sys); | 187 | static void list_types(const struct systypes *sys); |
188 | static unsigned read_int(unsigned low, unsigned dflt, unsigned high, unsigned base, char *mesg); | 188 | static unsigned read_int(unsigned low, unsigned dflt, unsigned high, unsigned base, const char *mesg); |
189 | #endif | 189 | #endif |
190 | static const char *partition_type(unsigned char type); | 190 | static const char *partition_type(unsigned char type); |
191 | static void fdisk_fatal(enum failure why) ATTRIBUTE_NORETURN; | 191 | static void fdisk_fatal(enum failure why) ATTRIBUTE_NORETURN; |
@@ -1410,7 +1410,7 @@ get_boot(enum action what) | |||
1410 | * There is no default if DFLT is not between LOW and HIGH. | 1410 | * There is no default if DFLT is not between LOW and HIGH. |
1411 | */ | 1411 | */ |
1412 | static unsigned | 1412 | static unsigned |
1413 | read_int(unsigned low, unsigned dflt, unsigned high, unsigned base, char *mesg) | 1413 | read_int(unsigned low, unsigned dflt, unsigned high, unsigned base, const char *mesg) |
1414 | { | 1414 | { |
1415 | unsigned i; | 1415 | unsigned i; |
1416 | int default_ok = 1; | 1416 | int default_ok = 1; |
diff --git a/util-linux/fdisk_osf.c b/util-linux/fdisk_osf.c index 3f56bd27d..2555c2e7b 100644 --- a/util-linux/fdisk_osf.c +++ b/util-linux/fdisk_osf.c | |||
@@ -630,7 +630,7 @@ xbsd_create_disklabel(void) | |||
630 | } | 630 | } |
631 | 631 | ||
632 | static int | 632 | static int |
633 | edit_int(int def, char *mesg) | 633 | edit_int(int def, const char *mesg) |
634 | { | 634 | { |
635 | mesg = xasprintf("%s (%d): ", mesg, def); | 635 | mesg = xasprintf("%s (%d): ", mesg, def); |
636 | do { | 636 | do { |
@@ -639,7 +639,7 @@ edit_int(int def, char *mesg) | |||
639 | } while (!isdigit(*line_ptr)); | 639 | } while (!isdigit(*line_ptr)); |
640 | def = atoi(line_ptr); | 640 | def = atoi(line_ptr); |
641 | ret: | 641 | ret: |
642 | free(mesg); | 642 | free((char*)mesg); |
643 | return def; | 643 | return def; |
644 | } | 644 | } |
645 | 645 | ||
@@ -707,9 +707,9 @@ sync_disks(void) | |||
707 | static void | 707 | static void |
708 | xbsd_write_bootstrap(void) | 708 | xbsd_write_bootstrap(void) |
709 | { | 709 | { |
710 | char *bootdir = BSD_LINUX_BOOTDIR; | ||
711 | char path[MAXPATHLEN]; | 710 | char path[MAXPATHLEN]; |
712 | char *dkbasename; | 711 | const char *bootdir = BSD_LINUX_BOOTDIR; |
712 | const char *dkbasename; | ||
713 | struct xbsd_disklabel dl; | 713 | struct xbsd_disklabel dl; |
714 | char *d, *p, *e; | 714 | char *d, *p, *e; |
715 | int sector; | 715 | int sector; |
diff --git a/util-linux/ipcrm.c b/util-linux/ipcrm.c index 507e58fe3..886c2efbd 100644 --- a/util-linux/ipcrm.c +++ b/util-linux/ipcrm.c | |||
@@ -152,8 +152,8 @@ int ipcrm_main(int argc, char **argv) | |||
152 | (c == 'm') ? shmget(key, 0, 0) : semget(key, 0, 0)); | 152 | (c == 'm') ? shmget(key, 0, 0) : semget(key, 0, 0)); |
153 | 153 | ||
154 | if (id < 0) { | 154 | if (id < 0) { |
155 | char *errmsg; | 155 | const char *errmsg; |
156 | const char * const what = "key"; | 156 | const char *const what = "key"; |
157 | 157 | ||
158 | error++; | 158 | error++; |
159 | switch (errno) { | 159 | switch (errno) { |
@@ -183,8 +183,8 @@ int ipcrm_main(int argc, char **argv) | |||
183 | semctl(id, 0, IPC_RMID, arg)); | 183 | semctl(id, 0, IPC_RMID, arg)); |
184 | 184 | ||
185 | if (result) { | 185 | if (result) { |
186 | char *errmsg; | 186 | const char *errmsg; |
187 | const char * const what = iskey ? "key" : "id"; | 187 | const char *const what = iskey ? "key" : "id"; |
188 | 188 | ||
189 | error++; | 189 | error++; |
190 | switch (errno) { | 190 | switch (errno) { |
diff --git a/util-linux/mount.c b/util-linux/mount.c index ee45f01a6..ba98519b6 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c | |||
@@ -64,7 +64,7 @@ enum { | |||
64 | * flags */ | 64 | * flags */ |
65 | 65 | ||
66 | struct { | 66 | struct { |
67 | char *name; | 67 | const char *name; |
68 | long flags; | 68 | long flags; |
69 | } static mount_options[] = { | 69 | } static mount_options[] = { |
70 | // MS_FLAGS set a bit. ~MS_FLAGS disable that bit. 0 flags are NOPs. | 70 | // MS_FLAGS set a bit. ~MS_FLAGS disable that bit. 0 flags are NOPs. |
@@ -122,7 +122,7 @@ struct { | |||
122 | #define VECTOR_SIZE(v) (sizeof(v) / sizeof((v)[0])) | 122 | #define VECTOR_SIZE(v) (sizeof(v) / sizeof((v)[0])) |
123 | 123 | ||
124 | /* Append mount options to string */ | 124 | /* Append mount options to string */ |
125 | static void append_mount_options(char **oldopts, char *newopts) | 125 | static void append_mount_options(char **oldopts, const char *newopts) |
126 | { | 126 | { |
127 | if (*oldopts && **oldopts) { | 127 | if (*oldopts && **oldopts) { |
128 | /* do not insert options which are already there */ | 128 | /* do not insert options which are already there */ |
@@ -303,7 +303,7 @@ static int mount_it_now(struct mntent *mp, int vfsflags, char *filteropts) | |||
303 | fsname = 0; | 303 | fsname = 0; |
304 | if (!mp->mnt_type || !*mp->mnt_type) { /* bind mount */ | 304 | if (!mp->mnt_type || !*mp->mnt_type) { /* bind mount */ |
305 | mp->mnt_fsname = fsname = bb_simplify_path(mp->mnt_fsname); | 305 | mp->mnt_fsname = fsname = bb_simplify_path(mp->mnt_fsname); |
306 | mp->mnt_type = "bind"; | 306 | mp->mnt_type = (char*)"bind"; |
307 | } | 307 | } |
308 | mp->mnt_freq = mp->mnt_passno = 0; | 308 | mp->mnt_freq = mp->mnt_passno = 0; |
309 | 309 | ||
@@ -1342,7 +1342,7 @@ prepare_kernel_data: | |||
1342 | 1342 | ||
1343 | do_mount: /* perform actual mount */ | 1343 | do_mount: /* perform actual mount */ |
1344 | 1344 | ||
1345 | mp->mnt_type = "nfs"; | 1345 | mp->mnt_type = (char*)"nfs"; |
1346 | retval = mount_it_now(mp, vfsflags, (char*)&data); | 1346 | retval = mount_it_now(mp, vfsflags, (char*)&data); |
1347 | goto ret; | 1347 | goto ret; |
1348 | 1348 | ||
@@ -1428,7 +1428,7 @@ static int singlemount(struct mntent *mp, int ignore_busy) | |||
1428 | // lock is required | 1428 | // lock is required |
1429 | vfsflags |= MS_MANDLOCK; | 1429 | vfsflags |= MS_MANDLOCK; |
1430 | 1430 | ||
1431 | mp->mnt_type = "cifs"; | 1431 | mp->mnt_type = (char*)"cifs"; |
1432 | rc = mount_it_now(mp, vfsflags, filteropts); | 1432 | rc = mount_it_now(mp, vfsflags, filteropts); |
1433 | if (ENABLE_FEATURE_CLEAN_UP) free(mp->mnt_fsname); | 1433 | if (ENABLE_FEATURE_CLEAN_UP) free(mp->mnt_fsname); |
1434 | goto report_error; | 1434 | goto report_error; |