Error reporting patches for 2016-06-20

-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIbBAABAgAGBQJXaAQPAAoJEDhwtADrkYZTbPMP+OmXlf1IwcUONhaHqD0SXAdC
 Q5NNHheNHbIdzrsOmgj2GAxCeGG08REPrdYLb8N9lI3Fev8ggQ0v3d9qiStL6Nvz
 2B7DeTxXba9Qmc2gY86RR4f7T6VK+8k1Kj9f3YcAoXHucdjDLRmtUozwES3Kk8mn
 oeBqd07yuTAO93xQhF6BDv3mfagPZV+kp15Se04ufWPpT9eG3Cp9Pl4/Yad/wJUr
 2B4pIvYnhISVlZIOvpuzdydBaCb/U0YefjWBDkawLwRBtM/kpNKoDdqr2UA0yChQ
 Xulgpt+UQLZ4aOYGLkzqBT7v3kDeEnYUFDdE03xZBLbHddOU05NEhLgzRVUEAdUS
 EAKWvWu692USDh9a2r0AYLqZW6J0+Fyi4fZ34gSuP69oi74CIvjJHDAEwsSdt6bm
 WHCchvfIk9kinzGiFA3hkAbVWAbI0EpB0J7k3mgCVVVelBpF9b9U4M2ydx9ZPufX
 t4ULXxQO9Qyxr7r0uiznugQAjIRwLMDOPPd1F5Vi+LX0wF3Pcrtc/F+3ehoLBjBD
 6zZA5lZVlUEISdzzytfjeX3ch5vRFwlujrTd2anxRuduuBV1/ztvE1v0Nsiii6Sw
 15BaHQJvBnMnAIO5LfhnAaVpIBk0jpQpwVyRcNUpeZ1VU2qlqVS4zxYZ0FDQgyer
 IZa1qYJ0Sz+oMkq9RXU=
 =TptL
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/armbru/tags/pull-error-2016-06-20' into staging

Error reporting patches for 2016-06-20

# gpg: Signature made Mon 20 Jun 2016 15:56:15 BST
# gpg:                using RSA key 0x3870B400EB918653
# gpg: Good signature from "Markus Armbruster <armbru@redhat.com>"
# gpg:                 aka "Markus Armbruster <armbru@pond.sub.org>"
# Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867  4E5F 3870 B400 EB91 8653

* remotes/armbru/tags/pull-error-2016-06-20:
  log: Fix qemu_set_log_filename() error handling
  log: Fix qemu_set_dfilter_ranges() error reporting
  log: Plug memory leak on multiple -dfilter
  coccinelle: Remove unnecessary variables for function return value
  error: Remove unnecessary local_err variables
  error: Remove NULL checks on error_propagate() calls
  vl: Error messages need to go to stderr, fix some

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2016-06-20 16:19:18 +01:00
commit 7fa124b273
68 changed files with 270 additions and 483 deletions

View File

@ -1131,8 +1131,6 @@ static void audio_timer (void *opaque)
*/ */
int AUD_write (SWVoiceOut *sw, void *buf, int size) int AUD_write (SWVoiceOut *sw, void *buf, int size)
{ {
int bytes;
if (!sw) { if (!sw) {
/* XXX: Consider options */ /* XXX: Consider options */
return size; return size;
@ -1143,14 +1141,11 @@ int AUD_write (SWVoiceOut *sw, void *buf, int size)
return 0; return 0;
} }
bytes = sw->hw->pcm_ops->write (sw, buf, size); return sw->hw->pcm_ops->write(sw, buf, size);
return bytes;
} }
int AUD_read (SWVoiceIn *sw, void *buf, int size) int AUD_read (SWVoiceIn *sw, void *buf, int size)
{ {
int bytes;
if (!sw) { if (!sw) {
/* XXX: Consider options */ /* XXX: Consider options */
return size; return size;
@ -1161,8 +1156,7 @@ int AUD_read (SWVoiceIn *sw, void *buf, int size)
return 0; return 0;
} }
bytes = sw->hw->pcm_ops->read (sw, buf, size); return sw->hw->pcm_ops->read(sw, buf, size);
return bytes;
} }
int AUD_get_buffer_size_out (SWVoiceOut *sw) int AUD_get_buffer_size_out (SWVoiceOut *sw)

20
block.c
View File

@ -301,9 +301,7 @@ static void coroutine_fn bdrv_create_co_entry(void *opaque)
assert(cco->drv); assert(cco->drv);
ret = cco->drv->bdrv_create(cco->filename, cco->opts, &local_err); ret = cco->drv->bdrv_create(cco->filename, cco->opts, &local_err);
if (local_err) { error_propagate(&cco->err, local_err);
error_propagate(&cco->err, local_err);
}
cco->ret = ret; cco->ret = ret;
} }
@ -364,9 +362,7 @@ int bdrv_create_file(const char *filename, QemuOpts *opts, Error **errp)
} }
ret = bdrv_create(drv, filename, opts, &local_err); ret = bdrv_create(drv, filename, opts, &local_err);
if (local_err) { error_propagate(errp, local_err);
error_propagate(errp, local_err);
}
return ret; return ret;
} }
@ -1763,18 +1759,14 @@ fail:
QDECREF(options); QDECREF(options);
bs->options = NULL; bs->options = NULL;
bdrv_unref(bs); bdrv_unref(bs);
if (local_err) { error_propagate(errp, local_err);
error_propagate(errp, local_err);
}
return NULL; return NULL;
close_and_fail: close_and_fail:
bdrv_unref(bs); bdrv_unref(bs);
QDECREF(snapshot_options); QDECREF(snapshot_options);
QDECREF(options); QDECREF(options);
if (local_err) { error_propagate(errp, local_err);
error_propagate(errp, local_err);
}
return NULL; return NULL;
} }
@ -3599,9 +3591,7 @@ void bdrv_img_create(const char *filename, const char *fmt,
out: out:
qemu_opts_del(opts); qemu_opts_del(opts);
qemu_opts_free(create_opts); qemu_opts_free(create_opts);
if (local_err) { error_propagate(errp, local_err);
error_propagate(errp, local_err);
}
} }
AioContext *bdrv_get_aio_context(BlockDriverState *bs) AioContext *bdrv_get_aio_context(BlockDriverState *bs)

View File

@ -974,11 +974,9 @@ err_exit2:
static int64_t qemu_archipelago_getlength(BlockDriverState *bs) static int64_t qemu_archipelago_getlength(BlockDriverState *bs)
{ {
int64_t ret;
BDRVArchipelagoState *s = bs->opaque; BDRVArchipelagoState *s = bs->opaque;
ret = archipelago_volume_info(s); return archipelago_volume_info(s);
return ret;
} }
static int qemu_archipelago_truncate(BlockDriverState *bs, int64_t offset) static int qemu_archipelago_truncate(BlockDriverState *bs, int64_t offset)

View File

@ -154,11 +154,9 @@ static int l2_load(BlockDriverState *bs, uint64_t l2_offset,
uint64_t **l2_table) uint64_t **l2_table)
{ {
BDRVQcow2State *s = bs->opaque; BDRVQcow2State *s = bs->opaque;
int ret;
ret = qcow2_cache_get(bs, s->l2_table_cache, l2_offset, (void**) l2_table); return qcow2_cache_get(bs, s->l2_table_cache, l2_offset,
(void **)l2_table);
return ret;
} }
/* /*

View File

@ -218,13 +218,10 @@ static int load_refcount_block(BlockDriverState *bs,
void **refcount_block) void **refcount_block)
{ {
BDRVQcow2State *s = bs->opaque; BDRVQcow2State *s = bs->opaque;
int ret;
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_LOAD); BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_LOAD);
ret = qcow2_cache_get(bs, s->refcount_block_cache, refcount_block_offset, return qcow2_cache_get(bs, s->refcount_block_cache, refcount_block_offset,
refcount_block); refcount_block);
return ret;
} }
/* /*

View File

@ -2403,9 +2403,7 @@ static int qcow2_create(const char *filename, QemuOpts *opts, Error **errp)
ret = qcow2_create2(filename, size, backing_file, backing_fmt, flags, ret = qcow2_create2(filename, size, backing_file, backing_fmt, flags,
cluster_size, prealloc, opts, version, refcount_order, cluster_size, prealloc, opts, version, refcount_order,
&local_err); &local_err);
if (local_err) { error_propagate(errp, local_err);
error_propagate(errp, local_err);
}
finish: finish:
g_free(backing_file); g_free(backing_file);

View File

@ -971,9 +971,7 @@ close_exit:
exit: exit:
qemu_opts_del(opts); qemu_opts_del(opts);
/* propagate error */ /* propagate error */
if (local_err) { error_propagate(errp, local_err);
error_propagate(errp, local_err);
}
return ret; return ret;
} }

View File

