Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/armbru/tags/pull-error-2016-06-…
Browse files Browse the repository at this point in the history
…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 <[email protected]>"
# gpg:                 aka "Markus Armbruster <[email protected]>"
# 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 <[email protected]>
  • Loading branch information
pm215 committed Jun 20, 2016
2 parents fd2590b + daa76aa commit 7fa124b
Show file tree
Hide file tree
Showing 68 changed files with 265 additions and 478 deletions.
10 changes: 2 additions & 8 deletions audio/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1131,8 +1131,6 @@ static void audio_timer (void *opaque)
*/
int AUD_write (SWVoiceOut *sw, void *buf, int size)
{
int bytes;

if (!sw) {
/* XXX: Consider options */
return size;
Expand All @@ -1143,14 +1141,11 @@ int AUD_write (SWVoiceOut *sw, void *buf, int size)
return 0;
}

bytes = sw->hw->pcm_ops->write (sw, buf, size);
return bytes;
return sw->hw->pcm_ops->write(sw, buf, size);
}

int AUD_read (SWVoiceIn *sw, void *buf, int size)
{
int bytes;

if (!sw) {
/* XXX: Consider options */
return size;
Expand All @@ -1161,8 +1156,7 @@ int AUD_read (SWVoiceIn *sw, void *buf, int size)
return 0;
}

bytes = sw->hw->pcm_ops->read (sw, buf, size);
return bytes;
return sw->hw->pcm_ops->read(sw, buf, size);
}

int AUD_get_buffer_size_out (SWVoiceOut *sw)
Expand Down
20 changes: 5 additions & 15 deletions block.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,7 @@ static void coroutine_fn bdrv_create_co_entry(void *opaque)
assert(cco->drv);

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;
}

Expand Down Expand Up @@ -364,9 +362,7 @@ int bdrv_create_file(const char *filename, QemuOpts *opts, Error **errp)
}

ret = bdrv_create(drv, filename, opts, &local_err);
if (local_err) {
error_propagate(errp, local_err);
}
error_propagate(errp, local_err);
return ret;
}

Expand Down Expand Up @@ -1763,18 +1759,14 @@ static BlockDriverState *bdrv_open_inherit(const char *filename,
QDECREF(options);
bs->options = NULL;
bdrv_unref(bs);
if (local_err) {
error_propagate(errp, local_err);
}
error_propagate(errp, local_err);
return NULL;

close_and_fail:
bdrv_unref(bs);
QDECREF(snapshot_options);
QDECREF(options);
if (local_err) {
error_propagate(errp, local_err);
}
error_propagate(errp, local_err);
return NULL;
}

Expand Down Expand Up @@ -3599,9 +3591,7 @@ void bdrv_img_create(const char *filename, const char *fmt,
out:
qemu_opts_del(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)
Expand Down
4 changes: 1 addition & 3 deletions block/archipelago.c
Original file line number Diff line number Diff line change
Expand Up @@ -974,11 +974,9 @@ static int64_t archipelago_volume_info(BDRVArchipelagoState *s)

static int64_t qemu_archipelago_getlength(BlockDriverState *bs)
{
int64_t ret;
BDRVArchipelagoState *s = bs->opaque;

ret = archipelago_volume_info(s);
return ret;
return archipelago_volume_info(s);
}

static int qemu_archipelago_truncate(BlockDriverState *bs, int64_t offset)
Expand Down
6 changes: 2 additions & 4 deletions block/qcow2-cluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,9 @@ static int l2_load(BlockDriverState *bs, uint64_t l2_offset,
uint64_t **l2_table)
{
BDRVQcow2State *s = bs->opaque;
int ret;

ret = qcow2_cache_get(bs, s->l2_table_cache, l2_offset, (void**) l2_table);

return ret;
return qcow2_cache_get(bs, s->l2_table_cache, l2_offset,
(void **)l2_table);
}

/*
Expand Down
7 changes: 2 additions & 5 deletions block/qcow2-refcount.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,10 @@ static int load_refcount_block(BlockDriverState *bs,
void **refcount_block)
{
BDRVQcow2State *s = bs->opaque;
int ret;

BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_LOAD);
ret = qcow2_cache_get(bs, s->refcount_block_cache, refcount_block_offset,
refcount_block);

return ret;
return qcow2_cache_get(bs, s->refcount_block_cache, refcount_block_offset,
refcount_block);
}

/*
Expand Down
4 changes: 1 addition & 3 deletions block/qcow2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
cluster_size, prealloc, opts, version, refcount_order,
&local_err);
if (local_err) {
error_propagate(errp, local_err);
}
error_propagate(errp, local_err);

finish:
g_free(backing_file);
Expand Down
4 changes: 1 addition & 3 deletions block/quorum.c
Original file line number Diff line number Diff line change
Expand Up @@ -971,9 +971,7 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
exit:
qemu_opts_del(opts);
/* propagate error */
if (local_err) {
error_propagate(errp, local_err);
}
error_propagate(errp, local_err);
return ret;
}

