All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: shemminger@vyatta.com
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH] tcp_probe: avoid modulus operation and wrap fix
Date: Sun, 24 Jan 2010 22:41:22 -0800 (PST)	[thread overview]
Message-ID: <20100124.224122.13742906.davem@davemloft.net> (raw)
In-Reply-To: <20100124215001.78251e25@nehalam>

From: Stephen Hemminger <shemminger@vyatta.com>
Date: Sun, 24 Jan 2010 21:50:01 -0800

> @@ -75,12 +75,12 @@ static struct {
>  
>  static inline int tcp_probe_used(void)
>  {
> -	return (tcp_probe.head - tcp_probe.tail) % bufsize;
> +	return (tcp_probe.head - tcp_probe.tail) & (bufsize - 1);
>  }
>  
>  static inline int tcp_probe_avail(void)
>  {
> -	return bufsize - tcp_probe_used();
> +	return bufsize - tcp_probe_used() - 1;
>  }
>  
>  /*

Hmmm...  When the ring is full head==tail, which means
tcp_probe_used() returns 0.  Which would now make tcp_probe_avail()
return "bufsize - 0 - 1".

Is that right?

  reply	other threads:[~2010-01-25  6:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-25  5:50 [PATCH] tcp_probe: avoid modulus operation and wrap fix Stephen Hemminger
2010-01-25  6:41 ` David Miller [this message]
2010-01-25 16:30   ` Stephen Hemminger
2010-01-25 23:48     ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100124.224122.13742906.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=shemminger@vyatta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.