@ -582,15 +582,9 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp) Error **errp)
{ {
BDRVRawState *s = bs->opaque; BDRVRawState *s = bs->opaque;
Error *local_err = NULL;
int ret;
s->type = FTYPE_FILE; s->type = FTYPE_FILE;
ret = raw_open_common(bs, options, flags, 0, &local_err); return raw_open_common(bs, options, flags, 0, errp);
if (local_err) {
error_propagate(errp, local_err);
}
return ret;
} }
static int raw_reopen_prepare(BDRVReopenState *state, static int raw_reopen_prepare(BDRVReopenState *state,
@ -2236,9 +2230,7 @@ hdev_open_Mac_error:
ret = raw_open_common(bs, options, flags, 0, &local_err); ret = raw_open_common(bs, options, flags, 0, &local_err);
if (ret < 0) { if (ret < 0) {
if (local_err) { error_propagate(errp, local_err);
error_propagate(errp, local_err);
}
#if defined(__APPLE__) && defined(__MACH__) #if defined(__APPLE__) && defined(__MACH__)
if (*bsd_path) { if (*bsd_path) {
filename = bsd_path; filename = bsd_path;
@ -2443,17 +2435,11 @@ static int cdrom_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp) Error **errp)
{ {
BDRVRawState *s = bs->opaque; BDRVRawState *s = bs->opaque;
Error *local_err = NULL;
int ret;
s->type = FTYPE_CD; s->type = FTYPE_CD;
/* open will not fail even if no CD is inserted, so add O_NONBLOCK */ /* open will not fail even if no CD is inserted, so add O_NONBLOCK */
ret = raw_open_common(bs, options, flags, O_NONBLOCK, &local_err); return raw_open_common(bs, options, flags, O_NONBLOCK, errp);
if (local_err) {
error_propagate(errp, local_err);
}
return ret;
} }
static int cdrom_probe_device(const char *filename) static int cdrom_probe_device(const char *filename)
@ -2571,9 +2557,7 @@ static int cdrom_open(BlockDriverState *bs, QDict *options, int flags,
ret = raw_open_common(bs, options, flags, 0, &local_err); ret = raw_open_common(bs, options, flags, 0, &local_err);
if (ret) { if (ret) {
if (local_err) { error_propagate(errp, local_err);
error_propagate(errp, local_err);
}
return ret; return ret;
} }

View File

@ -190,14 +190,7 @@ static int raw_has_zero_init(BlockDriverState *bs)
static int raw_create(const char *filename, QemuOpts *opts, Error **errp) static int raw_create(const char *filename, QemuOpts *opts, Error **errp)
{ {
Error *local_err = NULL; return bdrv_create_file(filename, opts, errp);
int ret;
ret = bdrv_create_file(filename, opts, &local_err);
if (local_err) {
error_propagate(errp, local_err);
}
return ret;
} }
static int raw_open(BlockDriverState *bs, QDict *options, int flags, static int raw_open(BlockDriverState *bs, QDict *options, int flags,

View File

@ -883,10 +883,8 @@ static int qemu_rbd_snap_rollback(BlockDriverState *bs,
const char *snapshot_name) const char *snapshot_name)
{ {
BDRVRBDState *s = bs->opaque; BDRVRBDState *s = bs->opaque;
int r;
r = rbd_snap_rollback(s->image, snapshot_name); return rbd_snap_rollback(s->image, snapshot_name);
return r;
} }
static int qemu_rbd_snap_list(BlockDriverState *bs, static int qemu_rbd_snap_list(BlockDriverState *bs,

View File

@ -358,9 +358,7 @@ int bdrv_snapshot_load_tmp_by_id_or_name(BlockDriverState *bs,
ret = bdrv_snapshot_load_tmp(bs, NULL, id_or_name, &local_err); ret = bdrv_snapshot_load_tmp(bs, NULL, id_or_name, &local_err);
} }
if (local_err) { error_propagate(errp, local_err);
error_propagate(errp, local_err);
}
return ret; return ret;
} }

View File

@ -1260,15 +1260,13 @@ static VmdkExtent *find_extent(BDRVVmdkState *s,
static inline uint64_t vmdk_find_offset_in_cluster(VmdkExtent *extent, static inline uint64_t vmdk_find_offset_in_cluster(VmdkExtent *extent,
int64_t offset) int64_t offset)
{ {
uint64_t offset_in_cluster, extent_begin_offset, extent_relative_offset; uint64_t extent_begin_offset, extent_relative_offset;
uint64_t cluster_size = extent->cluster_sectors * BDRV_SECTOR_SIZE; uint64_t cluster_size = extent->cluster_sectors * BDRV_SECTOR_SIZE;
extent_begin_offset = extent_begin_offset =
(extent->end_sector - extent->sectors) * BDRV_SECTOR_SIZE; (extent->end_sector - extent->sectors) * BDRV_SECTOR_SIZE;
extent_relative_offset = offset - extent_begin_offset; extent_relative_offset = offset - extent_begin_offset;
offset_in_cluster = extent_relative_offset % cluster_size; return extent_relative_offset % cluster_size;
return offset_in_cluster;
} }
static inline uint64_t vmdk_find_index_in_cluster(VmdkExtent *extent, static inline uint64_t vmdk_find_index_in_cluster(VmdkExtent *extent,

View File

@ -114,15 +114,12 @@ static inline int array_ensure_allocated(array_t* array, int index)
static inline void* array_get_next(array_t* array) { static inline void* array_get_next(array_t* array) {
unsigned int next = array->next; unsigned int next = array->next;
void* result;
if (array_ensure_allocated(array, next) < 0) if (array_ensure_allocated(array, next) < 0)
return NULL; return NULL;
array->next = next + 1; array->next = next + 1;
result = array_get(array, next); return array_get(array, next);
return result;
} }
static inline void* array_insert(array_t* array,unsigned int index,unsigned int count) { static inline void* array_insert(array_t* array,unsigned int index,unsigned int count) {

View File

@ -3644,9 +3644,7 @@ void qmp_drive_mirror(const char *device, const char *target,
has_unmap, unmap, has_unmap, unmap,
&local_err); &local_err);
bdrv_unref(target_bs); bdrv_unref(target_bs);
if (local_err) { error_propagate(errp, local_err);
error_propagate(errp, local_err);
}
out: out:
aio_context_release(aio_context); aio_context_release(aio_context);
} }
@ -3701,9 +3699,7 @@ void qmp_blockdev_mirror(const char *device, const char *target,
has_on_target_error, on_target_error, has_on_target_error, on_target_error,
true, true, true, true,
&local_err); &local_err);
if (local_err) { error_propagate(errp, local_err);
error_propagate(errp, local_err);
}
aio_context_release(aio_context); aio_context_release(aio_context);
} }
@ -3914,9 +3910,7 @@ void qmp_change_backing_file(const char *device,
if (ro) { if (ro) {
bdrv_reopen(image_bs, open_flags, &local_err); bdrv_reopen(image_bs, open_flags, &local_err);
if (local_err) { error_propagate(errp, local_err);
error_propagate(errp, local_err); /* will preserve prior errp */
}
} }
out: out:

View File

@ -302,9 +302,7 @@ static void device_set_bootindex(Object *obj, Visitor *v, const char *name,
add_boot_device_path(*prop->bootindex, prop->dev, prop->suffix); add_boot_device_path(*prop->bootindex, prop->dev, prop->suffix);
out: out:
if (local_err) { error_propagate(errp, local_err);
error_propagate(errp, local_err);
}
} }
static void property_release_bootindex(Object *obj, const char *name, static void property_release_bootindex(Object *obj, const char *name,

View File

@ -19,6 +19,7 @@
#include "qemu/osdep.h" #include "qemu/osdep.h"
#include <machine/trap.h> #include <machine/trap.h>
#include "qapi/error.h"
#include "qemu.h" #include "qemu.h"
#include "qemu/path.h" #include "qemu/path.h"
#include "qemu/help_option.h" #include "qemu/help_option.h"
@ -847,7 +848,7 @@ int main(int argc, char **argv)
/* init debug */ /* init debug */
qemu_log_needs_buffers(); qemu_log_needs_buffers();
qemu_set_log_filename(log_file); qemu_set_log_filename(log_file, &error_fatal);
if (log_mask) { if (log_mask) {
int mask; int mask;

4
dump.c
View File

@ -918,9 +918,7 @@ static void write_dump_header(DumpState *s, Error **errp)
} else { } else {
create_header64(s, &local_err); create_header64(s, &local_err);
} }
if (local_err) { error_propagate(errp, local_err);
error_propagate(errp, local_err);
}
} }
static size_t dump_bitmap_get_bufsize(DumpState *s) static size_t dump_bitmap_get_bufsize(DumpState *s)

View File

@ -324,12 +324,9 @@ static void aml_free(gpointer data, gpointer user_data)
Aml *init_aml_allocator(void) Aml *init_aml_allocator(void)
{ {
Aml *var;
assert(!alloc_list); assert(!alloc_list);
alloc_list = g_ptr_array_new(); alloc_list = g_ptr_array_new();
var = aml_alloc(); return aml_alloc();
return var;
} }
void free_aml_allocator(void) void free_aml_allocator(void)
@ -451,12 +448,10 @@ Aml *aml_name_decl(const char *name, Aml *val)
/* ACPI 1.0b: 16.2.6.1 Arg Objects Encoding */ /* ACPI 1.0b: 16.2.6.1 Arg Objects Encoding */
Aml *aml_arg(int pos) Aml *aml_arg(int pos)
{ {
Aml *var;
uint8_t op = 0x68 /* ARG0 op */ + pos; uint8_t op = 0x68 /* ARG0 op */ + pos;
assert(pos <= 6); assert(pos <= 6);
var = aml_opcode(op); return aml_opcode(op);
return var;
} }
/* ACPI 2.0a: 17.2.4.4 Type 2 Opcodes Encoding: DefToInteger */ /* ACPI 2.0a: 17.2.4.4 Type 2 Opcodes Encoding: DefToInteger */
@ -1082,12 +1077,10 @@ Aml *aml_string(const char *name_format, ...)
/* ACPI 1.0b: 16.2.6.2 Local Objects Encoding */ /* ACPI 1.0b: 16.2.6.2 Local Objects Encoding */
Aml *aml_local(int num) Aml *aml_local(int num)
{ {
Aml *var;
uint8_t op = 0x60 /* Local0Op */ + num; uint8_t op = 0x60 /* Local0Op */ + num;
assert(num <= 7); assert(num <= 7);
var = aml_opcode(op); return aml_opcode(op);
return var;
} }
/* ACPI 2.0a: 17.2.2 Data Objects Encoding: DefVarPackage */ /* ACPI 2.0a: 17.2.2 Data Objects Encoding: DefVarPackage */

View File

@ -219,10 +219,7 @@ static void intel_hda_reset(DeviceState *dev);
static hwaddr intel_hda_addr(uint32_t lbase, uint32_t ubase) static hwaddr intel_hda_addr(uint32_t lbase, uint32_t ubase)
{ {
hwaddr addr; return ((uint64_t)ubase << 32) | lbase;
addr = ((uint64_t)ubase << 32) | lbase;
return addr;
} }
static void intel_hda_update_int_sts(IntelHDAState *d) static void intel_hda_update_int_sts(IntelHDAState *d)

View File

@ -700,9 +700,7 @@ static void vbe_update_vgaregs(VGACommonState *s)
static uint32_t vbe_ioport_read_index(void *opaque, uint32_t addr) static uint32_t vbe_ioport_read_index(void *opaque, uint32_t addr)
{ {
VGACommonState *s = opaque; VGACommonState *s = opaque;
uint32_t val; return s->vbe_index;
val = s->vbe_index;
return val;
} }
uint32_t vbe_ioport_read_data(void *opaque, uint32_t addr) uint32_t vbe_ioport_read_data(void *opaque, uint32_t addr)

View File

@ -233,9 +233,7 @@ static void ide_dev_set_bootindex(Object *obj, Visitor *v, const char *name,
d->unit ? "/disk@1" : "/disk@0"); d->unit ? "/disk@1" : "/disk@0");
} }
out: out:
if (local_err) { error_propagate(errp, local_err);
error_propagate(errp, local_err);
}
} }
static void ide_dev_instance_init(Object *obj) static void ide_dev_instance_init(Object *obj)

