Live data from Hacker News

`three = 1` in the linux sourcecode

github.com

11–20 of 83 posts

Re: `three = 1` in the linux sourcecode

#13

> There are only two hard things in Computer Science: cache invalidation and naming things. > -- Phil Karlton

there are two hard things in computer science: cache invalidation, naming things, and off-by-one errors

http://martinfowler.com/bliki/TwoHardThings.html

Re: `three = 1` in the linux sourcecode

#17
post #8
post #3

Read 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…

See this comment: https://news.ycombinator.com/item?id=7296586 Good commenting is no substitute for good naming. For a variable containing the number 1, "three" is a shitty name.

Okay? Is that really worthy of being submitted to hn however?

The function being called is directly above this declaration. It's a static function not used outside of this file. What are the chances that someone would edit this code without understanding what "three" is used for in this context? Pretty slim I wager.

It's good that people are auditing the linux source code but if you stumble upon some weird looking code (which again, is not the case here in my opinion) the right way to deal with it is not to post it on hacker news. Contact the maintainer (look at the MAINTAINER file at the root of the kernel) if possible with a patch to fix the issue.

Re: `three = 1` in the linux sourcecode

#18

https://github.com/torvalds/linux/blob/d158fc7f36a25e19791d2... Variables `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…

A perfect example of a missing code-comment.

Re: `three = 1` in the linux sourcecode

#19

> There are only two hard things in Computer Science: cache invalidation and naming things. > -- Phil Karlton

I've always thought that the "naming things" refers to the more subtle problem of giving things unique identifiers in distributed systems, rather than coming up with variable names.

"Naming things" includes systems like MAC address allocation, IP address allocation, DNS, URLs for documents, process IDs, name to inode mapping in filesystems, autoincrement primary keys in databases, etc.

Any ideas on what Karlton really meant with the quote?

Re: `three = 1` in the linux sourcecode

#20

> There are only two hard things in Computer Science: cache invalidation and naming things. > -- Phil Karlton

there are two hard things in computer science: cache invalidation, naming things, and off-by-one errors

there are three hard things concurrency, in computer science: cache invalidation, naming things, and off-by-one errors
Post reply on HN