* funny looking equation
@ 2006-10-11 19:40 Steven Rostedt
2006-10-11 19:48 ` Randy Dunlap
0 siblings, 1 reply; 2+ messages in thread
From: Steven Rostedt @ 2006-10-11 19:40 UTC (permalink / raw)
To: LKML; +Cc: linux-net
I was just testing some of my parsing code on all the .c and .h files in
the Linux kernel, and I came up with this little equation:
from 2.6.18 drivers/atm/eni.c:1272
---
int div;
if (!*pcr) *pcr = eni_dev->tx_bw+reserved;
for (*pre = 3; *pre >= 0; (*pre)--)
if (TS_CLOCK/pre_div[*pre]/64 > -*pcr) break;
if (*pre < 3) (*pre)++; /* else fail later */
div = pre_div[*pre]*-*pcr;
^^^^^^^^^^^^^
This could really do with some spaces and a couple of parenthesis.
DPRINTK("max div %d\n",div);
*res = (TS_CLOCK+div-1)/div-1;
---
Oh well, this isn't a bug. Just something that someone might want to
clean up the next time they touch that code.
-- Steve
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: funny looking equation
2006-10-11 19:40 funny looking equation Steven Rostedt
@ 2006-10-11 19:48 ` Randy Dunlap
0 siblings, 0 replies; 2+ messages in thread
From: Randy Dunlap @ 2006-10-11 19:48 UTC (permalink / raw)
To: Steven Rostedt; +Cc: LKML, linux-net
On Wed, 11 Oct 2006 15:40:55 -0400 Steven Rostedt wrote:
> I was just testing some of my parsing code on all the .c and .h files in
> the Linux kernel, and I came up with this little equation:
>
> from 2.6.18 drivers/atm/eni.c:1272
>
>
> ---
> int div;
>
> if (!*pcr) *pcr = eni_dev->tx_bw+reserved;
> for (*pre = 3; *pre >= 0; (*pre)--)
> if (TS_CLOCK/pre_div[*pre]/64 > -*pcr) break;
> if (*pre < 3) (*pre)++; /* else fail later */
> div = pre_div[*pre]*-*pcr;
> ^^^^^^^^^^^^^
> This could really do with some spaces and a couple of parenthesis.
>
> DPRINTK("max div %d\n",div);
> *res = (TS_CLOCK+div-1)/div-1;
> ---
>
>
> Oh well, this isn't a bug. Just something that someone might want to
> clean up the next time they touch that code.
and break the if-lines into kernel style.
---
~Randy
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-10-11 19:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-11 19:40 funny looking equation Steven Rostedt
2006-10-11 19:48 ` Randy Dunlap
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.