Messages in this thread | | | Date | Mon, 18 May 2020 20:44:15 -0700 | From | Andrew Morton <> | Subject | Re: [PATCH] init/main.c: Print all command line when boot |
| |
On Tue, 19 May 2020 11:29:46 +0800 王程刚 <wangchenggang@vivo.com> wrote:
> Function pr_notice print max length maybe less than the command line length, > need more times to print all. > For example, arm64 has 2048 bytes command line length, but printk maximum > length is only 1024 bytes.
I can see why that might be a problem!
> --- a/init/main.c > +++ b/init/main.c > @@ -825,6 +825,16 @@ void __init __weak arch_call_rest_init(void) > rest_init(); > } > > +static void __init print_cmdline(void) > +{ > + const char *prefix = "Kernel command line: ";
const char prefix[] = "...";
might generate slightly more efficient code.
> + int len = -strlen(prefix);
hm, tricky. What the heck does printk() actually return to the caller? Seems that we forgot to document this, and there are so many different paths which a printk call can take internally that I'm not confident that they all got it right!
> + len += pr_notice("%s%s\n", prefix, boot_command_line); > + while (boot_command_line[len]) > + len += pr_notice("%s\n", &boot_command_line[len]); > +}
Did you really intend to insert a \n into the output every 1024'th character?
And what effect does this additional \n have upon the code logic? Doesn't this cause the printk() return value to be one greater than expected each time it is called?
> > ... >
| |