/* Returns 0 in case sectors are filled with 0, 1 if sectors contain non-zero data and negative value on error. */
static int check_empty_sectors(BlockDriverState *bs, int64_t sect_num, int sect_count, const char *filename, uint8_t *buffer, bool quiet)
/* Returns 0 in case sectors are filled with 0, 1 if sectors contain non-zero data and negative value on error. */
static int check_empty_sectors(BlockDriverState *bs, int64_t sect_num, int sect_count, const char *filename, uint8_t *buffer, bool quiet)
{
    int pnum, ret = 0;
    ret = bdrv_read(bs, sect_num, buffer, sect_count);
    if (ret < 0) {
        error_report("Error while reading offset %" PRId64 " of %s: %s",
                     sectors_to_bytes(sect_num), filename, strerror(-ret));
        return ret;
    }
    ret = is_allocated_sectors(buffer, sect_count, &pnum);
    if (ret || pnum != sect_count) {
        qprintf(quiet, "Content mismatch at offset %" PRId64 "!\n",
                sectors_to_bytes(ret ? sect_num : sect_num + pnum));
        return 1;
    }
    return 0;
}