Patchwork [2/2] batman-adv: compare_eth() should take const pointer arguments

login
register
mail settings
Submitter David Howells
Date June 14, 2011, 11:51 p.m.
Message ID <20110614235142.3724.92963.stgit@warthog.procyon.org.uk>
Download mbox | patch
Permalink /patch/100459/
State Awaiting Upstream
Delegated to: David Miller
Headers show

Comments

David Howells - June 14, 2011, 11:51 p.m.
compare_eth() should take const pointer arguments so that it can be passed
const pointers without the need for a cast, leading to:

net/batman-adv/vis.c: In function 'vis_data_insert_interface':
net/batman-adv/vis.c:146: warning: passing argument 2 of 'compare_eth' discards qualifiers from pointer target type

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Marek Lindner <lindner_marek@yahoo.de>
cc: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
cc: Sven Eckelmann <sven@narfation.org>
cc: b.a.t.m.a.n@lists.open-mesh.org
cc: netdev@vger.kernel.org
---

 net/batman-adv/main.h |    2 +-
 net/batman-adv/vis.c  |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sven Eckelmann - June 15, 2011, 5:56 a.m.
David Howells wrote:
> compare_eth() should take const pointer arguments so that it can be passed
> const pointers without the need for a cast, leading to:
> 
> net/batman-adv/vis.c: In function 'vis_data_insert_interface':
> net/batman-adv/vis.c:146: warning: passing argument 2 of 'compare_eth'
> discards qualifiers from pointer target type
> 
> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: Marek Lindner <lindner_marek@yahoo.de>
> cc: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
> cc: Sven Eckelmann <sven@narfation.org>
> cc: b.a.t.m.a.n@lists.open-mesh.org
> cc: netdev@vger.kernel.org
> ---
> 
>  net/batman-adv/main.h |    2 +-
>  net/batman-adv/vis.c  |    2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h
> index 148b49e..e6fc798 100644
> --- a/net/batman-adv/main.h
> +++ b/net/batman-adv/main.h
> @@ -172,7 +172,7 @@ static inline void bat_dbg(char type __always_unused,
>   *
>   * note: can't use compare_ether_addr() as it requires aligned memory
>   */
> -static inline int compare_eth(void *data1, void *data2)
> +static inline int compare_eth(const void *data1, const void *data2)
>  {
>  	return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0);
>  }
> diff --git a/net/batman-adv/vis.c b/net/batman-adv/vis.c
> index c39f20c..34053ac 100644
> --- a/net/batman-adv/vis.c
> +++ b/net/batman-adv/vis.c
> @@ -143,7 +143,7 @@ static void vis_data_insert_interface(const uint8_t
> *interface, struct hlist_node *pos;
> 
>  	hlist_for_each_entry(entry, pos, if_list, list) {
> -		if (compare_eth(entry->addr, (void *)interface))
> +		if (compare_eth(entry->addr, interface))
>  			return;
>  	}

Sry, but this patch doesn't apply here (net-next-2.6/linux-next)

Kind regards,
	Sven

Patch

diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h
index 148b49e..e6fc798 100644
--- a/net/batman-adv/main.h
+++ b/net/batman-adv/main.h
@@ -172,7 +172,7 @@  static inline void bat_dbg(char type __always_unused,
  *
  * note: can't use compare_ether_addr() as it requires aligned memory
  */
-static inline int compare_eth(void *data1, void *data2)
+static inline int compare_eth(const void *data1, const void *data2)
 {
 	return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0);
 }
diff --git a/net/batman-adv/vis.c b/net/batman-adv/vis.c
index c39f20c..34053ac 100644
--- a/net/batman-adv/vis.c
+++ b/net/batman-adv/vis.c
@@ -143,7 +143,7 @@  static void vis_data_insert_interface(const uint8_t *interface,
 	struct hlist_node *pos;
 
 	hlist_for_each_entry(entry, pos, if_list, list) {
-		if (compare_eth(entry->addr, (void *)interface))
+		if (compare_eth(entry->addr, interface))
 			return;
 	}