* [PATCH 6/42] decnet: Fix set-but-unused variable.
@ 2011-04-18 0:32 David Miller
2011-04-18 2:12 ` Ben Hutchings
0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2011-04-18 0:32 UTC (permalink / raw)
To: netdev
"next" in dn_rebuild_zone() is set but not actually used,
kill it off.
Signed-off-by: David S. Miller <davem@davemloft.net>
---
net/decnet/dn_table.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/net/decnet/dn_table.c b/net/decnet/dn_table.c
index 99d8d3a..d8ea583 100644
--- a/net/decnet/dn_table.c
+++ b/net/decnet/dn_table.c
@@ -124,11 +124,10 @@ static inline void dn_rebuild_zone(struct dn_zone *dz,
int old_divisor)
{
int i;
- struct dn_fib_node *f, **fp, *next;
+ struct dn_fib_node *f, **fp;
for(i = 0; i < old_divisor; i++) {
for(f = old_ht[i]; f; f = f->fn_next) {
- next = f->fn_next;
for(fp = dn_chain_p(f->fn_key, dz);
*fp && dn_key_leq((*fp)->fn_key, f->fn_key);
fp = &(*fp)->fn_next)
--
1.7.4.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 6/42] decnet: Fix set-but-unused variable.
2011-04-18 0:32 [PATCH 6/42] decnet: Fix set-but-unused variable David Miller
@ 2011-04-18 2:12 ` Ben Hutchings
2011-04-18 3:48 ` David Miller
0 siblings, 1 reply; 3+ messages in thread
From: Ben Hutchings @ 2011-04-18 2:12 UTC (permalink / raw)
To: David Miller; +Cc: netdev
On Sun, 2011-04-17 at 17:32 -0700, David Miller wrote:
> "next" in dn_rebuild_zone() is set but not actually used,
> kill it off.
>
> Signed-off-by: David S. Miller <davem@davemloft.net>
> ---
> net/decnet/dn_table.c | 3 +--
> 1 files changed, 1 insertions(+), 2 deletions(-)
>
> diff --git a/net/decnet/dn_table.c b/net/decnet/dn_table.c
> index 99d8d3a..d8ea583 100644
> --- a/net/decnet/dn_table.c
> +++ b/net/decnet/dn_table.c
> @@ -124,11 +124,10 @@ static inline void dn_rebuild_zone(struct dn_zone *dz,
> int old_divisor)
> {
> int i;
> - struct dn_fib_node *f, **fp, *next;
> + struct dn_fib_node *f, **fp;
>
> for(i = 0; i < old_divisor; i++) {
> for(f = old_ht[i]; f; f = f->fn_next) {
> - next = f->fn_next;
> for(fp = dn_chain_p(f->fn_key, dz);
> *fp && dn_key_leq((*fp)->fn_key, f->fn_key);
> fp = &(*fp)->fn_next)
This function is rebuilding a hash table after the number of buckets is
changed. After moving each element into a new bucket, it needs to carry
on iterating over the old bucket. Therefore the 'next' variable is
really needed and the second for-loop should use it: 'f = next', not
'f = f->fn_next'.
Currently this must just leak routes as the table grows, but I suppose
no-one really uses DECnet any more.
Ben.
--
Ben Hutchings, Senior Software Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 6/42] decnet: Fix set-but-unused variable.
2011-04-18 2:12 ` Ben Hutchings
@ 2011-04-18 3:48 ` David Miller
0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2011-04-18 3:48 UTC (permalink / raw)
To: bhutchings; +Cc: netdev
From: Ben Hutchings <bhutchings@solarflare.com>
Date: Mon, 18 Apr 2011 03:12:09 +0100
> On Sun, 2011-04-17 at 17:32 -0700, David Miller wrote:
>> "next" in dn_rebuild_zone() is set but not actually used,
>> kill it off.
>>
>> Signed-off-by: David S. Miller <davem@davemloft.net>
>> ---
>> net/decnet/dn_table.c | 3 +--
>> 1 files changed, 1 insertions(+), 2 deletions(-)
>>
>> diff --git a/net/decnet/dn_table.c b/net/decnet/dn_table.c
>> index 99d8d3a..d8ea583 100644
>> --- a/net/decnet/dn_table.c
>> +++ b/net/decnet/dn_table.c
>> @@ -124,11 +124,10 @@ static inline void dn_rebuild_zone(struct dn_zone *dz,
>> int old_divisor)
>> {
>> int i;
>> - struct dn_fib_node *f, **fp, *next;
>> + struct dn_fib_node *f, **fp;
>>
>> for(i = 0; i < old_divisor; i++) {
>> for(f = old_ht[i]; f; f = f->fn_next) {
>> - next = f->fn_next;
>> for(fp = dn_chain_p(f->fn_key, dz);
>> *fp && dn_key_leq((*fp)->fn_key, f->fn_key);
>> fp = &(*fp)->fn_next)
>
> This function is rebuilding a hash table after the number of buckets is
> changed. After moving each element into a new bucket, it needs to carry
> on iterating over the old bucket. Therefore the 'next' variable is
> really needed and the second for-loop should use it: 'f = next', not
> 'f = f->fn_next'.
Good catch, I committed the following:
--------------------
decnet: Don't leak entries when rebuilding zone.
As noticed by Ben Hutchings, when we move entries from
one table to another we leak all except the first entry.
Put back the "next" variable removed by commit
9bf9055eb716f85372c41b3fbc51f90bc7653740 ("decnet: Fix set-but-unused
variable.") and use it properly.
Reported-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
---
net/decnet/dn_table.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/net/decnet/dn_table.c b/net/decnet/dn_table.c
index d8ea583..bd0a52d 100644
--- a/net/decnet/dn_table.c
+++ b/net/decnet/dn_table.c
@@ -123,11 +123,12 @@ static inline void dn_rebuild_zone(struct dn_zone *dz,
struct dn_fib_node **old_ht,
int old_divisor)
{
+ struct dn_fib_node *f, **fp, *next;
int i;
- struct dn_fib_node *f, **fp;
for(i = 0; i < old_divisor; i++) {
- for(f = old_ht[i]; f; f = f->fn_next) {
+ for(f = old_ht[i]; f; f = next) {
+ next = f->fn_next;
for(fp = dn_chain_p(f->fn_key, dz);
*fp && dn_key_leq((*fp)->fn_key, f->fn_key);
fp = &(*fp)->fn_next)
--
1.7.4.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-04-18 3:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-18 0:32 [PATCH 6/42] decnet: Fix set-but-unused variable David Miller
2011-04-18 2:12 ` Ben Hutchings
2011-04-18 3:48 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).