[Mageia-dev] [soft-commits] [3964] Fix partition numbering on GPT (mga#3091)

Guillaume Rousse guillomovitch at gmail.com
Fri Apr 6 10:34:57 CEST 2012


Le 06/04/2012 09:58, Thierry Vignaud a écrit :
> On 6 April 2012 00:00,<root at mageia.org>  wrote:
>> Fix partition numbering on GPT (mga#3091)
>
> (...)
>
>> @@ -27,9 +28,20 @@
>>               $p{start} = $5;
>>               $p{size} = $7;
>>           }
>> -        \%p;
>> +        $p{part_number} =>  \%p;
>>       } c::get_disk_partitions($hd->{file});
>>
>> +    my @pt = map {
>> +	my $part_number = $_;
>> +	if ($parts{$part_number}) {
>> +	    $parts{$part_number};
>> +	} else {
>> +	    my %p;
>> +	    $p{part_number} = $part_number;
>> +	    \%p;
>
> This is simpler&  more readable:
>
> { part_number =>  $part_number };
>
> anyway it would be maybe simpler go one of the way I attach.
> WDYT?
I like the 'simpler' adjective when I have to read this stuff at least 3 
times to get an idea of what it happening... A simple comment wouldn't 
hurt there.

Anyway, allocating the list content in a single pass seems simpler to 
understand for me. I'd rather use something as:

# create an exhaustive list including %parts content if existing
# for given partition number, a default structure otherwise
my @pt = map {
         $parts{$_} ? $parts{$_} : { part_number => $_ }
     } 1..$nb_primary;

More general remarks:

What about using consistent variable names ? If you have a collection of 
'something' stored in a hash, why should it suddenly became of 
collection of 'st' when transfering them into an array ? Or using a 
consistent format for variables storing numbers, rather than having both 
nb_foo and bar_number ?

And I don't underestand the interest of using an hash for storing 
content with numerical indexes only. Especially if you have to convert 
it to an array at the end...

-- 
BOFH excuse #79:

Look, buddy:  Windows 3.1 IS A General Protection Fault.


More information about the Mageia-dev mailing list