Re: [PATCH] af_rose.c: s/suser/capable/ + micro cleanups

From: Rogier Wolff (R.E.Wolff@BitWizard.nl)
Date: Wed Aug 30 2000 - 02:17:24 EST


Arnaldo Carvalho de Melo wrote:
> Em Tue, Aug 29, 2000 at 10:31:22PM +0100, Philipp Rumpf escreveu:
> > On Sun, Aug 27, 2000 at 10:28:14PM +0200, Kenneth Johansson wrote:
> > > Arnaldo Carvalho de Melo wrote:
> > >
> > > > #include <linux/config.h>
> > > > @@ -510,10 +511,7 @@
> > > > if (put_user(len, optlen))
> > > > return -EFAULT;
> > > >
> > > > - if (copy_to_user(optval, &val, len))
> > > > - return -EFAULT;
> > > > -
> > > > - return 0;
> > > > + return copy_to_user(optval, &val, len) ? -EFAULT : 0;
> > > > }
> > >
> > > What is this are you trying to compress the source code ?
> > > I like the old way better. I think it is faster to read and understand.
> >
> > Same here. Linus, I didn't actually interpret your mail on the subject as
> > proposing changes like the one above. Care to enlighten this a bit ?

> source code smaller and more easier to read (yes, this is debatable,
> I think it becomes more clean, other think otherwise, I'm just
> following what Linus said he prefer).

The kernel is a multi-million-lines-of-code piece of software.
Software maintenance cost is found to correlate strongly with the
number of lines-of-code.

So, I would prefer the shorter version.

If it takes you a few seconds to look this over, that's fine. Even it
the one "complicated" line take twice as long (per line) as the
original 4 lines, then it's a win.

And when you take 10 times longer grokking that one line, you need to
do that just once. This construct is used all over the code. You
should learn to recognize it.

If you see:

        for (i=0;i<10;i++)

you immediately recognize a loop that iterates 10 times. Not 9, not
11. You don't go figuring out and counting things with the starting
and ending iteration.

With a little practise, the same will happen with the
        return ..?-efault : 0;

                        Roger.

-- 
** R.E.Wolff@BitWizard.nl ** http://www.BitWizard.nl/ ** +31-15-2137555 **
*-- BitWizard writes Linux device drivers for any device you may have! --*
*       Common sense is the collection of                                *
******  prejudices acquired by age eighteen.   -- Albert Einstein ********
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Aug 31 2000 - 21:00:25 EST