Re: Linux 3.0-rc3

From: Linus Torvalds
Date: Wed Jun 15 2011 - 15:52:24 EST


On Wed, Jun 15, 2011 at 12:44 PM, Linus Torvalds
<torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> I really don't see why you should ever parse a version number.

Let me modulate that: I do see why you would ever say "is this version
xyz" - but then you don't have to be very smart about parsing things,
because a failure to parse just means "no". So there is never any case
where a failure to parse something means that you cannot answer the
question, and failure to parse it never becomes a failure for the
program itself.

So doing

if (!strncmp(version, "v2.4", 4))
workaround_for_old_version = true;

is valid. But only if you really have special code for those specific
old versions that you know, and have normal code for everything else.

So if you then confinue with

else if (!strncmp(version, "v2.6", 4))
error("unknown version");

then you're just being an ass.

Why? At that point you're no longer correcting for known bugs or
mis-features, at that point you're just being stupid and parsing the
version string for no good reason.

So "checking for _particular_ old versions that you know about" is
fine. Checking for versions you _don't_ know about or understand is
stupid.

Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/