int qcow2_refcount_init(BlockDriverState *bs)

{

    BDRVQcowState *s = bs->opaque;

    unsigned int refcount_table_size2, i;

    int ret;



    assert(s->refcount_table_size <= INT_MAX / sizeof(uint64_t));

    refcount_table_size2 = s->refcount_table_size * sizeof(uint64_t);

    s->refcount_table = g_try_malloc(refcount_table_size2);



    if (s->refcount_table_size > 0) {

        if (s->refcount_table == NULL) {

            goto fail;

        }

        BLKDBG_EVENT(bs->file, BLKDBG_REFTABLE_LOAD);

        ret = bdrv_pread(bs->file, s->refcount_table_offset,

                         s->refcount_table, refcount_table_size2);

        if (ret != refcount_table_size2)

            goto fail;

        for(i = 0; i < s->refcount_table_size; i++)

            be64_to_cpus(&s->refcount_table[i]);

    }

    return 0;

 fail:

    return -ENOMEM;

}

int qcow2_refcount_init(BlockDriverState *bs)

{

    BDRVQcowState *s = bs->opaque;

    unsigned int refcount_table_size2, i;

    int ret;



    assert(s->refcount_table_size <= INT_MAX / sizeof(uint64_t));

    refcount_table_size2 = s->refcount_table_size * sizeof(uint64_t);

    s->refcount_table = g_try_malloc(refcount_table_size2);



    if (s->refcount_table_size > 0) {

        if (s->refcount_table == NULL) {

            goto fail;

        }

        BLKDBG_EVENT(bs->file, BLKDBG_REFTABLE_LOAD);

        ret = bdrv_pread(bs->file, s->refcount_table_offset,

                         s->refcount_table, refcount_table_size2);

        if (ret != refcount_table_size2)

            goto fail;

        for(i = 0; i < s->refcount_table_size; i++)

            be64_to_cpus(&s->refcount_table[i]);

    }

    return 0;

 fail:

    return -ENOMEM;

}

        if (ret != refcount_table_size2)     return -ENOMEM;
int FUNC_0(BlockDriverState *VAR_0)

{

    BDRVQcowState *s = VAR_0->opaque;

    unsigned int VAR_1, VAR_2;

    int VAR_3;



    assert(s->refcount_table_size <= INT_MAX / sizeof(uint64_t));

    VAR_1 = s->refcount_table_size * sizeof(uint64_t);

    s->refcount_table = g_try_malloc(VAR_1);



    if (s->refcount_table_size > 0) {

        if (s->refcount_table == NULL) {

            goto fail;

        }

        BLKDBG_EVENT(VAR_0->file, BLKDBG_REFTABLE_LOAD);

        VAR_3 = bdrv_pread(VAR_0->file, s->refcount_table_offset,

                         s->refcount_table, VAR_1);

        if (VAR_3 != VAR_1)

            goto fail;

        for(VAR_2 = 0; VAR_2 < s->refcount_table_size; VAR_2++)

            be64_to_cpus(&s->refcount_table[VAR_2]);

    }

    return 0;

 fail:

    return -ENOMEM;

}

int FUNC_0(BlockDriverState *VAR_0)
{ BDRVQcowState *s = VAR_0->opaque; unsigned int VAR_1, VAR_2; int VAR_3; assert(s->refcount_table_size <= INT_MAX / sizeof(uint64_t)); VAR_1 = s->refcount_table_size * sizeof(uint64_t); s->refcount_table = g_try_malloc(VAR_1); if (s->refcount_table_size > 0) { if (s->refcount_table == NULL) { goto fail; } BLKDBG_EVENT(VAR_0->file, BLKDBG_REFTABLE_LOAD); VAR_3 = bdrv_pread(VAR_0->file, s->refcount_table_offset,
s->refcount_table, VAR_1); if (VAR_3 != VAR_1)
goto fail; for(VAR_2 = 0; VAR_2 < s->refcount_table_size; VAR_2++) be64_to_cpus(&s->refcount_table[VAR_2]); } return 0; fail:
return -ENOMEM; }