Andy found this simple function in a C project he's working on.
void clearVal(int x) {
x = 0;
}
This is a thing of beauty, right here. From the very first premise, the function is useless: set an integer to zero. It's not even clearer about its intent than the original one liner- arguably it's less clear.
But it also has the benefit of not doing anything. Whoever wrote this function perhaps intended it to take a pointer. But as written, this just creates a local variable called x
, which starts with whatever value the caller passed in, and sets the value of the local variable to zero. Nothing outside the scope of this function gets changed.