[Bug 4520] [RFC] kexecboot: passing extra cmdline arguments

bugzilla-daemon at amethyst.openembedded.net bugzilla-daemon at amethyst.openembedded.net
Sat Aug 30 10:39:19 UTC 2008


http://bugs.openembedded.net/show_bug.cgi?id=4520





--- Comment #11 from Yuri Bushmelev <jay4mail at gmail.com>  2008-08-30 12:39:18 ---
I'm consider to replace this code:
---- code -----
if( boot->cmdline ) {
    /* we have cmdline and may be extra_cmdline */
    snprintf(command, sizeof(command), "/usr/sbin/kexec --command-line=\"%s%s
root=%s rootfstype=%s rootwait\" -l %s", 
        boot->cmdline, extra_cmdline, boot->device, boot->fstype,
boot->kernelpath);
} else if ('\0' != extra_cmdline[0]) {
    /* we have no cmdline but have extra_cmdline */
    snprintf(command, sizeof(command), "/usr/sbin/kexec --command-line=\"%s\"
-l %s", 
        extra_cmdline, boot->kernelpath);
} else {
    /* we have no cmdline and no extra_cmdline */
    snprintf(command, sizeof(command), "/usr/sbin/kexec -l %s",
boot->kernelpath);
}
---- /code -----

with only one invocation on snprintf. E.g.:

---- /code -----
    snprintf(command, sizeof(command), "/usr/sbin/kexec
--command-line=\"%s%s%croot=%s rootfstype=%s rootwait\" -l %s",
        boot->cmdline, extra_cmdline,
            (boot->cmdline || '\0' != extra_cmdline[0] ? ' ' : '\0'),
        boot->device, boot->fstype, boot->kernelpath);
---- code -----

We always have boot->device, boot-> fstype, boot->kernelpath (from devicescan).
Then we can allocate memory for command with exactly known length of pattern
string.

Anybody know reasons to not doing this?

-- 
Configure bugmail: http://bugs.openembedded.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.




More information about the Openembedded-issues mailing list