lkml.org 
[lkml]   [2013]   [Jul]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] block: support embedded device command line partition
On Sat, Jul 27, 2013 at 01:56:24PM +0000, Caizhiyong wrote:
> +static int parse_partitions(struct parsed_partitions *state,
> + struct cmdline_parts *parts)
> +{
> + int slot;
> + uint64_t from = 0;
> + uint64_t disk_size;
> + char buf[BDEVNAME_SIZE];
> + struct cmdline_subpart *subpart;
> +
> + bdevname(state->bdev, buf);
> +
> + while (parts && strncmp(buf, parts->name, BDEVNAME_SIZE))
> + parts = parts->next_parts;
> +
> + if (!parts)
> + return 0;
> +
> + disk_size = (uint64_t) get_capacity(state->bdev->bd_disk) << 9;
> +
> + for (slot = 1, subpart = parts->subpart;
> + subpart && slot < state->limit;
> + subpart = subpart->next_subpart, slot++) {
> +
> + unsigned label_max;
> + struct partition_meta_info *info;
> +
> + if (subpart->from == OFFSET_CONTINUOUS)
> + subpart->from = from;
> + else
> + from = subpart->from;
> +
> + if (from >= disk_size)
> + break;
> +
> + if (subpart->size > (disk_size - from))
> + subpart->size = disk_size - from;
> +
> + from += subpart->size;
> +
> + put_partition(state, slot, le64_to_cpu(subpart->from >> 9),
> + le64_to_cpu(subpart->size >> 9));

Why le64_to_cpu()?

I guess that memparse() does not return explicitly LE and it also
seems that your code on another places uses ->size and ->from
without any extra care.

Karel

--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com


\
 
 \ /
  Last update: 2013-07-31 16:01    [W:0.054 / U:0.808 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site