Commit 77099f0a authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Greg Kroah-Hartman

staging: batman-adv: remove useless addr_to_string()

Since all *printf() methods in the kernel understand '%pM' modifier the
conversion to the string is useless beforehand.

Additionally this patch decreases batman_if structure by 20 bytes.
Signed-off-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
Cc: Marek Lindner <lindner_marek@yahoo.de>
Cc: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
Cc: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent cd389a34
...@@ -159,8 +159,6 @@ static bool hardif_is_iface_up(struct batman_if *batman_if) ...@@ -159,8 +159,6 @@ static bool hardif_is_iface_up(struct batman_if *batman_if)
static void update_mac_addresses(struct batman_if *batman_if) static void update_mac_addresses(struct batman_if *batman_if)
{ {
addr_to_string(batman_if->addr_str, batman_if->net_dev->dev_addr);
memcpy(((struct batman_packet *)(batman_if->packet_buff))->orig, memcpy(((struct batman_packet *)(batman_if->packet_buff))->orig,
batman_if->net_dev->dev_addr, ETH_ALEN); batman_if->net_dev->dev_addr, ETH_ALEN);
memcpy(((struct batman_packet *)(batman_if->packet_buff))->prev_sender, memcpy(((struct batman_packet *)(batman_if->packet_buff))->prev_sender,
......
...@@ -145,11 +145,6 @@ void dec_module_count(void) ...@@ -145,11 +145,6 @@ void dec_module_count(void)
module_put(THIS_MODULE); module_put(THIS_MODULE);
} }
int addr_to_string(char *buff, uint8_t *addr)
{
return sprintf(buff, "%pM", addr);
}
/* returns 1 if they are the same originator */ /* returns 1 if they are the same originator */
int compare_orig(void *data1, void *data2) int compare_orig(void *data1, void *data2)
......
...@@ -58,7 +58,6 @@ ...@@ -58,7 +58,6 @@
#define PACKBUFF_SIZE 2000 #define PACKBUFF_SIZE 2000
#define LOG_BUF_LEN 8192 /* has to be a power of 2 */ #define LOG_BUF_LEN 8192 /* has to be a power of 2 */
#define ETH_STR_LEN 20
#define VIS_INTERVAL 5000 /* 5 seconds */ #define VIS_INTERVAL 5000 /* 5 seconds */
...@@ -136,7 +135,6 @@ int mesh_init(struct net_device *soft_iface); ...@@ -136,7 +135,6 @@ int mesh_init(struct net_device *soft_iface);
void mesh_free(struct net_device *soft_iface); void mesh_free(struct net_device *soft_iface);
void inc_module_count(void); void inc_module_count(void);
void dec_module_count(void); void dec_module_count(void);
int addr_to_string(char *buff, uint8_t *addr);
int compare_orig(void *data1, void *data2); int compare_orig(void *data1, void *data2);
int choose_orig(void *data, int32_t size); int choose_orig(void *data, int32_t size);
int is_my_mac(uint8_t *addr); int is_my_mac(uint8_t *addr);
......
...@@ -315,7 +315,6 @@ int orig_seq_print_text(struct seq_file *seq, void *offset) ...@@ -315,7 +315,6 @@ int orig_seq_print_text(struct seq_file *seq, void *offset)
int last_seen_secs; int last_seen_secs;
int last_seen_msecs; int last_seen_msecs;
unsigned long flags; unsigned long flags;
char orig_str[ETH_STR_LEN], router_str[ETH_STR_LEN];
if ((!bat_priv->primary_if) || if ((!bat_priv->primary_if) ||
(bat_priv->primary_if->if_status != IF_ACTIVE)) { (bat_priv->primary_if->if_status != IF_ACTIVE)) {
...@@ -329,10 +328,10 @@ int orig_seq_print_text(struct seq_file *seq, void *offset) ...@@ -329,10 +328,10 @@ int orig_seq_print_text(struct seq_file *seq, void *offset)
net_dev->name); net_dev->name);
} }
seq_printf(seq, "[B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%s (%s)]\n", seq_printf(seq, "[B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%pM (%s)]\n",
SOURCE_VERSION, REVISION_VERSION_STR, SOURCE_VERSION, REVISION_VERSION_STR,
bat_priv->primary_if->net_dev->name, bat_priv->primary_if->net_dev->name,
bat_priv->primary_if->addr_str, net_dev->name); bat_priv->primary_if->net_dev->dev_addr, net_dev->name);
seq_printf(seq, " %-15s %s (%s/%i) %17s [%10s]: %20s ...\n", seq_printf(seq, " %-15s %s (%s/%i) %17s [%10s]: %20s ...\n",
"Originator", "last-seen", "#", TQ_MAX_VALUE, "Nexthop", "Originator", "last-seen", "#", TQ_MAX_VALUE, "Nexthop",
"outgoingIF", "Potential nexthops"); "outgoingIF", "Potential nexthops");
...@@ -349,21 +348,18 @@ int orig_seq_print_text(struct seq_file *seq, void *offset) ...@@ -349,21 +348,18 @@ int orig_seq_print_text(struct seq_file *seq, void *offset)
if (orig_node->router->tq_avg == 0) if (orig_node->router->tq_avg == 0)
continue; continue;
addr_to_string(orig_str, orig_node->orig);
addr_to_string(router_str, orig_node->router->addr);
last_seen_secs = jiffies_to_msecs(jiffies - last_seen_secs = jiffies_to_msecs(jiffies -
orig_node->last_valid) / 1000; orig_node->last_valid) / 1000;
last_seen_msecs = jiffies_to_msecs(jiffies - last_seen_msecs = jiffies_to_msecs(jiffies -
orig_node->last_valid) % 1000; orig_node->last_valid) % 1000;
seq_printf(seq, "%-17s %4i.%03is (%3i) %17s [%10s]:", seq_printf(seq, "%pM %4i.%03is (%3i) %pM [%10s]:",
orig_str, last_seen_secs, last_seen_msecs, orig_node->orig, last_seen_secs, last_seen_msecs,
orig_node->router->tq_avg, router_str, orig_node->router->tq_avg, orig_node->router->addr,
orig_node->router->if_incoming->net_dev->name); orig_node->router->if_incoming->net_dev->name);
list_for_each_entry(neigh_node, &orig_node->neigh_list, list) { list_for_each_entry(neigh_node, &orig_node->neigh_list, list) {
addr_to_string(orig_str, neigh_node->addr); seq_printf(seq, " %pM (%3i)", neigh_node->addr,
seq_printf(seq, " %17s (%3i)", orig_str,
neigh_node->tq_avg); neigh_node->tq_avg);
} }
......
...@@ -554,11 +554,11 @@ void receive_bat_packet(struct ethhdr *ethhdr, ...@@ -554,11 +554,11 @@ void receive_bat_packet(struct ethhdr *ethhdr,
batman_packet->orig) ? 1 : 0); batman_packet->orig) ? 1 : 0);
bat_dbg(DBG_BATMAN, bat_priv, bat_dbg(DBG_BATMAN, bat_priv,
"Received BATMAN packet via NB: %pM, IF: %s [%s] " "Received BATMAN packet via NB: %pM, IF: %s [%pM] "
"(from OG: %pM, via prev OG: %pM, seqno %d, tq %d, " "(from OG: %pM, via prev OG: %pM, seqno %d, tq %d, "
"TTL %d, V %d, IDF %d)\n", "TTL %d, V %d, IDF %d)\n",
ethhdr->h_source, if_incoming->net_dev->name, ethhdr->h_source, if_incoming->net_dev->name,
if_incoming->addr_str, batman_packet->orig, if_incoming->net_dev->dev_addr, batman_packet->orig,
batman_packet->prev_sender, batman_packet->seqno, batman_packet->prev_sender, batman_packet->seqno,
batman_packet->tq, batman_packet->ttl, batman_packet->version, batman_packet->tq, batman_packet->ttl, batman_packet->version,
has_directlink_flag); has_directlink_flag);
......
...@@ -135,13 +135,13 @@ static void send_packet_to_if(struct forw_packet *forw_packet, ...@@ -135,13 +135,13 @@ static void send_packet_to_if(struct forw_packet *forw_packet,
"Forwarding")); "Forwarding"));
bat_dbg(DBG_BATMAN, bat_priv, bat_dbg(DBG_BATMAN, bat_priv,
"%s %spacket (originator %pM, seqno %d, TQ %d, TTL %d," "%s %spacket (originator %pM, seqno %d, TQ %d, TTL %d,"
" IDF %s) on interface %s [%s]\n", " IDF %s) on interface %s [%pM]\n",
fwd_str, (packet_num > 0 ? "aggregated " : ""), fwd_str, (packet_num > 0 ? "aggregated " : ""),
batman_packet->orig, ntohl(batman_packet->seqno), batman_packet->orig, ntohl(batman_packet->seqno),
batman_packet->tq, batman_packet->ttl, batman_packet->tq, batman_packet->ttl,
(batman_packet->flags & DIRECTLINK ? (batman_packet->flags & DIRECTLINK ?
"on" : "off"), "on" : "off"),
batman_if->net_dev->name, batman_if->addr_str); batman_if->net_dev->name, batman_if->net_dev->dev_addr);
buff_pos += sizeof(struct batman_packet) + buff_pos += sizeof(struct batman_packet) +
(batman_packet->num_hna * ETH_ALEN); (batman_packet->num_hna * ETH_ALEN);
...@@ -186,12 +186,12 @@ static void send_packet(struct forw_packet *forw_packet) ...@@ -186,12 +186,12 @@ static void send_packet(struct forw_packet *forw_packet)
/* FIXME: what about aggregated packets ? */ /* FIXME: what about aggregated packets ? */
bat_dbg(DBG_BATMAN, bat_priv, bat_dbg(DBG_BATMAN, bat_priv,
"%s packet (originator %pM, seqno %d, TTL %d) " "%s packet (originator %pM, seqno %d, TTL %d) "
"on interface %s [%s]\n", "on interface %s [%pM]\n",
(forw_packet->own ? "Sending own" : "Forwarding"), (forw_packet->own ? "Sending own" : "Forwarding"),
batman_packet->orig, ntohl(batman_packet->seqno), batman_packet->orig, ntohl(batman_packet->seqno),
batman_packet->ttl, batman_packet->ttl,
forw_packet->if_incoming->net_dev->name, forw_packet->if_incoming->net_dev->name,
forw_packet->if_incoming->addr_str); forw_packet->if_incoming->net_dev->dev_addr);
/* skb is only used once and than forw_packet is free'd */ /* skb is only used once and than forw_packet is free'd */
send_skb_packet(forw_packet->skb, forw_packet->if_incoming, send_skb_packet(forw_packet->skb, forw_packet->if_incoming,
......
...@@ -37,7 +37,6 @@ struct batman_if { ...@@ -37,7 +37,6 @@ struct batman_if {
struct list_head list; struct list_head list;
int16_t if_num; int16_t if_num;
char if_status; char if_status;
char addr_str[ETH_STR_LEN];
struct net_device *net_dev; struct net_device *net_dev;
atomic_t seqno; atomic_t seqno;
atomic_t frag_seqno; atomic_t frag_seqno;
......
...@@ -130,15 +130,13 @@ static ssize_t vis_data_read_prim_sec(char *buff, struct hlist_head *if_list) ...@@ -130,15 +130,13 @@ static ssize_t vis_data_read_prim_sec(char *buff, struct hlist_head *if_list)
{ {
struct if_list_entry *entry; struct if_list_entry *entry;
struct hlist_node *pos; struct hlist_node *pos;
char tmp_addr_str[ETH_STR_LEN];
size_t len = 0; size_t len = 0;
hlist_for_each_entry(entry, pos, if_list, list) { hlist_for_each_entry(entry, pos, if_list, list) {
if (entry->primary) if (entry->primary)
len += sprintf(buff + len, "PRIMARY, "); len += sprintf(buff + len, "PRIMARY, ");
else { else {
addr_to_string(tmp_addr_str, entry->addr); len += sprintf(buff + len, "SEC %pM, ", entry->addr);
len += sprintf(buff + len, "SEC %s, ", tmp_addr_str);
} }
} }
...@@ -165,14 +163,12 @@ static size_t vis_data_count_prim_sec(struct hlist_head *if_list) ...@@ -165,14 +163,12 @@ static size_t vis_data_count_prim_sec(struct hlist_head *if_list)
static ssize_t vis_data_read_entry(char *buff, struct vis_info_entry *entry, static ssize_t vis_data_read_entry(char *buff, struct vis_info_entry *entry,
uint8_t *src, bool primary) uint8_t *src, bool primary)
{ {
char to[18];
/* maximal length: max(4+17+2, 3+17+1+3+2) == 26 */ /* maximal length: max(4+17+2, 3+17+1+3+2) == 26 */
addr_to_string(to, entry->dest);
if (primary && entry->quality == 0) if (primary && entry->quality == 0)
return sprintf(buff, "HNA %s, ", to); return sprintf(buff, "HNA %pM, ", entry->dest);
else if (compare_orig(entry->src, src)) else if (compare_orig(entry->src, src))
return sprintf(buff, "TQ %s %d, ", to, entry->quality); return sprintf(buff, "TQ %pM %d, ", entry->dest,
entry->quality);
return 0; return 0;
} }
...@@ -190,7 +186,6 @@ int vis_seq_print_text(struct seq_file *seq, void *offset) ...@@ -190,7 +186,6 @@ int vis_seq_print_text(struct seq_file *seq, void *offset)
struct if_list_entry *entry; struct if_list_entry *entry;
struct hlist_node *pos, *n; struct hlist_node *pos, *n;
int i; int i;
char tmp_addr_str[ETH_STR_LEN];
unsigned long flags; unsigned long flags;
int vis_server = atomic_read(&bat_priv->vis_mode); int vis_server = atomic_read(&bat_priv->vis_mode);
size_t buff_pos, buf_size; size_t buff_pos, buf_size;
...@@ -255,9 +250,8 @@ int vis_seq_print_text(struct seq_file *seq, void *offset) ...@@ -255,9 +250,8 @@ int vis_seq_print_text(struct seq_file *seq, void *offset)
} }
hlist_for_each_entry(entry, pos, &vis_if_list, list) { hlist_for_each_entry(entry, pos, &vis_if_list, list) {
addr_to_string(tmp_addr_str, entry->addr); buff_pos += sprintf(buff + buff_pos, "%pM,",
buff_pos += sprintf(buff + buff_pos, "%s,", entry->addr);
tmp_addr_str);
for (i = 0; i < packet->entries; i++) for (i = 0; i < packet->entries; i++)
buff_pos += vis_data_read_entry(buff + buff_pos, buff_pos += vis_data_read_entry(buff + buff_pos,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment