boot: pass in args as const

Copy the arg that sets a variable to maximize the reuse of this
routine. There are places we call it from that are const char * and it
might not be safe to cast that away.

Sponsored by:		Netflix
This commit is contained in:
Warner Losh 2022-12-06 17:36:29 -07:00
parent 482380c6f8
commit ed56dcfc6b
2 changed files with 10 additions and 5 deletions

View File

@ -125,7 +125,7 @@ boot_howto_to_env(int howto)
* variable and set that instead. * variable and set that instead.
*/ */
int int
boot_parse_arg(char *v) boot_parse_arg(const char *v)
{ {
char *n; char *n;
int howto; int howto;
@ -170,11 +170,16 @@ static int howto_masks[] = {
} }
} }
} else { } else {
n = strsep(&v, "="); char buf[128];
if (v == NULL) char *vv = buf;
strlcpy(buf, v, sizeof(buf));
n = strsep(&vv, "=");
if (vv == NULL)
SETENV(n, "1"); SETENV(n, "1");
else else
SETENV(n, v); SETENV(n, vv);
free(vv);
} }
#endif #endif
return (howto); return (howto);

View File

@ -36,7 +36,7 @@
int boot_env_to_howto(void); int boot_env_to_howto(void);
void boot_howto_to_env(int howto); void boot_howto_to_env(int howto);
int boot_parse_arg(char *v); int boot_parse_arg(const char *v);
int boot_parse_cmdline_delim(char *cmdline, const char *delim); int boot_parse_cmdline_delim(char *cmdline, const char *delim);
int boot_parse_cmdline(char *cmdline); int boot_parse_cmdline(char *cmdline);
int boot_parse_args(int argc, char *argv[]); int boot_parse_args(int argc, char *argv[]);