* [B.A.T.M.A.N.] [RFC] batman-adv: pass value in batadv_hash_bytes
@ 2012-11-14 9:53 Simon Wunderlich
2012-11-14 11:59 ` Antonio Quartulli
2012-11-14 16:37 ` Marek Lindner
0 siblings, 2 replies; 5+ messages in thread
From: Simon Wunderlich @ 2012-11-14 9:53 UTC (permalink / raw)
To: b.a.t.m.a.n; +Cc: Simon Wunderlich
Passing the hash value by reference creates unneeded overhead. Pass by
value instead.
Reported-by: David Miller <davem@davemloft.net>
Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
---
bridge_loop_avoidance.c | 8 ++++----
hash.h | 12 ++++++++----
2 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c
index b6da6ae..fc56ea2 100644
--- a/bridge_loop_avoidance.c
+++ b/bridge_loop_avoidance.c
@@ -43,8 +43,8 @@ static inline uint32_t batadv_choose_claim(const void *data, uint32_t size)
struct batadv_claim *claim = (struct batadv_claim *)data;
uint32_t hash = 0;
- batadv_hash_bytes(&hash, &claim->addr, sizeof(claim->addr));
- batadv_hash_bytes(&hash, &claim->vid, sizeof(claim->vid));
+ hash = batadv_hash_bytes(hash, &claim->addr, sizeof(claim->addr));
+ hash = batadv_hash_bytes(hash, &claim->vid, sizeof(claim->vid));
hash += (hash << 3);
hash ^= (hash >> 11);
@@ -60,8 +60,8 @@ static inline uint32_t batadv_choose_backbone_gw(const void *data,
struct batadv_claim *claim = (struct batadv_claim *)data;
uint32_t hash = 0;
- batadv_hash_bytes(&hash, &claim->addr, sizeof(claim->addr));
- batadv_hash_bytes(&hash, &claim->vid, sizeof(claim->vid));
+ hash = batadv_hash_bytes(hash, &claim->addr, sizeof(claim->addr));
+ hash = batadv_hash_bytes(hash, &claim->vid, sizeof(claim->vid));
hash += (hash << 3);
hash ^= (hash >> 11);
diff --git a/hash.h b/hash.h
index f173427..e053339 100644
--- a/hash.h
+++ b/hash.h
@@ -86,17 +86,21 @@ static inline void batadv_hash_delete(struct batadv_hashtable *hash,
* @hash: previous hash value
* @data: data to be hashed
* @size: number of bytes to be hashed
+ *
+ * Returns the new hash value.
*/
-static inline void batadv_hash_bytes(uint32_t *hash, void *data, uint32_t size)
+static inline uint32_t batadv_hash_bytes(uint32_t hash, void *data,
+ uint32_t size)
{
const unsigned char *key = data;
int i;
for (i = 0; i < size; i++) {
- *hash += key[i];
- *hash += (*hash << 10);
- *hash ^= (*hash >> 6);
+ hash += key[i];
+ hash += (hash << 10);
+ hash ^= (hash >> 6);
}
+ return hash;
}
/**
--
1.7.10
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [B.A.T.M.A.N.] [RFC] batman-adv: pass value in batadv_hash_bytes
2012-11-14 9:53 [B.A.T.M.A.N.] [RFC] batman-adv: pass value in batadv_hash_bytes Simon Wunderlich
@ 2012-11-14 11:59 ` Antonio Quartulli
2012-11-14 13:13 ` Marek Lindner
2012-11-14 16:37 ` Marek Lindner
1 sibling, 1 reply; 5+ messages in thread
From: Antonio Quartulli @ 2012-11-14 11:59 UTC (permalink / raw)
To: Simon Wunderlich; +Cc: b.a.t.m.a.n, Simon Wunderlich
[-- Attachment #1: Type: text/plain, Size: 548 bytes --]
On Wed, Nov 14, 2012 at 10:53:48 +0100, Simon Wunderlich wrote:
> Passing the hash value by reference creates unneeded overhead. Pass by
> value instead.
>
> Reported-by: David Miller <davem@davemloft.net>
> Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
I think this was not meant to be an RFC :-)
And I suppose this patch should be applied to next and no to master, because it
should be merged with the next pull request.
Cheers,
--
Antonio Quartulli
..each of us alone is worth nothing..
Ernesto "Che" Guevara
[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [B.A.T.M.A.N.] [RFC] batman-adv: pass value in batadv_hash_bytes
2012-11-14 11:59 ` Antonio Quartulli
@ 2012-11-14 13:13 ` Marek Lindner
2012-11-14 13:21 ` Sven Eckelmann
0 siblings, 1 reply; 5+ messages in thread
From: Marek Lindner @ 2012-11-14 13:13 UTC (permalink / raw)
To: b.a.t.m.a.n; +Cc: Simon Wunderlich
On Wednesday, November 14, 2012 19:59:07 Antonio Quartulli wrote:
> On Wed, Nov 14, 2012 at 10:53:48 +0100, Simon Wunderlich wrote:
> > Passing the hash value by reference creates unneeded overhead. Pass by
> > value instead.
> >
> >
> >
> > Reported-by: David Miller <davem@davemloft.net>
> > Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
>
> I think this was not meant to be an RFC :-)
> And I suppose this patch should be applied to next and no to master,
> because it should be merged with the next pull request.
Aren't we supposed to remove the inline tag as well ?
Cheers,
Marek
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [B.A.T.M.A.N.] [RFC] batman-adv: pass value in batadv_hash_bytes
2012-11-14 13:13 ` Marek Lindner
@ 2012-11-14 13:21 ` Sven Eckelmann
0 siblings, 0 replies; 5+ messages in thread
From: Sven Eckelmann @ 2012-11-14 13:21 UTC (permalink / raw)
To: b.a.t.m.a.n; +Cc: Marek Lindner, Simon Wunderlich
[-- Attachment #1: Type: text/plain, Size: 741 bytes --]
On Wednesday 14 November 2012 21:13:36 Marek Lindner wrote:
> On Wednesday, November 14, 2012 19:59:07 Antonio Quartulli wrote:
> > On Wed, Nov 14, 2012 at 10:53:48 +0100, Simon Wunderlich wrote:
> > > Passing the hash value by reference creates unneeded overhead. Pass by
> > > value instead.
> > >
> > >
> > >
> > > Reported-by: David Miller <davem@davemloft.net>
> > > Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
> >
> > I think this was not meant to be an RFC :-)
> > And I suppose this patch should be applied to next and no to master,
> > because it should be merged with the next pull request.
>
> Aren't we supposed to remove the inline tag as well ?
Not in the header -- only in the c file
Kind regards,
Sven
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [B.A.T.M.A.N.] [RFC] batman-adv: pass value in batadv_hash_bytes
2012-11-14 9:53 [B.A.T.M.A.N.] [RFC] batman-adv: pass value in batadv_hash_bytes Simon Wunderlich
2012-11-14 11:59 ` Antonio Quartulli
@ 2012-11-14 16:37 ` Marek Lindner
1 sibling, 0 replies; 5+ messages in thread
From: Marek Lindner @ 2012-11-14 16:37 UTC (permalink / raw)
To: b.a.t.m.a.n; +Cc: Simon Wunderlich
On Wednesday, November 14, 2012 17:53:48 Simon Wunderlich wrote:
> Passing the hash value by reference creates unneeded overhead. Pass by
> value instead.
>
> Reported-by: David Miller <davem@davemloft.net>
> Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
> ---
> bridge_loop_avoidance.c | 8 ++++----
> hash.h | 12 ++++++++----
> 2 files changed, 12 insertions(+), 8 deletions(-)
Applied in revision 803bae0.
Thanks,
Marek
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-11-14 16:37 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-14 9:53 [B.A.T.M.A.N.] [RFC] batman-adv: pass value in batadv_hash_bytes Simon Wunderlich
2012-11-14 11:59 ` Antonio Quartulli
2012-11-14 13:13 ` Marek Lindner
2012-11-14 13:21 ` Sven Eckelmann
2012-11-14 16:37 ` Marek Lindner
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.