Commit 9be38598 authored by Eduardo Habkost's avatar Eduardo Habkost Committed by Markus Armbruster
Browse files

coccinelle: Remove unnecessary variables for function return value



Use Coccinelle script to replace 'ret = E; return ret' with
'return E'. The script will do the substitution only when the
function return type and variable type are the same.

Manual fixups:

* audio/audio.c: coding style of "read (...)" and "write (...)"
* block/qcow2-cluster.c: wrap line to make it shorter
* block/qcow2-refcount.c: change indentation of wrapped line
* target-tricore/op_helper.c: fix coding style of
  "remainder|quotient"
* target-mips/dsp_helper.c: reverted changes because I don't
  want to argue about checkpatch.pl
* ui/qemu-pixman.c: fix line indentation
* block/rbd.c: restore blank line between declarations and
  statements

Reviewed-by: default avatarEric Blake <eblake@redhat.com>
Signed-off-by: default avatarEduardo Habkost <ehabkost@redhat.com>
Message-Id: <1465855078-19435-4-git-send-email-ehabkost@redhat.com>
Reviewed-by: default avatarMarkus Armbruster <armbru@redhat.com>
[Unused Coccinelle rule name dropped along with a redundant comment;
whitespace touched up in block/qcow2-cluster.c; stale commit message
paragraph deleted]
Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
parent 6b62d961
Loading
Loading
Loading
Loading
+2 −8
Original line number Diff line number Diff line
@@ -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;
@@ -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;
@@ -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)
+1 −3
Original line number Diff line number Diff line
@@ -974,11 +974,9 @@ err_exit2:

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)
+2 −4
Original line number Diff line number Diff line
@@ -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);
}

/*
+2 −5
Original line number Diff line number Diff line
@@ -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,
    return qcow2_cache_get(bs, s->refcount_block_cache, refcount_block_offset,
                           refcount_block);

    return ret;
}

/*
+2 −6
Original line number Diff line number Diff line
@@ -582,11 +582,9 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags,
                    Error **errp)
{
    BDRVRawState *s = bs->opaque;
    int ret;

    s->type = FTYPE_FILE;
    ret = raw_open_common(bs, options, flags, 0, errp);
    return ret;
    return raw_open_common(bs, options, flags, 0, errp);
}

static int raw_reopen_prepare(BDRVReopenState *state,
@@ -2437,13 +2435,11 @@ static int cdrom_open(BlockDriverState *bs, QDict *options, int flags,
                      Error **errp)
{
    BDRVRawState *s = bs->opaque;
    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, errp);
    return ret;
    return raw_open_common(bs, options, flags, O_NONBLOCK, errp);
}

static int cdrom_probe_device(const char *filename)
Loading