[OpenBIOS] [PATCH] arch/ppc/qemu: do not override boot-device if already set
BALATON Zoltan
balaton at eik.bme.hu
Sun May 18 22:50:53 CEST 2014
On Sun, 18 May 2014, Mark Cave-Ayland wrote:
> On 18/05/14 00:18, BALATON Zoltan wrote:
>> + fword("boot-device");
>> + boot_device = pop_fstr_copy();
>> + if (strcmp(boot_device, "disk") == 0) {
>
> What is boot-device normally set to if no override is specified?
> pop_fstr_copy() has a little gotcha in that a zero length string becomes a
> NULL on conversion, so generally I tend to use a pattern like this:
I've tested it and the user can specify an empty string by not giving any
value "-prom-env boot-device=" but this does not lead to a crash because
the NULL value is only used in strcmp where it's not equal and in free
where it does nothing. So you could apply this patch as is (with
deobfuscating my email address in the commit message) unless you want
me to do some other changes.
Regards,
BALATON Zoltan
>
> if (boot_device && strcmp(boot_device, "disk") == 0) {
> ...
> }
>
> I'm just wondering if we shouldn't always assume that a value exists and is
> non-zero...
>
>> + switch (fw_cfg_read_i16(FW_CFG_BOOT_DEVICE)) {
>> + case 'c':
>> + boot_path = "hd";
>> + break;
>> + default:
>> + case 'd':
>> + boot_path = "cd";
>> + break;
>> + }
>> +
>> + snprintf(buf, sizeof(buf), "%s:,\\\\:tbxi %s:,\\ppc\\bootinfo.txt
>> %s:,%%BOOT", boot_path, boot_path, boot_path);
>> + push_str(buf);
>> + fword("encode-string");
>> + push_str("boot-device");
>> + fword("property");
>> }
>> + free(boot_device);
More information about the OpenBIOS
mailing list