diff options
author | Antonio Quartulli <ordex@autistici.org> | 2011-07-09 18:36:36 -0400 |
---|---|---|
committer | Marek Lindner <lindner_marek@yahoo.de> | 2011-08-22 09:16:19 -0400 |
commit | 1a1f37d9257a4792ca17b28b1c2e4ad15fe95b28 (patch) | |
tree | 5bc0aa0d34b87d1f9b70682f1c54298860ce7d13 /net/batman-adv/vis.c | |
parent | 322a8b034003c0d46d39af85bf24fee27b902f48 (diff) |
batman-adv: hash_add() has to discriminate on the return value
hash_add() returns 0 on success while returns -1 either on error and on
entry already present. The caller could use such information to select
its behaviour. For this reason it is useful that hash_add() returns -1
in case on error and returns 1 in case of entry already present.
Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Diffstat (limited to 'net/batman-adv/vis.c')
-rw-r--r-- | net/batman-adv/vis.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/net/batman-adv/vis.c b/net/batman-adv/vis.c index 8a1b98589d7..8b75cc56205 100644 --- a/net/batman-adv/vis.c +++ b/net/batman-adv/vis.c | |||
@@ -465,7 +465,7 @@ static struct vis_info *add_packet(struct bat_priv *bat_priv, | |||
465 | /* try to add it */ | 465 | /* try to add it */ |
466 | hash_added = hash_add(bat_priv->vis_hash, vis_info_cmp, vis_info_choose, | 466 | hash_added = hash_add(bat_priv->vis_hash, vis_info_cmp, vis_info_choose, |
467 | info, &info->hash_entry); | 467 | info, &info->hash_entry); |
468 | if (hash_added < 0) { | 468 | if (hash_added != 0) { |
469 | /* did not work (for some reason) */ | 469 | /* did not work (for some reason) */ |
470 | kref_put(&info->refcount, free_info); | 470 | kref_put(&info->refcount, free_info); |
471 | info = NULL; | 471 | info = NULL; |
@@ -920,7 +920,7 @@ int vis_init(struct bat_priv *bat_priv) | |||
920 | hash_added = hash_add(bat_priv->vis_hash, vis_info_cmp, vis_info_choose, | 920 | hash_added = hash_add(bat_priv->vis_hash, vis_info_cmp, vis_info_choose, |
921 | bat_priv->my_vis_info, | 921 | bat_priv->my_vis_info, |
922 | &bat_priv->my_vis_info->hash_entry); | 922 | &bat_priv->my_vis_info->hash_entry); |
923 | if (hash_added < 0) { | 923 | if (hash_added != 0) { |
924 | pr_err("Can't add own vis packet into hash\n"); | 924 | pr_err("Can't add own vis packet into hash\n"); |
925 | /* not in hash, need to remove it manually. */ | 925 | /* not in hash, need to remove it manually. */ |
926 | kref_put(&bat_priv->my_vis_info->refcount, free_info); | 926 | kref_put(&bat_priv->my_vis_info->refcount, free_info); |