diff options
Diffstat (limited to 'net/tipc/log.c')
-rw-r--r-- | net/tipc/log.c | 47 |
1 files changed, 5 insertions, 42 deletions
diff --git a/net/tipc/log.c b/net/tipc/log.c index d01e37a61b93..fa7ce927fda5 100644 --- a/net/tipc/log.c +++ b/net/tipc/log.c | |||
@@ -125,40 +125,6 @@ static int tipc_printbuf_empty(struct print_buf *pb) | |||
125 | } | 125 | } |
126 | 126 | ||
127 | /** | 127 | /** |
128 | * tipc_printbuf_validate - check for print buffer overflow | ||
129 | * @pb: pointer to print buffer structure | ||
130 | * | ||
131 | * Verifies that a print buffer has captured all data written to it. | ||
132 | * If data has been lost, linearize buffer and prepend an error message | ||
133 | * | ||
134 | * Returns length of print buffer data string (including trailing NUL) | ||
135 | */ | ||
136 | int tipc_printbuf_validate(struct print_buf *pb) | ||
137 | { | ||
138 | char *err = "\n\n*** PRINT BUFFER OVERFLOW ***\n\n"; | ||
139 | char *cp_buf; | ||
140 | struct print_buf cb; | ||
141 | |||
142 | if (!pb->buf) | ||
143 | return 0; | ||
144 | |||
145 | if (pb->buf[pb->size - 1] == 0) { | ||
146 | cp_buf = kmalloc(pb->size, GFP_ATOMIC); | ||
147 | if (cp_buf) { | ||
148 | tipc_printbuf_init(&cb, cp_buf, pb->size); | ||
149 | tipc_printbuf_move(&cb, pb); | ||
150 | tipc_printbuf_move(pb, &cb); | ||
151 | kfree(cp_buf); | ||
152 | memcpy(pb->buf, err, strlen(err)); | ||
153 | } else { | ||
154 | tipc_printbuf_reset(pb); | ||
155 | tipc_printf(pb, err); | ||
156 | } | ||
157 | } | ||
158 | return pb->crs - pb->buf + 1; | ||
159 | } | ||
160 | |||
161 | /** | ||
162 | * tipc_printbuf_move - move print buffer contents to another print buffer | 128 | * tipc_printbuf_move - move print buffer contents to another print buffer |
163 | * @pb_to: pointer to destination print buffer structure | 129 | * @pb_to: pointer to destination print buffer structure |
164 | * @pb_from: pointer to source print buffer structure | 130 | * @pb_from: pointer to source print buffer structure |
@@ -204,23 +170,20 @@ static void tipc_printbuf_move(struct print_buf *pb_to, | |||
204 | } | 170 | } |
205 | 171 | ||
206 | /** | 172 | /** |
207 | * tipc_printf - append formatted output to print buffer | 173 | * tipc_snprintf - append formatted output to print buffer |
208 | * @pb: pointer to print buffer | 174 | * @buf: pointer to print buffer |
175 | * @len: buffer length | ||
209 | * @fmt: formatted info to be printed | 176 | * @fmt: formatted info to be printed |
210 | */ | 177 | */ |
211 | void tipc_printf(struct print_buf *pb, const char *fmt, ...) | 178 | int tipc_snprintf(char *buf, int len, const char *fmt, ...) |
212 | { | 179 | { |
213 | int i; | 180 | int i; |
214 | va_list args; | 181 | va_list args; |
215 | char *buf; | ||
216 | int len; | ||
217 | 182 | ||
218 | buf = pb->crs; | ||
219 | len = pb->buf + pb->size - pb->crs; | ||
220 | va_start(args, fmt); | 183 | va_start(args, fmt); |
221 | i = vscnprintf(buf, len, fmt, args); | 184 | i = vscnprintf(buf, len, fmt, args); |
222 | va_end(args); | 185 | va_end(args); |
223 | pb->crs += i; | 186 | return i; |
224 | } | 187 | } |
225 | 188 | ||
226 | /** | 189 | /** |