mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-27 04:13:53 -06:00
Xen: use qemu_strtoul instead of strtol
No need to roll our own (with slightly incorrect handling of errno), when we can use the common version. Change signed parsing to unsigned, because what it read are values in PCI config space, which are non-negative. Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com> Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
599d0c4561
commit
f524bc3b3d
1 changed files with 4 additions and 8 deletions
|
@ -141,7 +141,7 @@ static int xen_host_pci_get_value(XenHostPCIDevice *d, const char *name,
|
||||||
char buf[XEN_HOST_PCI_GET_VALUE_BUFFER_SIZE];
|
char buf[XEN_HOST_PCI_GET_VALUE_BUFFER_SIZE];
|
||||||
int fd, rc;
|
int fd, rc;
|
||||||
unsigned long value;
|
unsigned long value;
|
||||||
char *endptr;
|
const char *endptr;
|
||||||
|
|
||||||
xen_host_pci_sysfs_path(d, name, path, sizeof(path));
|
xen_host_pci_sysfs_path(d, name, path, sizeof(path));
|
||||||
|
|
||||||
|
@ -158,13 +158,9 @@ static int xen_host_pci_get_value(XenHostPCIDevice *d, const char *name,
|
||||||
}
|
}
|
||||||
} while (rc < 0);
|
} while (rc < 0);
|
||||||
buf[rc] = 0;
|
buf[rc] = 0;
|
||||||
value = strtol(buf, &endptr, base);
|
rc = qemu_strtoul(buf, &endptr, base, &value);
|
||||||
if (endptr == buf || *endptr != '\n') {
|
if (!rc) {
|
||||||
rc = -1;
|
assert(value <= UINT_MAX);
|
||||||
} else if ((value == LONG_MIN || value == LONG_MAX) && errno == ERANGE) {
|
|
||||||
rc = -errno;
|
|
||||||
} else {
|
|
||||||
rc = 0;
|
|
||||||
*pvalue = value;
|
*pvalue = value;
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue