qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Sergio Lopez <slp@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>
Cc: ehabkost@redhat.com, mst@redhat.com, qemu-devel@nongnu.org,
	kraxel@redhat.com, pbonzini@redhat.com, imammedo@redhat.com,
	sgarzare@redhat.com, lersek@redhat.com, rth@twiddle.net
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	[thread overview]
Message-ID: <871rvj4uam.fsf@redhat.com> (raw)
In-Reply-To: <f147fefc-1bec-2ac1-b5d6-35bcfdddf2fc@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 2058 bytes --]


Philippe Mathieu-Daudé <philmd@redhat.com> 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 <slp@redhat.com>
>> ---
>>   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);
>>       }
>>


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

  reply	other threads:[~2019-10-11  7:27 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-10 14:31 [PATCH v8 00/15] Introduce the microvm machine type Sergio Lopez
2019-10-10 14:31 ` [PATCH v8 01/15] hw/virtio: Factorize virtio-mmio headers Sergio Lopez
2019-10-10 14:31 ` [PATCH v8 02/15] hw/i386/pc: rename functions shared with non-PC machines Sergio Lopez
2019-10-10 14:31 ` [PATCH v8 03/15] hw/i386/pc: fix code style issues on functions that will be moved out Sergio Lopez
2019-10-10 15:36   ` Philippe Mathieu-Daudé
2019-10-10 14:31 ` [PATCH v8 04/15] hw/i386/pc: replace use of strtol with qemu_strtol in x86_load_linux() Sergio Lopez
2019-10-10 15:47   ` Philippe Mathieu-Daudé
2019-10-11  7:26     ` Sergio Lopez [this message]
2019-10-11 15:07       ` Philippe Mathieu-Daudé
2019-10-11 15:16         ` Sergio Lopez
2019-10-10 14:31 ` [PATCH v8 05/15] hw/i386/pc: avoid an assignment in if condition " Sergio Lopez
2019-10-10 15:39   ` Philippe Mathieu-Daudé
2019-10-10 14:31 ` [PATCH v8 06/15] hw/i386/pc: remove commented out code from x86_load_linux() Sergio Lopez
2019-10-10 15:49   ` Philippe Mathieu-Daudé
2019-10-10 14:31 ` Sergio Lopez
2019-10-10 14:31 ` [PATCH v8 07/15] hw/i386/pc: move shared x86 functions to x86.c and export them Sergio Lopez
2019-10-10 14:31 ` [PATCH v8 08/15] hw/i386: split PCMachineState deriving X86MachineState from it Sergio Lopez
2019-10-10 14:31 ` [PATCH v8 09/15] hw/i386: make x86.c independent from PCMachineState Sergio Lopez
2019-10-10 14:31 ` [PATCH v8 10/15] fw_cfg: add "modify" functions for all types Sergio Lopez
2019-10-10 14:31 ` [PATCH v8 11/15] hw/intc/apic: reject pic ints if isa_pic == NULL Sergio Lopez
2019-10-10 14:31 ` [PATCH v8 12/15] roms: add microvm-bios (qboot) as binary and git submodule Sergio Lopez
2019-10-10 14:31 ` [PATCH v8 13/15] docs/microvm.rst: document the new microvm machine type Sergio Lopez
2019-10-10 14:31 ` [PATCH v8 14/15] hw/i386: Introduce the " Sergio Lopez
2019-10-10 14:31 ` [PATCH v8 15/15] MAINTAINERS: add microvm related files Sergio Lopez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871rvj4uam.fsf@redhat.com \
    --to=slp@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=lersek@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=sgarzare@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).