-Wshadow=local patches patches for 2023-10-06

-----BEGIN PGP SIGNATURE-----
 
 iQJGBAABCAAwFiEENUvIs9frKmtoZ05fOHC0AOuRhlMFAmUf72kSHGFybWJydUBy
 ZWRoYXQuY29tAAoJEDhwtADrkYZTDU4P/3R9y5D5d3cj4uI+eaM22+Da0MFUL2gq
 bFL192gYj1cmnNqxp+d6ur7FbSlP2AuERHb50Off7jJzdNee+tEeRUPekY+HhKfT
 5Aj6r9M2jV3/sNXqzns7x9Yj2B8xaJlclKPUAaVAxIuhVradWqJiPSkc26sKPB7l
 eyqjVvr9+GTQYPSh+YVbYDAUYU9rEL6FiWLPkKm7Kt3/xqp5pTVbUSQbgKQczGWL
 /JFILJc5pjISzYPyVxDPSNJY9q4k37JtcJmsO94G9O0GEe5vE72I85OQwI3Fl824
 1fc2bfkGB6cg1QcJAluOgjuMUe8Wqaw6tnnHgipr1mwFOizrQ9wQW2xRI9RRJfYa
 bZmVWIw22P691pgTnFIHWKV6/A2xyq+j00VojQhLyMX9CPPCbIm9hKCZXz6lPGDt
 xPX2//q866anFCCyQmimMSeJ4E1GgBTnWgLZMYJ+S3DL/VkW2FGZjiQMyOsRplDm
 O6+m6GOiF3wW51uqphaRHwF+PxxNE4Dv+61pYEeKdQELSCAmYrN574BDPehVTcfa
 luvSLZEl+qvUbkbw4ysrtiCX2YzVI4COxSscjxCXbku3wRbGSkHBeDadb3p17kuQ
 7FZILaFJo1wXHAine4/f6aNeV/GZihMqJ1cok6SDJh2E1PycF9NTdiKMb/6Zvvf+
 KOVyBhY4NXlj
 =uE1Y
 -----END PGP SIGNATURE-----

Merge tag 'pull-shadow-2023-10-06' of https://repo.or.cz/qemu/armbru into staging

-Wshadow=local patches patches for 2023-10-06

# -----BEGIN PGP SIGNATURE-----
#
# iQJGBAABCAAwFiEENUvIs9frKmtoZ05fOHC0AOuRhlMFAmUf72kSHGFybWJydUBy
# ZWRoYXQuY29tAAoJEDhwtADrkYZTDU4P/3R9y5D5d3cj4uI+eaM22+Da0MFUL2gq
# bFL192gYj1cmnNqxp+d6ur7FbSlP2AuERHb50Off7jJzdNee+tEeRUPekY+HhKfT
# 5Aj6r9M2jV3/sNXqzns7x9Yj2B8xaJlclKPUAaVAxIuhVradWqJiPSkc26sKPB7l
# eyqjVvr9+GTQYPSh+YVbYDAUYU9rEL6FiWLPkKm7Kt3/xqp5pTVbUSQbgKQczGWL
# /JFILJc5pjISzYPyVxDPSNJY9q4k37JtcJmsO94G9O0GEe5vE72I85OQwI3Fl824
# 1fc2bfkGB6cg1QcJAluOgjuMUe8Wqaw6tnnHgipr1mwFOizrQ9wQW2xRI9RRJfYa
# bZmVWIw22P691pgTnFIHWKV6/A2xyq+j00VojQhLyMX9CPPCbIm9hKCZXz6lPGDt
# xPX2//q866anFCCyQmimMSeJ4E1GgBTnWgLZMYJ+S3DL/VkW2FGZjiQMyOsRplDm
# O6+m6GOiF3wW51uqphaRHwF+PxxNE4Dv+61pYEeKdQELSCAmYrN574BDPehVTcfa
# luvSLZEl+qvUbkbw4ysrtiCX2YzVI4COxSscjxCXbku3wRbGSkHBeDadb3p17kuQ
# 7FZILaFJo1wXHAine4/f6aNeV/GZihMqJ1cok6SDJh2E1PycF9NTdiKMb/6Zvvf+
# KOVyBhY4NXlj
# =uE1Y
# -----END PGP SIGNATURE-----
# gpg: Signature made Fri 06 Oct 2023 07:28:41 EDT
# gpg:                using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653
# gpg:                issuer "armbru@redhat.com"
# gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" [full]
# gpg:                 aka "Markus Armbruster <armbru@pond.sub.org>" [full]
# Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867  4E5F 3870 B400 EB91 8653

* tag 'pull-shadow-2023-10-06' of https://repo.or.cz/qemu/armbru: (32 commits)
  linux-user/syscall.c: clean up local variable shadowing in xattr syscalls
  linux-user/syscall.c: clean up local variable shadowing in TARGET_NR_getcpu
  linux-user/syscall.c: clean up local variable shadowing in do_ioctl_dm()
  linux-user/mmap.c: clean up local variable shadowing
  linux-user/flatload: clean up local variable shadowing
  hw/usb: Silence compiler warnings in USB code when compiling with -Wshadow
  target/ppc: Clean up local variable shadowing in kvm_arch_*_registers()
  trace/control: Clean up global variable shadowing
  sysemu/tpm: Clean up global variable shadowing
  softmmu/vl: Clean up global variable shadowing
  semihosting/arm-compat: Clean up local variable shadowing
  util/guest-random: Clean up global variable shadowing
  util/cutils: Clean up global variable shadowing in get_relocated_path()
  ui/cocoa: Clean up global variable shadowing
  semihosting: Clean up global variable shadowing
  qom/object_interfaces: Clean up global variable shadowing
  qemu-io: Clean up global variable shadowing
  qemu-img: Clean up global variable shadowing
  plugins/loader: Clean up global variable shadowing
  os-posix: Clean up global variable shadowing
  ...

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
Stefan Hajnoczi 2023-10-09 10:10:20 -04:00
commit 17a319b175
46 changed files with 170 additions and 178 deletions

View file

