`three = 1` in the linux sourcecode
github.com
`three = 1` in the linux sourcecode
1–10 of 83 posts
Re: `three = 1` in the linux sourcecode
#2Re: `three = 1` in the linux sourcecode
#3https://github.com/torvalds/linux/blob/d158fc7f36a25e19791d2...
/*
* Iterate through the groups which hold BACKUP superblock/GDT copies in an
* ext4 filesystem. The counters should be initialized to 1, 5, and 7 before
* calling this for the first time. In a sparse filesystem it will be the
* sequence of powers of 3, 5, and 7: 1, 3, 5, 7, 9, 25, 27, 49, 81, ...
* For a non-sparse filesystem it will be every group: 1, 2, 3, 4, ...
*/
I'm not sure what's so noteworthy about that. There's ton of arcane code in any kernel, as long as it's commented correctly there's no issue.Re: `three = 1` in the linux sourcecode
#4Variables `three`, `five` and `seven` are better described as `next_power_of_three`, `next_power_of_five` and `next_power_of_seven`. Since the `ext4_list_backups` function should iterate through 1 (= 3^0 = 5^0 = 7^0), 3, 5, 7, 3^2, 5^2, 3^3, 7^2, ... and 1 should not repeat three times, the initial value of `next_power_of_three` (or any of others) should be 1 and those of others should not be 1. The naming is a bit unfortunate (couldn't they be `threes` etc., for example?) but actually makes sense.
Re: `three = 1` in the linux sourcecode
#5Re: `three = 1` in the linux sourcecode
#6So I think this means three = pow(3, 0);
Re: `three = 1` in the linux sourcecode
#7At line 655: "... In a sparse filesystem it will be the sequence of powers of 3, 5, and 7: ..." So I think this means three = pow(3, 0);
Re: `three = 1` in the linux sourcecode
#8Read the comment above ext4_list_backups right above: https://github.com/torvalds/linux/blob/d158fc7f36a25e19791d2... /* * Iterate through the groups which hold BACKUP superblock/GDT copies in an * ext4 filesystem. The counters should be initialized to 1, 5, and 7 before * calling this for the first time. In a sparse filesystem it will be the * sequence of powers of 3, 5, and 7: 1, 3, 5, 7, 9, 25, 27, 49, 81, ... * F…
Good commenting is no substitute for good naming. For a variable containing the number 1, "three" is a shitty name.
Re: `three = 1` in the linux sourcecode
#9> -- Phil Karlton
Re: `three = 1` in the linux sourcecode
#10That deserves an explanation in the code comments...