aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/bearer.c
diff options
context:
space:
mode:
authorErik Hugne <erik.hugne@ericsson.com>2012-06-29 00:50:23 -0400
committerPaul Gortmaker <paul.gortmaker@windriver.com>2012-07-13 19:33:28 -0400
commitdc1aed37d17b4fe4f28a74d804c065b877bc7bed (patch)
tree83907b44c25a9a10c84106d17eecfceff00864ce /net/tipc/bearer.c
parente2dbd601346aeb64b1b387168b217fd5c301644e (diff)
tipc: phase out most of the struct print_buf usage
The tipc_printf is renamed to tipc_snprintf, as the new name describes more what the function actually does. It is also changed to take a buffer and length parameter and return number of characters written to the buffer. All callers of this function that used to pass a print_buf are updated. Final removal of the struct print_buf itself will be done synchronously with the pending removal of the deprecated logging code that also was using it. Functions that build up a response message with a list of ports, nametable contents etc. are changed to return the number of characters written to the output buffer. This information was previously hidden in a field of the print_buf struct, and the number of chars written was fetched with a call to tipc_printbuf_validate. This function is removed since it is no longer referenced nor needed. A generic max size ULTRA_STRING_MAX_LEN is defined, named in keeping with the existing TIPC_TLV_ULTRA_STRING, and the various definitions in port, link and nametable code that largely duplicated this information are removed. This means that amount of link statistics that can be returned is now increased from 2k to 32k. The buffer overflow check is now done just before the reply message is passed over netlink or TIPC to a remote node and the message indicating a truncated buffer is changed to a less dramatic one (less CAPS), placed at the end of the message. Signed-off-by: Erik Hugne <erik.hugne@ericsson.com> Signed-off-by: Jon Maloy <jon.maloy@ericsson.com> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Diffstat (limited to 'net/tipc/bearer.c')
-rw-r--r--net/tipc/bearer.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
index 1840e1fadd2e..09e71241265d 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -130,21 +130,23 @@ exit:
130/** 130/**
131 * tipc_media_addr_printf - record media address in print buffer 131 * tipc_media_addr_printf - record media address in print buffer
132 */ 132 */
133void tipc_media_addr_printf(struct print_buf *pb, struct tipc_media_addr *a) 133void tipc_media_addr_printf(char *buf, int len, struct tipc_media_addr *a)
134{ 134{
135 char addr_str[MAX_ADDR_STR]; 135 char addr_str[MAX_ADDR_STR];
136 struct tipc_media *m_ptr; 136 struct tipc_media *m_ptr;
137 int ret;
137 138
138 m_ptr = media_find_id(a->media_id); 139 m_ptr = media_find_id(a->media_id);
139 140
140 if (m_ptr && !m_ptr->addr2str(a, addr_str, sizeof(addr_str))) 141 if (m_ptr && !m_ptr->addr2str(a, addr_str, sizeof(addr_str)))
141 tipc_printf(pb, "%s(%s)", m_ptr->name, addr_str); 142 ret = tipc_snprintf(buf, len, "%s(%s)", m_ptr->name, addr_str);
142 else { 143 else {
143 u32 i; 144 u32 i;
144 145
145 tipc_printf(pb, "UNKNOWN(%u)", a->media_id); 146 ret = tipc_snprintf(buf, len, "UNKNOWN(%u)", a->media_id);
146 for (i = 0; i < sizeof(a->value); i++) 147 for (i = 0; i < sizeof(a->value); i++)
147 tipc_printf(pb, "-%02x", a->value[i]); 148 ret += tipc_snprintf(buf - ret, len + ret,
149 "-%02x", a->value[i]);
148 } 150 }
149} 151}
150 152