View File

@ -195,7 +195,7 @@ static int kvm_s390_register_io_adapter(S390FLICState *fs, uint32_t id,
.swap = swap, .swap = swap,
}; };
KVMS390FLICState *flic = KVM_S390_FLIC(fs); KVMS390FLICState *flic = KVM_S390_FLIC(fs);
int r, ret; int r;
struct kvm_device_attr attr = { struct kvm_device_attr attr = {
.group = KVM_DEV_FLIC_ADAPTER_REGISTER, .group = KVM_DEV_FLIC_ADAPTER_REGISTER,
.addr = (uint64_t)&adapter, .addr = (uint64_t)&adapter,
@ -208,8 +208,7 @@ static int kvm_s390_register_io_adapter(S390FLICState *fs, uint32_t id,
r = ioctl(flic->fd, KVM_SET_DEVICE_ATTR, &attr); r = ioctl(flic->fd, KVM_SET_DEVICE_ATTR, &attr);
ret = r ? -errno : 0; return r ? -errno : 0;
return ret;
} }
static int kvm_s390_io_adapter_map(S390FLICState *fs, uint32_t id, static int kvm_s390_io_adapter_map(S390FLICState *fs, uint32_t id,

View File

@ -127,9 +127,7 @@ static void isa_ne2000_set_bootindex(Object *obj, Visitor *v,
s->c.bootindex = boot_index; s->c.bootindex = boot_index;
out: out:
if (local_err) { error_propagate(errp, local_err);
error_propagate(errp, local_err);
}
} }
static void isa_ne2000_instance_init(Object *obj) static void isa_ne2000_instance_init(Object *obj)

View File

@ -62,12 +62,9 @@ typedef struct UNINState {
static int pci_unin_map_irq(PCIDevice *pci_dev, int irq_num) static int pci_unin_map_irq(PCIDevice *pci_dev, int irq_num)
{ {
int retval;
int devfn = pci_dev->devfn & 0x00FFFFFF; int devfn = pci_dev->devfn & 0x00FFFFFF;
retval = (((devfn >> 11) & 0x1F) + irq_num) & 3; return (((devfn >> 11) & 0x1F) + irq_num) & 3;
return retval;
} }
static void pci_unin_set_irq(void *opaque, int irq_num, int level) static void pci_unin_set_irq(void *opaque, int irq_num, int level)

View File

@ -57,12 +57,9 @@ static char *spapr_vio_get_dev_name(DeviceState *qdev)
{ {
VIOsPAPRDevice *dev = VIO_SPAPR_DEVICE(qdev); VIOsPAPRDevice *dev = VIO_SPAPR_DEVICE(qdev);
VIOsPAPRDeviceClass *pc = VIO_SPAPR_DEVICE_GET_CLASS(dev); VIOsPAPRDeviceClass *pc = VIO_SPAPR_DEVICE_GET_CLASS(dev);
char *name;
/* Device tree style name device@reg */ /* Device tree style name device@reg */
name = g_strdup_printf("%s@%x", pc->dt_name, dev->reg); return g_strdup_printf("%s@%x", pc->dt_name, dev->reg);
return name;
} }
static void spapr_vio_bus_class_init(ObjectClass *klass, void *data) static void spapr_vio_bus_class_init(ObjectClass *klass, void *data)

View File

@ -180,10 +180,8 @@ static HotplugHandler *s390_get_hotplug_handler(MachineState *machine,
static void s390_hot_add_cpu(const int64_t id, Error **errp) static void s390_hot_add_cpu(const int64_t id, Error **errp)
{ {
MachineState *machine = MACHINE(qdev_get_machine()); MachineState *machine = MACHINE(qdev_get_machine());
Error *err = NULL;
s390x_new_cpu(machine->cpu_model, id, &err); s390x_new_cpu(machine->cpu_model, id, errp);
error_propagate(errp, err);
} }
static void ccw_machine_class_init(ObjectClass *oc, void *data) static void ccw_machine_class_init(ObjectClass *oc, void *data)

View File

@ -884,15 +884,11 @@ static void virtio_ccw_net_realize(VirtioCcwDevice *ccw_dev, Error **errp)
DeviceState *qdev = DEVICE(ccw_dev); DeviceState *qdev = DEVICE(ccw_dev);
VirtIONetCcw *dev = VIRTIO_NET_CCW(ccw_dev); VirtIONetCcw *dev = VIRTIO_NET_CCW(ccw_dev);
DeviceState *vdev = DEVICE(&dev->vdev); DeviceState *vdev = DEVICE(&dev->vdev);
Error *err = NULL;
virtio_net_set_netclient_name(&dev->vdev, qdev->id, virtio_net_set_netclient_name(&dev->vdev, qdev->id,
object_get_typename(OBJECT(qdev))); object_get_typename(OBJECT(qdev)));
qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus)); qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
object_property_set_bool(OBJECT(vdev), true, "realized", &err); object_property_set_bool(OBJECT(vdev), true, "realized", errp);
if (err) {
error_propagate(errp, err);
}
} }
static void virtio_ccw_net_instance_init(Object *obj) static void virtio_ccw_net_instance_init(Object *obj)
@ -909,13 +905,9 @@ static void virtio_ccw_blk_realize(VirtioCcwDevice *ccw_dev, Error **errp)
{ {
VirtIOBlkCcw *dev = VIRTIO_BLK_CCW(ccw_dev); VirtIOBlkCcw *dev = VIRTIO_BLK_CCW(ccw_dev);
DeviceState *vdev = DEVICE(&dev->vdev); DeviceState *vdev = DEVICE(&dev->vdev);
Error *err = NULL;
qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus)); qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
object_property_set_bool(OBJECT(vdev), true, "realized", &err); object_property_set_bool(OBJECT(vdev), true, "realized", errp);
if (err) {
error_propagate(errp, err);
}
} }
static void virtio_ccw_blk_instance_init(Object *obj) static void virtio_ccw_blk_instance_init(Object *obj)
@ -935,7 +927,6 @@ static void virtio_ccw_serial_realize(VirtioCcwDevice *ccw_dev, Error **errp)
VirtioSerialCcw *dev = VIRTIO_SERIAL_CCW(ccw_dev); VirtioSerialCcw *dev = VIRTIO_SERIAL_CCW(ccw_dev);
DeviceState *vdev = DEVICE(&dev->vdev); DeviceState *vdev = DEVICE(&dev->vdev);
DeviceState *proxy = DEVICE(ccw_dev); DeviceState *proxy = DEVICE(ccw_dev);
Error *err = NULL;
char *bus_name; char *bus_name;
/* /*
@ -949,10 +940,7 @@ static void virtio_ccw_serial_realize(VirtioCcwDevice *ccw_dev, Error **errp)
} }
qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus)); qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
object_property_set_bool(OBJECT(vdev), true, "realized", &err); object_property_set_bool(OBJECT(vdev), true, "realized", errp);
if (err) {
error_propagate(errp, err);
}
} }
@ -968,13 +956,9 @@ static void virtio_ccw_balloon_realize(VirtioCcwDevice *ccw_dev, Error **errp)
{ {
VirtIOBalloonCcw *dev = VIRTIO_BALLOON_CCW(ccw_dev); VirtIOBalloonCcw *dev = VIRTIO_BALLOON_CCW(ccw_dev);
DeviceState *vdev = DEVICE(&dev->vdev); DeviceState *vdev = DEVICE(&dev->vdev);
Error *err = NULL;
qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus)); qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
object_property_set_bool(OBJECT(vdev), true, "realized", &err); object_property_set_bool(OBJECT(vdev), true, "realized", errp);
if (err) {
error_propagate(errp, err);
}
} }
static void virtio_ccw_balloon_instance_init(Object *obj) static void virtio_ccw_balloon_instance_init(Object *obj)
@ -995,7 +979,6 @@ static void virtio_ccw_scsi_realize(VirtioCcwDevice *ccw_dev, Error **errp)
VirtIOSCSICcw *dev = VIRTIO_SCSI_CCW(ccw_dev); VirtIOSCSICcw *dev = VIRTIO_SCSI_CCW(ccw_dev);
DeviceState *vdev = DEVICE(&dev->vdev); DeviceState *vdev = DEVICE(&dev->vdev);
DeviceState *qdev = DEVICE(ccw_dev); DeviceState *qdev = DEVICE(ccw_dev);
Error *err = NULL;
char *bus_name; char *bus_name;
/* /*
@ -1009,10 +992,7 @@ static void virtio_ccw_scsi_realize(VirtioCcwDevice *ccw_dev, Error **errp)
} }
qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus)); qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
object_property_set_bool(OBJECT(vdev), true, "realized", &err); object_property_set_bool(OBJECT(vdev), true, "realized", errp);
if (err) {
error_propagate(errp, err);
}
} }
static void virtio_ccw_scsi_instance_init(Object *obj) static void virtio_ccw_scsi_instance_init(Object *obj)
@ -1030,13 +1010,9 @@ static void vhost_ccw_scsi_realize(VirtioCcwDevice *ccw_dev, Error **errp)
{ {
VHostSCSICcw *dev = VHOST_SCSI_CCW(ccw_dev); VHostSCSICcw *dev = VHOST_SCSI_CCW(ccw_dev);
DeviceState *vdev = DEVICE(&dev->vdev); DeviceState *vdev = DEVICE(&dev->vdev);
Error *err = NULL;
qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus)); qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
object_property_set_bool(OBJECT(vdev), true, "realized", &err); object_property_set_bool(OBJECT(vdev), true, "realized", errp);
if (err) {
error_propagate(errp, err);
}
} }
static void vhost_ccw_scsi_instance_init(Object *obj) static void vhost_ccw_scsi_instance_init(Object *obj)
@ -1854,13 +1830,9 @@ static void virtio_ccw_9p_realize(VirtioCcwDevice *ccw_dev, Error **errp)
{ {
V9fsCCWState *dev = VIRTIO_9P_CCW(ccw_dev); V9fsCCWState *dev = VIRTIO_9P_CCW(ccw_dev);
DeviceState *vdev = DEVICE(&dev->vdev); DeviceState *vdev = DEVICE(&dev->vdev);
Error *err = NULL;
qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus)); qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
object_property_set_bool(OBJECT(vdev), true, "realized", &err); object_property_set_bool(OBJECT(vdev), true, "realized", errp);
if (err) {
error_propagate(errp, err);
}
} }
static void virtio_ccw_9p_class_init(ObjectClass *klass, void *data) static void virtio_ccw_9p_class_init(ObjectClass *klass, void *data)

View File

@ -410,17 +410,14 @@ static void megasas_encode_lba(uint8_t *cdb, uint64_t lba,
static uint64_t megasas_fw_time(void) static uint64_t megasas_fw_time(void)
{ {
struct tm curtime; struct tm curtime;
uint64_t bcd_time;
qemu_get_timedate(&curtime, 0); qemu_get_timedate(&curtime, 0);
bcd_time = ((uint64_t)curtime.tm_sec & 0xff) << 48 | return ((uint64_t)curtime.tm_sec & 0xff) << 48 |
((uint64_t)curtime.tm_min & 0xff) << 40 | ((uint64_t)curtime.tm_min & 0xff) << 40 |
((uint64_t)curtime.tm_hour & 0xff) << 32 | ((uint64_t)curtime.tm_hour & 0xff) << 32 |
((uint64_t)curtime.tm_mday & 0xff) << 24 | ((uint64_t)curtime.tm_mday & 0xff) << 24 |
((uint64_t)curtime.tm_mon & 0xff) << 16 | ((uint64_t)curtime.tm_mon & 0xff) << 16 |
((uint64_t)(curtime.tm_year + 1900) & 0xffff); ((uint64_t)(curtime.tm_year + 1900) & 0xffff);
return bcd_time;
} }
/* /*

View File

@ -579,10 +579,7 @@ const SCSIReqOps scsi_generic_req_ops = {
static SCSIRequest *scsi_new_request(SCSIDevice *d, uint32_t tag, uint32_t lun, static SCSIRequest *scsi_new_request(SCSIDevice *d, uint32_t tag, uint32_t lun,
uint8_t *buf, void *hba_private) uint8_t *buf, void *hba_private)
{ {
SCSIRequest *req; return scsi_req_alloc(&scsi_generic_req_ops, d, tag, lun, hba_private);
req = scsi_req_alloc(&scsi_generic_req_ops, d, tag, lun, hba_private);
return req;
} }
static Property scsi_generic_properties[] = { static Property scsi_generic_properties[] = {

View File

@ -105,12 +105,10 @@ static inline bool rtc_running(RTCState *s)
static uint64_t get_guest_rtc_ns(RTCState *s) static uint64_t get_guest_rtc_ns(RTCState *s)
{ {
uint64_t guest_rtc;
uint64_t guest_clock = qemu_clock_get_ns(rtc_clock); uint64_t guest_clock = qemu_clock_get_ns(rtc_clock);
guest_rtc = s->base_rtc * NANOSECONDS_PER_SECOND + return s->base_rtc * NANOSECONDS_PER_SECOND +
guest_clock - s->last_update + s->offset; guest_clock - s->last_update + s->offset;
return guest_rtc;
} }
#ifdef TARGET_I386 #ifdef TARGET_I386

View File

@ -818,9 +818,7 @@ static void usb_msd_set_bootindex(Object *obj, Visitor *v, const char *name,
} }
out: out:
if (local_err) { error_propagate(errp, local_err);
error_propagate(errp, local_err);
}
} }
static const TypeInfo usb_storage_dev_type_info = { static const TypeInfo usb_storage_dev_type_info = {

View File

@ -761,9 +761,7 @@ static int kvm_virtio_pci_irqfd_use(VirtIOPCIProxy *proxy,
VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus); VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
VirtQueue *vq = virtio_get_queue(vdev, queue_no); VirtQueue *vq = virtio_get_queue(vdev, queue_no);
EventNotifier *n = virtio_queue_get_guest_notifier(vq); EventNotifier *n = virtio_queue_get_guest_notifier(vq);
int ret; return kvm_irqchip_add_irqfd_notifier_gsi(kvm_state, n, NULL, irqfd->virq);
ret = kvm_irqchip_add_irqfd_notifier_gsi(kvm_state, n, NULL, irqfd->virq);
return ret;
} }
static void kvm_virtio_pci_irqfd_release(VirtIOPCIProxy *proxy, static void kvm_virtio_pci_irqfd_release(VirtIOPCIProxy *proxy,

View File

@ -106,8 +106,8 @@ extern const QEMULogItem qemu_log_items[];
void qemu_set_log(int log_flags); void qemu_set_log(int log_flags);
void qemu_log_needs_buffers(void); void qemu_log_needs_buffers(void);
void qemu_set_log_filename(const char *filename); void qemu_set_log_filename(const char *filename, Error **errp);
void qemu_set_dfilter_ranges(const char *ranges); void qemu_set_dfilter_ranges(const char *ranges, Error **errp);
bool qemu_log_in_addr_range(uint64_t addr); bool qemu_log_in_addr_range(uint64_t addr);
int qemu_str_to_log_mask(const char *str); int qemu_str_to_log_mask(const char *str);

View File

@ -21,6 +21,7 @@
#include <sys/syscall.h> #include <sys/syscall.h>
#include <sys/resource.h> #include <sys/resource.h>
#include "qapi/error.h"
#include "qemu.h" #include "qemu.h"
#include "qemu/path.h" #include "qemu/path.h"
#include "qemu/cutils.h" #include "qemu/cutils.h"
@ -3845,7 +3846,7 @@ static void handle_arg_log(const char *arg)
static void handle_arg_log_filename(const char *arg) static void handle_arg_log_filename(const char *arg)
{ {
qemu_set_log_filename(arg); qemu_set_log_filename(arg, &error_fatal);
} }
static void handle_arg_set_env(const char *arg) static void handle_arg_set_env(const char *arg)

View File

@ -195,7 +195,6 @@ int block_signals(void)
{ {
TaskState *ts = (TaskState *)thread_cpu->opaque; TaskState *ts = (TaskState *)thread_cpu->opaque;
sigset_t set; sigset_t set;
int pending;
/* It's OK to block everything including SIGSEGV, because we won't /* It's OK to block everything including SIGSEGV, because we won't
* run any further guest code before unblocking signals in * run any further guest code before unblocking signals in
@ -204,9 +203,7 @@ int block_signals(void)
sigfillset(&set); sigfillset(&set);
sigprocmask(SIG_SETMASK, &set, 0); sigprocmask(SIG_SETMASK, &set, 0);
pending = atomic_xchg(&ts->signal_pending, 1); return atomic_xchg(&ts->signal_pending, 1);
return pending;
} }
/* Wrapper for sigprocmask function /* Wrapper for sigprocmask function
@ -3956,9 +3953,7 @@ static void setup_sigcontext(struct target_sigcontext *sc,
static inline unsigned long align_sigframe(unsigned long sp) static inline unsigned long align_sigframe(unsigned long sp)
{ {
unsigned long i; return sp & ~3UL;
i = sp & ~3UL;
return i;
} }
static inline abi_ulong get_sigframe(struct target_sigaction *ka, static inline abi_ulong get_sigframe(struct target_sigaction *ka,
@ -4555,7 +4550,7 @@ static target_ulong get_sigframe(struct target_sigaction *ka,
CPUPPCState *env, CPUPPCState *env,
int frame_size) int frame_size)
{ {
target_ulong oldsp, newsp; target_ulong oldsp;
oldsp = env->gpr[1]; oldsp = env->gpr[1];
@ -4565,9 +4560,7 @@ static target_ulong get_sigframe(struct target_sigaction *ka,
+ target_sigaltstack_used.ss_size); + target_sigaltstack_used.ss_size);
} }
newsp = (oldsp - frame_size) & ~0xFUL; return (oldsp - frame_size) & ~0xFUL;
return newsp;
} }
static void save_user_regs(CPUPPCState *env, struct target_mcontext *frame) static void save_user_regs(CPUPPCState *env, struct target_mcontext *frame)

View File

@ -1111,7 +1111,12 @@ void qmp_client_migrate_info(const char *protocol, const char *hostname,
static void hmp_logfile(Monitor *mon, const QDict *qdict) static void hmp_logfile(Monitor *mon, const QDict *qdict)
{ {
qemu_set_log_filename(qdict_get_str(qdict, "filename")); Error *err = NULL;
qemu_set_log_filename(qdict_get_str(qdict, "filename"), &err);
if (err) {
error_report_err(err);
}
} }
static void hmp_log(Monitor *mon, const QDict *qdict) static void hmp_log(Monitor *mon, const QDict *qdict)

View File

@ -111,11 +111,8 @@ void cache_fini(PageCache *cache)
static size_t cache_get_cache_pos(const PageCache *cache, static size_t cache_get_cache_pos(const PageCache *cache,
uint64_t address) uint64_t address)
{ {
size_t pos;
g_assert(cache->max_num_items); g_assert(cache->max_num_items);
pos = (address / cache->page_size) & (cache->max_num_items - 1); return (address / cache->page_size) & (cache->max_num_items - 1);
return pos;
} }
static CacheItem *cache_get_by_addr(const PageCache *cache, uint64_t addr) static CacheItem *cache_get_by_addr(const PageCache *cache, uint64_t addr)

View File

@ -127,7 +127,6 @@ int64_t qmp_guest_get_time(Error **errp)
{ {
int ret; int ret;
qemu_timeval tq; qemu_timeval tq;
int64_t time_ns;
ret = qemu_gettimeofday(&tq); ret = qemu_gettimeofday(&tq);
if (ret < 0) { if (ret < 0) {
@ -135,8 +134,7 @@ int64_t qmp_guest_get_time(Error **errp)
return -1; return -1;
} }
time_ns = tq.tv_sec * 1000000000LL + tq.tv_usec * 1000; return tq.tv_sec * 1000000000LL + tq.tv_usec * 1000;
return time_ns;
} }
void qmp_guest_set_time(bool has_time, int64_t time_ns, Error **errp) void qmp_guest_set_time(bool has_time, int64_t time_ns, Error **errp)

View File

@ -247,9 +247,7 @@ out:
if (token) { if (token) {
CloseHandle(token); CloseHandle(token);
} }
if (local_err) { error_propagate(errp, local_err);
error_propagate(errp, local_err);
}
} }
static void execute_async(DWORD WINAPI (*func)(LPVOID), LPVOID opaque, static void execute_async(DWORD WINAPI (*func)(LPVOID), LPVOID opaque,
@ -882,9 +880,7 @@ static void check_suspend_mode(GuestSuspendMode mode, Error **errp)
} }
out: out:
if (local_err) { error_propagate(errp, local_err);
error_propagate(errp, local_err);
}
} }
static DWORD WINAPI do_suspend(LPVOID opaque) static DWORD WINAPI do_suspend(LPVOID opaque)
@ -1154,7 +1150,6 @@ out:
int64_t qmp_guest_get_time(Error **errp) int64_t qmp_guest_get_time(Error **errp)
{ {
SYSTEMTIME ts = {0}; SYSTEMTIME ts = {0};
int64_t time_ns;
FILETIME tf; FILETIME tf;
GetSystemTime(&ts); GetSystemTime(&ts);
@ -1168,10 +1163,8 @@ int64_t qmp_guest_get_time(Error **errp)
return -1; return -1;
} }
time_ns = ((((int64_t)tf.dwHighDateTime << 32) | tf.dwLowDateTime) return ((((int64_t)tf.dwHighDateTime << 32) | tf.dwLowDateTime)
- W32_FT_OFFSET) * 100; - W32_FT_OFFSET) * 100;
return time_ns;
} }
void qmp_guest_set_time(bool has_time, int64_t time_ns, Error **errp) void qmp_guest_set_time(bool has_time, int64_t time_ns, Error **errp)

View File

@ -100,7 +100,6 @@ QObject *qlist_pop(QList *qlist)
QObject *qlist_peek(QList *qlist) QObject *qlist_peek(QList *qlist)
{ {
QListEntry *entry; QListEntry *entry;
QObject *ret;
if (qlist == NULL || QTAILQ_EMPTY(&qlist->head)) { if (qlist == NULL || QTAILQ_EMPTY(&qlist->head)) {
return NULL; return NULL;
@ -108,9 +107,7 @@ QObject *qlist_peek(QList *qlist)
entry = QTAILQ_FIRST(&qlist->head); entry = QTAILQ_FIRST(&qlist->head);
ret = entry->value; return entry->value;
return ret;
} }
int qlist_empty(const QList *qlist) int qlist_empty(const QList *qlist)

View File

@ -549,9 +549,7 @@ Object *object_new_with_propv(const char *typename,
return obj; return obj;
error: error:
if (local_err) { error_propagate(errp, local_err);
error_propagate(errp, local_err);
}
object_unref(obj); object_unref(obj);
return NULL; return NULL;
} }

View File

@ -0,0 +1,10 @@
// error_propagate() already ignores local_err==NULL, so there's
// no need to check it before calling.
@@
identifier L;
expression E;
@@
-if (L) {
error_propagate(E, L);
-}

View File

@ -0,0 +1,29 @@
// Replace unnecessary usage of local_err variable with
// direct usage of errp argument
@@
identifier F;
expression list ARGS;
expression F2;
identifier LOCAL_ERR;
identifier ERRP;
idexpression V;
typedef Error;
@@
F(..., Error **ERRP)
{
...
- Error *LOCAL_ERR;
... when != LOCAL_ERR
when != ERRP
(
- F2(ARGS, &LOCAL_ERR);
- error_propagate(ERRP, LOCAL_ERR);
+ F2(ARGS, ERRP);
|
- V = F2(ARGS, &LOCAL_ERR);
- error_propagate(ERRP, LOCAL_ERR);
+ V = F2(ARGS, ERRP);
)
... when != LOCAL_ERR
}

View File

@ -0,0 +1,19 @@
// replace 'R = X; return R;' with 'return R;'
@@
identifier VAR;
expression E;
type T;
identifier F;
@@
T F(...)
{
...
- T VAR;
... when != VAR
- VAR =
+ return
E;
- return VAR;
... when != VAR
}

View File

@ -1875,7 +1875,6 @@ static void x86_cpu_get_feature_words(Object *obj, Visitor *v,
{ {
uint32_t *array = (uint32_t *)opaque; uint32_t *array = (uint32_t *)opaque;
FeatureWord w; FeatureWord w;
Error *err = NULL;
X86CPUFeatureWordInfo word_infos[FEATURE_WORDS] = { }; X86CPUFeatureWordInfo word_infos[FEATURE_WORDS] = { };
X86CPUFeatureWordInfoList list_entries[FEATURE_WORDS] = { }; X86CPUFeatureWordInfoList list_entries[FEATURE_WORDS] = { };
X86CPUFeatureWordInfoList *list = NULL; X86CPUFeatureWordInfoList *list = NULL;
@ -1895,8 +1894,7 @@ static void x86_cpu_get_feature_words(Object *obj, Visitor *v,
list = &list_entries[w]; list = &list_entries[w];
} }
visit_type_X86CPUFeatureWordInfoList(v, "feature-words", &list, &err); visit_type_X86CPUFeatureWordInfoList(v, "feature-words", &list, errp);
error_propagate(errp, err);
} }
static void x86_get_hv_spinlocks(Object *obj, Visitor *v, const char *name, static void x86_get_hv_spinlocks(Object *obj, Visitor *v, const char *name,

View File

@ -298,18 +298,12 @@ int32_t helper_fistt_ST0(CPUX86State *env)
int32_t helper_fisttl_ST0(CPUX86State *env) int32_t helper_fisttl_ST0(CPUX86State *env)
{ {
int32_t val; return floatx80_to_int32_round_to_zero(ST0, &env->fp_status);
val = floatx80_to_int32_round_to_zero(ST0, &env->fp_status);
return val;
} }
int64_t helper_fisttll_ST0(CPUX86State *env) int64_t helper_fisttll_ST0(CPUX86State *env)
{ {
int64_t val; return floatx80_to_int64_round_to_zero(ST0, &env->fp_status);
val = floatx80_to_int64_round_to_zero(ST0, &env->fp_status);
return val;
} }
void helper_fldt_ST0(CPUX86State *env, target_ulong ptr) void helper_fldt_ST0(CPUX86State *env, target_ulong ptr)

View File

@ -1346,7 +1346,7 @@ static int kvm_put_xsave(X86CPU *cpu)
CPUX86State *env = &cpu->env; CPUX86State *env = &cpu->env;
X86XSaveArea *xsave = env->kvm_xsave_buf; X86XSaveArea *xsave = env->kvm_xsave_buf;
uint16_t cwd, swd, twd; uint16_t cwd, swd, twd;
int i, r; int i;
if (!has_xsave) { if (!has_xsave) {
return kvm_put_fpu(cpu); return kvm_put_fpu(cpu);
@ -1395,8 +1395,7 @@ static int kvm_put_xsave(X86CPU *cpu)
16 * sizeof env->xmm_regs[16]); 16 * sizeof env->xmm_regs[16]);
memcpy(&xsave->pkru_state, &env->pkru, sizeof env->pkru); memcpy(&xsave->pkru_state, &env->pkru, sizeof env->pkru);
#endif #endif
r = kvm_vcpu_ioctl(CPU(cpu), KVM_SET_XSAVE, xsave); return kvm_vcpu_ioctl(CPU(cpu), KVM_SET_XSAVE, xsave);
return r;
} }
static int kvm_put_xcrs(X86CPU *cpu) static int kvm_put_xcrs(X86CPU *cpu)

View File

@ -133,10 +133,8 @@ static inline uint64_t get_HILO(CPUMIPSState *env)
static inline target_ulong set_HIT0_LO(CPUMIPSState *env, uint64_t HILO) static inline target_ulong set_HIT0_LO(CPUMIPSState *env, uint64_t HILO)
{ {
target_ulong tmp;
env->active_tc.LO[0] = (int32_t)(HILO & 0xFFFFFFFF); env->active_tc.LO[0] = (int32_t)(HILO & 0xFFFFFFFF);
tmp = env->active_tc.HI[0] = (int32_t)(HILO >> 32); return env->active_tc.HI[0] = (int32_t)(HILO >> 32);
return tmp;
} }
static inline target_ulong set_HI_LOT0(CPUMIPSState *env, uint64_t HILO) static inline target_ulong set_HI_LOT0(CPUMIPSState *env, uint64_t HILO)

View File

@ -70,11 +70,7 @@ void s390x_cpu_timer(void *opaque)
S390CPU *cpu_s390x_create(const char *cpu_model, Error **errp) S390CPU *cpu_s390x_create(const char *cpu_model, Error **errp)
{ {
S390CPU *cpu; return S390_CPU(object_new(TYPE_S390_CPU));
cpu = S390_CPU(object_new(TYPE_S390_CPU));
return cpu;
} }
S390CPU *s390x_new_cpu(const char *cpu_model, int64_t id, Error **errp) S390CPU *s390x_new_cpu(const char *cpu_model, int64_t id, Error **errp)

View File

@ -200,10 +200,7 @@ static uint32_t compute_all_addx_xcc(CPUSPARCState *env)
static uint32_t compute_C_addx_xcc(CPUSPARCState *env) static uint32_t compute_C_addx_xcc(CPUSPARCState *env)
{ {
uint32_t ret; return get_C_addx_xcc(CC_DST, CC_SRC, CC_SRC2);
ret = get_C_addx_xcc(CC_DST, CC_SRC, CC_SRC2);
return ret;
} }
#endif #endif
@ -219,10 +216,7 @@ static uint32_t compute_all_addx(CPUSPARCState *env)
static uint32_t compute_C_addx(CPUSPARCState *env) static uint32_t compute_C_addx(CPUSPARCState *env)
{ {
uint32_t ret; return get_C_addx_icc(CC_DST, CC_SRC, CC_SRC2);
ret = get_C_addx_icc(CC_DST, CC_SRC, CC_SRC2);
return ret;
} }
static inline uint32_t get_V_tag_icc(target_ulong src1, target_ulong src2) static inline uint32_t get_V_tag_icc(target_ulong src1, target_ulong src2)
@ -365,10 +359,7 @@ static uint32_t compute_all_subx_xcc(CPUSPARCState *env)
static uint32_t compute_C_subx_xcc(CPUSPARCState *env) static uint32_t compute_C_subx_xcc(CPUSPARCState *env)
{ {
uint32_t ret; return get_C_subx_xcc(CC_DST, CC_SRC, CC_SRC2);
ret = get_C_subx_xcc(CC_DST, CC_SRC, CC_SRC2);
return ret;
} }
#endif #endif
@ -384,10 +375,7 @@ static uint32_t compute_all_subx(CPUSPARCState *env)
static uint32_t compute_C_subx(CPUSPARCState *env) static uint32_t compute_C_subx(CPUSPARCState *env)
{ {
uint32_t ret; return get_C_subx_icc(CC_DST, CC_SRC, CC_SRC2);
ret = get_C_subx_icc(CC_DST, CC_SRC, CC_SRC2);
return ret;
} }
static uint32_t compute_all_tsub(CPUSPARCState *env) static uint32_t compute_all_tsub(CPUSPARCState *env)
@ -479,8 +467,5 @@ void helper_compute_psr(CPUSPARCState *env)
uint32_t helper_compute_C_icc(CPUSPARCState *env) uint32_t helper_compute_C_icc(CPUSPARCState *env)
{ {
uint32_t ret; return icc_table[CC_OP].compute_c(env) >> PSR_CARRY_SHIFT;
ret = icc_table[CC_OP].compute_c(env) >> PSR_CARRY_SHIFT;
return ret;
} }

View File

@ -2117,7 +2117,7 @@ uint64_t helper_dvadj(uint64_t r1, uint32_t r2)
int32_t eq_pos = x_sign & ((r1 >> 32) == r2); int32_t eq_pos = x_sign & ((r1 >> 32) == r2);
int32_t eq_neg = x_sign & ((r1 >> 32) == -r2); int32_t eq_neg = x_sign & ((r1 >> 32) == -r2);
uint32_t quotient; uint32_t quotient;
uint64_t ret, remainder; uint64_t remainder;
if ((q_sign & ~eq_neg) | eq_pos) { if ((q_sign & ~eq_neg) | eq_pos) {
quotient = (r1 + 1) & 0xffffffff; quotient = (r1 + 1) & 0xffffffff;
@ -2130,8 +2130,7 @@ uint64_t helper_dvadj(uint64_t r1, uint32_t r2)
} else { } else {
remainder = (r1 & 0xffffffff00000000ull); remainder = (r1 & 0xffffffff00000000ull);
} }
ret = remainder|quotient; return remainder | quotient;
return ret;
} }
uint64_t helper_dvstep(uint64_t r1, uint32_t r2) uint64_t helper_dvstep(uint64_t r1, uint32_t r2)
@ -2236,7 +2235,6 @@ uint64_t helper_divide_u(CPUTriCoreState *env, uint32_t r1, uint32_t r2)
uint64_t helper_mul_h(uint32_t arg00, uint32_t arg01, uint64_t helper_mul_h(uint32_t arg00, uint32_t arg01,
uint32_t arg10, uint32_t arg11, uint32_t n) uint32_t arg10, uint32_t arg11, uint32_t n)
{ {
uint64_t ret;
uint32_t result0, result1; uint32_t result0, result1;
int32_t sc1 = ((arg00 & 0xffff) == 0x8000) && int32_t sc1 = ((arg00 & 0xffff) == 0x8000) &&
@ -2253,8 +2251,7 @@ uint64_t helper_mul_h(uint32_t arg00, uint32_t arg01,
} else { } else {
result0 = (((uint32_t)(arg01 * arg11)) << n); result0 = (((uint32_t)(arg01 * arg11)) << n);
} }
ret = (((uint64_t)result1 << 32)) | result0; return (((uint64_t)result1 << 32)) | result0;
return ret;
} }
uint64_t helper_mulm_h(uint32_t arg00, uint32_t arg01, uint64_t helper_mulm_h(uint32_t arg00, uint32_t arg01,
@ -2308,11 +2305,9 @@ uint32_t helper_mulr_h(uint32_t arg00, uint32_t arg01,
uint32_t helper_crc32(uint32_t arg0, uint32_t arg1) uint32_t helper_crc32(uint32_t arg0, uint32_t arg1)
{ {
uint8_t buf[4]; uint8_t buf[4];
uint32_t ret;
stl_be_p(buf, arg0); stl_be_p(buf, arg0);
ret = crc32(arg1, buf, 4); return crc32(arg1, buf, 4);
return ret;
} }
/* context save area (CSA) related helpers */ /* context save area (CSA) related helpers */

View File

@ -50,8 +50,6 @@ static void pci_virtio_vga(void)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int ret;
g_test_init(&argc, &argv, NULL); g_test_init(&argc, &argv, NULL);
qtest_add_func("/display/pci/cirrus", pci_cirrus); qtest_add_func("/display/pci/cirrus", pci_cirrus);
@ -62,7 +60,5 @@ int main(int argc, char **argv)
#ifdef CONFIG_VIRTIO_VGA #ifdef CONFIG_VIRTIO_VGA
qtest_add_func("/display/pci/virtio-vga", pci_virtio_vga); qtest_add_func("/display/pci/virtio-vga", pci_virtio_vga);
#endif #endif
ret = g_test_run(); return g_test_run();
return ret;
} }

View File

@ -282,7 +282,6 @@ static void test_endianness_combine(gconstpointer data)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
const char *arch = qtest_get_arch(); const char *arch = qtest_get_arch();
int ret;
int i; int i;
g_test_init(&argc, &argv, NULL); g_test_init(&argc, &argv, NULL);
@ -305,7 +304,5 @@ int main(int argc, char **argv)
qtest_add_data_func(path, &test_cases[i], test_endianness_combine); qtest_add_data_func(path, &test_cases[i], test_endianness_combine);
} }
ret = g_test_run(); return g_test_run();
return ret;
} }

