*: placate warnings where strchr/strstr returns constant pointer
No binary (build failed)
gcc -Wp,-MD,applets/.usage.d -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -Iinclude -Iinclude -o applets/usage applets/usage.c
(log yok)
| @@ -1155,7 +1155,7 @@ dump_strings(off_t address, off_t end_offset) | |
| leading '+' return nonzero and set *OFFSET to the offset it denotes. */ | |
| static int | |
| - | parse_old_offset(const char *s, off_t *offset) |
| + | parse_old_offset(char *s, off_t *offset) |
| { | |
| static const struct suffix_mult Bb[] ALIGN_SUFFIX = { | |
| { "B", 1024 }, | |
| @@ -1181,7 +1181,8 @@ parse_old_offset(const char *s, off_t *offset) | |
| radix = 16; | |
| *offset = xstrtooff_sfx(s, radix, Bb); | |
| - | if (p) p[0] = '.'; |
| + | if (p) |
| + | p[0] = '.'; /* undo cheating */ |
| return (*offset >= 0); | |
| } | |
| @@ -1234,7 +1235,7 @@ int od_main(int argc UNUSED_PARAM, char **argv) | |
| static const uint8_t doxn_address_pad_len_char[] ALIGN1 = { | |
| '7', '7', '6', /* '?' */ | |
| }; | |
| - | char *p; |
| + | const char *p; |
| int pos; | |
| p = strchr(doxn, str_A[0]); | |
| if (!p) | |
| @@ -354,7 +354,7 @@ static char **print_formatted(char *f, char **argv, int *conv_err) | |
| /* Add "ll" if integer modifier, then print */ | |
| { | |
| static const char format_chars[] ALIGN1 = "diouxXfeEgGcs"; | |
| - | char *p = strchr(format_chars, *f); |
| + | char *p = (char*)strchr(format_chars, *f); |
| /* needed - try "printf %" without it */ | |
| if (p == NULL || *f == '\0') { | |
| bb_error_msg("%s: invalid format", direc_start); | |
| @@ -2841,7 +2841,7 @@ static NOINLINE var *exec_builtin(node *op, var *res) | |
| l = strlen(as[0]) - ll; | |
| if (ll > 0 && l >= 0) { | |
| if (!icase) { | |
| - | char *s = strstr(as[0], as[1]); |
| + | const char *s = strstr(as[0], as[1]); |
| if (s) | |
| n = (s - as[0]) + 1; | |
| } else { | |
| @@ -31,7 +31,7 @@ | |
| * - /dev/ram (alias to /dev/ram0) | |
| * - /dev/mtd | |
| */ | |
| - | static dev_t name_to_dev_t(const char *devname) |
| + | static dev_t name_to_dev_t(char *devname) |
| { | |
| char devfile[sizeof(int)*3 * 2 + 4]; | |
| char *sysname; | |
| @@ -24,12 +24,12 @@ const char* FAST_FUNC bb_basename(const char *name) | |
| */ | |
| char* FAST_FUNC bb_get_last_path_component_nostrip(const char *path) | |
| { | |
| - | char *slash = strrchr(path, '/'); |
| + | const char *slash = strrchr(path, '/'); |
| if (!slash || (slash == path && !slash[1])) | |
| return (char*)path; | |
| - | return slash + 1; |
| + | return (char*)slash + 1; |
| } | |
| /* | |
| @@ -28,7 +28,8 @@ unsigned FAST_FUNC count_strstr(const char *str, const char *sub) | |
| char* FAST_FUNC xmalloc_substitute_string(const char *src, int count, const char *sub, const char *repl) | |
| { | |
| - | char *buf, *dst, *end; |
| + | char *buf, *dst; |
| + | const char *end; |
| size_t sub_len = strlen(sub); | |
| size_t repl_len = strlen(repl); | |
| @@ -19,10 +19,10 @@ char* FAST_FUNC strrstr(const char *haystack, const char *needle) | |
| if (!needle[0]) | |
| return (char*)haystack + strlen(haystack); | |
| while (1) { | |
| - | char *p = strstr(haystack, needle); |
| + | const char *p = strstr(haystack, needle); |
| if (!p) | |
| return r; | |
| - | r = p; |
| + | r = (char *)p; |
| haystack = p + 1; | |
| } | |
| } | |
| @@ -379,7 +379,7 @@ void FAST_FUNC bb_unsetenv(const char *var) | |
| char onstack[128 - 16]; /* smaller stack setup code on x86 */ | |
| char *tp; | |
| - | tp = strchr(var, '='); |
| + | tp = (char*)strchr(var, '='); |
| if (tp) { | |
| /* In case var was putenv'ed, we can't replace '=' | |
| * with NUL and unsetenv(var) - it won't work, | |
| @@ -32,7 +32,8 @@ int FAST_FUNC get_uidgid(struct bb_uidgid_t *u, const char *ug) | |
| { | |
| struct passwd *pwd; | |
| struct group *gr; | |
| - | char *user, *group; |
| + | char *user; |
| + | const char *group; |
| unsigned n; | |
| user = (char*)ug; | |
| @@ -5525,7 +5525,7 @@ static void xc_program_printString(const char *str) | |
| char c = *str++; | |
| if (c == '\\') { | |
| static const char esc[] ALIGN1 = "nabfrt""e\\"; | |
| - | char *n; |
| + | const char *n; |
| c = *str++; | |
| n = strchr(esc, c); // note: if c is NUL, n = \0 at end of esc | |
| @@ -1846,7 +1846,7 @@ static void send_cgi_and_exit( | |
| */ | |
| static NOINLINE void send_file_and_exit(const char *url, int what) | |
| { | |
| - | char *suffix; |
| + | const char *suffix; |
| int fd; | |
| ssize_t count; | |
| @@ -336,7 +336,7 @@ int ifconfig_main(int argc UNUSED_PARAM, char **argv) | |
| #endif | |
| char *p; | |
| /*char host[128];*/ | |
| - | const char *host = NULL; /* make gcc happy */ |
| + | char *host = NULL; /* make gcc happy */ |
| IF_FEATURE_IFCONFIG_STATUS(char *show_all_param;) | |
| did_flags = 0; | |
| @@ -363,7 +363,7 @@ static char *parse(const char *command, struct interface_defn_t *ifd) | |
| break; | |
| case '%': | |
| { | |
| - | char *nextpercent; |
| + | const char *nextpercent; |
| char *varvalue; | |
| command++; | |
| @@ -260,7 +260,7 @@ int nbdclient_main(int argc, char **argv) | |
| // needs some other process to sit in ioctl(nbd, NBD_DO_IT). | |
| if (fork() == 0) { | |
| /* child */ | |
| - | char *s = strrchr(device, '/'); |
| + | const char *s = strrchr(device, '/'); |
| sprintf(data, "/sys/block/%.32s/pid", s ? s + 1 : device); | |
| // Is it up yet? | |
| for (;;) { | |
| @@ -179,7 +179,7 @@ static NOINLINE void INET_setroute(int action, char **args) | |
| memset(rt, 0, sizeof(*rt)); | |
| { | |
| - | const char *target = *args++; |
| + | char *target = *args++; |
| char *prefix; | |
| /* recognize x.x.x.x/mask format. */ | |
| @@ -353,25 +353,25 @@ static NOINLINE void INET6_setroute(int action, char **args) | |
| int prefix_len, skfd; | |
| const char *devname; | |
| - | /* We know args isn't NULL from the check in route_main. */ |
| - | const char *target = *args++; |
| - | |
| - | if (strcmp(target, "default") == 0) { |
| - | prefix_len = 0; |
| - | memset(&sa6, 0, sizeof(sa6)); |
| + | /* We know args isn't NULL from the check in route_main. */ |
| + | char *target = *args++; |
| + | |
| + | if (strcmp(target, "default") == 0) { |
| + | prefix_len = 0; |
| + | memset(&sa6, 0, sizeof(sa6)); |
| + | } else { |
| + | char *cp; |
| + | cp = strchr(target, '/'); /* Yes... const to non is ok. */ |
| + | if (cp) { |
| + | *cp = '\0'; |
| + | prefix_len = xatoul_range(cp + 1, 0, 128); |
| } else { | |
| - | char *cp; |
| - | cp = strchr(target, '/'); /* Yes... const to non is ok. */ |
| - | if (cp) { |
| - | *cp = '\0'; |
| - | prefix_len = xatoul_range(cp + 1, 0, 128); |
| - | } else { |
| - | prefix_len = 128; |
| - | } |
| - | if (INET6_resolve(target, (struct sockaddr_in6 *) &sa6) < 0) { |
| - | bb_error_msg_and_die("resolving %s", target); |
| - | } |
| + | prefix_len = 128; |
| } | |
| + | if (INET6_resolve(target, (struct sockaddr_in6 *) &sa6) < 0) { |
| + | bb_error_msg_and_die("resolving %s", target); |
| + | } |
| + | } |
| /* Clean out the RTREQ structure. */ | |
| memset(&rt, 0, sizeof(rt)); | |
| @@ -116,7 +116,8 @@ int FAST_FUNC d6_listen_socket(int port, const char *inf) | |
| bb_simple_perror_msg_and_die("SO_BROADCAST"); | |
| /* SO_BINDTODEVICE doesn't work on ethernet aliases (ethN:M) */ | |
| - | colon = strrchr(inf, ':'); |
| + | colon = (char*)strrchr(inf, ':'); |
| + | /* NB: inf can really be a *const* string if it's a default, but defaults have no ':' */ |
| if (colon) | |
| *colon = '\0'; | |
| @@ -90,7 +90,8 @@ int FAST_FUNC udhcp_listen_socket(/*uint32_t ip,*/ int port, const char *inf) | |
| bb_simple_perror_msg_and_die("SO_BROADCAST"); | |
| /* SO_BINDTODEVICE doesn't work on ethernet aliases (ethN:M) */ | |
| - | colon = strrchr(inf, ':'); |
| + | colon = (char*)strrchr(inf, ':'); |
| + | /* NB: inf can really be a *const* string if it's a default, but defaults have no ':' */ |
| if (colon) | |
| *colon = '\0'; | |
| @@ -122,7 +122,7 @@ int lpqr_main(int argc UNUSED_PARAM, char **argv) | |
| { | |
| // queue name is to the left of '@' | |
| - | char *s = strchr(queue, '@'); |
| + | char *s = (char *)strchr(queue, '@'); |
| if (s) { | |
| // server name is to the right of '@' | |
| *s = '\0'; | |
| @@ -913,7 +913,8 @@ int nmeter_main(int argc UNUSED_PARAM, char **argv) | |
| // parameters as seen by e.g. ps. Making a copy... | |
| cur = xstrdup(argv[0]); | |
| while (1) { | |
| - | char *param, *p; |
| + | char *param; |
| + | const char *p; |
| prev = cur; | |
| again: | |
| cur = strchr(cur, '%'); | |
| @@ -929,7 +930,7 @@ int nmeter_main(int argc UNUSED_PARAM, char **argv) | |
| // format: %[foptstring] | |
| cur++; | |
| p = strchr(options, cur[0]); | |
| - | param = cur+1; |
| + | param = cur + 1; |
| while (cur[0] != ']') { | |
| if (!cur[0]) | |
| bb_show_usage(); | |
| @@ -238,7 +238,7 @@ static void save_line(const char *string, int count) | |
| #if ENABLE_FEATURE_POWERTOP_PROCIRQ | |
| static int is_hpet_irq(const char *name) | |
| { | |
| - | char *p; |
| + | const char *p; |
| # if BLOATY_HPET_IRQ_NUM_DETECTION | |
| long hpet_chan; | |
| @@ -423,7 +423,8 @@ static NOINLINE int process_timer_stats(void) | |
| // 1, 2159 udisks-daemon hrtimer_start_range_ns (hrtimer_wakeup) | |
| // 331 total events, 249.059 events/sec | |
| while (fgets(buf, sizeof(buf), fp)) { | |
| - | const char *count, *process, *func; |
| + | const char *process, *func; |
| + | char *count; |
| char *p; | |
| int idx; | |
| unsigned cnt; | |
| @@ -348,7 +348,7 @@ int conf_write(const char *name) | |
| dirname[0] = 0; | |
| if (name && name[0]) { | |
| struct stat st; | |
| - | char *slash; |
| + | const char *slash; |
| if (!stat(name, &st) && S_ISDIR(st.st_mode)) { | |
| strcpy(dirname, name); | |
| @@ -8725,7 +8725,7 @@ test_exec(/*const char *fullname,*/ struct stat *statb) | |
| } | |
| /* Circular dep: find_command->find_builtin->builtintab[]->hashcmd->find_command */ | |
| - | static struct builtincmd *find_builtin(const char *name); |
| + | static const struct builtincmd *find_builtin(const char *name); |
| #if ENABLE_ASH_BASH_NOT_FOUND_HOOK | |
| static int evalfun(struct funcnode *func, int argc, char **argv, int flags); | |
| #endif | |
| @@ -8746,7 +8746,7 @@ find_command(char *name, struct cmdentry *entry, int act, const char *path) | |
| struct stat statb; | |
| int e; | |
| int updatetbl; | |
| - | struct builtincmd *bcmd; |
| + | const struct builtincmd *bcmd; |
| int len; | |
| /* If name contains a slash, don't use PATH or hash table */ | |
| @@ -10836,10 +10836,10 @@ static const struct builtincmd builtintab[] = { | |
| /* | |
| * Search the table of builtin commands. | |
| */ | |
| - | static struct builtincmd * |
| + | static const struct builtincmd * |
| find_builtin(const char *name) | |
| { | |
| - | struct builtincmd *bp; |
| + | const struct builtincmd *bp; |
| bp = bsearch( | |
| name, builtintab, ARRAY_SIZE(builtintab), sizeof(builtintab[0]), | |
| @@ -12927,12 +12927,12 @@ decode_dollar_squote(void) | |
| { | |
| static const char C_escapes[] ALIGN1 = "nrbtfav""x\\01234567"; | |
| int c, cnt; | |
| - | char *p; |
| char buf[4]; | |
| c = pgetc(); | |
| - | p = strchr(C_escapes, c); |
| - | if (p) { |
| + | if (strchr(C_escapes, c)) { |
| + | char *p; |
| + | |
| buf[0] = c; | |
| p = buf; | |
| cnt = 3; | |