diff options
author | Allan Stephens <allan.stephens@windriver.com> | 2011-10-07 11:31:49 -0400 |
---|---|---|
committer | Paul Gortmaker <paul.gortmaker@windriver.com> | 2011-12-27 11:13:06 -0500 |
commit | c61b666e260d5cc2e0203b21c689321e6ab0d676 (patch) | |
tree | 3099d9f46c035b36c7555e75221df44f79f477a3 /net | |
parent | 6c349210101352103d9055636845155bc801ae9b (diff) |
tipc: Improve handling of media address printing errors
Enhances conversion of a media address to printable form so that an
unconvertable address will be displayed as a string of hex digits,
rather than not being displayed at all. (Also removes a pointless check
for the existence of the media-specific address conversion routine,
since the routine is not optional.)
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/tipc/bearer.c | 12 | ||||
-rw-r--r-- | net/tipc/bearer.h | 3 | ||||
-rw-r--r-- | net/tipc/eth_media.c | 12 |
3 files changed, 12 insertions, 15 deletions
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c index f908b804a968..17652f20a359 100644 --- a/net/tipc/bearer.c +++ b/net/tipc/bearer.c | |||
@@ -136,20 +136,18 @@ exit: | |||
136 | 136 | ||
137 | void tipc_media_addr_printf(struct print_buf *pb, struct tipc_media_addr *a) | 137 | void tipc_media_addr_printf(struct print_buf *pb, struct tipc_media_addr *a) |
138 | { | 138 | { |
139 | char addr_str[MAX_ADDR_STR]; | ||
139 | struct media *m_ptr; | 140 | struct media *m_ptr; |
140 | u32 media_type; | 141 | u32 media_type; |
141 | u32 i; | ||
142 | 142 | ||
143 | media_type = ntohl(a->type); | 143 | media_type = ntohl(a->type); |
144 | m_ptr = media_find_id(media_type); | 144 | m_ptr = media_find_id(media_type); |
145 | 145 | ||
146 | if (m_ptr && (m_ptr->addr2str != NULL)) { | 146 | if (m_ptr && !m_ptr->addr2str(a, addr_str, sizeof(addr_str))) |
147 | char addr_str[MAX_ADDR_STR]; | 147 | tipc_printf(pb, "%s(%s)", m_ptr->name, addr_str); |
148 | 148 | else { | |
149 | tipc_printf(pb, "%s(%s)", m_ptr->name, | ||
150 | m_ptr->addr2str(a, addr_str, sizeof(addr_str))); | ||
151 | } else { | ||
152 | unchar *addr = (unchar *)&a->dev_addr; | 149 | unchar *addr = (unchar *)&a->dev_addr; |
150 | u32 i; | ||
153 | 151 | ||
154 | tipc_printf(pb, "UNKNOWN(%u)", media_type); | 152 | tipc_printf(pb, "UNKNOWN(%u)", media_type); |
155 | for (i = 0; i < (sizeof(*a) - sizeof(a->type)); i++) | 153 | for (i = 0; i < (sizeof(*a) - sizeof(a->type)); i++) |
diff --git a/net/tipc/bearer.h b/net/tipc/bearer.h index 148ed04493ac..4e9367f956a4 100644 --- a/net/tipc/bearer.h +++ b/net/tipc/bearer.h | |||
@@ -83,8 +83,7 @@ struct media { | |||
83 | struct tipc_media_addr *dest); | 83 | struct tipc_media_addr *dest); |
84 | int (*enable_bearer)(struct tipc_bearer *b_ptr); | 84 | int (*enable_bearer)(struct tipc_bearer *b_ptr); |
85 | void (*disable_bearer)(struct tipc_bearer *b_ptr); | 85 | void (*disable_bearer)(struct tipc_bearer *b_ptr); |
86 | char *(*addr2str)(struct tipc_media_addr *a, | 86 | int (*addr2str)(struct tipc_media_addr *a, char *str_buf, int str_size); |
87 | char *str_buf, int str_size); | ||
88 | struct tipc_media_addr bcast_addr; | 87 | struct tipc_media_addr bcast_addr; |
89 | u32 priority; | 88 | u32 priority; |
90 | u32 tolerance; | 89 | u32 tolerance; |
diff --git a/net/tipc/eth_media.c b/net/tipc/eth_media.c index 15c685b868db..67f616aa5dbb 100644 --- a/net/tipc/eth_media.c +++ b/net/tipc/eth_media.c | |||
@@ -243,15 +243,15 @@ static int recv_notification(struct notifier_block *nb, unsigned long evt, | |||
243 | * eth_addr2str - convert Ethernet address to string | 243 | * eth_addr2str - convert Ethernet address to string |
244 | */ | 244 | */ |
245 | 245 | ||
246 | static char *eth_addr2str(struct tipc_media_addr *a, char *str_buf, int str_size) | 246 | static int eth_addr2str(struct tipc_media_addr *a, char *str_buf, int str_size) |
247 | { | 247 | { |
248 | unchar *addr = (unchar *)&a->dev_addr; | 248 | unchar *addr = (unchar *)&a->dev_addr; |
249 | 249 | ||
250 | if (str_size < 18) | 250 | if (str_size < 18) /* 18 = strlen("aa:bb:cc:dd:ee:ff\0") */ |
251 | *str_buf = '\0'; | 251 | return 1; |
252 | else | 252 | |
253 | sprintf(str_buf, "%pM", addr); | 253 | sprintf(str_buf, "%pM", addr); |
254 | return str_buf; | 254 | return 0; |
255 | } | 255 | } |
256 | 256 | ||
257 | /* | 257 | /* |