View File

@ -394,7 +394,6 @@ static void request_pflash(FirmwareTestFixture *fixture,
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
TestData data; TestData data;
int ret;
g_test_init(&argc, &argv, NULL); g_test_init(&argc, &argv, NULL);
@ -405,6 +404,5 @@ int main(int argc, char **argv)
add_firmware_test("i440fx/firmware/bios", request_bios); add_firmware_test("i440fx/firmware/bios", request_bios);
add_firmware_test("i440fx/firmware/pflash", request_pflash); add_firmware_test("i440fx/firmware/pflash", request_pflash);
ret = g_test_run(); return g_test_run();
return ret;
} }

View File

@ -31,13 +31,9 @@ static void ich9_test(void)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int ret;
g_test_init(&argc, &argv, NULL); g_test_init(&argc, &argv, NULL);
qtest_add_func("/intel-hda/ich6", ich6_test); qtest_add_func("/intel-hda/ich6", ich6_test);
qtest_add_func("/intel-hda/ich9", ich9_test); qtest_add_func("/intel-hda/ich9", ich9_test);
ret = g_test_run(); return g_test_run();
return ret;
} }

View File

@ -209,12 +209,8 @@ static void test_redirector_rx(void)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int ret;
g_test_init(&argc, &argv, NULL); g_test_init(&argc, &argv, NULL);
qtest_add_func("/netfilter/redirector_tx", test_redirector_tx); qtest_add_func("/netfilter/redirector_tx", test_redirector_tx);
qtest_add_func("/netfilter/redirector_rx", test_redirector_rx); qtest_add_func("/netfilter/redirector_rx", test_redirector_rx);
ret = g_test_run(); return g_test_run();
return ret;
} }

