Re: New sparse warning in net/mac80211/debugfs_sta.c

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Johannes Berg <johannes@...>
Cc: David Miller <davem@...>, <harvey.harrison@...>, <netdev@...>
Date: Thursday, February 21, 2008 - 1:54 pm

On Thu, 2008-02-21 at 11:17 +0100, Johannes Berg wrote:

This removes the __pure from print_mac, so reject as appropriate...

Add some type safety to print_mac by using 
struct print_mac_buf * instead of char *.

Signed-off-by: Joe Perches <joe@perches.com>

diff --git a/include/linux/if_ether.h b/include/linux/if_ether.h
index 42dc6a3..2f8df76 100644
--- a/include/linux/if_ether.h
+++ b/include/linux/if_ether.h
@@ -129,9 +129,16 @@ extern ssize_t sysfs_format_mac(char *buf, const unsigned char *addr, int len);
 /*
  *	Display a 6 byte device address (MAC) in a readable format.
  */
-extern __pure char *print_mac(char *buf, const unsigned char *addr);
-#define MAC_BUF_SIZE	18
-#define DECLARE_MAC_BUF(var) char var[MAC_BUF_SIZE] __maybe_unused
+
+struct print_mac_buf {
+	char formatted_mac_addr[18];
+};
+
+#define DECLARE_MAC_BUF(var) \
+	struct print_mac_buf __maybe_unused _##var; \
+	struct print_mac_buf __maybe_unused *var = &_##var
+
+extern char *print_mac(struct print_mac_buf *buf, const unsigned char *addr);
 
 #endif
 
diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c
index a7b4175..ce607ab 100644
--- a/net/ethernet/eth.c
+++ b/net/ethernet/eth.c
@@ -384,9 +384,10 @@ ssize_t sysfs_format_mac(char *buf, const unsigned char *addr, int len)
 }
 EXPORT_SYMBOL(sysfs_format_mac);
 
-char *print_mac(char *buf, const unsigned char *addr)
+char *print_mac(struct print_mac_buf *buf, const unsigned char *addr)
 {
-	_format_mac_addr(buf, MAC_BUF_SIZE, addr, ETH_ALEN);
-	return buf;
+	_format_mac_addr(buf->formatted_mac_addr,
+			 sizeof(buf->formatted_mac_addr), addr, ETH_ALEN);
+	return buf->formatted_mac_addr;
 }
 EXPORT_SYMBOL(print_mac);


--
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
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: New sparse warning in net/mac80211/debugfs_sta.c, Harvey Harrison, (Thu Feb 21, 6:01 am)
Re: New sparse warning in net/mac80211/debugfs_sta.c, David Miller, (Thu Feb 21, 6:05 am)
Re: New sparse warning in net/mac80211/debugfs_sta.c, Patrick McHardy, (Thu Feb 21, 1:45 pm)
Re: New sparse warning in net/mac80211/debugfs_sta.c, Joe Perches, (Thu Feb 21, 1:17 pm)
Re: New sparse warning in net/mac80211/debugfs_sta.c, Johannes Berg, (Thu Feb 21, 6:17 am)
Re: New sparse warning in net/mac80211/debugfs_sta.c, Joe Perches, (Thu Feb 21, 1:54 pm)
Re: New sparse warning in net/mac80211/debugfs_sta.c, Patrick McHardy, (Thu Feb 21, 2:00 pm)
Re: New sparse warning in net/mac80211/debugfs_sta.c, Patrick McHardy, (Thu Feb 21, 2:15 pm)
Re: New sparse warning in net/mac80211/debugfs_sta.c, David Miller, (Sun Feb 24, 12:02 am)
Re: New sparse warning in net/mac80211/debugfs_sta.c, Patrick McHardy, (Mon Feb 25, 7:47 am)
Re: New sparse warning in net/mac80211/debugfs_sta.c, Joe Perches, (Mon Feb 25, 3:58 pm)
Re: New sparse warning in net/mac80211/debugfs_sta.c, Patrick McHardy, (Tue Apr 8, 4:18 pm)
Re: New sparse warning in net/mac80211/debugfs_sta.c, Joe Perches, (Tue Apr 8, 5:02 pm)
Re: New sparse warning in net/mac80211/debugfs_sta.c, Patrick McHardy, (Tue Apr 8, 5:19 pm)
Re: New sparse warning in net/mac80211/debugfs_sta.c, Joe Perches, (Tue Apr 8, 6:09 pm)
Re: New sparse warning in net/mac80211/debugfs_sta.c, Patrick McHardy, (Tue Apr 8, 6:32 pm)
Re: New sparse warning in net/mac80211/debugfs_sta.c, David Miller, (Tue Apr 8, 6:30 pm)
Re: New sparse warning in net/mac80211/debugfs_sta.c, Joe Perches, (Tue Apr 8, 6:41 pm)
Re: New sparse warning in net/mac80211/debugfs_sta.c, David Miller, (Tue Apr 8, 5:16 pm)
Re: New sparse warning in net/mac80211/debugfs_sta.c, Johannes Berg, (Mon Feb 25, 5:53 am)
Re: New sparse warning in net/mac80211/debugfs_sta.c, David Miller, (Mon Feb 25, 3:52 pm)
Re: New sparse warning in net/mac80211/debugfs_sta.c, Johannes Berg, (Mon Feb 25, 3:56 pm)
Re: New sparse warning in net/mac80211/debugfs_sta.c, David Miller, (Mon Feb 25, 4:12 pm)
Re: New sparse warning in net/mac80211/debugfs_sta.c, Johannes Berg, (Mon Feb 25, 4:05 pm)
Re: New sparse warning in net/mac80211/debugfs_sta.c, David Miller, (Mon Feb 25, 4:14 pm)
Re: New sparse warning in net/mac80211/debugfs_sta.c, Johannes Berg, (Mon Feb 25, 1:23 pm)
Re: New sparse warning in net/mac80211/debugfs_sta.c, Joe Perches, (Mon Feb 25, 12:53 pm)
Re: New sparse warning in net/mac80211/debugfs_sta.c, Johannes Berg, (Mon Feb 25, 1:29 pm)
Re: New sparse warning in net/mac80211/debugfs_sta.c, Harvey Harrison, (Thu Feb 21, 6:14 am)