Expand Down
24 changes: 4 additions & 20 deletions block/raw-posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -582,15 +582,9 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVRawState *s = bs->opaque;
Error *local_err = NULL;
int ret;

s->type = FTYPE_FILE;
ret = raw_open_common(bs, options, flags, 0, &local_err);
if (local_err) {
error_propagate(errp, local_err);
}
return ret;
return raw_open_common(bs, options, flags, 0, errp);
}

static int raw_reopen_prepare(BDRVReopenState *state,
Expand Down Expand Up @@ -2236,9 +2230,7 @@ static int hdev_open(BlockDriverState *bs, QDict *options, int flags,

ret = raw_open_common(bs, options, flags, 0, &local_err);
if (ret < 0) {
if (local_err) {
error_propagate(errp, local_err);
}
error_propagate(errp, local_err);
#if defined(__APPLE__) && defined(__MACH__)
if (*bsd_path) {
filename = bsd_path;
Expand Down Expand Up @@ -2443,17 +2435,11 @@ static int cdrom_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVRawState *s = bs->opaque;
Error *local_err = NULL;
int ret;

s->type = FTYPE_CD;

/* 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);
if (local_err) {
error_propagate(errp, local_err);
}
return ret;
return raw_open_common(bs, options, flags, O_NONBLOCK, errp);
}

static int cdrom_probe_device(const char *filename)
Expand Down Expand Up @@ -2571,9 +2557,7 @@ static int cdrom_open(BlockDriverState *bs, QDict *options, int flags,

ret = raw_open_common(bs, options, flags, 0, &local_err);
if (ret) {
if (local_err) {
error_propagate(errp, local_err);
}
error_propagate(errp, local_err);
return ret;
}

Expand Down
9 changes: 1 addition & 8 deletions block/raw_bsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,7 @@ static int raw_has_zero_init(BlockDriverState *bs)

static int raw_create(const char *filename, QemuOpts *opts, Error **errp)
{
Error *local_err = NULL;
int ret;

ret = bdrv_create_file(filename, opts, &local_err);
if (local_err) {
error_propagate(errp, local_err);
}
return ret;
return bdrv_create_file(filename, opts, errp);
}

static int raw_open(BlockDriverState *bs, QDict *options, int flags,
Expand Down
4 changes: 1 addition & 3 deletions block/rbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -883,10 +883,8 @@ static int qemu_rbd_snap_rollback(BlockDriverState *bs,
const char *snapshot_name)
{
BDRVRBDState *s = bs->opaque;
int r;

r = rbd_snap_rollback(s->image, snapshot_name);
return r;
return rbd_snap_rollback(s->image, snapshot_name);
}

static int qemu_rbd_snap_list(BlockDriverState *bs,
Expand Down
4 changes: 1 addition & 3 deletions block/snapshot.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

if (local_err) {
error_propagate(errp, local_err);
}
error_propagate(errp, local_err);

return ret;
}
Expand Down
6 changes: 2 additions & 4 deletions block/vmdk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1260,15 +1260,13 @@ static VmdkExtent *find_extent(BDRVVmdkState *s,
static inline uint64_t vmdk_find_offset_in_cluster(VmdkExtent *extent,
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;

extent_begin_offset =
(extent->end_sector - extent->sectors) * BDRV_SECTOR_SIZE;
extent_relative_offset = offset - extent_begin_offset;
offset_in_cluster = extent_relative_offset % cluster_size;

return offset_in_cluster;
return extent_relative_offset % cluster_size;
}

static inline uint64_t vmdk_find_index_in_cluster(VmdkExtent *extent,
Expand Down
5 changes: 1 addition & 4 deletions block/vvfat.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,12 @@ static inline int array_ensure_allocated(array_t* array, int index)

static inline void* array_get_next(array_t* array) {
unsigned int next = array->next;
void* result;

if (array_ensure_allocated(array, next) < 0)
return NULL;

array->next = next + 1;
result = array_get(array, next);

return result;
return array_get(array, next);
}

static inline void* array_insert(array_t* array,unsigned int index,unsigned int count) {
Expand Down
12 changes: 3 additions & 9 deletions blockdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -3644,9 +3644,7 @@ void qmp_drive_mirror(const char *device, const char *target,
has_unmap, unmap,
&local_err);
bdrv_unref(target_bs);
if (local_err) {
error_propagate(errp, local_err);
}
error_propagate(errp, local_err);
out:
aio_context_release(aio_context);
}
Expand Down Expand Up @@ -3701,9 +3699,7 @@ void qmp_blockdev_mirror(const char *device, const char *target,
has_on_target_error, on_target_error,
true, true,
&local_err);
if (local_err) {
error_propagate(errp, local_err);
}
error_propagate(errp, local_err);

aio_context_release(aio_context);
}
Expand Down Expand Up @@ -3914,9 +3910,7 @@ void qmp_change_backing_file(const char *device,

if (ro) {
bdrv_reopen(image_bs, open_flags, &local_err);
if (local_err) {
error_propagate(errp, local_err); /* will preserve prior errp */
}
error_propagate(errp, local_err);
}

out:
Expand Down
4 changes: 1 addition & 3 deletions bootdevice.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

out:
if (local_err) {
error_propagate(errp, local_err);
}
error_propagate(errp, local_err);
}

static void property_release_bootindex(Object *obj, const char *name,
Expand Down
3 changes: 2 additions & 1 deletion bsd-user/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "qemu/osdep.h"
#include <machine/trap.h>

#include "qapi/error.h"
#include "qemu.h"
#include "qemu/path.h"
#include "qemu/help_option.h"
Expand Down Expand Up @@ -847,7 +848,7 @@ int main(int argc, char **argv)

/* init debug */
qemu_log_needs_buffers();
qemu_set_log_filename(log_file);
qemu_set_log_filename(log_file, &error_fatal);
if (log_mask) {
int mask;

Expand Down
4 changes: 1 addition & 3 deletions dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -918,9 +918,7 @@ static void write_dump_header(DumpState *s, Error **errp)
} else {
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)
Expand Down
13 changes: 3 additions & 10 deletions hw/acpi/aml-build.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,12 +324,9 @@ static void aml_free(gpointer data, gpointer user_data)

Aml *init_aml_allocator(void)
{
Aml *var;

assert(!alloc_list);
alloc_list = g_ptr_array_new();
var = aml_alloc();
return var;
return aml_alloc();
}

void free_aml_allocator(void)
Expand Down Expand Up @@ -451,12 +448,10 @@ Aml *aml_name_decl(const char *name, Aml *val)
/* ACPI 1.0b: 16.2.6.1 Arg Objects Encoding */
Aml *aml_arg(int pos)
{
Aml *var;
uint8_t op = 0x68 /* ARG0 op */ + pos;

assert(pos <= 6);
var = aml_opcode(op);
return var;
return aml_opcode(op);
}

/* ACPI 2.0a: 17.2.4.4 Type 2 Opcodes Encoding: DefToInteger */
Expand Down Expand Up @@ -1082,12 +1077,10 @@ Aml *aml_string(const char *name_format, ...)
/* ACPI 1.0b: 16.2.6.2 Local Objects Encoding */
Aml *aml_local(int num)
{
Aml *var;
uint8_t op = 0x60 /* Local0Op */ + num;

assert(num <= 7);
var = aml_opcode(op);
return var;
return aml_opcode(op);
}

/* ACPI 2.0a: 17.2.2 Data Objects Encoding: DefVarPackage */
Expand Down
Loading

0 comments on commit 7fa124b

Please sign in to comment.