News for hackers. Stuff that matters.
Re:`three = 1` in the Linux sourcecode (2014) by oji0hub on Tuesday March 09, 2021 @06:46AM (#26397913)
People make typos and simple mistakes all the time, regardless of experience.
Re:`three = 1` in the Linux sourcecode (2014) by scotty79 on Tuesday March 09, 2021 @08:47AM (#26398684)
True. But the intention of writing

    int three = 3;
is insane.

I would never ascribe to previous programmer (unless he just learned what variables are) the intention of creating variable (not even constant, which wouldn't make it any better) named 'three' and assigning actual value 3 to it.

Re:`three = 1` in the Linux sourcecode (2014) by forgottenlogin9 on Tuesday March 09, 2021 @09:13AM (#26398929)
If that is insane, you may not have issue with this specific line but you surely have issue with the 2 “insane” lines that follow it?
Re:`three = 1` in the Linux sourcecode (2014) by esrauch on Tuesday March 09, 2021 @09:23AM (#26399013)
All three lines would be "insane" if the variables weren't mutated. As in a variable named "three" is insane if it solely contains either of the values 1 or 3.

When it contains other values it is still subpar variable naming.

Re:`three = 1` in the Linux sourcecode (2014) by scotty79 on Tuesday March 09, 2021 @10:49AM (#26399935)
If something looks insane, but probablu sane person made it and it works then that's usually good indicator that you are missing part of the picture and should look around. It still might be bad, but probably not insane.
Re:`three = 1` in the Linux sourcecode (2014) by Guthur on Tuesday March 09, 2021 @06:50AM (#26397941)
+1 seen it so many times, often times from some cut and paste heavy refactor, one is more or less going on autopilot just moving substrings around and then bam. Review process hopefully catches it, when it is a bug, and potentially when the semantics are unclear...