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.
*/
int
boot_parse_arg(char *v)
boot_parse_arg(const char *v)
{
char *n;
int howto;
@ -170,11 +170,16 @@ static int howto_masks[] = {
}
}
} else {
n = strsep(&v, "=");
if (v == NULL)
char buf[128];
char *vv = buf;
strlcpy(buf, v, sizeof(buf));
n = strsep(&vv, "=");
if (vv == NULL)
SETENV(n, "1");
else
SETENV(n, v);
SETENV(n, vv);
free(vv);
}
#endif
return (howto);

View File

@ -36,7 +36,7 @@
int boot_env_to_howto(void);
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(char *cmdline);
int boot_parse_args(int argc, char *argv[]);