On Wed, Mar 7, 2012 at 9:22 AM, Dong Xu Wang <[email protected]> wrote:
> + for (i = 0; i < table_noffsets; i++) {
> + l2_offset = s->l1_table->offsets[i];
> + if (l2_offset == 0) {
if (qed_offset_is_unalloc_cluster(l2_offset)) {
> + continue;
> + }
> + ret = bdrv_pread(bs->file, l2_offset, table, size);
> + if (ret < 0) {
> + qemu_vfree(table);
> + return ret;
> + }
> + for (j = 0; j < size/sizeof(uint64_t); j++) {
> + uint64_t *offset = (uint64_t *)(table + j);
No need to cast, table is already uint64_t*.
Since you don't write to the offset, I would just do:
uint64_t offset = table[j];
> + if (*offset < cluster_size) {
> + continue;
> + }
if (!qed_check_cluster_offset(s, offset)) {
continue;
}
We will skip unallocated clusters and zero clusters.
Stefan