[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1389985724.31367.497.camel@edumazet-glaptop2.roam.corp.google.com>
Date: Fri, 17 Jan 2014 11:08:44 -0800
From: Eric Dumazet <eric.dumazet@...il.com>
To: Ben Hutchings <bhutchings@...arflare.com>
Cc: Hannes Frederic Sowa <hannes@...essinduktion.org>,
netdev@...r.kernel.org, Daniel Borkmann <dborkman@...hat.com>,
Jakub Zawadzki <darkjames-ws@...kjames.pl>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next v2 2/3] net: add trim helper and convert users
On Fri, 2014-01-17 at 18:15 +0000, Ben Hutchings wrote:
> On Fri, 2014-01-17 at 01:28 +0100, Hannes Frederic Sowa wrote:
> [...]
> > --- a/include/linux/kernel.h
> > +++ b/include/linux/kernel.h
> > @@ -193,6 +193,25 @@ extern int _cond_resched(void);
> > (__x < 0) ? -__x : __x; \
> > })
> >
> > +/**
> > + * trim - perform a reciprocal multiplication in order to "clamp" a
> > + * value into range [0, ep_ro), where the upper interval
> > + * endpoint is right-open. This is useful, e.g. for accessing
> > + * a index of an array containing ep_ro elements, for example.
> > + * Think of it as sort of modulus, only that the result isn't
> > + * that of modulo. ;)
> > + * More: http://homepage.cs.uiowa.edu/~jones/bcd/divide.html
> [...]
>
> And you think trim() is an obvious name for that?!
> How about: scale_u32_to_range().
>
> Also the first physical line of a kernel-doc comment (after the name) is
> a summary which is used, for example, in the summary line on a manual
> page. It seems like you have the summary and full description the wrong
> way round here.
BTW the 'scaling' depends on u32 value being pretty much random.
If initial input is a small value like 0 .. 1000, then trim(x, 1000)
will return 0
I liked the reciprocal name because it was really expressing the
reciprocal idea.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists