int qed_check(BDRVQEDState *s, BdrvCheckResult *result, bool fix)

{

    QEDCheck check = {

        .s = s,

        .result = result,

        .nclusters = qed_bytes_to_clusters(s, s->file_size),

        .request = { .l2_table = NULL },

        .fix = fix,

    };

    int ret;



    check.used_clusters = g_try_malloc0(((check.nclusters + 31) / 32) *

                                        sizeof(check.used_clusters[0]));

    if (check.nclusters && check.used_clusters == NULL) {

        return -ENOMEM;

    }



    check.result->bfi.total_clusters =

        (s->header.image_size + s->header.cluster_size - 1) /

            s->header.cluster_size;

    ret = qed_check_l1_table(&check, s->l1_table);

    if (ret == 0) {

        /* Only check for leaks if entire image was scanned successfully */

        qed_check_for_leaks(&check);



        if (fix) {

            qed_check_mark_clean(s, result);

        }

    }



    g_free(check.used_clusters);

    return ret;

}

int qed_check(BDRVQEDState *s, BdrvCheckResult *result, bool fix)

{

    QEDCheck check = {

        .s = s,

        .result = result,

        .nclusters = qed_bytes_to_clusters(s, s->file_size),

        .request = { .l2_table = NULL },

        .fix = fix,

    };

    int ret;



    check.used_clusters = g_try_malloc0(((check.nclusters + 31) / 32) *

                                        sizeof(check.used_clusters[0]));

    if (check.nclusters && check.used_clusters == NULL) {

        return -ENOMEM;

    }



    check.result->bfi.total_clusters =

        (s->header.image_size + s->header.cluster_size - 1) /

            s->header.cluster_size;

    ret = qed_check_l1_table(&check, s->l1_table);

    if (ret == 0) {

        

        qed_check_for_leaks(&check);



        if (fix) {

            qed_check_mark_clean(s, result);

        }

    }



    g_free(check.used_clusters);

    return ret;

}

    check.used_clusters = g_try_malloc0(((check.nclusters + 31) / 32) *                                         sizeof(check.used_clusters[0]));
int FUNC_0(BDRVQEDState *VAR_0, BdrvCheckResult *VAR_1, bool VAR_2)

{

    QEDCheck check = {

        .VAR_0 = VAR_0,

        .VAR_1 = VAR_1,

        .nclusters = qed_bytes_to_clusters(VAR_0, VAR_0->file_size),

        .request = { .l2_table = NULL },

        .VAR_2 = VAR_2,

    };

    int VAR_3;



    check.used_clusters = g_try_malloc0(((check.nclusters + 31) / 32) *

                                        sizeof(check.used_clusters[0]));

    if (check.nclusters && check.used_clusters == NULL) {

        return -ENOMEM;

    }



    check.VAR_1->bfi.total_clusters =

        (VAR_0->header.image_size + VAR_0->header.cluster_size - 1) /

            VAR_0->header.cluster_size;

    VAR_3 = qed_check_l1_table(&check, VAR_0->l1_table);

    if (VAR_3 == 0) {

        

        qed_check_for_leaks(&check);



        if (VAR_2) {

            qed_check_mark_clean(VAR_0, VAR_1);

        }

    }



    g_free(check.used_clusters);

    return VAR_3;

}

int FUNC_0(BDRVQEDState *VAR_0, BdrvCheckResult *VAR_1, bool VAR_2)
{ QEDCheck check = { .VAR_0 = VAR_0,
.VAR_1 = VAR_1,
.nclusters = qed_bytes_to_clusters(VAR_0, VAR_0->file_size),
.request = { .l2_table = NULL }, .VAR_2 = VAR_2,
}; int VAR_3; check.used_clusters = g_try_malloc0(((check.nclusters + 31) / 32) *
sizeof(check.used_clusters[0])); if (check.nclusters && check.used_clusters == NULL) { return -ENOMEM; } check.VAR_1->bfi.total_clusters =
(VAR_0->header.image_size + VAR_0->header.cluster_size - 1) /
VAR_0->header.cluster_size; VAR_3 = qed_check_l1_table(&check, VAR_0->l1_table); if (VAR_3 == 0) { qed_check_for_leaks(&check); if (VAR_2) { qed_check_mark_clean(VAR_0, VAR_1); } } g_free(check.used_clusters); return VAR_3; }