static void compare_refcounts(BlockDriverState *bs, BdrvCheckResult *res,

                              BdrvCheckMode fix, int64_t *highest_cluster,

                              uint16_t *refcount_table, int64_t nb_clusters)

{

    BDRVQcowState *s = bs->opaque;

    int64_t i;

    int refcount1, refcount2, ret;



    for (i = 0, *highest_cluster = 0; i < nb_clusters; i++) {

        refcount1 = get_refcount(bs, i);

        if (refcount1 < 0) {

            fprintf(stderr, "Can't get refcount for cluster %" PRId64 ": %s\n",

                i, strerror(-refcount1));

            res->check_errors++;

            continue;

        }



        refcount2 = refcount_table[i];



        if (refcount1 > 0 || refcount2 > 0) {

            *highest_cluster = i;

        }



        if (refcount1 != refcount2) {

            /* Check if we're allowed to fix the mismatch */

            int *num_fixed = NULL;

            if (refcount1 > refcount2 && (fix & BDRV_FIX_LEAKS)) {

                num_fixed = &res->leaks_fixed;

            } else if (refcount1 < refcount2 && (fix & BDRV_FIX_ERRORS)) {

                num_fixed = &res->corruptions_fixed;

            }



            fprintf(stderr, "%s cluster %" PRId64 " refcount=%d reference=%d\n",

                   num_fixed != NULL     ? "Repairing" :

                   refcount1 < refcount2 ? "ERROR" :

                                           "Leaked",

                   i, refcount1, refcount2);



            if (num_fixed) {

                ret = update_refcount(bs, i << s->cluster_bits, 1,

                                      refcount2 - refcount1,

                                      QCOW2_DISCARD_ALWAYS);

                if (ret >= 0) {

                    (*num_fixed)++;

                    continue;

                }

            }



            /* And if we couldn't, print an error */

            if (refcount1 < refcount2) {

                res->corruptions++;

            } else {

                res->leaks++;

            }

        }

    }

}

static void compare_refcounts(BlockDriverState *bs, BdrvCheckResult *res,

                              BdrvCheckMode fix, int64_t *highest_cluster,

                              uint16_t *refcount_table, int64_t nb_clusters)

{

    BDRVQcowState *s = bs->opaque;

    int64_t i;

    int refcount1, refcount2, ret;



    for (i = 0, *highest_cluster = 0; i < nb_clusters; i++) {

        refcount1 = get_refcount(bs, i);

        if (refcount1 < 0) {

            fprintf(stderr, "Can't get refcount for cluster %" PRId64 ": %s\n",

                i, strerror(-refcount1));

            res->check_errors++;

            continue;

        }



        refcount2 = refcount_table[i];



        if (refcount1 > 0 || refcount2 > 0) {

            *highest_cluster = i;

        }



        if (refcount1 != refcount2) {

            

            int *num_fixed = NULL;

            if (refcount1 > refcount2 && (fix & BDRV_FIX_LEAKS)) {

                num_fixed = &res->leaks_fixed;

            } else if (refcount1 < refcount2 && (fix & BDRV_FIX_ERRORS)) {

                num_fixed = &res->corruptions_fixed;

            }



            fprintf(stderr, "%s cluster %" PRId64 " refcount=%d reference=%d\n",

                   num_fixed != NULL     ? "Repairing" :

                   refcount1 < refcount2 ? "ERROR" :

                                           "Leaked",

                   i, refcount1, refcount2);



            if (num_fixed) {

                ret = update_refcount(bs, i << s->cluster_bits, 1,

                                      refcount2 - refcount1,

                                      QCOW2_DISCARD_ALWAYS);

                if (ret >= 0) {

                    (*num_fixed)++;

                    continue;

                }

            }



            

            if (refcount1 < refcount2) {

                res->corruptions++;

            } else {

                res->leaks++;

            }

        }

    }

}

    BDRVQcowState *s = bs->opaque;     BDRVQcowState *s = bs->opaque;                               BdrvCheckMode fix, int64_t *highest_cluster,             if (refcount1 > refcount2 && (fix & BDRV_FIX_LEAKS)) {
static void FUNC_0(BlockDriverState *VAR_0, BdrvCheckResult *VAR_1,

                              BdrvCheckMode VAR_2, int64_t *VAR_3,

                              uint16_t *VAR_4, int64_t VAR_5)

{

    BDRVQcowState *s = VAR_0->opaque;

    int64_t i;

    int VAR_6, VAR_7, VAR_8;



    for (i = 0, *VAR_3 = 0; i < VAR_5; i++) {

        VAR_6 = get_refcount(VAR_0, i);

        if (VAR_6 < 0) {

            fprintf(stderr, "Can't get refcount for cluster %" PRId64 ": %s\n",

                i, strerror(-VAR_6));

            VAR_1->check_errors++;

            continue;

        }



        VAR_7 = VAR_4[i];



        if (VAR_6 > 0 || VAR_7 > 0) {

            *VAR_3 = i;

        }



        if (VAR_6 != VAR_7) {

            

            int *num_fixed = NULL;

            if (VAR_6 > VAR_7 && (VAR_2 & BDRV_FIX_LEAKS)) {

                num_fixed = &VAR_1->leaks_fixed;

            } else if (VAR_6 < VAR_7 && (VAR_2 & BDRV_FIX_ERRORS)) {

                num_fixed = &VAR_1->corruptions_fixed;

            }



            fprintf(stderr, "%s cluster %" PRId64 " refcount=%d reference=%d\n",

                   num_fixed != NULL     ? "Repairing" :

                   VAR_6 < VAR_7 ? "ERROR" :

                                           "Leaked",

                   i, VAR_6, VAR_7);



            if (num_fixed) {

                VAR_8 = update_refcount(VAR_0, i << s->cluster_bits, 1,

                                      VAR_7 - VAR_6,

                                      QCOW2_DISCARD_ALWAYS);

                if (VAR_8 >= 0) {

                    (*num_fixed)++;

                    continue;

                }

            }



            

            if (VAR_6 < VAR_7) {

                VAR_1->corruptions++;

            } else {

                VAR_1->leaks++;

            }

        }

    }

}

static void FUNC_0(BlockDriverState *VAR_0, BdrvCheckResult *VAR_1,
BdrvCheckMode VAR_2, int64_t *VAR_3,
uint16_t *VAR_4, int64_t VAR_5)
{ BDRVQcowState *s = VAR_0->opaque; int64_t i; int VAR_6, VAR_7, VAR_8; for (i = 0, *VAR_3 = 0; i < VAR_5; i++) { VAR_6 = get_refcount(VAR_0, i); if (VAR_6 < 0) { fprintf(stderr, "Can't get refcount for cluster %" PRId64 ": %s\n",
i, strerror(-VAR_6)); VAR_1->check_errors++; continue; } VAR_7 = VAR_4[i]; if (VAR_6 > 0 || VAR_7 > 0) { *VAR_3 = i; } if (VAR_6 != VAR_7) { int *num_fixed = NULL; if (VAR_6 > VAR_7 && (VAR_2 & BDRV_FIX_LEAKS)) { num_fixed = &VAR_1->leaks_fixed; } else if (VAR_6 < VAR_7 && (VAR_2 & BDRV_FIX_ERRORS)) { num_fixed = &VAR_1->corruptions_fixed; } fprintf(stderr, "%s cluster %" PRId64 " refcount=%d reference=%d\n",
num_fixed != NULL     ? "Repairing" :
VAR_6 < VAR_7 ? "ERROR" :
"Leaked",
i, VAR_6, VAR_7); if (num_fixed) { VAR_8 = update_refcount(VAR_0, i << s->cluster_bits, 1,
VAR_7 - VAR_6,
QCOW2_DISCARD_ALWAYS); if (VAR_8 >= 0) { (*num_fixed)++; continue; } } if (VAR_6 < VAR_7) { VAR_1->corruptions++; } else { VAR_1->leaks++; } } } }