[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 2/9] hw/core/qdev-properties: Use qemu_strtoul() in set_pci_h
From: |
Richard Henderson |
Subject: |
Re: [PATCH 2/9] hw/core/qdev-properties: Use qemu_strtoul() in set_pci_host_devaddr() |
Date: |
Sun, 15 Mar 2020 14:43:01 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 |
On 3/13/20 11:46 AM, Philippe Mathieu-Daudé wrote:
> Replace strtoul() by qemu_strtoul() so checkpatch.pl won't complain
> if we move this code later.
...
> p = str;
> - val = strtoul(p, &e, 16);
> - if (e == p || *e != ':') {
> + if (qemu_strtoul(p, &e, 16, &val) < 0 || val > 0xffff || e == p) {
> + goto inval;
> + }
> + if (*e != ':') {
You can drop the e == p test. That's done in check_strtox_error, called by
qemu_strtoul. Same for the other 2 instances.
The range check looks wrong, as we have not yet decided if this element is
"dom" or "bus".
> - if (dom > 0xffff || bus > 0xff || slot > 0x1f || func > 7) {
> + if (bus > 0xff) {
I think it makes sense to leave this line unchanged. Increase the slot and
func local variables increased to unsigned long so that the range check isn't
truncated.
r~
- [PATCH 0/9] user-mode: Prune build dependencies (part 3), Philippe Mathieu-Daudé, 2020/03/13
- [PATCH 2/9] hw/core/qdev-properties: Use qemu_strtoul() in set_pci_host_devaddr(), Philippe Mathieu-Daudé, 2020/03/13
- Re: [PATCH 2/9] hw/core/qdev-properties: Use qemu_strtoul() in set_pci_host_devaddr(),
Richard Henderson <=
- [PATCH 3/9] hw/core/qdev-properties: Fix code style, Philippe Mathieu-Daudé, 2020/03/13
- [PATCH 4/9] hw/core/qdev-properties: Export enum-related functions, Philippe Mathieu-Daudé, 2020/03/13
- [PATCH 1/9] hw/core/qdev-properties: Use qemu_strtol() in set_mac() handler, Philippe Mathieu-Daudé, 2020/03/13
- [PATCH 5/9] hw/core/qdev-properties: Export qdev_prop_enum, Philippe Mathieu-Daudé, 2020/03/13
- [PATCH 6/9] hw/core/qdev-properties: Export some integer-related functions, Philippe Mathieu-Daudé, 2020/03/13