[pve-devel] [PATCH storage 3/5] Diskmanage: add append_partition sub

Thomas Lamprecht t.lamprecht at proxmox.com
Tue Jun 4 10:32:27 CEST 2019


On 6/4/19 10:29 AM, Dominik Csapak wrote:
> On 6/4/19 10:25 AM, Thomas Lamprecht wrote:
>> On 6/4/19 9:21 AM, Dominik Csapak wrote:
>>> [snip]
>>> +
>>> +    my $newpartid = 1;
>>> +    dir_glob_foreach("/sys/block/$devname", qr/\Q$devname\E.+/, sub {
>>> +    my ($part) = @_;
>>> +
>>> +    my ($partid) = $part =~ m/(\d+)$/;
>>> +    $partid = int($partid);
>>
>> could be undef, if no parition is present, not sure if you then can hit
>> this code path at all, but maybe still worth dealing with that..
>> And yes, I know that int(undef) == 0, but it produces also a warning
>> and is a bit to subtle for my taste..
> 
> mhmm, right, better would be to include the (\d+) in the glob regex directly, so that we have it already extracted as parameter
> e.g. qr/\Q$devname\E.*?(\d+)/
> 
> ?
> 

yes, good idea, should be the correct and also a bit cleaner solution.





More information about the pve-devel mailing list