View File

@ -27,11 +27,14 @@
#include "qemu/osdep.h" #include "qemu/osdep.h"
#include "qemu-common.h" #include "qemu-common.h"
#include "include/qemu/log.h" #include "qapi/error.h"
#include "qemu/log.h"
static void test_parse_range(void) static void test_parse_range(void)
{ {
qemu_set_dfilter_ranges("0x1000+0x100"); Error *err = NULL;
qemu_set_dfilter_ranges("0x1000+0x100", &error_abort);
g_assert_false(qemu_log_in_addr_range(0xfff)); g_assert_false(qemu_log_in_addr_range(0xfff));
g_assert(qemu_log_in_addr_range(0x1000)); g_assert(qemu_log_in_addr_range(0x1000));
@ -39,102 +42,57 @@ static void test_parse_range(void)
g_assert(qemu_log_in_addr_range(0x10ff)); g_assert(qemu_log_in_addr_range(0x10ff));
g_assert_false(qemu_log_in_addr_range(0x1100)); g_assert_false(qemu_log_in_addr_range(0x1100));
qemu_set_dfilter_ranges("0x1000-0x100"); qemu_set_dfilter_ranges("0x1000-0x100", &error_abort);
g_assert_false(qemu_log_in_addr_range(0x1001)); g_assert_false(qemu_log_in_addr_range(0x1001));
g_assert(qemu_log_in_addr_range(0x1000)); g_assert(qemu_log_in_addr_range(0x1000));
g_assert(qemu_log_in_addr_range(0x0f01)); g_assert(qemu_log_in_addr_range(0x0f01));
g_assert_false(qemu_log_in_addr_range(0x0f00)); g_assert_false(qemu_log_in_addr_range(0x0f00));
qemu_set_dfilter_ranges("0x1000..0x1100"); qemu_set_dfilter_ranges("0x1000..0x1100", &error_abort);
g_assert_false(qemu_log_in_addr_range(0xfff)); g_assert_false(qemu_log_in_addr_range(0xfff));
g_assert(qemu_log_in_addr_range(0x1000)); g_assert(qemu_log_in_addr_range(0x1000));
g_assert(qemu_log_in_addr_range(0x1100)); g_assert(qemu_log_in_addr_range(0x1100));
g_assert_false(qemu_log_in_addr_range(0x1101)); g_assert_false(qemu_log_in_addr_range(0x1101));
qemu_set_dfilter_ranges("0x1000..0x1000"); qemu_set_dfilter_ranges("0x1000..0x1000", &error_abort);
g_assert_false(qemu_log_in_addr_range(0xfff)); g_assert_false(qemu_log_in_addr_range(0xfff));
g_assert(qemu_log_in_addr_range(0x1000)); g_assert(qemu_log_in_addr_range(0x1000));
g_assert_false(qemu_log_in_addr_range(0x1001)); g_assert_false(qemu_log_in_addr_range(0x1001));
qemu_set_dfilter_ranges("0x1000+0x100,0x2100-0x100,0x3000..0x3100"); qemu_set_dfilter_ranges("0x1000+0x100,0x2100-0x100,0x3000..0x3100",
&error_abort);
g_assert(qemu_log_in_addr_range(0x1050)); g_assert(qemu_log_in_addr_range(0x1050));
g_assert(qemu_log_in_addr_range(0x2050)); g_assert(qemu_log_in_addr_range(0x2050));
g_assert(qemu_log_in_addr_range(0x3050)); g_assert(qemu_log_in_addr_range(0x3050));
qemu_set_dfilter_ranges("0x1000+onehundred", &err);
error_free_or_abort(&err);
qemu_set_dfilter_ranges("0x1000+0", &err);
error_free_or_abort(&err);
} }
#ifdef CONFIG_HAS_GLIB_SUBPROCESS_TESTS
static void test_parse_invalid_range_subprocess(void)
{
qemu_set_dfilter_ranges("0x1000+onehundred");
}
static void test_parse_invalid_range(void)
{
g_test_trap_subprocess("/logging/parse_invalid_range/subprocess", 0, 0);
g_test_trap_assert_failed();
g_test_trap_assert_stdout("");
g_test_trap_assert_stderr("*Failed to parse range in: 0x1000+onehundred\n");
}
static void test_parse_zero_range_subprocess(void)
{
qemu_set_dfilter_ranges("0x1000+0");
}
static void test_parse_zero_range(void)
{
g_test_trap_subprocess("/logging/parse_zero_range/subprocess", 0, 0);
g_test_trap_assert_failed();
g_test_trap_assert_stdout("");
g_test_trap_assert_stderr("*Failed to parse range in: 0x1000+0\n");
}
/* As the only real failure from a bad log filename path spec is
* reporting to the user we have to use the g_test_trap_subprocess
* mechanism and check no errors reported on stderr.
*/
static void test_parse_path_subprocess(void)
{
/* All these should work without issue */
qemu_set_log_filename("/tmp/qemu.log");
qemu_set_log_filename("/tmp/qemu-%d.log");
qemu_set_log_filename("/tmp/qemu.log.%d");
}
static void test_parse_path(void) static void test_parse_path(void)
{ {
g_test_trap_subprocess ("/logging/parse_path/subprocess", 0, 0); Error *err = NULL;
g_test_trap_assert_passed();
g_test_trap_assert_stdout(""); qemu_set_log_filename("/tmp/qemu.log", &error_abort);
g_test_trap_assert_stderr(""); qemu_set_log_filename("/tmp/qemu-%d.log", &error_abort);
qemu_set_log_filename("/tmp/qemu.log.%d", &error_abort);
qemu_set_log_filename("/tmp/qemu-%d%d.log", &err);
error_free_or_abort(&err);
} }
static void test_parse_invalid_path_subprocess(void)
{
qemu_set_log_filename("/tmp/qemu-%d%d.log");
}
static void test_parse_invalid_path(void)
{
g_test_trap_subprocess ("/logging/parse_invalid_path/subprocess", 0, 0);
g_test_trap_assert_passed();
g_test_trap_assert_stdout("");
g_test_trap_assert_stderr("Bad logfile format: /tmp/qemu-%d%d.log\n");
}
#endif /* CONFIG_HAS_GLIB_SUBPROCESS_TESTS */
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
g_test_init(&argc, &argv, NULL); g_test_init(&argc, &argv, NULL);
g_test_add_func("/logging/parse_range", test_parse_range); g_test_add_func("/logging/parse_range", test_parse_range);
#ifdef CONFIG_HAS_GLIB_SUBPROCESS_TESTS
g_test_add_func("/logging/parse_invalid_range/subprocess", test_parse_invalid_range_subprocess);
g_test_add_func("/logging/parse_invalid_range", test_parse_invalid_range);
g_test_add_func("/logging/parse_zero_range/subprocess", test_parse_zero_range_subprocess);
g_test_add_func("/logging/parse_zero_range", test_parse_zero_range);
g_test_add_func("/logging/parse_path", test_parse_path); g_test_add_func("/logging/parse_path", test_parse_path);
g_test_add_func("/logging/parse_path/subprocess", test_parse_path_subprocess);
g_test_add_func("/logging/parse_invalid_path", test_parse_invalid_path);
g_test_add_func("/logging/parse_invalid_path/subprocess", test_parse_invalid_path_subprocess);
#endif
return g_test_run(); return g_test_run();
} }