@ -549,7 +549,6 @@ static int oss_init_out(HWVoiceOut *hw, struct audsettings *as,
hw->size_emul); hw->size_emul);
hw->buf_emul = NULL; hw->buf_emul = NULL;
} else { } else {
int err;
int trig = 0; int trig = 0;
if (ioctl (fd, SNDCTL_DSP_SETTRIGGER, &trig) < 0) { if (ioctl (fd, SNDCTL_DSP_SETTRIGGER, &trig) < 0) {
oss_logerr (errno, "SNDCTL_DSP_SETTRIGGER 0 failed\n"); oss_logerr (errno, "SNDCTL_DSP_SETTRIGGER 0 failed\n");

View file

@ -1872,20 +1872,20 @@ static void dump_init(DumpState *s, int fd, bool has_format,
if (vmci) { if (vmci) {
uint64_t addr, note_head_size, name_size, desc_size; uint64_t addr, note_head_size, name_size, desc_size;
uint32_t size; uint32_t size;
uint16_t format; uint16_t guest_format;
note_head_size = dump_is_64bit(s) ? note_head_size = dump_is_64bit(s) ?
sizeof(Elf64_Nhdr) : sizeof(Elf32_Nhdr); sizeof(Elf64_Nhdr) : sizeof(Elf32_Nhdr);
format = le16_to_cpu(vmci->vmcoreinfo.guest_format); guest_format = le16_to_cpu(vmci->vmcoreinfo.guest_format);
size = le32_to_cpu(vmci->vmcoreinfo.size); size = le32_to_cpu(vmci->vmcoreinfo.size);
addr = le64_to_cpu(vmci->vmcoreinfo.paddr); addr = le64_to_cpu(vmci->vmcoreinfo.paddr);
if (!vmci->has_vmcoreinfo) { if (!vmci->has_vmcoreinfo) {
warn_report("guest note is not present"); warn_report("guest note is not present");
} else if (size < note_head_size || size > MAX_GUEST_NOTE_SIZE) { } else if (size < note_head_size || size > MAX_GUEST_NOTE_SIZE) {
warn_report("guest note size is invalid: %" PRIu32, size); warn_report("guest note size is invalid: %" PRIu32, size);
} else if (format != FW_CFG_VMCOREINFO_FORMAT_ELF) { } else if (guest_format != FW_CFG_VMCOREINFO_FORMAT_ELF) {
warn_report("guest note format is unsupported: %" PRIu16, format); warn_report("guest note format is unsupported: %" PRIu16, guest_format);
} else { } else {
s->guest_note = g_malloc(size + 1); /* +1 for adding \0 */ s->guest_note = g_malloc(size + 1); /* +1 for adding \0 */
cpu_physical_memory_read(addr, s->guest_note, size); cpu_physical_memory_read(addr, s->guest_note, size);

View file

@ -83,7 +83,7 @@ void show_valid_soundhw(void)
static struct soundhw *selected = NULL; static struct soundhw *selected = NULL;
static const char *audiodev_id; static const char *audiodev_id;
void select_soundhw(const char *optarg, const char *audiodev) void select_soundhw(const char *name, const char *audiodev)
{ {
struct soundhw *c; struct soundhw *c;
@ -92,7 +92,7 @@ void select_soundhw(const char *optarg, const char *audiodev)
} }
for (c = soundhw; c->name; ++c) { for (c = soundhw; c->name; ++c) {
if (g_str_equal(c->name, optarg)) { if (g_str_equal(c->name, name)) {
selected = c; selected = c;
audiodev_id = audiodev; audiodev_id = audiodev;
break; break;
@ -100,7 +100,7 @@ void select_soundhw(const char *optarg, const char *audiodev)
} }
if (!c->name) { if (!c->name) {
error_report("Unknown sound card name `%s'", optarg); error_report("Unknown sound card name `%s'", name);
show_valid_soundhw(); show_valid_soundhw();
exit(1); exit(1);
} }

View file

@ -283,13 +283,13 @@ static void memdev_reg_init_common(CXLDeviceState *cxl_dstate) { }
void cxl_device_register_init_common(CXLDeviceState *cxl_dstate) void cxl_device_register_init_common(CXLDeviceState *cxl_dstate)
{ {
uint64_t *cap_hdrs = cxl_dstate->caps_reg_state64; uint64_t *cap_h = cxl_dstate->caps_reg_state64;
const int cap_count = 3; const int cap_count = 3;
/* CXL Device Capabilities Array Register */ /* CXL Device Capabilities Array Register */
ARRAY_FIELD_DP64(cap_hdrs, CXL_DEV_CAP_ARRAY, CAP_ID, 0); ARRAY_FIELD_DP64(cap_h, CXL_DEV_CAP_ARRAY, CAP_ID, 0);
ARRAY_FIELD_DP64(cap_hdrs, CXL_DEV_CAP_ARRAY, CAP_VERSION, 1); ARRAY_FIELD_DP64(cap_h, CXL_DEV_CAP_ARRAY, CAP_VERSION, 1);
ARRAY_FIELD_DP64(cap_hdrs, CXL_DEV_CAP_ARRAY, CAP_COUNT, cap_count); ARRAY_FIELD_DP64(cap_h, CXL_DEV_CAP_ARRAY, CAP_COUNT, cap_count);
cxl_device_cap_init(cxl_dstate, DEVICE_STATUS, 1, 2); cxl_device_cap_init(cxl_dstate, DEVICE_STATUS, 1, 2);
device_reg_init_common(cxl_dstate); device_reg_init_common(cxl_dstate);

View file

@ -55,8 +55,8 @@ static void acpi_dsdt_add_virtio(Aml *scope,
bus = sysbus_get_default(); bus = sysbus_get_default();
QTAILQ_FOREACH(kid, &bus->children, sibling) { QTAILQ_FOREACH(kid, &bus->children, sibling) {
DeviceState *dev = kid->child; Object *obj = object_dynamic_cast(OBJECT(kid->child),
Object *obj = object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MMIO); TYPE_VIRTIO_MMIO);
if (obj) { if (obj) {
VirtIOMMIOProxy *mmio = VIRTIO_MMIO(obj); VirtIOMMIOProxy *mmio = VIRTIO_MMIO(obj);

View file

@ -1049,7 +1049,6 @@ void pc_memory_init(PCMachineState *pcms,
if (machine->device_memory) { if (machine->device_memory) {
uint64_t *val = g_malloc(sizeof(*val)); uint64_t *val = g_malloc(sizeof(*val));
PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
uint64_t res_mem_end = machine->device_memory->base; uint64_t res_mem_end = machine->device_memory->base;
if (!pcmc->broken_reserved_end) { if (!pcmc->broken_reserved_end) {

View file

@ -365,8 +365,6 @@ void x86_cpu_pre_plug(HotplugHandler *hotplug_dev,
cpu_slot = x86_find_cpu_slot(MACHINE(x86ms), cpu->apic_id, &idx); cpu_slot = x86_find_cpu_slot(MACHINE(x86ms), cpu->apic_id, &idx);
if (!cpu_slot) { if (!cpu_slot) {
MachineState *ms = MACHINE(x86ms);
x86_topo_ids_from_apicid(cpu->apic_id, &topo_info, &topo_ids); x86_topo_ids_from_apicid(cpu->apic_id, &topo_info, &topo_ids);
error_setg(errp, error_setg(errp,
"Invalid CPU [socket: %u, die: %u, core: %u, thread: %u] with" "Invalid CPU [socket: %u, die: %u, core: %u, thread: %u] with"

View file

@ -1622,9 +1622,7 @@ void ahci_uninit(AHCIState *s)
AHCIDevice *ad = &s->dev[i]; AHCIDevice *ad = &s->dev[i];
for (j = 0; j < 2; j++) { for (j = 0; j < 2; j++) {
IDEState *s = &ad->port.ifs[j]; ide_exit(&ad->port.ifs[j]);
ide_exit(s);
} }
object_unparent(OBJECT(&ad->port)); object_unparent(OBJECT(&ad->port));
} }

View file

@ -662,7 +662,7 @@ static void loongarch_irq_init(LoongArchMachineState *lams)
sysbus_mmio_get_region(d, 2)); sysbus_mmio_get_region(d, 2));
/* Connect pch_pic irqs to extioi */ /* Connect pch_pic irqs to extioi */
for (int i = 0; i < num; i++) { for (i = 0; i < num; i++) {
qdev_connect_gpio_out(DEVICE(d), i, qdev_get_gpio_in(extioi, i)); qdev_connect_gpio_out(DEVICE(d), i, qdev_get_gpio_in(extioi, i));
} }

View file

@ -313,8 +313,8 @@ fail:
/* Queue might not be ready for start */ /* Queue might not be ready for start */
continue; continue;
} }
int r = vhost_net_set_backend(&net->dev, &file); int ret = vhost_net_set_backend(&net->dev, &file);
assert(r >= 0); assert(ret >= 0);
} }
} }
if (net->nc->info->poll) { if (net->nc->info->poll) {
@ -629,8 +629,8 @@ err_start:
if (net->nc->info->type == NET_CLIENT_DRIVER_TAP) { if (net->nc->info->type == NET_CLIENT_DRIVER_TAP) {
file.fd = VHOST_FILE_UNBIND; file.fd = VHOST_FILE_UNBIND;
file.index = idx; file.index = idx;
int r = vhost_net_set_backend(&net->dev, &file); int ret = vhost_net_set_backend(&net->dev, &file);
assert(r >= 0); assert(ret >= 0);
} }
vhost_dev_stop(&net->dev, vdev, false); vhost_dev_stop(&net->dev, vdev, false);

View file

@ -227,7 +227,7 @@ int usb_desc_endpoint(const USBDescEndpoint *ep, int flags,
} }
if (superlen) { if (superlen) {
USBDescriptor *d = (void *)(dest + bLength); d = (void *)(dest + bLength);
d->bLength = 0x06; d->bLength = 0x06;
d->bDescriptorType = USB_DT_ENDPOINT_COMPANION; d->bDescriptorType = USB_DT_ENDPOINT_COMPANION;

View file

@ -402,7 +402,7 @@ static void usb_hub_handle_control(USBDevice *dev, USBPacket *p,
{ {
unsigned int n = index - 1; unsigned int n = index - 1;
USBHubPort *port; USBHubPort *port;
USBDevice *dev; USBDevice *pdev;
trace_usb_hub_set_port_feature(s->dev.addr, index, trace_usb_hub_set_port_feature(s->dev.addr, index,
feature_name(value)); feature_name(value));
@ -411,7 +411,7 @@ static void usb_hub_handle_control(USBDevice *dev, USBPacket *p,
goto fail; goto fail;
} }
port = &s->ports[n]; port = &s->ports[n];
dev = port->port.dev; pdev = port->port.dev;
switch(value) { switch(value) {
case PORT_SUSPEND: case PORT_SUSPEND:
port->wPortStatus |= PORT_STAT_SUSPEND; port->wPortStatus |= PORT_STAT_SUSPEND;
@ -419,8 +419,8 @@ static void usb_hub_handle_control(USBDevice *dev, USBPacket *p,
case PORT_RESET: case PORT_RESET:
usb_hub_port_set(port, PORT_STAT_RESET); usb_hub_port_set(port, PORT_STAT_RESET);
usb_hub_port_clear(port, PORT_STAT_RESET); usb_hub_port_clear(port, PORT_STAT_RESET);
if (dev && dev->attached) { if (pdev && pdev->attached) {
usb_device_reset(dev); usb_device_reset(pdev);
usb_hub_port_set(port, PORT_STAT_ENABLE); usb_hub_port_set(port, PORT_STAT_ENABLE);
} }
usb_wakeup(s->intr, 0); usb_wakeup(s->intr, 0);

View file

@ -403,7 +403,7 @@ static void usb_msd_handle_data(USBDevice *dev, USBPacket *p)
struct usb_msd_cbw cbw; struct usb_msd_cbw cbw;
uint8_t devep = p->ep->nr; uint8_t devep = p->ep->nr;
SCSIDevice *scsi_dev; SCSIDevice *scsi_dev;
uint32_t len; int len;
if (s->needs_reset) { if (s->needs_reset) {
p->status = USB_RET_STALL; p->status = USB_RET_STALL;
@ -465,7 +465,7 @@ static void usb_msd_handle_data(USBDevice *dev, USBPacket *p)
usb_msd_copy_data(s, p); usb_msd_copy_data(s, p);
} }
if (le32_to_cpu(s->csw.residue)) { if (le32_to_cpu(s->csw.residue)) {
int len = p->iov.size - p->actual_length; len = p->iov.size - p->actual_length;
if (len) { if (len) {
usb_packet_skip(p, len); usb_packet_skip(p, len);
if (len > s->data_len) { if (len > s->data_len) {
@ -526,7 +526,7 @@ static void usb_msd_handle_data(USBDevice *dev, USBPacket *p)
usb_msd_copy_data(s, p); usb_msd_copy_data(s, p);
} }
if (le32_to_cpu(s->csw.residue)) { if (le32_to_cpu(s->csw.residue)) {
int len = p->iov.size - p->actual_length; len = p->iov.size - p->actual_length;
if (len) { if (len) {
usb_packet_skip(p, len); usb_packet_skip(p, len);
if (len > s->data_len) { if (len > s->data_len) {

View file

@ -217,10 +217,10 @@ enum {
(((data) >> field##_SHIFT) & field##_MASK) (((data) >> field##_SHIFT) & field##_MASK)
#define set_field(data, newval, field) do { \ #define set_field(data, newval, field) do { \
uint32_t val = *data; \ uint32_t val_ = *data; \
val &= ~(field##_MASK << field##_SHIFT); \ val_ &= ~(field##_MASK << field##_SHIFT); \
val |= ((newval) & field##_MASK) << field##_SHIFT; \ val_ |= ((newval) & field##_MASK) << field##_SHIFT; \
*data = val; \ *data = val_; \
} while (0) } while (0)
typedef enum EPType { typedef enum EPType {
@ -1894,7 +1894,7 @@ static void xhci_kick_epctx(XHCIEPContext *epctx, unsigned int streamid)
} }
if (epctx->retry) { if (epctx->retry) {
XHCITransfer *xfer = epctx->retry; xfer = epctx->retry;
trace_usb_xhci_xfer_retry(xfer); trace_usb_xhci_xfer_retry(xfer);
assert(xfer->running_retry); assert(xfer->running_retry);

View file

@ -1010,7 +1010,7 @@ static int usb_host_open(USBHostDevice *s, libusb_device *dev, int hostfd)
* Speeds are defined in linux/usb/ch9.h, file not included * Speeds are defined in linux/usb/ch9.h, file not included
* due to name conflicts. * due to name conflicts.
*/ */
int rc = ioctl(hostfd, USBDEVFS_GET_SPEED, NULL); rc = ioctl(hostfd, USBDEVFS_GET_SPEED, NULL);
switch (rc) { switch (rc) {
case 1: /* low */ case 1: /* low */
libusb_speed = LIBUSB_SPEED_LOW; libusb_speed = LIBUSB_SPEED_LOW;

View file

@ -66,12 +66,12 @@ static void vhost_dev_sync_region(struct vhost_dev *dev,
uint64_t mfirst, uint64_t mlast, uint64_t mfirst, uint64_t mlast,
uint64_t rfirst, uint64_t rlast) uint64_t rfirst, uint64_t rlast)
{ {
vhost_log_chunk_t *log = dev->log->log; vhost_log_chunk_t *dev_log = dev->log->log;
uint64_t start = MAX(mfirst, rfirst); uint64_t start = MAX(mfirst, rfirst);
uint64_t end = MIN(mlast, rlast); uint64_t end = MIN(mlast, rlast);
vhost_log_chunk_t *from = log + start / VHOST_LOG_CHUNK; vhost_log_chunk_t *from = dev_log + start / VHOST_LOG_CHUNK;
vhost_log_chunk_t *to = log + end / VHOST_LOG_CHUNK + 1; vhost_log_chunk_t *to = dev_log + end / VHOST_LOG_CHUNK + 1;
uint64_t addr = QEMU_ALIGN_DOWN(start, VHOST_LOG_CHUNK); uint64_t addr = QEMU_ALIGN_DOWN(start, VHOST_LOG_CHUNK);
if (end < start) { if (end < start) {
@ -549,7 +549,7 @@ static void vhost_commit(MemoryListener *listener)
changed = true; changed = true;
} else { } else {
/* Same size, lets check the contents */ /* Same size, lets check the contents */
for (int i = 0; i < n_old_sections; i++) { for (i = 0; i < n_old_sections; i++) {
if (!MemoryRegionSection_eq(&old_sections[i], if (!MemoryRegionSection_eq(&old_sections[i],
&dev->mem_sections[i])) { &dev->mem_sections[i])) {
changed = true; changed = true;

View file

@ -780,15 +780,15 @@ static void virtio_write_config(PCIDevice *pci_dev, uint32_t address,
pci_cfg_data), pci_cfg_data),
sizeof cfg->pci_cfg_data)) { sizeof cfg->pci_cfg_data)) {
uint32_t off; uint32_t off;
uint32_t len; uint32_t caplen;
cfg = (void *)(proxy->pci_dev.config + proxy->config_cap); cfg = (void *)(proxy->pci_dev.config + proxy->config_cap);
off = le32_to_cpu(cfg->cap.offset); off = le32_to_cpu(cfg->cap.offset);
len = le32_to_cpu(cfg->cap.length); caplen = le32_to_cpu(cfg->cap.length);
if (len == 1 || len == 2 || len == 4) { if (caplen == 1 || caplen == 2 || caplen == 4) {
assert(len <= sizeof cfg->pci_cfg_data); assert(caplen <= sizeof cfg->pci_cfg_data);
virtio_address_space_write(proxy, off, cfg->pci_cfg_data, len); virtio_address_space_write(proxy, off, cfg->pci_cfg_data, caplen);
} }
} }
} }
@ -804,15 +804,15 @@ static uint32_t virtio_read_config(PCIDevice *pci_dev,
pci_cfg_data), pci_cfg_data),
sizeof cfg->pci_cfg_data)) { sizeof cfg->pci_cfg_data)) {
uint32_t off; uint32_t off;
uint32_t len; uint32_t caplen;
cfg = (void *)(proxy->pci_dev.config + proxy->config_cap); cfg = (void *)(proxy->pci_dev.config + proxy->config_cap);
off = le32_to_cpu(cfg->cap.offset); off = le32_to_cpu(cfg->cap.offset);
len = le32_to_cpu(cfg->cap.length); caplen = le32_to_cpu(cfg->cap.length);
if (len == 1 || len == 2 || len == 4) { if (caplen == 1 || caplen == 2 || caplen == 4) {
assert(len <= sizeof cfg->pci_cfg_data); assert(caplen <= sizeof cfg->pci_cfg_data);
virtio_address_space_read(proxy, off, cfg->pci_cfg_data, len); virtio_address_space_read(proxy, off, cfg->pci_cfg_data, caplen);
} }
} }

View file

@ -8,6 +8,6 @@ void deprecated_register_soundhw(const char *name, const char *descr,
void soundhw_init(void); void soundhw_init(void);
void show_valid_soundhw(void); void show_valid_soundhw(void);
void select_soundhw(const char *optarg, const char *audiodev); void select_soundhw(const char *name, const char *audiodev);
#endif #endif

View file

@ -247,9 +247,9 @@ extern const char *host_net_devices[];
/* from net.c */ /* from net.c */
extern NetClientStateList net_clients; extern NetClientStateList net_clients;
bool netdev_is_modern(const char *optarg); bool netdev_is_modern(const char *optstr);
void netdev_parse_modern(const char *optarg); void netdev_parse_modern(const char *optstr);
void net_client_parse(QemuOptsList *opts_list, const char *str); void net_client_parse(QemuOptsList *opts_list, const char *optstr);
void show_netdevs(void); void show_netdevs(void);
void net_init_clients(void); void net_init_clients(void);
void net_check_clients(void); void net_check_clients(void);

View file

@ -13,16 +13,16 @@
#define QEMU_GUEST_RANDOM_H #define QEMU_GUEST_RANDOM_H
/** /**
* qemu_guest_random_seed_main(const char *optarg, Error **errp) * qemu_guest_random_seed_main(const char *seedstr, Error **errp)
* @optarg: a non-NULL pointer to a C string * @seedstr: a non-NULL pointer to a C string
* @errp: an error indicator * @errp: an error indicator
* *
* The @optarg value is that which accompanies the -seed argument. * The @seedstr value is that which accompanies the -seed argument.
* This forces qemu_guest_getrandom into deterministic mode. * This forces qemu_guest_getrandom into deterministic mode.
* *
* Returns 0 on success, < 0 on failure while setting *errp. * Returns 0 on success, < 0 on failure while setting *errp.
*/ */
int qemu_guest_random_seed_main(const char *optarg, Error **errp); int qemu_guest_random_seed_main(const char *seedstr, Error **errp);
/** /**
* qemu_guest_random_seed_thread_part1(void) * qemu_guest_random_seed_thread_part1(void)

View file

@ -50,7 +50,7 @@ static inline void qemu_plugin_add_opts(void)
qemu_add_opts(&qemu_plugin_opts); qemu_add_opts(&qemu_plugin_opts);
} }
void qemu_plugin_opt_parse(const char *optarg, QemuPluginList *head); void qemu_plugin_opt_parse(const char *optstr, QemuPluginList *head);
int qemu_plugin_load_list(QemuPluginList *head, Error **errp); int qemu_plugin_load_list(QemuPluginList *head, Error **errp);
union qemu_plugin_cb_sig { union qemu_plugin_cb_sig {
@ -242,7 +242,7 @@ void qemu_plugin_user_postfork(bool is_child);
static inline void qemu_plugin_add_opts(void) static inline void qemu_plugin_add_opts(void)
{ } { }
static inline void qemu_plugin_opt_parse(const char *optarg, static inline void qemu_plugin_opt_parse(const char *optstr,
QemuPluginList *head) QemuPluginList *head)
{ {
error_report("plugin interface not enabled in this build"); error_report("plugin interface not enabled in this build");

View file

@ -99,7 +99,7 @@ void user_creatable_add_qapi(ObjectOptions *options, Error **errp);
/** /**
* user_creatable_parse_str: * user_creatable_parse_str:
* @optarg: the object definition string as passed on the command line * @str: the object definition string as passed on the command line
* @errp: if an error occurs, a pointer to an area to store the error * @errp: if an error occurs, a pointer to an area to store the error
* *
* Parses the option for the user creatable object with a keyval parser and * Parses the option for the user creatable object with a keyval parser and
@ -110,14 +110,14 @@ void user_creatable_add_qapi(ObjectOptions *options, Error **errp);
* Returns: ObjectOptions on success, NULL when an error occurred (*errp is set * Returns: ObjectOptions on success, NULL when an error occurred (*errp is set
* then) or help was printed (*errp is not set). * then) or help was printed (*errp is not set).
*/ */
ObjectOptions *user_creatable_parse_str(const char *optarg, Error **errp); ObjectOptions *user_creatable_parse_str(const char *str, Error **errp);
/** /**
* user_creatable_add_from_str: * user_creatable_add_from_str:
* @optarg: the object definition string as passed on the command line * @str: the object definition string as passed on the command line
* @errp: if an error occurs, a pointer to an area to store the error * @errp: if an error occurs, a pointer to an area to store the error
* *
* Create an instance of the user creatable object by parsing optarg * Create an instance of the user creatable object by parsing @str
* with a keyval parser and implicit key 'qom-type', converting the * with a keyval parser and implicit key 'qom-type', converting the
* result to ObjectOptions and calling into qmp_object_add(). * result to ObjectOptions and calling into qmp_object_add().
* *
@ -126,13 +126,13 @@ ObjectOptions *user_creatable_parse_str(const char *optarg, Error **errp);
* Returns: true when an object was successfully created, false when an error * Returns: true when an object was successfully created, false when an error
* occurred (*errp is set then) or help was printed (*errp is not set). * occurred (*errp is set then) or help was printed (*errp is not set).
*/ */
bool user_creatable_add_from_str(const char *optarg, Error **errp); bool user_creatable_add_from_str(const char *str, Error **errp);
/** /**
* user_creatable_process_cmdline: * user_creatable_process_cmdline:
* @optarg: the object definition string as passed on the command line * @cmdline: the object definition string as passed on the command line
* *
* Create an instance of the user creatable object by parsing optarg * Create an instance of the user creatable object by parsing @cmdline
* with a keyval parser and implicit key 'qom-type', converting the * with a keyval parser and implicit key 'qom-type', converting the
* result to ObjectOptions and calling into qmp_object_add(). * result to ObjectOptions and calling into qmp_object_add().
* *
@ -141,7 +141,7 @@ bool user_creatable_add_from_str(const char *optarg, Error **errp);
* This function is only meant to be called during command line parsing. * This function is only meant to be called during command line parsing.
* It exits the process on failure or after printing help. * It exits the process on failure or after printing help.
*/ */
void user_creatable_process_cmdline(const char *optarg); void user_creatable_process_cmdline(const char *cmdline);
/** /**
* user_creatable_print_help: * user_creatable_print_help:

View file

@ -66,7 +66,7 @@ const char *semihosting_get_cmdline(void);
void semihosting_arg_fallback(const char *file, const char *cmd); void semihosting_arg_fallback(const char *file, const char *cmd);
/* for vl.c hooks */ /* for vl.c hooks */
void qemu_semihosting_enable(void); void qemu_semihosting_enable(void);
int qemu_semihosting_config_options(const char *opt); int qemu_semihosting_config_options(const char *optstr);
void qemu_semihosting_chardev_init(void); void qemu_semihosting_chardev_init(void);
void qemu_semihosting_console_init(Chardev *); void qemu_semihosting_console_init(Chardev *);
#endif /* CONFIG_USER_ONLY */ #endif /* CONFIG_USER_ONLY */

View file

@ -49,8 +49,8 @@ void os_setup_signal_handling(void);
int os_set_daemonize(bool d); int os_set_daemonize(bool d);
bool is_daemonized(void); bool is_daemonized(void);
void os_daemonize(void); void os_daemonize(void);
bool os_set_runas(const char *optarg); bool os_set_runas(const char *user_id);
void os_set_chroot(const char *optarg); void os_set_chroot(const char *path);
void os_setup_post(void); void os_setup_post(void);
int os_mlock(void); int os_mlock(void);

View file

@ -17,7 +17,7 @@
#ifdef CONFIG_TPM #ifdef CONFIG_TPM
int tpm_config_parse(QemuOptsList *opts_list, const char *optarg); int tpm_config_parse(QemuOptsList *opts_list, const char *optstr);
int tpm_init(void); int tpm_init(void);
void tpm_cleanup(void); void tpm_cleanup(void);

View file

@ -755,15 +755,15 @@ int load_flt_binary(struct linux_binprm *bprm, struct image_info *info)
/* Update data segment pointers for all libraries */ /* Update data segment pointers for all libraries */
for (i=0; i<MAX_SHARED_LIBS; i++) { for (i=0; i<MAX_SHARED_LIBS; i++) {
if (libinfo[i].loaded) { if (libinfo[i].loaded) {
abi_ulong p; abi_ulong seg;
p = libinfo[i].start_data; seg = libinfo[i].start_data;
for (j=0; j<MAX_SHARED_LIBS; j++) { for (j=0; j<MAX_SHARED_LIBS; j++) {
p -= 4; seg -= 4;
/* FIXME - handle put_user() failures */ /* FIXME - handle put_user() failures */
if (put_user_ual(libinfo[j].loaded if (put_user_ual(libinfo[j].loaded
? libinfo[j].start_data ? libinfo[j].start_data
: UNLOADED_LIB, : UNLOADED_LIB,
p)) seg))
return -EFAULT; return -EFAULT;
} }
} }

View file

@ -910,16 +910,16 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size,
} }
} }
} else { } else {
int prot = 0; int page_flags = 0;
if (reserved_va && old_size < new_size) { if (reserved_va && old_size < new_size) {
abi_ulong addr; abi_ulong addr;
for (addr = old_addr + old_size; for (addr = old_addr + old_size;
addr < old_addr + new_size; addr < old_addr + new_size;
addr++) { addr++) {
prot |= page_get_flags(addr); page_flags |= page_get_flags(addr);
} }
} }
if (prot == 0) { if (page_flags == 0) {
host_addr = mremap(g2h_untagged(old_addr), host_addr = mremap(g2h_untagged(old_addr),
old_size, new_size, flags); old_size, new_size, flags);

View file

@ -5050,8 +5050,8 @@ static abi_long do_ioctl_dm(const IOCTLEntry *ie, uint8_t *buf_temp, int fd,
{ {
void *gspec = argptr; void *gspec = argptr;
void *cur_data = host_data; void *cur_data = host_data;
const argtype arg_type[] = { MK_STRUCT(STRUCT_dm_target_spec) }; const argtype dm_arg_type[] = { MK_STRUCT(STRUCT_dm_target_spec) };
int spec_size = thunk_type_size(arg_type, 0); int spec_size = thunk_type_size(dm_arg_type, 0);
int i; int i;
for (i = 0; i < host_dm->target_count; i++) { for (i = 0; i < host_dm->target_count; i++) {
@ -5059,7 +5059,7 @@ static abi_long do_ioctl_dm(const IOCTLEntry *ie, uint8_t *buf_temp, int fd,
uint32_t next; uint32_t next;
int slen; int slen;
thunk_convert(spec, gspec, arg_type, THUNK_HOST); thunk_convert(spec, gspec, dm_arg_type, THUNK_HOST);
slen = strlen((char*)gspec + spec_size) + 1; slen = strlen((char*)gspec + spec_size) + 1;
next = spec->next; next = spec->next;
spec->next = sizeof(*spec) + slen; spec->next = sizeof(*spec) + slen;
@ -5099,7 +5099,7 @@ static abi_long do_ioctl_dm(const IOCTLEntry *ie, uint8_t *buf_temp, int fd,
struct dm_name_list *nl = (void*)host_dm + host_dm->data_start; struct dm_name_list *nl = (void*)host_dm + host_dm->data_start;
uint32_t remaining_data = guest_data_size; uint32_t remaining_data = guest_data_size;
void *cur_data = argptr; void *cur_data = argptr;
const argtype arg_type[] = { MK_STRUCT(STRUCT_dm_name_list) }; const argtype dm_arg_type[] = { MK_STRUCT(STRUCT_dm_name_list) };
int nl_size = 12; /* can't use thunk_size due to alignment */ int nl_size = 12; /* can't use thunk_size due to alignment */
while (1) { while (1) {
@ -5111,7 +5111,7 @@ static abi_long do_ioctl_dm(const IOCTLEntry *ie, uint8_t *buf_temp, int fd,
host_dm->flags |= DM_BUFFER_FULL_FLAG; host_dm->flags |= DM_BUFFER_FULL_FLAG;
break; break;
} }
thunk_convert(cur_data, nl, arg_type, THUNK_TARGET); thunk_convert(cur_data, nl, dm_arg_type, THUNK_TARGET);
strcpy(cur_data + nl_size, nl->name); strcpy(cur_data + nl_size, nl->name);
cur_data += nl->next; cur_data += nl->next;
remaining_data -= nl->next; remaining_data -= nl->next;
@ -5127,8 +5127,8 @@ static abi_long do_ioctl_dm(const IOCTLEntry *ie, uint8_t *buf_temp, int fd,
{ {
struct dm_target_spec *spec = (void*)host_dm + host_dm->data_start; struct dm_target_spec *spec = (void*)host_dm + host_dm->data_start;
void *cur_data = argptr; void *cur_data = argptr;
const argtype arg_type[] = { MK_STRUCT(STRUCT_dm_target_spec) }; const argtype dm_arg_type[] = { MK_STRUCT(STRUCT_dm_target_spec) };
int spec_size = thunk_type_size(arg_type, 0); int spec_size = thunk_type_size(dm_arg_type, 0);
int i; int i;
for (i = 0; i < host_dm->target_count; i++) { for (i = 0; i < host_dm->target_count; i++) {
@ -5139,7 +5139,7 @@ static abi_long do_ioctl_dm(const IOCTLEntry *ie, uint8_t *buf_temp, int fd,
host_dm->flags |= DM_BUFFER_FULL_FLAG; host_dm->flags |= DM_BUFFER_FULL_FLAG;
break; break;
} }
thunk_convert(cur_data, spec, arg_type, THUNK_TARGET); thunk_convert(cur_data, spec, dm_arg_type, THUNK_TARGET);
strcpy(cur_data + spec_size, (char*)&spec[1]); strcpy(cur_data + spec_size, (char*)&spec[1]);
cur_data = argptr + spec->next; cur_data = argptr + spec->next;
spec = (void*)host_dm + host_dm->data_start + next; spec = (void*)host_dm + host_dm->data_start + next;
@ -5167,8 +5167,8 @@ static abi_long do_ioctl_dm(const IOCTLEntry *ie, uint8_t *buf_temp, int fd,
struct dm_target_versions *vers = (void*)host_dm + host_dm->data_start; struct dm_target_versions *vers = (void*)host_dm + host_dm->data_start;
uint32_t remaining_data = guest_data_size; uint32_t remaining_data = guest_data_size;
void *cur_data = argptr; void *cur_data = argptr;
const argtype arg_type[] = { MK_STRUCT(STRUCT_dm_target_versions) }; const argtype dm_arg_type[] = { MK_STRUCT(STRUCT_dm_target_versions) };
int vers_size = thunk_type_size(arg_type, 0); int vers_size = thunk_type_size(dm_arg_type, 0);
while (1) { while (1) {
uint32_t next = vers->next; uint32_t next = vers->next;
@ -5179,7 +5179,7 @@ static abi_long do_ioctl_dm(const IOCTLEntry *ie, uint8_t *buf_temp, int fd,
host_dm->flags |= DM_BUFFER_FULL_FLAG; host_dm->flags |= DM_BUFFER_FULL_FLAG;
break; break;
} }
thunk_convert(cur_data, vers, arg_type, THUNK_TARGET); thunk_convert(cur_data, vers, dm_arg_type, THUNK_TARGET);
strcpy(cur_data + vers_size, vers->name); strcpy(cur_data + vers_size, vers->name);
cur_data += vers->next; cur_data += vers->next;
remaining_data -= vers->next; remaining_data -= vers->next;
@ -11177,14 +11177,14 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
} }
case TARGET_NR_getcpu: case TARGET_NR_getcpu:
{ {
unsigned cpu, node; unsigned cpuid, node;
ret = get_errno(sys_getcpu(arg1 ? &cpu : NULL, ret = get_errno(sys_getcpu(arg1 ? &cpuid : NULL,
arg2 ? &node : NULL, arg2 ? &node : NULL,
NULL)); NULL));
if (is_error(ret)) { if (is_error(ret)) {
return ret; return ret;
} }
if (arg1 && put_user_u32(cpu, arg1)) { if (arg1 && put_user_u32(cpuid, arg1)) {
return -TARGET_EFAULT; return -TARGET_EFAULT;
} }
if (arg2 && put_user_u32(node, arg2)) { if (arg2 && put_user_u32(node, arg2)) {
@ -12339,7 +12339,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
case TARGET_NR_listxattr: case TARGET_NR_listxattr:
case TARGET_NR_llistxattr: case TARGET_NR_llistxattr:
{ {
void *p, *b = 0; void *b = 0;
if (arg2) { if (arg2) {
b = lock_user(VERIFY_WRITE, arg2, arg3, 0); b = lock_user(VERIFY_WRITE, arg2, arg3, 0);
if (!b) { if (!b) {
@ -12376,7 +12376,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
case TARGET_NR_setxattr: case TARGET_NR_setxattr:
case TARGET_NR_lsetxattr: case TARGET_NR_lsetxattr:
{ {
void *p, *n, *v = 0; void *n, *v = 0;
if (arg3) { if (arg3) {
v = lock_user(VERIFY_READ, arg3, arg4, 1); v = lock_user(VERIFY_READ, arg3, arg4, 1);
if (!v) { if (!v) {
@ -12421,7 +12421,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
case TARGET_NR_getxattr: case TARGET_NR_getxattr:
case TARGET_NR_lgetxattr: case TARGET_NR_lgetxattr:
{ {
void *p, *n, *v = 0; void *n, *v = 0;
if (arg3) { if (arg3) {
v = lock_user(VERIFY_WRITE, arg3, arg4, 0); v = lock_user(VERIFY_WRITE, arg3, arg4, 0);
if (!v) { if (!v) {
@ -12466,7 +12466,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
case TARGET_NR_removexattr: case TARGET_NR_removexattr:
case TARGET_NR_lremovexattr: case TARGET_NR_lremovexattr:
{ {
void *p, *n; void *n;
p = lock_user_string(arg1); p = lock_user_string(arg1);
n = lock_user_string(arg2); n = lock_user_string(arg2);
if (p && n) { if (p && n) {

View file

@ -1677,7 +1677,7 @@ void net_init_clients(void)
* Modern syntax is to be parsed with netdev_parse_modern(). * Modern syntax is to be parsed with netdev_parse_modern().
* Traditional syntax is to be parsed with net_client_parse(). * Traditional syntax is to be parsed with net_client_parse().
*/ */
bool netdev_is_modern(const char *optarg) bool netdev_is_modern(const char *optstr)
{ {
QemuOpts *opts; QemuOpts *opts;
bool is_modern; bool is_modern;
@ -1689,13 +1689,13 @@ bool netdev_is_modern(const char *optarg)
.desc = { { } }, .desc = { { } },
}; };
if (optarg[0] == '{') { if (optstr[0] == '{') {
/* This is JSON, which means it's modern syntax */ /* This is JSON, which means it's modern syntax */
return true; return true;
} }
opts = qemu_opts_create(&dummy_opts, NULL, false, &error_abort); opts = qemu_opts_create(&dummy_opts, NULL, false, &error_abort);
qemu_opts_do_parse(opts, optarg, dummy_opts.implied_opt_name, qemu_opts_do_parse(opts, optstr, dummy_opts.implied_opt_name,
&error_abort); &error_abort);
type = qemu_opt_get(opts, "type"); type = qemu_opt_get(opts, "type");
is_modern = !g_strcmp0(type, "stream") || !g_strcmp0(type, "dgram"); is_modern = !g_strcmp0(type, "stream") || !g_strcmp0(type, "dgram");
@ -1711,12 +1711,12 @@ bool netdev_is_modern(const char *optarg)
* netdev_parse_modern() appends to @nd_queue, whereas net_client_parse() * netdev_parse_modern() appends to @nd_queue, whereas net_client_parse()
* appends to @qemu_netdev_opts. * appends to @qemu_netdev_opts.
*/ */
void netdev_parse_modern(const char *optarg) void netdev_parse_modern(const char *optstr)
{ {
Visitor *v; Visitor *v;
NetdevQueueEntry *nd; NetdevQueueEntry *nd;
v = qobject_input_visitor_new_str(optarg, "type", &error_fatal); v = qobject_input_visitor_new_str(optstr, "type", &error_fatal);
nd = g_new(NetdevQueueEntry, 1); nd = g_new(NetdevQueueEntry, 1);
visit_type_Netdev(v, NULL, &nd->nd, &error_fatal); visit_type_Netdev(v, NULL, &nd->nd, &error_fatal);
visit_free(v); visit_free(v);
@ -1725,9 +1725,9 @@ void netdev_parse_modern(const char *optarg)
QSIMPLEQ_INSERT_TAIL(&nd_queue, nd, entry); QSIMPLEQ_INSERT_TAIL(&nd_queue, nd, entry);
} }
void net_client_parse(QemuOptsList *opts_list, const char *optarg) void net_client_parse(QemuOptsList *opts_list, const char *optstr)
{ {
if (!qemu_opts_parse_noisily(opts_list, optarg, true)) { if (!qemu_opts_parse_noisily(opts_list, optstr, true)) {
exit(1); exit(1);
} }
} }

View file

@ -94,13 +94,13 @@ static uid_t user_uid = (uid_t)-1; /* -1 -1 >=0 */
static gid_t user_gid = (gid_t)-1; /* -1 -1 >=0 */ static gid_t user_gid = (gid_t)-1; /* -1 -1 >=0 */
/* /*
* Prepare to change user ID. optarg can be one of 3 forms: * Prepare to change user ID. user_id can be one of 3 forms:
* - a username, in which case user ID will be changed to its uid, * - a username, in which case user ID will be changed to its uid,
* with primary and supplementary groups set up too; * with primary and supplementary groups set up too;
* - a numeric uid, in which case only the uid will be set; * - a numeric uid, in which case only the uid will be set;
* - a pair of numeric uid:gid. * - a pair of numeric uid:gid.
*/ */
bool os_set_runas(const char *optarg) bool os_set_runas(const char *user_id)
{ {
unsigned long lv; unsigned long lv;
const char *ep; const char *ep;
@ -108,14 +108,14 @@ bool os_set_runas(const char *optarg)
gid_t got_gid; gid_t got_gid;
int rc; int rc;
user_pwd = getpwnam(optarg); user_pwd = getpwnam(user_id);
if (user_pwd) { if (user_pwd) {
user_uid = -1; user_uid = -1;
user_gid = -1; user_gid = -1;
return true; return true;
} }
rc = qemu_strtoul(optarg, &ep, 0, &lv); rc = qemu_strtoul(user_id, &ep, 0, &lv);
got_uid = lv; /* overflow here is ID in C99 */ got_uid = lv; /* overflow here is ID in C99 */
if (rc || *ep != ':' || got_uid != lv || got_uid == (uid_t)-1) { if (rc || *ep != ':' || got_uid != lv || got_uid == (uid_t)-1) {
return false; return false;
@ -173,9 +173,9 @@ static void change_process_uid(void)
static const char *chroot_dir; static const char *chroot_dir;
void os_set_chroot(const char *optarg) void os_set_chroot(const char *path)
{ {
chroot_dir = optarg; chroot_dir = path;
} }
static void change_root(void) static void change_root(void)

View file

@ -140,12 +140,12 @@ static int plugin_add(void *opaque, const char *name, const char *value,
return 0; return 0;
} }
void qemu_plugin_opt_parse(const char *optarg, QemuPluginList *head) void qemu_plugin_opt_parse(const char *optstr, QemuPluginList *head)
{ {
struct qemu_plugin_parse_arg arg; struct qemu_plugin_parse_arg arg;
QemuOpts *opts; QemuOpts *opts;
opts = qemu_opts_parse_noisily(qemu_find_opts("plugin"), optarg, true); opts = qemu_opts_parse_noisily(qemu_find_opts("plugin"), optstr, true);
if (opts == NULL) { if (opts == NULL) {
exit(1); exit(1);
} }

View file

@ -235,25 +235,25 @@ void help(void)
} }
/* /*
* Is @optarg safe for accumulate_options()? * Is @list safe for accumulate_options()?
* It is when multiple of them can be joined together separated by ','. * It is when multiple of them can be joined together separated by ','.
* To make that work, @optarg must not start with ',' (or else a * To make that work, @list must not start with ',' (or else a
* separating ',' preceding it gets escaped), and it must not end with * separating ',' preceding it gets escaped), and it must not end with
* an odd number of ',' (or else a separating ',' following it gets * an odd number of ',' (or else a separating ',' following it gets
* escaped), or be empty (or else a separating ',' preceding it can * escaped), or be empty (or else a separating ',' preceding it can
* escape a separating ',' following it). * escape a separating ',' following it).
* *
*/ */
static bool is_valid_option_list(const char *optarg) static bool is_valid_option_list(const char *list)
{ {
size_t len = strlen(optarg); size_t len = strlen(list);
size_t i; size_t i;
if (!optarg[0] || optarg[0] == ',') { if (!list[0] || list[0] == ',') {
return false; return false;
} }
for (i = len; i > 0 && optarg[i - 1] == ','; i--) { for (i = len; i > 0 && list[i - 1] == ','; i--) {
} }
if ((len - i) % 2) { if ((len - i) % 2) {
return false; return false;
@ -262,19 +262,19 @@ static bool is_valid_option_list(const char *optarg)
return true; return true;
} }
static int accumulate_options(char **options, char *optarg) static int accumulate_options(char **options, char *list)
{ {
char *new_options; char *new_options;
if (!is_valid_option_list(optarg)) { if (!is_valid_option_list(list)) {
error_report("Invalid option list: %s", optarg); error_report("Invalid option list: %s", list);
return -1; return -1;
} }
if (!*options) { if (!*options) {
*options = g_strdup(optarg); *options = g_strdup(list);
} else { } else {
new_options = g_strdup_printf("%s,%s", *options, optarg); new_options = g_strdup_printf("%s,%s", *options, list);
g_free(*options); g_free(*options);
*options = new_options; *options = new_options;
} }

View file

@ -475,10 +475,10 @@ static int command_loop(void)
return last_error; return last_error;
} }
static void add_user_command(char *optarg) static void add_user_command(char *user_cmd)
{ {
cmdline = g_renew(char *, cmdline, ++ncmdline); cmdline = g_renew(char *, cmdline, ++ncmdline);
cmdline[ncmdline-1] = optarg; cmdline[ncmdline - 1] = user_cmd;
} }
static void reenable_tty_echo(void) static void reenable_tty_echo(void)

View file

@ -259,7 +259,7 @@ static void user_creatable_print_help_from_qdict(QDict *args)
} }
} }
ObjectOptions *user_creatable_parse_str(const char *optarg, Error **errp) ObjectOptions *user_creatable_parse_str(const char *str, Error **errp)
{ {
ERRP_GUARD(); ERRP_GUARD();
QObject *obj; QObject *obj;
@ -267,14 +267,14 @@ ObjectOptions *user_creatable_parse_str(const char *optarg, Error **errp)
Visitor *v; Visitor *v;
ObjectOptions *options; ObjectOptions *options;
if (optarg[0] == '{') { if (str[0] == '{') {
obj = qobject_from_json(optarg, errp); obj = qobject_from_json(str, errp);
if (!obj) { if (!obj) {
return NULL; return NULL;
} }
v = qobject_input_visitor_new(obj); v = qobject_input_visitor_new(obj);
} else { } else {
QDict *args = keyval_parse(optarg, "qom-type", &help, errp); QDict *args = keyval_parse(str, "qom-type", &help, errp);
if (*errp) { if (*errp) {
return NULL; return NULL;
} }
@ -295,12 +295,12 @@ ObjectOptions *user_creatable_parse_str(const char *optarg, Error **errp)
return options; return options;
} }
bool user_creatable_add_from_str(const char *optarg, Error **errp) bool user_creatable_add_from_str(const char *str, Error **errp)
{ {
ERRP_GUARD(); ERRP_GUARD();
ObjectOptions *options; ObjectOptions *options;
options = user_creatable_parse_str(optarg, errp); options = user_creatable_parse_str(str, errp);
if (!options) { if (!options) {
return false; return false;
} }
@ -310,9 +310,9 @@ bool user_creatable_add_from_str(const char *optarg, Error **errp)
return !*errp; return !*errp;
} }
void user_creatable_process_cmdline(const char *optarg) void user_creatable_process_cmdline(const char *cmdline)
{ {
if (!user_creatable_add_from_str(optarg, &error_fatal)) { if (!user_creatable_add_from_str(cmdline, &error_fatal)) {
/* Help was printed */ /* Help was printed */
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }

View file

@ -367,7 +367,6 @@ void do_common_semihosting(CPUState *cs)
target_ulong ul_ret; target_ulong ul_ret;
char * s; char * s;
int nr; int nr;
uint32_t ret;
int64_t elapsed; int64_t elapsed;
nr = common_semi_arg(cs, 0) & 0xffffffffU; nr = common_semi_arg(cs, 0) & 0xffffffffU;
@ -725,6 +724,9 @@ void do_common_semihosting(CPUState *cs)
case TARGET_SYS_EXIT: case TARGET_SYS_EXIT:
case TARGET_SYS_EXIT_EXTENDED: case TARGET_SYS_EXIT_EXTENDED:
{
uint32_t ret;
if (common_semi_sys_exit_extended(cs, nr)) { if (common_semi_sys_exit_extended(cs, nr)) {
/* /*
* The A64 version of SYS_EXIT takes a parameter block, * The A64 version of SYS_EXIT takes a parameter block,
@ -752,6 +754,7 @@ void do_common_semihosting(CPUState *cs)
} }
gdb_exit(ret); gdb_exit(ret);
exit(ret); exit(ret);
}
case TARGET_SYS_ELAPSED: case TARGET_SYS_ELAPSED:
elapsed = get_clock() - clock_start; elapsed = get_clock() - clock_start;

View file

@ -131,10 +131,10 @@ void qemu_semihosting_enable(void)
semihosting.target = SEMIHOSTING_TARGET_AUTO; semihosting.target = SEMIHOSTING_TARGET_AUTO;
} }
int qemu_semihosting_config_options(const char *optarg) int qemu_semihosting_config_options(const char *optstr)
{ {
QemuOptsList *opt_list = qemu_find_opts("semihosting-config"); QemuOptsList *opt_list = qemu_find_opts("semihosting-config");
QemuOpts *opts = qemu_opts_parse_noisily(opt_list, optarg, false); QemuOpts *opts = qemu_opts_parse_noisily(opt_list, optstr, false);
semihosting.enabled = true; semihosting.enabled = true;
@ -155,7 +155,7 @@ int qemu_semihosting_config_options(const char *optarg)
semihosting.target = SEMIHOSTING_TARGET_AUTO; semihosting.target = SEMIHOSTING_TARGET_AUTO;
} else { } else {
error_report("unsupported semihosting-config %s", error_report("unsupported semihosting-config %s",
optarg); optstr);
return 1; return 1;
} }
} else { } else {
@ -165,7 +165,7 @@ int qemu_semihosting_config_options(const char *optarg)
qemu_opt_foreach(opts, add_semihosting_arg, qemu_opt_foreach(opts, add_semihosting_arg,
&semihosting, NULL); &semihosting, NULL);
} else { } else {
error_report("unsupported semihosting-config %s", optarg); error_report("unsupported semihosting-config %s", optstr);
return 1; return 1;
} }

View file

@ -175,15 +175,15 @@ int tpm_init(void)
* Parse the TPM configuration options. * Parse the TPM configuration options.
* To display all available TPM backends the user may use '-tpmdev help' * To display all available TPM backends the user may use '-tpmdev help'
*/ */
int tpm_config_parse(QemuOptsList *opts_list, const char *optarg) int tpm_config_parse(QemuOptsList *opts_list, const char *optstr)
{ {
QemuOpts *opts; QemuOpts *opts;
if (!strcmp(optarg, "help")) { if (!strcmp(optstr, "help")) {
tpm_display_backend_drivers(); tpm_display_backend_drivers();
return -1; return -1;
} }
opts = qemu_opts_parse_noisily(opts_list, optarg, true); opts = qemu_opts_parse_noisily(opts_list, optstr, true);
if (!opts) { if (!opts) {
return -1; return -1;
} }

View file

@ -1066,12 +1066,12 @@ static void select_vgahw(const MachineClass *machine_class, const char *p)
} }
} }
static void parse_display_qapi(const char *optarg) static void parse_display_qapi(const char *str)
{ {
DisplayOptions *opts; DisplayOptions *opts;
Visitor *v; Visitor *v;
v = qobject_input_visitor_new_str(optarg, "type", &error_fatal); v = qobject_input_visitor_new_str(str, "type", &error_fatal);
visit_type_DisplayOptions(v, NULL, &opts, &error_fatal); visit_type_DisplayOptions(v, NULL, &opts, &error_fatal);
QAPI_CLONE_MEMBERS(DisplayOptions, &dpy, opts); QAPI_CLONE_MEMBERS(DisplayOptions, &dpy, opts);
@ -1221,21 +1221,21 @@ static int mon_init_func(void *opaque, QemuOpts *opts, Error **errp)
return monitor_init_opts(opts, errp); return monitor_init_opts(opts, errp);
} }
static void monitor_parse(const char *optarg, const char *mode, bool pretty) static void monitor_parse(const char *str, const char *mode, bool pretty)
{ {
static int monitor_device_index = 0; static int monitor_device_index = 0;
QemuOpts *opts; QemuOpts *opts;
const char *p; const char *p;
char label[32]; char label[32];
if (strstart(optarg, "chardev:", &p)) { if (strstart(str, "chardev:", &p)) {
snprintf(label, sizeof(label), "%s", p); snprintf(label, sizeof(label), "%s", p);
} else { } else {
snprintf(label, sizeof(label), "compat_monitor%d", snprintf(label, sizeof(label), "compat_monitor%d",
monitor_device_index); monitor_device_index);
opts = qemu_chr_parse_compat(label, optarg, true); opts = qemu_chr_parse_compat(label, str, true);
if (!opts) { if (!opts) {
error_report("parse error: %s", optarg); error_report("parse error: %s", str);
exit(1); exit(1);
} }
} }
@ -1631,13 +1631,13 @@ static const QEMUOption *lookup_opt(int argc, char **argv,
static MachineClass *select_machine(QDict *qdict, Error **errp) static MachineClass *select_machine(QDict *qdict, Error **errp)
{ {
const char *optarg = qdict_get_try_str(qdict, "type"); const char *machine_type = qdict_get_try_str(qdict, "type");
GSList *machines = object_class_get_list(TYPE_MACHINE, false); GSList *machines = object_class_get_list(TYPE_MACHINE, false);
MachineClass *machine_class; MachineClass *machine_class;
Error *local_err = NULL; Error *local_err = NULL;
if (optarg) { if (machine_type) {
machine_class = find_machine(optarg, machines); machine_class = find_machine(machine_type, machines);
qdict_del(qdict, "type"); qdict_del(qdict, "type");
if (!machine_class) { if (!machine_class) {
error_setg(&local_err, "unsupported machine type"); error_setg(&local_err, "unsupported machine type");
@ -1781,20 +1781,20 @@ static void object_option_add_visitor(Visitor *v)
QTAILQ_INSERT_TAIL(&object_opts, opt, next); QTAILQ_INSERT_TAIL(&object_opts, opt, next);
} }
static void object_option_parse(const char *optarg) static void object_option_parse(const char *str)
{ {
QemuOpts *opts; QemuOpts *opts;
const char *type; const char *type;
Visitor *v; Visitor *v;
if (optarg[0] == '{') { if (str[0] == '{') {
QObject *obj = qobject_from_json(optarg, &error_fatal); QObject *obj = qobject_from_json(str, &error_fatal);
v = qobject_input_visitor_new(obj); v = qobject_input_visitor_new(obj);
qobject_unref(obj); qobject_unref(obj);
} else { } else {
opts = qemu_opts_parse_noisily(qemu_find_opts("object"), opts = qemu_opts_parse_noisily(qemu_find_opts("object"),
optarg, true); str, true);
if (!opts) { if (!opts) {
exit(1); exit(1);
} }

View file

@ -36,7 +36,7 @@ void qemu_semihosting_enable(void)
{ {
} }
int qemu_semihosting_config_options(const char *optarg) int qemu_semihosting_config_options(const char *optstr)
{ {
return 1; return 1;
} }

View file

@ -2020,13 +2020,13 @@ void helper_vsum4ubs(CPUPPCState *env, ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
ppc_avr_t result; \ ppc_avr_t result; \
\ \
for (i = 0; i < ARRAY_SIZE(r->u32); i++) { \ for (i = 0; i < ARRAY_SIZE(r->u32); i++) { \
uint16_t e = b->u16[hi ? i : i + 4]; \ uint16_t _e = b->u16[hi ? i : i + 4]; \
uint8_t a = (e >> 15) ? 0xff : 0; \ uint8_t _a = (_e >> 15) ? 0xff : 0; \
uint8_t r = (e >> 10) & 0x1f; \ uint8_t _r = (_e >> 10) & 0x1f; \
uint8_t g = (e >> 5) & 0x1f; \ uint8_t _g = (_e >> 5) & 0x1f; \
uint8_t b = e & 0x1f; \ uint8_t _b = _e & 0x1f; \
\ \
result.u32[i] = (a << 24) | (r << 16) | (g << 8) | b; \ result.u32[i] = (_a << 24) | (_r << 16) | (_g << 8) | _b; \
} \ } \
*r = result; \ *r = result; \
} }

View file

@ -960,8 +960,6 @@ int kvm_arch_put_registers(CPUState *cs, int level)
} }
if (cap_one_reg) { if (cap_one_reg) {
int i;
/* /*
* We deliberately ignore errors here, for kernels which have * We deliberately ignore errors here, for kernels which have
* the ONE_REG calls, but don't support the specific * the ONE_REG calls, but don't support the specific
@ -1262,8 +1260,6 @@ int kvm_arch_get_registers(CPUState *cs)
} }
if (cap_one_reg) { if (cap_one_reg) {
int i;
/* /*
* We deliberately ignore errors here, for kernels which have * We deliberately ignore errors here, for kernels which have
* the ONE_REG calls, but don't support the specific * the ONE_REG calls, but don't support the specific

View file

@ -285,10 +285,10 @@ bool trace_init_backends(void)
return true; return true;
} }
void trace_opt_parse(const char *optarg) void trace_opt_parse(const char *optstr)
{ {
QemuOpts *opts = qemu_opts_parse_noisily(qemu_find_opts("trace"), QemuOpts *opts = qemu_opts_parse_noisily(qemu_find_opts("trace"),
optarg, true); optstr, true);
if (!opts) { if (!opts) {
exit(1); exit(1);
} }

View file

@ -197,11 +197,11 @@ extern QemuOptsList qemu_trace_opts;
/** /**
* trace_opt_parse: * trace_opt_parse:
* @optarg: A string argument of --trace command line argument * @optstr: A string argument of --trace command line argument
* *
* Initialize tracing subsystem. * Initialize tracing subsystem.
*/ */
void trace_opt_parse(const char *optarg); void trace_opt_parse(const char *optstr);
/** /**
* trace_get_vcpu_event_count: * trace_get_vcpu_event_count:

View file

@ -343,9 +343,9 @@ QemuCocoaView *cocoaView;
static CGEventRef handleTapEvent(CGEventTapProxy proxy, CGEventType type, CGEventRef cgEvent, void *userInfo) static CGEventRef handleTapEvent(CGEventTapProxy proxy, CGEventType type, CGEventRef cgEvent, void *userInfo)
{ {
QemuCocoaView *cocoaView = userInfo; QemuCocoaView *view = userInfo;
NSEvent *event = [NSEvent eventWithCGEvent:cgEvent]; NSEvent *event = [NSEvent eventWithCGEvent:cgEvent];
if ([cocoaView isMouseGrabbed] && [cocoaView handleEvent:event]) { if ([view isMouseGrabbed] && [view handleEvent:event]) {
COCOA_DEBUG("Global events tap: qemu handled the event, capturing!\n"); COCOA_DEBUG("Global events tap: qemu handled the event, capturing!\n");
return NULL; return NULL;
} }

View file

@ -1144,7 +1144,6 @@ char *get_relocated_path(const char *dir)
{ {
size_t prefix_len = strlen(CONFIG_PREFIX); size_t prefix_len = strlen(CONFIG_PREFIX);
const char *bindir = CONFIG_BINDIR; const char *bindir = CONFIG_BINDIR;
const char *exec_dir = qemu_get_exec_dir();
GString *result; GString *result;
int len_dir, len_bindir; int len_dir, len_bindir;

View file

@ -87,11 +87,11 @@ void qemu_guest_random_seed_thread_part2(uint64_t seed)
} }
} }
int qemu_guest_random_seed_main(const char *optarg, Error **errp) int qemu_guest_random_seed_main(const char *seedstr, Error **errp)
{ {
uint64_t seed; uint64_t seed;
if (parse_uint_full(optarg, 0, &seed)) { if (parse_uint_full(seedstr, 0, &seed)) {
error_setg(errp, "Invalid seed number: %s", optarg); error_setg(errp, "Invalid seed number: %s", seedstr);
return -1; return -1;
} else { } else {
deterministic = true; deterministic = true;