[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v8 04/15] hw/i386/pc: replace use of strtol with qemu_strtol
From: |
Sergio Lopez |
Subject: |
Re: [PATCH v8 04/15] hw/i386/pc: replace use of strtol with qemu_strtol in x86_load_linux() |
Date: |
Fri, 11 Oct 2019 09:26:25 +0200 |
User-agent: |
mu4e 1.2.0; emacs 26.2 |
Philippe Mathieu-Daudé <address@hidden> writes:
> Hi Sergio,
>
> On 10/10/19 4:31 PM, Sergio Lopez wrote:
>> Follow checkpatch.pl recommendation and replace the use of strtol with
>> qemu_strtol in x86_load_linux().
>>
>> Signed-off-by: Sergio Lopez <address@hidden>
>> ---
>> hw/i386/pc.c | 11 +++++++++--
>> 1 file changed, 9 insertions(+), 2 deletions(-)
>>
>> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
>> index 77e86bfc3d..e6bcc3ff42 100644
>> --- a/hw/i386/pc.c
>> +++ b/hw/i386/pc.c
>> @@ -68,6 +68,7 @@
>> #include "qemu/config-file.h"
>> #include "qemu/error-report.h"
>> #include "qemu/option.h"
>> +#include "qemu/cutils.h"
>> #include "hw/acpi/acpi.h"
>> #include "hw/acpi/cpu_hotplug.h"
>> #include "hw/boards.h"
>> @@ -1201,7 +1202,8 @@ static void x86_load_linux(PCMachineState *pcms,
>> /* handle vga= parameter */
>> vmode = strstr(kernel_cmdline, "vga=");
>> if (vmode) {
>> - unsigned int video_mode;
>> + long video_mode;
>
> Why do you change 'video_mode' to a signed type?
qemu_strtol fourth argument is a pointer to long int. According to
"linux/Documentation/admin-guide/svga.rst", valid video modes are in the
in the range of 0x0 to 0xffff (matching the stw_p below), so this change
shouldn't be a problem.
>> + int ret;
>> /* skip "vga=" */
>> vmode += 4;
>> if (!strncmp(vmode, "normal", 6)) {
>> @@ -1211,7 +1213,12 @@ static void x86_load_linux(PCMachineState *pcms,
>> } else if (!strncmp(vmode, "ask", 3)) {
>> video_mode = 0xfffd;
>> } else {
>> - video_mode = strtol(vmode, NULL, 0);
>> + ret = qemu_strtol(vmode, NULL, 0, &video_mode);
>> + if (ret != 0) {
>> + fprintf(stderr, "qemu: can't parse 'vga' parameter: %s\n",
>> + strerror(-ret));
>> + exit(1);
>> + }
>> }
>> stw_p(header + 0x1fa, video_mode);
>> }
>>
signature.asc
Description: PGP signature
[PATCH v8 05/15] hw/i386/pc: avoid an assignment in if condition in x86_load_linux(), Sergio Lopez, 2019/10/10
[PATCH v8 06/15] hw/i386/pc: remove commented out code from x86_load_linux(), Sergio Lopez, 2019/10/10
[PATCH v8 06/15] hw/i386/pc: remove commented out code from x86_load_linux(), Sergio Lopez, 2019/10/10
[PATCH v8 07/15] hw/i386/pc: move shared x86 functions to x86.c and export them, Sergio Lopez, 2019/10/10
[PATCH v8 08/15] hw/i386: split PCMachineState deriving X86MachineState from it, Sergio Lopez, 2019/10/10
[PATCH v8 09/15] hw/i386: make x86.c independent from PCMachineState, Sergio Lopez, 2019/10/10