@@ -117,9 +117,8 @@ error:
static void fw_cfg_bootsplash(FWCfgState *s)
{
- int boot_splash_time = -1;
+ uint64_t boot_splash_time = -1;
const char *boot_splash_filename = NULL;
- char *p;
char *filename, *file_data;
gsize file_size;
int file_type;
@@ -133,18 +132,14 @@ static void fw_cfg_bootsplash(FWCfgState *s)
if (temp != NULL) {
boot_splash_filename = temp;
}
- temp = qemu_opt_get(opts, "splash-time");
- if (temp != NULL) {
- p = (char *)temp;
- boot_splash_time = strtol(p, &p, 10);
- }
+ boot_splash_time = qemu_opt_get_number(opts, "splash-time", -1);
}
/* insert splash time if user configurated */
- if (boot_splash_time >= 0) {
+ if ((int64_t)boot_splash_time >= 0) {
/* validate the input */
if (boot_splash_time > 0xffff) {
- error_report("splash time is big than 65535, force it to 65535.");
+ error_report("splash time is big than 65535, force it to 65535");
boot_splash_time = 0xffff;
}
/* use little endian format */
@@ -185,26 +180,18 @@ static void fw_cfg_bootsplash(FWCfgState *s)
static void fw_cfg_reboot(FWCfgState *s)
{
- int reboot_timeout = -1;
- char *p;
- const char *temp;
+ uint64_t reboot_timeout = -1;
/* get user configuration */
QemuOptsList *plist = qemu_find_opts("boot-opts");
QemuOpts *opts = QTAILQ_FIRST(&plist->head);
- if (opts != NULL) {
- temp = qemu_opt_get(opts, "reboot-timeout");
- if (temp != NULL) {
- p = (char *)temp;
- reboot_timeout = strtol(p, &p, 10);
- }
- }
+ reboot_timeout = qemu_opt_get_number(opts, "reboot-timeout", -1);
- if (reboot_timeout >= 0) {
+ if ((int64_t)reboot_timeout >= 0) {
/* validate the input */
if (reboot_timeout > 0xffff) {
error_report("reboot timeout is larger than 65535,"
- "force it to 65535.");
+ "force it to 65535");
reboot_timeout = 0xffff;
}
fw_cfg_add_file(s, "etc/boot-fail-wait",
@@ -336,10 +336,10 @@ static QemuOptsList qemu_boot_opts = {
.type = QEMU_OPT_STRING,
}, {
.name = "splash-time",
- .type = QEMU_OPT_STRING,
+ .type = QEMU_OPT_NUMBER,
}, {
.name = "reboot-timeout",
- .type = QEMU_OPT_STRING,
+ .type = QEMU_OPT_NUMBER,
}, {
.name = "strict",
.type = QEMU_OPT_BOOL,
Currently the splash-time and reboot-timeout in boot_opts uses qemu_opt_get() to get a string, then convert it to a number ourselves. This is wrong. Change the opt's type to QEMU_OPT_NUMBER and use qemu_opt_get_number to parse it. Signed-off-by: Li Qiang <liq3ea@gmail.com> --- hw/nvram/fw_cfg.c | 29 ++++++++--------------------- vl.c | 4 ++-- 2 files changed, 10 insertions(+), 23 deletions(-)