/* Performs sanity check for supplied partition. Offset and size are verified to be within valid range. Partition type is checked and part_validate_eraseblock() is called with the argument of part. */
static int part_validate(struct mtdids *id, struct part_info *part)
/* Performs sanity check for supplied partition. Offset and size are verified to be within valid range. Partition type is checked and part_validate_eraseblock() is called with the argument of part. */
static int part_validate(struct mtdids *id, struct part_info *part)
{
	if (part->size == SIZE_REMAINING)
		part->size = id->size - part->offset;
	if (part->offset > id->size) {
		printf("%s: offset %08llx beyond flash size %08llx\n",
				id->mtd_id, part->offset, id->size);
		return 1;
	}
	if ((part->offset + part->size) <= part->offset) {
		printf("%s%d: partition (%s) size too big\n",
				MTD_DEV_TYPE(id->type), id->num, part->name);
		return 1;
	}
	if (part->offset + part->size > id->size) {
		printf("%s: partitioning exceeds flash size\n", id->mtd_id);
		return 1;
	}
	return part_validate_eraseblock(id, part);
}