[parted-devel] [PATCH] Read an msdos partition table from a device with 2K sectors.

Jim Meyering jim at meyering.net
Wed May 30 22:34:24 UTC 2007


Otavio Salvador <otavio at debian.org> wrote:

> Jim Meyering <jim at meyering.net> writes:
>
>>  static int
>>  msdos_probe (const PedDevice *dev)
>>  {
>>  	PedDiskType*	disk_type;
>> -	DosRawTable	part_table;
>> +	DosRawTable*	part_table;
>>  	int		i;
>>
>>  	PED_ASSERT (dev != NULL, return 0);
>>
>> -        if (dev->sector_size != 512)
>> +        if (dev->sector_size < sizeof *part_table)
>>                  return 0;
>
> Shouldn't it be sizeof(DosRawTable)? part_table points to a unkown
> place at this point or am I missing something?

No.  First, "*part_table" as an argument to sizeof doesn't
cause a dereference.  Rather it identifies the type that the
sizeof operator operates on.

FYI, using the variable name with sizeof is better coding
style (more maintainable) than using the type name.  And if you
did want to use a type there, it'd have to be "struct DosRawTable"
in this case.

>> -	if (!ped_device_read (dev, &part_table, 0, 1))
>> +	char *label;
>> +	if (!read_sector (dev, 0, &label))
>>  		return 0;
>>
>> +        part_table = (DosRawTable *) label;
>> +
>
> Please, fix this indent to follow rest of file "standard" :(

Ok.



More information about the parted-devel mailing list