View File

@ -753,7 +753,6 @@ static void mmio_basic(void)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int ret;
const char *arch = qtest_get_arch(); const char *arch = qtest_get_arch();
g_test_init(&argc, &argv, NULL); g_test_init(&argc, &argv, NULL);
@ -769,7 +768,5 @@ int main(int argc, char **argv)
qtest_add_func("/virtio/blk/mmio/basic", mmio_basic); qtest_add_func("/virtio/blk/mmio/basic", mmio_basic);
} }
ret = g_test_run(); return g_test_run();
return ret;
} }

View File

@ -27,13 +27,9 @@ static void serialport_pci_nop(void)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int ret;
g_test_init(&argc, &argv, NULL); g_test_init(&argc, &argv, NULL);
qtest_add_func("/virtio/console/pci/nop", console_pci_nop); qtest_add_func("/virtio/console/pci/nop", console_pci_nop);
qtest_add_func("/virtio/serialport/pci/nop", serialport_pci_nop); qtest_add_func("/virtio/serialport/pci/nop", serialport_pci_nop);
ret = g_test_run(); return g_test_run();
return ret;
} }

View File

@ -250,8 +250,6 @@ static void hotplug(void)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int ret;
g_test_init(&argc, &argv, NULL); g_test_init(&argc, &argv, NULL);
#ifndef _WIN32 #ifndef _WIN32
qtest_add_data_func("/virtio/net/pci/basic", send_recv_test, pci_basic); qtest_add_data_func("/virtio/net/pci/basic", send_recv_test, pci_basic);
@ -260,7 +258,5 @@ int main(int argc, char **argv)
#endif #endif
qtest_add_func("/virtio/net/pci/hotplug", hotplug); qtest_add_func("/virtio/net/pci/hotplug", hotplug);
ret = g_test_run(); return g_test_run();
return ret;
} }

View File

@ -247,15 +247,11 @@ static void test_unaligned_write_same(void)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int ret;
g_test_init(&argc, &argv, NULL); g_test_init(&argc, &argv, NULL);
qtest_add_func("/virtio/scsi/pci/nop", pci_nop); qtest_add_func("/virtio/scsi/pci/nop", pci_nop);
qtest_add_func("/virtio/scsi/pci/hotplug", hotplug); qtest_add_func("/virtio/scsi/pci/hotplug", hotplug);
qtest_add_func("/virtio/scsi/pci/scsi-disk/unaligned-write-same", qtest_add_func("/virtio/scsi/pci/scsi-disk/unaligned-write-same",
test_unaligned_write_same); test_unaligned_write_same);
ret = g_test_run(); return g_test_run();
return ret;
} }

View File

@ -117,15 +117,11 @@ static void ib700_none(void)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int ret;
g_test_init(&argc, &argv, NULL); g_test_init(&argc, &argv, NULL);
qtest_add_func("/wdt_ib700/pause", ib700_pause); qtest_add_func("/wdt_ib700/pause", ib700_pause);
qtest_add_func("/wdt_ib700/reset", ib700_reset); qtest_add_func("/wdt_ib700/reset", ib700_reset);
qtest_add_func("/wdt_ib700/shutdown", ib700_shutdown); qtest_add_func("/wdt_ib700/shutdown", ib700_shutdown);
qtest_add_func("/wdt_ib700/none", ib700_none); qtest_add_func("/wdt_ib700/none", ib700_none);
ret = g_test_run(); return g_test_run();
return ret;
} }

View File

