Re: chvt issue

From: Toon van der Pas
Date: Mon Jan 24 2005 - 05:57:13 EST


On Mon, Jan 24, 2005 at 09:14:49AM +0100, Andries Brouwer wrote:
> On Mon, Jan 24, 2005 at 01:34:56AM +0100, Alessandro Sappia wrote:
>
> > I was reading vt driver
> > and I saw
> > /*
> > * To have permissions to do most of the vt ioctls, we either have
> > * to be the owner of the tty, or have CAP_SYS_TTY_CONFIG.
> > */
> > perm = 0;
> > if (current->signal->tty == tty || capable(CAP_SYS_TTY_CONFIG))
> > perm = 1;
> >
> > (lines 382-388 - drivers/char/vt_ioctl.c)
> >
> > After reading the comment I thinked I can change vt
> > from one of my own to another one of mine.
>
> Yes, the comment. But you should read the code instead.

In general, a comment reflects the intention of the programmer, whereas
the code reflects what he in fact ended up doing (the implementation).
So if the two don't match, the code is probably buggy.
This is why comments can be important; they reflect the intention of
the programmer at the time he wrote the code.

Toon.
--
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it." - Brian W. Kernighan
-
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/