lkml.org 
[lkml]   [2011]   [Jun]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: Linux 3.0-rc3
On Wed, Jun 15, 2011 at 12:44 PM, Linus Torvalds
<torvalds@linux-foundation.org> 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


\
 
 \ /
  Last update: 2011-06-15 21:55    [W:0.048 / U:1.816 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site