@ -19,6 +19,7 @@
#ifdef CONFIG_TRACE_LOG #ifdef CONFIG_TRACE_LOG
#include "qemu/log.h" #include "qemu/log.h"
#endif #endif
#include "qapi/error.h"
#include "qemu/error-report.h" #include "qemu/error-report.h"
#include "monitor/monitor.h" #include "monitor/monitor.h"
@ -187,7 +188,7 @@ void trace_init_file(const char *file)
* only applies to the simple backend; use "-D" for the log backend. * only applies to the simple backend; use "-D" for the log backend.
*/ */
if (file) { if (file) {
qemu_set_log_filename(file); qemu_set_log_filename(file, &error_fatal);
} }
#else #else
if (file) { if (file) {

View File

@ -81,18 +81,12 @@ void cursor_print_ascii_art(QEMUCursor *c, const char *prefix)
QEMUCursor *cursor_builtin_hidden(void) QEMUCursor *cursor_builtin_hidden(void)
{ {
QEMUCursor *c; return cursor_parse_xpm(cursor_hidden_xpm);
c = cursor_parse_xpm(cursor_hidden_xpm);
return c;
} }
QEMUCursor *cursor_builtin_left_ptr(void) QEMUCursor *cursor_builtin_left_ptr(void)
{ {
QEMUCursor *c; return cursor_parse_xpm(cursor_left_ptr_xpm);
c = cursor_parse_xpm(cursor_left_ptr_xpm);
return c;
} }
QEMUCursor *cursor_alloc(int width, int height) QEMUCursor *cursor_alloc(int width, int height)

View File

@ -180,14 +180,11 @@ void qemu_pixman_linebuf_copy(pixman_image_t *fb, int width, int x, int y,
pixman_image_t *qemu_pixman_mirror_create(pixman_format_code_t format, pixman_image_t *qemu_pixman_mirror_create(pixman_format_code_t format,
pixman_image_t *image) pixman_image_t *image)
{ {
pixman_image_t *mirror; return pixman_image_create_bits(format,
pixman_image_get_width(image),
mirror = pixman_image_create_bits(format, pixman_image_get_height(image),
pixman_image_get_width(image), NULL,
pixman_image_get_height(image), pixman_image_get_stride(image));
NULL,
pixman_image_get_stride(image));
return mirror;
} }
void qemu_pixman_image_unref(pixman_image_t *image) void qemu_pixman_image_unref(pixman_image_t *image)

View File

@ -22,6 +22,7 @@
#include "qemu/log.h" #include "qemu/log.h"
#include "qemu/range.h" #include "qemu/range.h"
#include "qemu/error-report.h" #include "qemu/error-report.h"
#include "qapi/error.h"
#include "qemu/cutils.h" #include "qemu/cutils.h"
#include "trace/control.h" #include "trace/control.h"
@ -102,7 +103,7 @@ void qemu_log_needs_buffers(void)
* substituted with the current PID. This is useful for debugging many * substituted with the current PID. This is useful for debugging many
* nested linux-user tasks but will result in lots of logs. * nested linux-user tasks but will result in lots of logs.
*/ */
void qemu_set_log_filename(const char *filename) void qemu_set_log_filename(const char *filename, Error **errp)
{ {
char *pidstr; char *pidstr;
g_free(logfilename); g_free(logfilename);
@ -111,8 +112,8 @@ void qemu_set_log_filename(const char *filename)
if (pidstr) { if (pidstr) {
/* We only accept one %d, no other format strings */ /* We only accept one %d, no other format strings */
if (pidstr[1] != 'd' || strchr(pidstr + 2, '%')) { if (pidstr[1] != 'd' || strchr(pidstr + 2, '%')) {
error_report("Bad logfile format: %s", filename); error_setg(errp, "Bad logfile format: %s", filename);
logfilename = NULL; return;
} else { } else {
logfilename = g_strdup_printf(filename, getpid()); logfilename = g_strdup_printf(filename, getpid());
} }
@ -142,68 +143,75 @@ bool qemu_log_in_addr_range(uint64_t addr)
} }
void qemu_set_dfilter_ranges(const char *filter_spec) void qemu_set_dfilter_ranges(const char *filter_spec, Error **errp)
{ {
gchar **ranges = g_strsplit(filter_spec, ",", 0); gchar **ranges = g_strsplit(filter_spec, ",", 0);
if (ranges) { int i;
gchar **next = ranges;
gchar *r = *next++;
debug_regions = g_array_sized_new(FALSE, FALSE,
sizeof(Range), g_strv_length(ranges));
while (r) {
char *range_op = strstr(r, "-");
char *r2 = range_op ? range_op + 1 : NULL;
if (!range_op) {
range_op = strstr(r, "+");
r2 = range_op ? range_op + 1 : NULL;
}
if (!range_op) {
range_op = strstr(r, "..");
r2 = range_op ? range_op + 2 : NULL;
}
if (range_op) {
const char *e = NULL;
uint64_t r1val, r2val;
if ((qemu_strtoull(r, &e, 0, &r1val) == 0) && if (debug_regions) {
(qemu_strtoull(r2, NULL, 0, &r2val) == 0) && g_array_unref(debug_regions);
r2val > 0) { debug_regions = NULL;
struct Range range;
g_assert(e == range_op);
switch (*range_op) {
case '+':
{
range.begin = r1val;
range.end = r1val + (r2val - 1);
break;
}
case '-':
{
range.end = r1val;
range.begin = r1val - (r2val - 1);
break;
}
case '.':
range.begin = r1val;
range.end = r2val;
break;
default:
g_assert_not_reached();
}
g_array_append_val(debug_regions, range);
} else {
g_error("Failed to parse range in: %s", r);
}
} else {
g_error("Bad range specifier in: %s", r);
}
r = *next++;
}
g_strfreev(ranges);
} }
debug_regions = g_array_sized_new(FALSE, FALSE,
sizeof(Range), g_strv_length(ranges));
for (i = 0; ranges[i]; i++) {
const char *r = ranges[i];
const char *range_op, *r2, *e;
uint64_t r1val, r2val;
struct Range range;
range_op = strstr(r, "-");
r2 = range_op ? range_op + 1 : NULL;
if (!range_op) {
range_op = strstr(r, "+");
r2 = range_op ? range_op + 1 : NULL;
}
if (!range_op) {
range_op = strstr(r, "..");
r2 = range_op ? range_op + 2 : NULL;
}
if (!range_op) {
error_setg(errp, "Bad range specifier");
goto out;
}
if (qemu_strtoull(r, &e, 0, &r1val)
|| e != range_op) {
error_setg(errp, "Invalid number to the left of %.*s",
(int)(r2 - range_op), range_op);
goto out;
}
if (qemu_strtoull(r2, NULL, 0, &r2val)) {
error_setg(errp, "Invalid number to the right of %.*s",
(int)(r2 - range_op), range_op);
goto out;
}
if (r2val == 0) {
error_setg(errp, "Invalid range");
goto out;
}
switch (*range_op) {
case '+':
range.begin = r1val;
range.end = r1val + (r2val - 1);
break;
case '-':
range.end = r1val;
range.begin = r1val - (r2val - 1);
break;
case '.':
range.begin = r1val;
range.end = r2val;
break;
default:
g_assert_not_reached();
}
g_array_append_val(debug_regions, range);
}
out:
g_strfreev(ranges);
} }
/* fflush() the log file */ /* fflush() the log file */

View File

@ -55,13 +55,9 @@ static void init_lists(void)
static ModuleTypeList *find_type(module_init_type type) static ModuleTypeList *find_type(module_init_type type)
{ {
ModuleTypeList *l;
init_lists(); init_lists();
l = &init_type_list[type]; return &init_type_list[type];
return l;
} }
void register_module_init(void (*fn)(void), module_init_type type) void register_module_init(void (*fn)(void), module_init_type type)

17
vl.c
View File

@ -2352,10 +2352,7 @@ static int chardev_init_func(void *opaque, QemuOpts *opts, Error **errp)
#ifdef CONFIG_VIRTFS #ifdef CONFIG_VIRTFS
static int fsdev_init_func(void *opaque, QemuOpts *opts, Error **errp) static int fsdev_init_func(void *opaque, QemuOpts *opts, Error **errp)
{ {
int ret; return qemu_fsdev_add(opts);
ret = qemu_fsdev_add(opts);
return ret;
} }
#endif #endif
@ -3068,7 +3065,7 @@ int main(int argc, char **argv, char **envp)
popt = lookup_opt(argc, argv, &optarg, &optind); popt = lookup_opt(argc, argv, &optarg, &optind);
if (!(popt->arch_mask & arch_type)) { if (!(popt->arch_mask & arch_type)) {
printf("Option %s not supported for this target\n", popt->name); error_report("Option not supported for this target");
exit(1); exit(1);
} }
switch(popt->index) { switch(popt->index) {
@ -3342,7 +3339,7 @@ int main(int argc, char **argv, char **envp)
log_file = optarg; log_file = optarg;
break; break;
case QEMU_OPTION_DFILTER: case QEMU_OPTION_DFILTER:
qemu_set_dfilter_ranges(optarg); qemu_set_dfilter_ranges(optarg, &error_fatal);
break; break;
case QEMU_OPTION_s: case QEMU_OPTION_s:
add_device_config(DEV_GDB, "tcp::" DEFAULT_GDBSTUB_PORT); add_device_config(DEV_GDB, "tcp::" DEFAULT_GDBSTUB_PORT);
@ -3846,21 +3843,21 @@ int main(int argc, char **argv, char **envp)
break; break;
case QEMU_OPTION_xen_domid: case QEMU_OPTION_xen_domid:
if (!(xen_available())) { if (!(xen_available())) {
printf("Option %s not supported for this target\n", popt->name); error_report("Option not supported for this target");
exit(1); exit(1);
} }
xen_domid = atoi(optarg); xen_domid = atoi(optarg);
break; break;
case QEMU_OPTION_xen_create: case QEMU_OPTION_xen_create:
if (!(xen_available())) { if (!(xen_available())) {
printf("Option %s not supported for this target\n", popt->name); error_report("Option not supported for this target");
exit(1); exit(1);
} }
xen_mode = XEN_CREATE; xen_mode = XEN_CREATE;
break; break;
case QEMU_OPTION_xen_attach: case QEMU_OPTION_xen_attach:
if (!(xen_available())) { if (!(xen_available())) {
printf("Option %s not supported for this target\n", popt->name); error_report("Option not supported for this target");
exit(1); exit(1);
} }
xen_mode = XEN_ATTACH; xen_mode = XEN_ATTACH;
@ -4057,7 +4054,7 @@ int main(int argc, char **argv, char **envp)
/* Open the logfile at this point and set the log mask if necessary. /* Open the logfile at this point and set the log mask if necessary.
*/ */
if (log_file) { if (log_file) {
qemu_set_log_filename(log_file); qemu_set_log_filename(log_file, &error_fatal);
} }
if (log_mask) { if (log_mask) {